How do I get the last four digits of the real card number in apple Pay by "PKSecureElementPass.primaryAccountNumberSuffix"?

we want to get the last four digits of the real card number in apple Pay, and I found information about it in the document, link: https://developer.apple.com/documentation/passkit_apple_pay_and_wallet/pksecureelementpass/3543366-primaryaccountnumbersuffix?language=objc My question is how to use it,can you provide sample code? We are very anxious, thank you!

Answered by DTS Engineer in 809581022

Hi @zhangruiguo,

The user's pass library only provides passes that are eligible for your apps and app extensions. The issuer of the pass needs to add your bundle IDs and App IDs to its payment network operator metadata, and the pass itself should also contain your bundle ID.

If you are not the issuer of any card, or associated with any issuer of cards activated on the device, an empty array is expected.

Cheers,

Paris X Pinkney |  WWDR | DTS Engineer

if (@available(iOS 13.4, *)) { NSArray<PKSecureElementPass *> *secureArray = [passLib remoteSecureElementPasses];

NSLog(@"Number of passes in library are: %lu", (unsigned long)[secureArray count]);

if ([secureArray count] > 0) {
    PKSecureElementPass *onePass = [secureArray objectAtIndex:0];

    NSLog(@"One pass: %@", onePass);

    PKPaymentPass *paymentPass = [onePass paymentPass];

    if (paymentPass) {
        NSLog(@"Pass activation code: %lu", (unsigned long)[paymentPass activationState]);

        NSLog(@"AuthenticationToken: %@, DeviceAccountIdentifier: %@, PrimaryAccountNumberSuffix: %@",
              [paymentPass authenticationToken],
              [paymentPass deviceAccountIdentifier],
              [paymentPass primaryAccountNumberSuffix]);
    }
}

} else { // Fallback on earlier versions } I try to use "remoteSecureElementPasses", but either distribute certificate or development certificate, the array's count is always 0.

Hi @zhangruiguo,

The user's pass library only provides passes that are eligible for your apps and app extensions. The issuer of the pass needs to add your bundle IDs and App IDs to its payment network operator metadata, and the pass itself should also contain your bundle ID.

If you are not the issuer of any card, or associated with any issuer of cards activated on the device, an empty array is expected.

Cheers,

Paris X Pinkney |  WWDR | DTS Engineer

How do I get the last four digits of the real card number in apple Pay by "PKSecureElementPass.primaryAccountNumberSuffix"?
 
 
Q