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.58k stars 412 forks source link

iOS: app crash on unrecognized network name #352

Open Uriah-Eisenstein-ATT opened 2 years ago

Uriah-Eisenstein-ATT commented 2 years ago

Example:

const METHOD_DATA = [{
  supportedMethods: ['apple-pay'],
  data: {
    merchantIdentifier: 'merchant.com.your-app.namespace',
    supportedNetworks: ['visa', 'mastercard', 'amex', 'UNKNOWN-NETWORK'],
    countryCode: 'US',
    currencyCode: 'USD'
  }
}];
...
const paymentRequest = new PaymentRequest(METHOD_DATA, DETAILS);

The last line crashes on iOS because of trying to add null to an array, in ReactNativePayments.getSupportedNetworksFromMethodData.

Uriah-Eisenstein-ATT commented 2 years ago

PR #351 patches this crash.