Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: AbortError on paymentRequest.show() #383

Open
dentep opened this issue Jan 18, 2023 · 4 comments
Open

Error: AbortError on paymentRequest.show() #383

dentep opened this issue Jan 18, 2023 · 4 comments

Comments

@dentep
Copy link

dentep commented Jan 18, 2023

Hello everyone. I am trying to follow a demo and setup Apple Pay on ios. I have configured merchantID and the library works well with a simulator. Unfortunately when I launch the app on a real device I get following error:

[Error: AbortError]

Code for running the function:

  const PaymentRequest = require('react-native-payments').PaymentRequest;
  
  const payApple = async () => {
    console.log('payApple')
    const METHOD_DATA = [{
      supportedMethods: ['apple-pay'],
      data: {
        merchantIdentifier: '****',
        supportedNetworks: ['visa'],
        countryCode: 'US',
        currencyCode: 'USD'
      }
    }];

    const OPTIONS = {
      requestPayerName: false,
      requestPayerPhone: false,
      requestPayerEmail: false,
      requestShipping: false
    };

    const DETAILS = {
      id: 'example',
      displayItems: [
        {
          label: 'Movie Ticket',
          amount: { currency: 'USD', value: '15.00' }
        }
      ],
      total: {
        label: 'Merchant Name',
        amount: { currency: 'USD', value: '15.00' }
      }
    };

    const paymentRequest = new PaymentRequest(METHOD_DATA, DETAILS, OPTIONS);
    paymentRequest.canMakePayments().
      then((canMakePayment) => {
        if (canMakePayment) {
          console.log('Can Make Payment');
          paymentRequest.show()
            .then(paymentResponse => {
              console.log('payments response')
              // Your payment processing code goes here
              paymentResponse.complete('success');
            })
            .catch((error) => {
              //error here
              console.log(error)
              console.log("Show Error", JSON.stringify(error, null, 2));
            })
        } else {
          console.log('Cant Make Payment');
        }
      })
      .catch((error) => {
        console.log("Can Make Payments Error", error);
      })
  }
"react-native": "0.67.4",
"react-native-payments": "^0.8.4",
@hivie7510
Copy link

I wish I could get this far. Even using your code I am stuck at null is not an object (evaluating 'ReactNativePayments.createPaymentRequest'). I know this is a week later, but if you see this do you have anything that you remember that would have caused this issue.

@sagarjeu
Copy link

sagarjeu commented Mar 7, 2023

[Error: AbortError]
on simulator iphone 14 for merchantIdentifier: 'merchant.apple.test',

ApplepayAPi() {
const METHOD_DATA = [
{
supportedMethods: ['apple-pay'],
data: {
merchantIdentifier: 'merchant.apple.test',
supportedNetworks: ['visa'],
countryCode: 'US',
currencyCode: 'USD',
},
},
];
const DETAILS = {
id: 'example',
displayItems: [
{
label: 'Movie Ticket',
amount: {currency: 'USD', value: '15.00'},
},
],
total: {
label: 'Merchant Name',
amount: {currency: 'USD', value: '15.00'},
},
};
const OPTIONS = {
requestPayerName: false,
requestPayerPhone: false,
requestPayerEmail: false,
requestShipping: false,
};
let paymentRequest = new PaymentRequest(METHOD_DATA, DETAILS, OPTIONS);

paymentRequest.addEventListener('shippingaddresschange', e => {
  const updatedDetails = getUpdatedDetailsForShippingAddress(
    paymentRequest.shippingAddress,
  );

  e.updateWith(updatedDetails);
});

paymentRequest.addEventListener('shippingoptionchange', e => {
  const updatedDetails = getUpdatedDetailsForShippingOption(
    paymentRequest.shippingOption,
  );

  e.updateWith(updatedDetails);
});

paymentRequest
  .canMakePayments()
  .then(canMakePayment => {
    if (canMakePayment) {
      console.log('Can Make Payment');
      paymentRequest
        .show()
        .then(paymentResponse => {
          // Your payment processing code goes here
          paymentResponse.complete('success');
          Alert.alert('Payment Complete');
        })
        .catch(error => {
          console.log('Show Error', error);
        });
    } else {
      console.log('Cant Make Payment');
    }
  })
  .catch(error => {
    console.log('Can Make Payments Error', error);
  });

}

@Nouman-Javaid
Copy link

I am facing the same error i- e
[Error: AbortError]

Did anyone find any solution?

@dfragosodiaz
Copy link

dfragosodiaz commented Jul 3, 2023

Hi! Our team is also getting a similar issue where the app crashes when using apple pay. Does anyone have any idea of why this might be happening? Did something change lately with this package that might be causing problems interacting with ApplePay?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants