Я создаю простое приложение, которое должно использовать полосу для платежей. В моем методе viewDidLoad () у меня есть следующий код:
let addCardViewController = STPAddCardViewController()
addCardViewController.delegate = self
navigationController?.pushViewController(addCardViewController, animated: true)
У меня есть следующие методы делегата:
extension Checkout: STPAddCardViewControllerDelegate {
func addCardViewControllerDidCancel(_ addCardViewController: STPAddCardViewController) {
navigationController?.popViewController(animated: true)
}
private func addCardViewController(_ addCardViewController: STPAddCardViewController, didCreateToken token: STPToken, completion: @escaping STPErrorBlock) {
StripeClient.shared.completeCharge(with: token, amount: 50) { result in
switch result {
case .success:
completion(nil)
let alertController = UIAlertController(title: "Congrats", message: "Your payment was successful!", preferredStyle: .alert)
let alertAction = UIAlertAction(title: "OK", style: .default, handler: { _ in
self.navigationController?.popViewController(animated: true)
})
alertController.addAction(alertAction)
self.present(alertController, animated: true)
case .failure(let error):
completion(error)
}
}
}
}
Однако метод didCreateToken никогда не вызывается, и я неконечно почему. Помощь будет оценена!