I successfully call DropIn
view from Braintree SDK. The BTDropInRequest
settings should display three items:
- PayPal
- Credit Cards
- Apple Pay
But for some reason in DropIn
view renders only two items instead of three:
- PayPal
- 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)
}