2
votes

I successfully call DropIn view from Braintree SDK. The BTDropInRequest settings should display three items:

  1. PayPal
  2. Credit Cards
  3. Apple Pay

But for some reason in DropIn view renders only two items instead of three:

  1. PayPal
  2. Credit Cards

What I did wrong?

Preparation:

  • All certificates are created and uploaded
  • Apple Pay is enabled on the project capabilities
  • Merchant ID is added
  • The device on which I do testing is supported Apple Pay

Here is a code of method which does request:

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
I was facing the same issue. Turns out that Apple Pay was not supported in my country, although it was supported on the device I was using. Try running the same in simulator. Solved my problem.bhakti123
@bhakti123, A few hours ago I received the answer from Braintree support. While Apple Pay may support their rollout in my Ukraine, Braintree does not yet. I also tried to lunch app on the simulator - the same result, no Apple Pay button. Did you do some preparations before lunch app on the simulator?Roman Romanenko
@RomanRomanenko are you find the solution ?balkaran singh
@balkaran singh, everything I have done, I have done right. Button didn’t appear with my local test server. I tested it in Ukraine, customers were in the USA. When a server side done all preparation (they registered Braintree account as USA merchant) and I obtain the keys from the server, the Apple Pay button finally appears!Roman Romanenko

1 Answers

0
votes

Base on a document from Braintree, you should complete the Apple Pay integration and the customer's device and card type are supported.

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

Also, take note at this point

If using a client token with a customer id, the Apple Pay card will not automatically be vaulted. You can use the payment method nonce to create a payment method on your server.