Open bavarnasivakumar opened 1 year ago
Hi, Thanks for reaching out with this issue. We do not expose types for this package from this repository, it actually comes from here https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-native-razorpay I will make sure we amend this from that repo ( in future we should try to expose these types from this repo only)
Description
Razorpay Package Version :
2.2.9
types version: 2.2.0
What you did:
I called Razorpaycheckout.open method and when the Razorpay screen is displayed, I closed the screen using close icon on top right.
What happened:
This is causing app crash and getting following error.
TypeError: undefined is not an object (evaluating 'errorResponse.metadata.order_id')
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
Suggested solution:
This happens when using types. Make metadata of ErrorResponse to be optional. This is not returned as part of ErrorResponse when user cancels the operation.
Code example, screenshot, or link to a repository:
import RazorpayCheckout, { ErrorResponse, SuccessResponse } from 'react-native-razorpay';
export const makePayment = () => { var options = { description: 'Credits towards consultation', currency: 'INR', key: RAZOR_PAY_KEY, amount: 5000, // Amount is in currency subunits. Default currency is INR. Hence, 50000 refers to 50000 paise name: 'Acme Corp', order_id: 'xxxxxxxx', };
RazorpayCheckout.open( options, (data: SuccessResponse) => { console.log('success data : ' + data.razorpay_order_id); }, (errorResponse: ErrorResponse) => { // console.log('failure data ', errorResponse.metadata.order_id); }, );
};