Add Apple Pay as a payment account

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 GetPaymentAccountDetailsto 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 Paydiant system, this will ensure a unique Paydiant 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:

- (void)addApplePay:(PDTenderType *)tender {

    AppDelegate *appDelegate = ((AppDelegate *)[UIApplication sharedApplication].delegate);

    if ([PKPaymentAuthorizationViewController canMakePayments] == NO ||
        [PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:appDelegate.applePayNetwork] == NO) {
        [CommonUtil displayMessageWithTitle:@"Error" 
                                andDescription:@"Can't add Apple Pay Account to your mobile wallet successfully."];

        return;
    }

    PDAddPaymentAccountRequest *addRequest = [[PDAddPaymentAccountRequest alloc] init];
    addRequest.paymentAccountTypeUri = tender.paymentAccountType.paymentAccountTypeUri;
    addRequest.paymentAccountNetworkTypeUri = tender.paymentAccountNetworkType.paymentAccountNetworkTypeUri;
     
    [CommonUtil showProgressIndicatorOnView:self];
    PDManagePaymentInstrumentsCoordinator *pdManagePaymentInstrumentsCoordinator = [[PDManagePaymentInstrumentsCoordinator alloc] init];
     
    NSMutableArray *metaDataArray = [[NSMutableArray alloc] init];

    {
        // Create a PDMetaData object.
        PDMetaData *metaData = [[PDMetaData alloc] init];
        metaData.key = @"CARD_NUMBER";
        metaData.value = @"1234567890";
        [metaDataArray addObject:metaData];
    }

    {
        // Create a PDMetaData object.
        PDMetaData *metaData = [[PDMetaData alloc] init];
        metaData.key = @"NICK_NAME";
        metaData.value = @"test card";
        [metaDataArray addObject:metaData];
    }
    addRequest.metaData = metaDataArray;

    [pdManagePaymentInstrumentsCoordinator addPaymentAccount:addRequest completionBlock: ^(PDPaymentAccount *addedPaymentAccount, PDAddPaymentAccountResponse *response) {
        [CommonUtil hideProgressIndicatorOnView:self];
        [CommonUtil displayMessageWithTitle:@"Success" andDescription:@"Apple Pay Added !"];
        [[NSNotificationCenter defaultCenter] postNotificationName:kPaymentAccountsChangedNotification object:self];
    } failureBlock: ^(PDPaydiantError *error) {
        [CommonUtil hideProgressIndicatorOnView:self];
        [CommonUtil displayError:error];
    }];
}