How to test Braintree + Apple Pay on a real device?

I am developing an application using Apple Pay for an American client from outside the United States. I am using Braintree + Apple Pay. We support real Passbook credit cards, but we cannot verify them.

I successfully generated the self.braintree client self.braintree and tried to use both integration methods.

  • BTPaymentProvider is our abstraction when creating a payment method.

     if(self.braintree && ![self.braintree isKindOfClass:[NSNull class]]) { self.provider = [braintree paymentProviderWithDelegate:self]; if ([self.provider canCreatePaymentMethodWithProviderType:BTPaymentProviderTypeApplePay]) { self.provider.paymentSummaryItems = @[[PKPaymentSummaryItem summaryItemWithLabel:@"XXXX" amount:[NSDecimalNumber decimalNumberWithString:@"1"]]]; } [self.provider createPaymentMethod:BTPaymentProviderTypeApplePay]; } 

    but does not click " PKPaymentAuthorizationViewController ". No exception also tracks it.

  • PassKit - ApplePay API.

     if([PKPaymentAuthorizationViewController canMakePayments]) // It returns TRUE { PKPaymentRequest *paymentRequest = [[PKPaymentRequest alloc] init]; paymentRequest.countryCode = @"US"; paymentRequest.currencyCode = @"USD"; paymentRequest.merchantCapabilities = PKMerchantCapabilityEMV | PKMerchantCapability3DS; paymentRequest.merchantIdentifier = MERCHANTID; paymentRequest.supportedNetworks = @[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]; paymentRequest.paymentSummaryItems = @[ [PKPaymentSummaryItem summaryItemWithLabel:@"TEST" amount:[NSDecimalNumber decimalNumberWithString:@"1"]] ]; if([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]]) // Returns FALSE { PKPaymentAuthorizationViewController *vc = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:paymentRequest]; vc.delegate = self; [self presentViewController:vc animated:YES completion:nil]; } } 

    This gives "vc" nil .

Correct me if he is wrong. How to check it on a real device?

+6
source share
3 answers

It is likely that your Apple Pay app right is not configured correctly.

I noticed that canMakePayments returns YES and canMakePaymentsUsingNetworks: returns NO when the right is not set.

(I also noticed that they can return YES when the seller ID set by you on PKPaymentRequest does not match the seller ID of your Apple Pay right. In this case, your PKPaymentAuthorizationViewController will be non-nil, but it will register a cryptic error in the console).

So, to make sure that Apple Pay is configured for your application, make sure that “Apple Pay” is “On” in the “Features” section of your target settings and that it has a merchant ID (which you will need to configure if you still have this did not do).

Then either:

  • If you use your BTPaymentProvider integration BTPaymentProvider , make sure that the certificate and seller ID are correctly configured in the Braintree control panel.
  • If you use the PassKit direct integration PassKit , make sure that you set the merchantIdentifier property to the appropriate seller ID in the right.
+10
source

Most likely, this is because no payment cards are configured for any of these networks. From the documentation:

On devices that support payments but not configured payment cards, the canMakePayments method returns YES , since hardware and parental controls allow payments, but the canMakePaymentsUsingNetworks: method returns NO regardless of the network.

The documentation also mentions other reasons:

The user may not make payments for various reasons. For example, this functionality may not be supported by their hardware or may be limited by parental controls.


In a separate note, if(self.braintree!=nil && self.braintree != Nil is redundant - the same. I would simply break it into if (self.braintree) { …

+3
source

In version 3.9.3 of BraintreeSDK, I found an error in BTClientTokenApplePayPaymentNetworksValueTransformer , in which there is no case for the Discover card when deserializing BTConfiguration.applePaySupportedNetworks . The result is a PKPaymentRequest with an array containing an NSNull instance in its supported networks. Passing this array to PKPaymentAuthorizationViewController.canMakePaymentsUsingNetworks results in NO. This method contains an error:

 - (id)transformedValue:(id)value { if ([PKPaymentRequest class]) { if ([value isEqualToString:@"amex"]) { return PKPaymentNetworkAmex; } else if ([value isEqualToString:@"visa"]) { return PKPaymentNetworkVisa; } else if ([value isEqualToString:@"mastercard"]) { return PKPaymentNetworkMasterCard; } } return [NSNull null]; } 
-1
source

Source: https://habr.com/ru/post/981400/


All Articles