opsway / react-native-paytm

Unofficial React Native wrapper for PayTM iOS/Android SDK
10 stars 10 forks source link

How to know if payment succeeds? #5

Closed karanpratapsingh closed 5 years ago

karanpratapsingh commented 5 years ago

Right now after the payment is complete...It just shows a blank white screen, how can I know if it has succeeded or failed?

Thanks

philly25 commented 5 years ago

In usage example you should use onPayTmResponse method to handle PayTM response. On Android you should check property STATUS, if it's 'TXN_SUCCESS', then transaction succeed.

onPayTmResponse = (resp) => {
    const {STATUS, status, response} = resp;

    if (Platform.OS === 'ios') {
      if (status === 'Success') {
        const jsonResponse = JSON.parse(response);
        const {STATUS} = jsonResponse;

        if (STATUS && STATUS === 'TXN_SUCCESS') {
          // Payment succeed!
        }
      }
    } else {
      if (STATUS && STATUS === 'TXN_SUCCESS') {
        // Payment succeed!
      }
    }
  };
philly25 commented 5 years ago

this response comes from Transaction Status API request. This is the last step of the PayTm flow.

karanpratapsingh commented 5 years ago

Thanks