正如标题所说,我的付款(在iOS中)总是失败.显然,我同事的工作(Android)付款成功.
我从这里完整地遵循了示例代码和指南:https://developers.braintreepayments.com/guides/paypal/client-side/ios/v4
在iOS中,经过所有过程(客户端令牌从我们的服务器 – > BT SDK – > PayPal浏览器 – >应用程序 – >发送nonce到我们的服务器),我从我们的服务器得到的错误总是:
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浏览器太快就解散了,这就是为什么我得到的nonce总是无效的.这是为什么?
完全披露:我在Braintree工作.如果您有任何其他问题,请随时联系support.
根据您在问题中发布的付款方式nonce,我能够查看服务器端日志以查看问题所在.
在没有泄露任何特定的API Credentials的情况下,似乎您的设置中负责generating a client token的服务器传递的是与负责使用该支付方式nonce创建交易的服务器不同的Sandbox merchant ID,这导致错误.
您的服务器负责生成客户端令牌,其中包含客户端初始化客户端SDK所需的授权和配置详细信息.创建付款方式nonce时,它与客户端令牌授权中指定的商家ID相关联. merchant ID passed during the Transaction Sale call or other API Calls必须与该特定付款方式nonce绑定的商家ID匹配,因此您需要在后端代码中修复此差异.
