react-native-payments icon indicating copy to clipboard operation
react-native-payments copied to clipboard

iOS getting Cannot read property 'createPaymentRequest' of undefined

Open alex-mironov opened this issue 5 years ago • 5 comments

After installation of the library, an attempt to initiate payment request fails with

 WARN  Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'createPaymentRequest' of undefined
TypeError: Cannot read property 'createPaymentRequest' of undefined
    at http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:151410:29
    at tryCallTwo (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3245:7)
    at doResolve (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3409:15)
    at new Promise (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3268:5)
    at Object.createPaymentRequest (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:151405:14)
    at new PaymentRequest (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:151070:31)
    at http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:111655:30
    at http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30694:21
    at _callTimer (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30611:9)
    at Object.callTimers (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30818:9)
 WARN  Possible Unhandled Promise Rejection (id: 1):
TypeError: Cannot read property 'canMakePayments' of undefined
TypeError: Cannot read property 'canMakePayments' of undefined

The code is straightforward:

const METHOD_DATA = [{
        supportedMethods: ['apple-pay'],
        data: {
          merchantIdentifier: 'merchant.co.ynd.coffeeheroes.ios',
          supportedNetworks: ['visa', 'mastercard', 'amex'],
          countryCode: 'US',
          currencyCode: 'USD'
        }
      }]

      const DETAILS = {
        id: 'basic-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);
      paymentRequest.canMakePayments().then((canMakePayment) => {
        if (canMakePayment) {
          Alert.alert(
            'Apple Pay',
            'Apple Pay is available in this device'
          );
        }
      })

alex-mironov avatar Feb 20 '20 15:02 alex-mironov

In the node_modules ios directory is missing, any ide why is that? Screen Shot 2020-02-20 at 17 31 32

alex-mironov avatar Feb 20 '20 15:02 alex-mironov

+1

tendallas avatar Aug 06 '20 09:08 tendallas

Any solution here?

MoeMamdouh avatar Sep 03 '20 10:09 MoeMamdouh

same here

kalininilya avatar Sep 14 '20 14:09 kalininilya

same

mayur2345 avatar Sep 29 '20 12:09 mayur2345