0

I'm trying to connect my app to the google pay however when I try it I'm getting some sort of error!

I'm already tried to put in array but it didn't work.

  global.PaymentRequest = require('react-native-payments').PaymentRequest;

  export default class App extends Component<Props> {
    render() {

      const METHOD_DATA = [{
    supportedMethods: ['android-pay'],
    data: {
      supportedNetworks: ['visa', 'mastercard', 'amex'],
      currencyCode: 'USD',
      environment: 'TEST', // defaults to production
      paymentMethodTokenizationParameters: {
        tokenizationType: 'NETWORK_TOKEN',
        parameters: {
          publicKey: 'my public key'
        }
      }
    }
  }];

  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);


      return (
        <View style={styles.container}>
         <TouchableOpacity onPress={()=>paymentRequest.show()}>
          <Text  style={styles.welcome}>pay button!</Text>
          </TouchableOpacity>
        </View>
      );
    }
  }

Please inform me if I'm doing something wrong.

the error is Possile Unhandled Promise Rejection (id:0)

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Jamiryo
  • 92
  • 6
  • You could improve this question by including the error details rather than saying 'I get some sort of error'. – Knelis May 23 '19 at 13:11
  • As I mentioned in the title it is Possile Unhandled Promise Rejection (id:0) – Jamiryo May 23 '19 at 13:13
  • `paymentRequest.show()` returns a Promise. Apparently this fails, and since you're calling it right from the template, you are not handling its result. You might want to add a method to your component that wraps this call. Then chain a `.catch()` or `.then()` to catch the error and handle it properly. – Knelis May 23 '19 at 13:20

0 Answers0