Braintree DropIn + Apple Pay,没有出现Apple Pay项目

时间:2018-10-10 13:34:36

标签: ios swift applepay braintree-sandbox

我从Braintree SDK成功调用了DropIn视图。 BTDropInRequest设置应显示三个项目:

  1. PayPal
  2. 信用卡
  3. Apple Pay

但是由于某种原因,在DropIn视图中仅呈现两个项目,而不是三个:

  1. PayPal
  2. 信用卡

我做错了什么?

准备工作:

  • 所有证书均已创建并上传
  • 项目功能启用了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)
    }

1 个答案:

答案 0 :(得分:0)

基于Braintree的文档,您应该完成Apple Pay集成,并且支持客户的设备和卡类型。

https://developers.braintreepayments.com/guides/drop-in/setup-and-integration/ios/v4#apple-pay

此外,请注意这一点

  

如果使用带有客户ID的客户令牌,Apple Pay卡将   不会自动被拱顶。您可以使用付款方式随机数来   在服务器上创建付款方式。