Stripe iOS: получена неизвестная ошибка параметра при подтверждении PaymentIntent с помощью SDK - PullRequest
0 голосов
/ 22 мая 2019

Я получаю код 50, ошибка:

Получен неизвестный параметр: payment_method_data [карта] [токен]

при использовании STPAPIClient.shared().confirmPaymentIntent() и токен, полученный от didCreateToken.

Я назначаю токен параметрам карты следующим образом:

cardParams.token = token.tokenId

Версия Stripe: 15.0.1.Есть идеи, как ее решить?

Полный код:

 func addCardViewController(_ addCardViewController: STPAddCardViewController, didCreateToken token: STPToken, completion: @escaping STPErrorBlock) {

        let cardParams = STPPaymentMethodCardParams()
        cardParams.token = token.tokenId
        let paymentMethodParams = STPPaymentMethodParams(card: cardParams, billingDetails: nil, metadata: nil)

        //let paymentMethodParams = STPPaymentMethodParams(card: cardParams, billingDetails: billingDetails, metadata: nil)
        let clientSecret = paymentIntentData?.token ?? "" //recieve from the API
        let paymentIntentParams = STPPaymentIntentParams(clientSecret: clientSecret)
        paymentIntentParams.paymentMethodParams = paymentMethodParams
        //paymentIntentParams.returnURL = "your-app://stripe-redirect"

        let client = STPAPIClient.shared()
        client.confirmPaymentIntent(with: paymentIntentParams, completion: { (paymentIntent, error) in
            if let error = error {
                // handle error
                print(error)
            } else if let paymentIntent = paymentIntent {
                // see below to handle the confirmed PaymentIntent
                if paymentIntent.status == .requiresAction {
                    guard let redirectContext = STPRedirectContext(paymentIntent: paymentIntent, completion: { clientSecret, redirectError in
                        // Fetch the latest status of the Payment Intent if necessary
                        STPAPIClient.shared().retrievePaymentIntent(withClientSecret: clientSecret) { paymentIntent, error in
                            // Check paymentIntent.status
                            print(paymentIntent)
                        }
                    }) else {
                        // This PaymentIntent action is not yet supported by the SDK.
                        return;
                    }
                    // Note you must retain this for the duration of the redirect flow - it dismisses any presented view controller upon deallocation.
                    self.redirectContext = redirectContext

                    // opens SFSafariViewController to the necessary URL
                    redirectContext.startRedirectFlow(from: self)
                } else {
                    // Show success message
                    print("Success")
                }
            }
            self.navigationController?.popViewController(animated: true)
        })


    }
...