ios - Braintree DropIn + Apple Pay,不出现 Apple Pay 项目
问题描述
DropIn
我成功地从 Braintree SDK调用视图。设置应显示BTDropInRequest
三个项目:
- 贝宝
- 信用卡
- 苹果支付
但是由于某种原因,DropIn
视图中只呈现了两个项目而不是三个:
- 贝宝
- 信用卡
我做错了什么?
准备:
- 创建并上传所有证书
- 项目功能上启用了 Apple Pay
- 已添加商户 ID
- 我进行测试的设备支持 Apple Pay
这是一个请求的方法代码:
func showDropIn(clientTokenOrTokenizationKey: String) {
BTUIKAppearance.darkTheme()
let request = BTDropInRequest()
let canMakePayments = PKPaymentAuthorizationViewController.canMakePayments() && PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [.amex, .visa, .masterCard])
request.applePayDisabled = !canMakePayments
request.cardDisabled = false
let dropIn = BTDropInController.init(authorization: clientTokenOrTokenizationKey, request: request) { (controller, result, error) in
if (error != nil) {
print("ERROR")
} else if (result?.isCancelled == true) {
print("CANCELLED")
} else if let result = result{
switch result.paymentOptionType {
case .applePay ,.payPal,.masterCard,.discover,.visa:
if let paymentMethod = result.paymentMethod {
controller.dismiss(animated: true, completion: nil)
} else {
controller.dismiss(animated: true, completion: {
self.braintreeClient = BTAPIClient(authorization: clientTokenOrTokenizationKey)
let paymentRequest = self.paymentRequest()
if let vc = PKPaymentAuthorizationViewController(paymentRequest: paymentRequest)
as PKPaymentAuthorizationViewController?
{
vc.delegate = self
self.present(vc, animated: true, completion: nil)
} else {
print("Error: Payment request is invalid.")
}
})
}
default:
print("error")
controller.dismiss(animated: true, completion: nil)
}
}
}
self.present(dropIn!, animated: true, completion: nil)
}
解决方案
根据 Braintree 的文档,您应该完成 Apple Pay 集成并且支持客户的设备和卡类型。
https://developers.braintreepayments.com/guides/drop-in/setup-and-integration/ios/v4#apple-pay
另外,此时请注意
如果使用带有客户 ID 的客户令牌,Apple Pay 卡将不会被自动保管。您可以使用付款方式 nonce 在您的服务器上创建付款方式。
推荐阅读
- python - 需要修复python中导入本地文件的问题
- flutter - 颤振堆栈/对齐
- java - 具有属性“data-mfp-src”的按钮有时不会在 selenium 中单击
- python - 连接值相同的 DataFrame 并删除值不同的值
- c# - 是否有包含 Wi-Fi Direct 功能的托管 Wifi API?
- vert.x - 请建议如何为 vertx 3.7.1 使用 vertx Timeout 处理程序
- amazon-web-services - Aws Marketplace ResolveCustomer 操作在调用时失败并出现 com.amazon.coral.service#UnknownOperationException
- javascript - 如何让 p5.js 在特定位置创建画布
- sql - 试图从sql中的数据中获取最新记录
- sql - SQL CTE 返回 Not A Group By Expression 错误