Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas committed Aug 4, 2020
2 parents 998a7fc + 2e4cfe5 commit 9788e05
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ This method provides the data needed to create a request to add your payment pas
* Use the callback response JSON payload to complete addition process
* Expect
* res = {
* "certificateSubCA":"Base64 string represents certificateSubCA",
* "certificateLeaf":"Base64 string represents certificateLeaf"
* "nonce":"Base64 string represents nonce",
* "nonceSignature":"Base64 string represents nonceSignature",
* "data": {
* "certificateSubCA":"Base64 string represents certificateSubCA",
* "certificateLeaf":"Base64 string represents certificateLeaf"
* "nonce":"Base64 string represents nonce",
* "nonceSignature":"Base64 string represents nonceSignature",
* }
* }
*/
})
Expand Down
34 changes: 20 additions & 14 deletions src/ios/CDVAppleWallet.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ - (void) checkCardEligibility:(CDVInvokedUrlCommand*)command {
// NSArray<PKPass *> *paymentPasses = [passLibrary passesOfType:PKPassTypePayment];
NSArray *paymentPasses = [[NSArray alloc] init];
if (@available(iOS 13.5, *)) { // PKPassTypePayment is deprecated in iOS13.5
paymentPasses = [passLibaray passesOfType: PKPassTypeSecureElement];
paymentPasses = [passLibrary passesOfType: PKPassTypeSecureElement];
for (PKPass *pass in paymentPasses) {
PKSecureElementPass *paymentPass = [pass secureElementPass];
if ([paymentPass primaryAccountIdentifier] == cardIdentifier) {
if ([[paymentPass primaryAccountIdentifier] isEqualToString:cardIdentifier]) {
cardAddedtoPasses = true;
}
}
} else {
paymentPasses = [passLibrary passesOfType: PKPassTypePayment];
for (PKPass *pass in paymentPasses) {
PKPaymentPass *paymentPass = [pass paymentPass];
if([paymentPass primaryAccountIdentifier] == cardIdentifier) {
if([[paymentPass primaryAccountIdentifier] isEqualToString:cardIdentifier]) {
cardAddedtoPasses = true;
}
}
Expand All @@ -84,15 +84,15 @@ - (void) checkCardEligibility:(CDVInvokedUrlCommand*)command {
if (@available(iOS 13.5, *)) {
paymentPasses = [passLibrary remoteSecureElementPasses]; // remotePaymentPasses is deprecated in iOS13.5
for (PKSecureElementPass *pass in paymentPasses) {
if ([pass primaryAccountIdentifier] == cardIdentifier) {
if ([[pass primaryAccountIdentifier] isEqualToString:cardIdentifier]) {
cardAddedtoPasses = true;
}
}
} else {
paymentPasses = [passLibrary remotePaymentPasses];
for (PKPass *pass in paymentPasses) {
PKPaymentPass * paymentPass = [pass paymentPass];
if([paymentPass primaryAccountIdentifier] == cardIdentifier)
if([[paymentPass primaryAccountIdentifier] isEqualToString:cardIdentifier])
cardAddedtoRemotePasses = true;
}
}
Expand Down Expand Up @@ -126,15 +126,15 @@ - (void) checkCardEligibilityBySuffix:(CDVInvokedUrlCommand*)command {
paymentPasses = [passLibrary passesOfType: PKPassTypeSecureElement];
for (PKPass *pass in paymentPasses) {
PKSecureElementPass *paymentPass = [pass secureElementPass];
if ([paymentPass primaryAccountNumberSuffix] == cardSuffix) {
if ([[paymentPass primaryAccountNumberSuffix] isEqualToString:cardSuffix]) {
cardAddedtoPasses = true;
}
}
} else {
paymentPasses = [passLibrary passesOfType: PKPassTypePayment];
for (PKPass *pass in paymentPasses) {
PKPaymentPass * paymentPass = [pass paymentPass];
if([paymentPass primaryAccountNumberSuffix] == cardSuffix)
if([[paymentPass primaryAccountNumberSuffix] isEqualToString:cardSuffix])
cardAddedtoPasses = true;
}
}
Expand All @@ -148,15 +148,15 @@ - (void) checkCardEligibilityBySuffix:(CDVInvokedUrlCommand*)command {
if (@available(iOS 13.5, *)) { // remotePaymentPasses is deprecated in iOS 13.5
paymentPasses = [passLibrary remoteSecureElementPasses];
for (PKSecureElementPass *pass in paymentPasses) {
if ([pass primaryAccountNumberSuffix] == cardSuffix) {
if ([[pass primaryAccountNumberSuffix] isEqualToString:cardSuffix]) {
cardAddedtoPasses = true;
}
}
} else {
paymentPasses = [passLibrary remotePaymentPasses];
for (PKPass *pass in paymentPasses) {
PKPaymentPass * paymentPass = [pass paymentPass];
if([paymentPass primaryAccountNumberSuffix] == cardSuffix)
if([[paymentPass primaryAccountNumberSuffix] isEqualToString:cardSuffix])
cardAddedtoRemotePasses = true;
}
}
Expand Down Expand Up @@ -236,7 +236,7 @@ - (NSString *) getCardFPAN:(NSString *) cardSuffix{
NSArray<PKPass *> *paymentPasses = [passLibrary passesOfType:PKPassTypePayment];
for (PKPass *pass in paymentPasses) {
PKPaymentPass * paymentPass = [pass paymentPass];
if([paymentPass primaryAccountNumberSuffix] == cardSuffix)
if([[paymentPass primaryAccountNumberSuffix] isEqualToString:cardSuffix])
return [paymentPass primaryAccountIdentifier];
}

Expand All @@ -249,13 +249,13 @@ - (NSString *) getCardFPAN:(NSString *) cardSuffix{
paymentPasses = [passLibrary remotePaymentPasses];
for (PKPass *pass in paymentPasses) {
PKPaymentPass * paymentPass = [pass paymentPass];
if([paymentPass primaryAccountNumberSuffix] == cardSuffix)
if([[paymentPass primaryAccountNumberSuffix] isEqualToString:cardSuffix])
return [paymentPass primaryAccountIdentifier];
}
}
}

return @"";
return nil;
}


Expand Down Expand Up @@ -302,7 +302,7 @@ - (void) startAddPaymentPass:(CDVInvokedUrlCommand *)command
configuration.localizedDescription = [options objectForKey:@"localizedDescription"];

// Filters the device and attached devices that already have this card provisioned. No filter is applied if the parameter is omitted
configuration.primaryAccountIdentifier = [options objectForKey:@"primaryAccountIdentifier"]; //@"V-3018253329239943005544";//@"";
configuration.primaryAccountIdentifier = [self getCardFPAN:configuration.primaryAccountSuffix]; //@"V-3018253329239943005544";//@"";


// Filters the networks shown in the introduction view to this single network.
Expand Down Expand Up @@ -414,10 +414,16 @@ - (void) completeAddPaymentPass:(CDVInvokedUrlCommand *)command
NSString* activationData = [options objectForKey:@"activationData"];
NSString* encryptedPassData = [options objectForKey:@"encryptedPassData"];
NSString* wrappedKey = [options objectForKey:@"wrappedKey"];
NSString* ephemeralPublicKey = [options objectForKey:@"ephemeralPublicKey"];

request.activationData = [[NSData alloc] initWithBase64EncodedString:activationData options:0]; //[activationData dataUsingEncoding:NSUTF8StringEncoding];
request.encryptedPassData = [[NSData alloc] initWithBase64EncodedString:encryptedPassData options:0];
request.wrappedKey = [[NSData alloc] initWithBase64EncodedString:wrappedKey options:0];
if (wrappedKey) {
request.wrappedKey = [[NSData alloc] initWithBase64EncodedString:wrappedKey options:0];
}
if (ephemeralPublicKey) {
request.ephemeralPublicKey = [[NSData alloc] initWithBase64EncodedString:ephemeralPublicKey options:0];
}

// Issue request
self.completionHandler(request);
Expand Down

0 comments on commit 9788e05

Please sign in to comment.