通过 Braintree PayPal 付款总是失败 iOS

Payment via Braintree PayPal always fails iOS

我已经在 Braintree iOS's GITHub. 上开了一张关于这个的工单,希望能尽快得到一些帮助。问题来了:

正如标题所说,我的付款(在iOS)总是失败。显然,我同事的工作 (Android) 中的付款成功了。

我完全遵循了此处的示例代码和指南:https://developers.braintreepayments.com/guides/paypal/client-side/ios/v4

在 iOS 中,完成所有过程(来自我们服务器的客户端令牌 --> BT SDK --> PayPal 浏览器 --> 应用程序 --> 将随机数发送到我们的服务器),我得到错误来自我们服务器的始终是:

PayPal pending payments are not supported.

我的后端人员也不知道这背后的原因,他只显示并给了我这个日志:

{
   "errors": {},
   "params": {
       "transaction": {
           "type": "sale",
           "amount": "1",
           "merchantAccountId": "USD",
           "paymentMethodNonce": "80823f63-5ea9-0b8b-67da-0710bd7d9ff1",
           "orderId": "333",
           "descriptor": {
               "name": "company name*myurl.com"
           },
           "options": {
               "submitForSettlement": "true",
               "paypal": {
                   "customField": "custom",
                   "description": "description"
               }
           }
       }
   },
   "message": "Unknown or expired payment_method_nonce.",
   "creditCardVerification": null,
   "transaction": null,
   "subscription": null,
   "merchantAccount": null,
   "verification": null
}

下面是我在设置 SDK 时所做的:

private func processPayPalClientToken(_ clientToken: String) {
        SVProgressHUD.show(withStatus: "Please wait...")

        self.braintreeClient = BTAPIClient(authorization: clientToken)

        let payPalDriver = BTPayPalDriver(apiClient: self.braintreeClient)
        payPalDriver.viewControllerPresentingDelegate = self
        payPalDriver.appSwitchDelegate = self

        let request = BTPayPalRequest(amount: self.bookingViewModel.getTotalAmount())
        payPalDriver.requestOneTimePayment(request) { (nonce, error) in
            SVProgressHUD.dismiss(completion: {
                if let error = error {
                    self.showAlert(title: "title...", message: "Error: \(error.localizedDescription).", okayButtonTitle: "OK") { _ in }
                    return
                }

                guard let nonce = nonce else { return }

                self.processNonceToServer(nonce)
            })

        }
    }

所以...知道这背后的原因是什么吗?谢谢!

编辑:我刚才找到的附加信息。 SFSafari 浏览器过早地自我解散,这就是为什么我得到的随机数总是无效的。这是为什么?

完全披露:我在 Braintree 工作。如果您有任何其他问题,请随时联系 support.

根据您在问题中发布的付款方式随机数,我可以查看我们的服务器端日志以了解问题所在。

除了负责使用该付款方式随机数创建交易的服务器外,没有提供任何特定的 API Credentials, it appears as if the server responsible for generating a client token in your setup is passing a different Sandbox merchant ID,这会导致错误。

您的服务器负责生成客户端令牌,其中包含您的客户端初始化客户端 SDK 所需的授权和配置详细信息。创建支付方式随机数时,它会绑定到客户端令牌授权中指定的商家 ID。 merchant ID passed during the Transaction Sale call or other API Calls 必须与绑定到该特定支付方式随机数的商家 ID 相匹配,因此您需要在后端代码中修复此差异。

为了遇到同样问题的其他人的利益,请查看我在 Braintree 的 Github 上提交的已关闭票证(link 以上或此:https://github.com/braintree/braintree_ios/issues/405

这是我和我的同事发现的:

  1. 我们可以使用这种 CREDIT UNION 付款方式成功付款。
  2. 但是我们不能使用 PAYPAL 余额支付。
  3. PayPal余额选项出现如下错误

PayPal pending payments are not supported

所以这个问题的答案是:确保您客户端中的所有内容都正常工作,并且您使用正确且相同的 clientToken 帐户和您用于支付的 PayPal 帐户。