cordova-plugin-applepay
cordova-plugin-applepay copied to clipboard
Payment Not Completed
2021-01-27 14:09:14.772749+1300 [47437:1094357] ApplePay canMakePayments == true 2021-01-27 14:09:14.776377+1300 [47437:1094357] ApplePay request == <PKPaymentRequest: 0x7fe72df2b630; APIType: PKPaymentRequestAPITypeInApp, requestType: PKPaymentRequestTypeApplePay, requestor: PKPaymentRequestorDefault, countryCode: NZ, merchantCapabilities: d, currencyCode: NZD, shippingType: SHIPPING, shouldUseMerchantSession: 0, suppressTotal: 0, paymentSummaryPinned: 0, supportedNetworks: ( Visa, MasterCard, Discover ), paymentSummaryItems: 1, requiredBillingContactFields: {( name, email, phone )}, shippingMethods: 0, > 2021-01-27 14:09:14.784550+1300 [47437:1094357] THREAD WARNING: ['ApplePay'] took '19.363037' ms. Plugin should use a background thread. 2021-01-27 14:09:18.375341+1300 [47437:1094357] CDVApplePay: didAuthorizePayment 2021-01-27 14:09:18.381786+1300 [47437:1094357] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: paymentMethodNetwork)' *** First throw call stack: ( 0 CoreFoundation 0x00007fff20420af6 __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007fff20177e78 objc_exception_throw + 48 2 CoreFoundation 0x00007fff2049d77f _CFThrowFormattedException + 194 3 CoreFoundation 0x00007fff204a9035 -[__NSDictionaryM setObject:forKey:].cold.3 + 0 4 CoreFoundation 0x00007fff2048d134 -[__NSDictionaryM setObject:forKey:] + 922 5 0x000000010e218e4e -[CDVApplePay formatPaymentForApplication:] + 702 6 0x000000010e21a941 -[CDVApplePay paymentAuthorizationViewController:didAuthorizePayment:completion:] + 177 7 PassKit 0x00007fff39e91f62 __100-[PKPaymentAuthorizationViewController paymentAuthorizationCoordinator:didAuthorizePayment:handler:]_block_invoke + 247 8 libdispatch.dylib 0x0000000110f227ec _dispatch_call_block_and_release + 12 9 libdispatch.dylib 0x0000000110f239c8 _dispatch_client_callout + 8 10 libdispatch.dylib 0x0000000110f31e75 _dispatch_main_queue_callback_4CF + 1152 11 CoreFoundation 0x00007fff2038edbb CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9 12 CoreFoundation 0x00007fff2038963e __CFRunLoopRun + 2685 13 CoreFoundation 0x00007fff203886d6 CFRunLoopRunSpecific + 567 14 GraphicsServices 0x00007fff2bededb3 GSEventRunModal + 139 15 UIKitCore 0x00007fff24690e0b -[UIApplication _run] + 912 16 UIKitCore 0x00007fff24695cbc UIApplicationMain + 101 17 0x000000010e20d6a1 main + 65 18 libdyld.dylib 0x00007fff202593e9 start + 1 19 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: paymentMethodNetwork)' terminating with uncaught exception of type NSException CoreSimulator 732.18.6 - Device: iPhone 12 Pro Max (F986B485-8EFC-42DF-9210-38C8565629A3) - Runtime: iOS 14.3 (18C61) - DeviceType: iPhone 12 Pro Max (lldb)
this.applePay.makePaymentRequest({
items: [
{ label: '3 x Basket Items', amount: 1.00 },
],
supportedNetworks: ['visa', 'masterCard', 'discover'],
merchantCapabilities: ['3ds', 'debit', 'credit'],
merchantIdentifier: 'merchant.xx.xx.xxx',
currencyCode: 'NZD',
countryCode: 'NZ',
billingAddressRequirement: ['name', 'email', 'phone'],
shippingAddressRequirement: 'none',
shippingType: 'shipping'
}).then(paymentResponse => {
// user approved payment, token generated
alert(JSON.stringify(paymentResponse));
this.applePay.completeLastTransaction('success');
}).catch(err => {
// error or user cancelled
console.log(err);
});
I tested on simulator and real device, both same issue.
Hope someone can help me.
Thanks in advance.
The errors happens on the following line:
https://github.com/samkelleher/cordova-plugin-applepay/blob/ac09198332fd3779ad04efd5cc53c8690a2a98f6/src/ios/CDVApplePay.m#L344
It happens because payment.token.paymentMethod.network
is nil
.
When I'm testing with a simulator, I get the same error.
When I'm testing with a real device that has a Test Credit Card, then it works as expected.