i want to use the create token function but its deprecated but in kotlin its still working how can i fetch the token from stripe?
import UIKit
import Foundation
import Stripe
import StripePaymentsUI
class StripeCardManager: NSObject, STPAddCardViewControllerDelegate {
static let shared = StripeCardManager()
private var successHandler: ((STPPaymentMethod) -> Void)?
private var failureHandler: ((Error?) -> Void)?
private override init() {
super.init()
}
func presentAddCardViewController(from viewController: UIViewController, success: @escaping (STPPaymentMethod) -> Void, failure: @escaping (Error?) -> Void) {
self.successHandler = success
self.failureHandler = failure
let config = STPPaymentConfiguration.shared
config.requiredBillingAddressFields = .none
config.cardScanningEnabled = false
let addCardViewController = STPAddCardViewController(configuration: .shared, theme: .defaultTheme)
addCardViewController.delegate = self
let navigationController = UINavigationController(rootViewController: addCardViewController)
viewController.present(navigationController, animated: true, completion: nil)
}
// MARK: - STPAddCardViewControllerDelegate
func addCardViewControllerDidCancel(_ addCardViewController: STPAddCardViewController) {
addCardViewController.dismiss(animated: true, completion: nil)
failureHandler?(nil) // Invoke failure handler on cancellation
}
func addCardViewController(_ addCardViewController: STPAddCardViewController, didCreatePaymentMethod paymentMethod: STPPaymentMethod, completion: @escaping STPErrorBlock) {
// You can now dismiss the view controller
addCardViewController.dismiss(animated: true, completion: nil)
successHandler?(paymentMethod) // Invoke success handler with token
completion(nil)
}
}
func addCardViewController(_ addCardViewController: STPAddCardViewController, didCreatePaymentMethod paymentMethod: STPPaymentMethod, completion: @escaping STPErrorBlock) {
// You can now dismiss the view controller
addCardViewController.dismiss(animated: true, completion: nil)
successHandler?(paymentMethod) // Invoke success handler with token
completion(nil)
}
how can i use didCreatePaymentMethod in kotlin
im currently using didCreatePaymentMethod but i cant get the token from this i got stripe id which is no use for me which starts from pm i want which starts from tok
in ios i use paymentsheet so i dint have full account number also createToken function is deprecated.




