naoufal / react-native-payments

Accept Payments with Apple Pay and Android Pay using the Payment Request API.
https://www.npmjs.com/package/react-native-payments
1.59k stars 413 forks source link

Changing or Editing Shipping info in Apple Pay trigger processing and results in "Abort Error" #358

Open mkekovic opened 2 years ago

mkekovic commented 2 years ago

Hello,

I am using react native payments on ios platform and my implementation looks like this.

pr = new PaymentRequest(appConfigValues?.apple_pay?.apple_pay_methods_data, DETAILS, { ...appConfigValues?.apple_pay?.apple_pay_options, ...shippingRequired });
    pr.canMakePayments()
      .then(canMakePayment => {
        if (canMakePayment) {
          pr.show()
            .then((paymentResponse: any) => {
              // ommitted for simplicity 
            })
            .catch((err: any) => {
              pr = new PaymentRequest(appConfigValues?.apple_pay?.apple_pay_methods_data, DETAILS, appConfigValues?.apple_pay?.apple_pay_options);

              console.log('this is error in apple pay', err);
            });
        } else {
          console.log('Cant Make Payment');
        }
      })
      .catch((error: any) => {
        pr = new PaymentRequest(appConfigValues?.apple_pay?.apple_pay_methods_data, DETAILS, { ...appConfigValues?.apple_pay?.apple_pay_options, ...shippingRequired });
        console.log('Can Make Payments Error', error);
      });

The payment (ApplePay) works with the orders that are not for shipping. When shipping option is added, everything works fine, however, when a user click on apple pay button in the app and changes their shipping address within the apple wallet, or updates the current one, the payment starts processing without users actual approval. Essentially .show() method never resolves and goes to .catch block. This ends up failing with the Abort Error (content of err). Any help is appreciated.