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

Apple Pay not opening in latest v0.8.0 #256

Closed dhairyasenjaliya closed 3 years ago

dhairyasenjaliya commented 3 years ago

Library version : "react-native-payments": "0.8.0", React Version : "react-native": "0.63.2",

when I try to open apple Pay with this method paymentRequest.show() it always throws error : [ AbortError ] also I have check for paymentRequest.canMakePayments() which returns true

Please any help would really appreciated I really need to add ApplePay in my app

nabilfreeman commented 3 years ago

Hi @dhairyasenjaliya , can you try and replicate by cloning the example project at https://github.com/freeman-industries/react-native-payments-example-ios?

It would be helpful to know if it's a configuration issue, an environment one or a bug in the code.

Please let me know how you get on and I can advise further. Feel free to post the arguments you are initializing paymentRequest with (careful not to share your Stripe/Braintree keys)

dhairyasenjaliya commented 3 years ago

Hello @nabilfreeman im using basic details only and also let me try example so to get idea

const DETAILS = [{ id: 'basic-example', displayItems: [ { label: productName, amount: { currency: 'USD', value: this.props.orderType == '1' ? totalPrice : totalPrice, }, }, ], total: { label: 'Amount', amount: { currency: 'USD', value: this.props.orderType == '1' ? payAmount : payAmount, }, }, };]

  const METHOD_DATA = [
    {
      supportedMethods: ['apple-pay'],
      data: {
        merchantIdentifier: 'test',

        supportedNetworks: ['visa', 'mastercard', 'amex'],
        countryCode: 'US',
        currencyCode: 'USD',
      },
    },
  ];
dhairyasenjaliya commented 3 years ago

Hello @nabilfreeman I have tried your example its not opening in real devices however its working in simulator [Error: AbortError] throwing this error while paymentRequest.show()

Not Working in device Device : iPhone 6s Os Version : 14.2

Working in simulator Simulator : iPhone 11 Pro Os Version: 14.2

dineshkokare123 commented 3 years ago

possible unhandled promise rejection typeerror undefined is not an object ('ReactNativePayments.canMakePayments') check = () => { paymentRequest.canMakePayments().then((canMakePayment) => { if (canMakePayment) { Alert.alert( 'Apple Pay', 'Apple Pay is available in this device' ); } }) }

pay = () => { paymentRequest.canMakePayments().then((canMakePayment) => { if (canMakePayment) { console.log('Can Make Payment') paymentRequest.show() .then(paymentResponse => { // Your payment processing code goes here

      paymentResponse.complete('success');
    });
}
else {
  console.log('Cant Make Payment')
}

}) }

dhairyasenjaliya commented 3 years ago

@dineshkokare123 but im not able to open apple Pay menu and I'm getting canMakePayment === true

dhairyasenjaliya commented 3 years ago

Hello @nabilfreeman I managed to figure out that issue was with merchantIdentifier was not correct 😆 and congratulation for the baby 🤗

dineshkokare123 commented 3 years ago

@nabilfreeman I have this issue can help me to figure whats wrong happend with me thanks in advacne. possible unhandled promise rejection typeerror undefined is not an object ('ReactNativePayments.canMakePayments') check = () => { paymentRequest.canMakePayments().then((canMakePayment) => { if (canMakePayment) { Alert.alert( 'Apple Pay', 'Apple Pay is available in this device' ); } }) }

pay = () => { paymentRequest.canMakePayments().then((canMakePayment) => { if (canMakePayment) { console.log('Can Make Payment') paymentRequest.show() .then(paymentResponse => { // Your payment processing code goes here

  paymentResponse.complete('success');
});

} else { console.log('Cant Make Payment') } }) }

nabilfreeman commented 3 years ago

Thanks mate!! That's really good to know. It would be better if this was easy to debug so I'll bear that in mind.

And I appreciate your congratulations 😍