FedorX
FedorX

Reputation: 13

ApplePay doesn't work on devices

I have two problems, 1) first of all when I've started application and tap on ApplePay button I have an exception without additional information, what did I do wrong?
2) Second, in a delegate method

paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
               didAuthorizePayment:(PKPayment *)payment
                        completion:(void (^)(PKPaymentAuthorizationStatus))completion

for some reason payment.token.paymentData == nil and I don't understand why. What I did: activate ApplePay in a target, added certificate in Apple Developer Account, and create object like this:

- (PKPaymentRequest *)paymentRequest
{
    PKPaymentRequest *paymentRequest = [[PKPaymentRequest alloc] init];
    paymentRequest.merchantIdentifier = @"xxx.xxx.xxx.xxx";
    paymentRequest.supportedNetworks = @[PKPaymentNetworkVisa, PKPaymentNetworkMasterCard];
    paymentRequest.merchantCapabilities = PKMerchantCapability3DS;
    paymentRequest.countryCode = @"RU";
    paymentRequest.currencyCode = @"RUB";
    paymentRequest.paymentSummaryItems =
    @[
      [PKPaymentSummaryItem summaryItemWithLabel:@"Ticket" amount:[NSDecimalNumber decimalNumberWithString:@"2000"]]
      ];

    return paymentRequest;
}

Upvotes: 1

Views: 503

Answers (1)

Christian Valencia
Christian Valencia

Reputation: 1

first of all, your domain needs to be prepared, the domain have to host the apple-developer-merchantid-domain-association file and the merchant has to be registered using the API or in the developer portal https://developer.apple.com/documentation/applepaywebmerchantregistrationapi/preparing-merchant-domains-for-verification after that, the domain must match the domain registered against Apple Pay, when you click on the Apple Pay button, the SDK validates the merchant and the domain of the session with the domain of the browser, it must match exactly

Upvotes: 0

Related Questions