sorokin0andrey / react-native-apay

React Native bridge for Apple Pay
55 stars 30 forks source link

TypeError null is not an object (evaluating 'K.ApplePay.canMakePayments') #12

Closed ramisalem closed 4 years ago

ramisalem commented 4 years ago

Hello thanks for awsome libaray, I am trying to create a payment Request it works in my siumlator but not in real device after building it


  const requestData = {
    merchantIdentifier: 'my MID',
    supportedNetworks: ['mastercard', 'visa'],
    countryCode:  'SR',
    currencyCode: 'SAR',
    paymentSummaryItems: [
      {
        label: 'PAY TO',
        amount:  '100' ,
      },
    ],
  }

 const pay = async () => {
   // Check if ApplePay is available
   if (ApplePay.canMakePayments) {
     try {
       const paymentRequest = await ApplePay.requestPayment(requestData);
       ApplePay.complete(ApplePay.SUCCESS);
     } catch (error) {
       console.log(error);
       ApplePay.complete(ApplePay.FAILURE);
     }
   } else {
     alert("Cant make a payment")
   }
 }; 

Any tips please thanks in advnace