通过Braintree PayPal付款始终无法通过iOS

Gle*_*enn 3 paypal braintree ios swift

我已经在Braintree iOS的GITHub上打开了一张与此有关的票。只是希望能快速获得帮助。问题来了:

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

我从这里彻底遵循了示例代码和准则:https : //developers.braintreepayments.com/guides/paypal/client-side/ios/v4

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

不支持PayPal待付款。

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

{
   "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
}
Run Code Online (Sandbox Code Playgroud)

这是我设置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)
            })

        }
    }
Run Code Online (Sandbox Code Playgroud)

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

编辑:我不久前发现的其他信息。SFSafari浏览器过早地关闭了自身,这就是为什么我得到的随机数始终无效的原因。这是为什么?

小智 5

全面披露:我在Braintree工作。如果您还有其他疑问,请随时与支持小组联系 。

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

在不放弃任何特定API凭据的情况下,似乎负责在您的设置中生成客户令牌的服务器传递的沙箱商家ID与负责使用该付款方式随机数创建交易的服务器传递的沙丘商家ID不同,这会导致错误。

您的服务器负责生成客户端令牌,其中包含客户端初始化客户端SDK所需的授权和配置详细信息。创建付款方式随机数后,它会与客户令牌授权中指定的商家ID绑定。在交易销售调用或其他API调用期间传递商家ID必须与绑定到该特定付款方式随机数的商家ID匹配,因此您需要在后端代码中解决此差异。