razorpay / react-native-razorpay

React Native wrapper for Razorpay's mobile SDKs
https://www.npmjs.com/package/react-native-razorpay
MIT License
124 stars 107 forks source link

RazorpayCheckout.open not calling success and failure callbacks #322

Closed stackwit closed 3 years ago

stackwit commented 3 years ago

Description

For Android Integration : The App is getting crashed on successful payment or failure payment. The App is also not able to handle back and the close button on the Razorpay popup. I have tested with the test environment, What I found the SDK is not calling its success or failure callback which we provide.

Razorpay Package Version :

react-native-razorpay 2.2.4.

Java and Gradle Version (android)

Java 8 and Gradle 5.5.

What you did:

Initiating the Payment in my react-native app using the below code snippet: var options = { description: 'MY_BRAND_NAME', image: 'MY_IMAGE_URL', currency: 'INR', key: 'MY_TEST_KEY', amount: this.state.baseamt, name: ''MY_BRAND_NAME', order_id: order.payload.response.rzp_order, prefill: { email: this.state.email, contact: this.state.telephone, name: this.state.firstname, }, theme: { color: '#6E175E' },

};

RazorpayCheckout.open(options) .then(data => { // handle success // The success callback is not getting called console.log('razorpay', data); this.RazorPay( data.razorpay_payment_id, data.razorpay_signature, data.razorpay_order_id, ); this.props.navigation.navigate('ThankYou', { order_id: place_order.payload.response, amount: this.state.baseamt, paymenttype : this.state.paymentmode, }); }) .catch(error => { // handle failure //console.log('razorpay error', ); // THis failure callback is also not getting called. this.props.navigation.navigate('ThankYou', { order_id: 'place_order.payload.response', amount: 'this.state.baseamt', paymenttype : 'this.state.paymentmode', }); ToastAndroid.showWithGravityAndOffset( error.description, ToastAndroid.LONG, ToastAndroid.BOTTOM, 0, 10, ); });

sumedht commented 3 years ago

@genioapps Will look into this.

0x61x commented 3 years ago

@genioapps how did you solve this? I'm facing the same issue.

stackwit commented 3 years ago

@genioapps how did you solve this? I'm facing the same issue.

Some other third party plugin was conflicting with the react-native-razorpay package on the native side. The steps I have taken in order to resolve that are as mentioned below:

Thanks

0x61x commented 3 years ago

@genioapps thanks for the quick reply. I'm thinking in the same direction. Could you please share the conflicting package in your case, maybe it will help me to identify it quickly?

Thanks

Aryan6290 commented 3 years ago

Any solution for this issue?

0x61x commented 3 years ago

In my case, onActivityResult function in MainActivity.java was conflicting with Razorpay package. Removing the conflicting function from MainActivity.java allowed the onActivityResult of Razorpay package to execute and solved the issue.

Hope this helps!

Aryan6290 commented 3 years ago

For anyone who is facing this problem , downgrade to 2.2.7 instead of 2.2.8 , it works as expected after rebuilding !