Add Apple Pay as a payment account
Last updated: Aug 15th, 7:44am
Different types of payment accounts require different properties to be passed in order to be authorized as a valid payment instrument.
To correctly populate this request, call GetPaymentAccountDetails
to get the properties required for the tender type. Check the dataGroup attribute of each returned property to ensure that only CARD_INFORMATION
and BILLING_INFORMATION
properties are submitted (if required).
Note: When provisioning Apple Pay in a mobile wallet, populate the CARD_NUMER
key with the value of the <username>
for the wallet account holder. Since username
is unique across the WLW system, this will ensure a unique WLW value is associated with each Apple Pay account.
You must also populate NICK_NAME
as part of this process. You can either have the user explicitly type in a NICK_NAME
or you can programmatically set it for the user with a simple default value such as "Apple Pay".
Here is an example AddCard
for Apple Pay:
1- (void)addApplePay:(PDTenderType *)tender {23 AppDelegate *appDelegate = ((AppDelegate *)[UIApplication sharedApplication].delegate);45 if ([PKPaymentAuthorizationViewController canMakePayments] == NO ||6 [PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:appDelegate.applePayNetwork] == NO) {7 [CommonUtil displayMessageWithTitle:@"Error"8 andDescription:@"Can't add Apple Pay Account to your mobile wallet successfully."];910 return;11 }1213 PDAddPaymentAccountRequest *addRequest = [[PDAddPaymentAccountRequest alloc] init];14 addRequest.paymentAccountTypeUri = tender.paymentAccountType.paymentAccountTypeUri;15 addRequest.paymentAccountNetworkTypeUri = tender.paymentAccountNetworkType.paymentAccountNetworkTypeUri;1617 [CommonUtil showProgressIndicatorOnView:self];18 PDManagePaymentInstrumentsCoordinator *pdManagePaymentInstrumentsCoordinator = [[PDManagePaymentInstrumentsCoordinator alloc] init];1920 NSMutableArray *metaDataArray = [[NSMutableArray alloc] init];2122 {23 // Create a PDMetaData object.24 PDMetaData *metaData = [[PDMetaData alloc] init];25 metaData.key = @"CARD_NUMBER";26 metaData.value = @"1234567890";27 [metaDataArray addObject:metaData];28 }2930 {31 // Create a PDMetaData object.32 PDMetaData *metaData = [[PDMetaData alloc] init];33 metaData.key = @"NICK_NAME";34 metaData.value = @"test card";35 [metaDataArray addObject:metaData];36 }37 addRequest.metaData = metaDataArray;3839 [pdManagePaymentInstrumentsCoordinator addPaymentAccount:addRequest completionBlock: ^(PDPaymentAccount *addedPaymentAccount, PDAddPaymentAccountResponse *response) {40 [CommonUtil hideProgressIndicatorOnView:self];41 [CommonUtil displayMessageWithTitle:@"Success" andDescription:@"Apple Pay Added !"];42 [[NSNotificationCenter defaultCenter] postNotificationName:kPaymentAccountsChangedNotification object:self];43 } failureBlock: ^(PDPaydiantError *error) {44 [CommonUtil hideProgressIndicatorOnView:self];45 [CommonUtil displayError:error];46 }];47}