我成功地从Braintree SDK调用了DropIn视图。BTDropInRequest设置应该显示三项:
但是由于某种原因,在DropIn视图中只呈现两项而不是三项:
我做错了什么?
准备工作:
下面是一个方法代码,它确实请求:
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)
}发布于 2018-10-10 15:22:55
基于Braintree的文档,您应该完成Apple Pay的集成,并支持客户的设备和卡类型。
https://developers.braintreepayments.com/guides/drop-in/setup-and-integration/ios/v4#apple-pay
同时,注意到这一点。
如果使用带有客户id的客户令牌,则苹果支付卡将不会自动被拱形。您可以使用当前的支付方法在服务器上创建支付方法。
https://stackoverflow.com/questions/52741477
复制相似问题