Search code examples
react-nativerazorpay

How to navigate to another page if payment is success


code is working when i placed this line of code just below onpress()

but inside success callback not working

check handle success

<TouchableOpacity 
        style={styles.item}
            onPress={() => {
          RazorpayCheckout.open({
            ...
            theme: { color: "#f7b500" }
          })
            .then(data => {
              ***// handle success***
                console.log(`Success: ${data.razorpay_payment_id}`);
                console.log(reference)
                **reference.navigation.navigate("ThankyouScreen", {
                    AvailablePoints: creditScorePoints - item.cash
                });**
            })
            .catch(error => {
             ...
            });
        }}
      >

Solution

  • What is reference? if it is this.props then Make sure it is defined globally. Try to change your code with:

    //on top of class
    var reference = null;
    
    //In componentDidMount
    
    reference = this.props;