Reputation: 274
I am working on React Native Razorpay payment gateway integration. I am using react-native-razorpay.
Code is below:-
Send Params are:-
var options = {
description: "Credits towards consultation",
image: "https://i.imgur.com/3g7nmJC.png",
currency: "INR",
key: "a-----b----ccc-dd",
amount: Math.round(Number(order_total).toFixed(2) * 100),
name: "Product",
prefill: {
email: email ? email : "[email protected]",
contact: mobile ? mobile : "1111111111",
name:
firstname && lastname
? `${firstname} ${lastname}`
: "Razorpay Software"
},
theme: { color: theme.colors.primaryColor },
payment_capture: 1
};
Checkout Method:-
RazorpayCheckout.open(options)
.then(data => {
// handle success
console.log("payment success", data);
if (data && data.razorpay_payment_id) {
orderData.payment = data.razorpay_payment_id;
this.props.payMyOrder(orderData);
}
})
.catch(error => {
// handle failure
this.toast.show(error.description);
});
I am getting only razorpay_payment_id in response but, razorpay_payment_id and razorpay_signature are missing. Also, in Razorpay backend Razorpay Order Id and Order Id are missing.
Upvotes: 10
Views: 7903
Reputation: 895
Issue mostly will be because of invalid order Id, the order id received from Backend should be the one backend got from Razorpay.
Something like below should be used at your backend to generate order id (format of order id will be order_<some id>)
. You can get language based backend implementation at this link
var instance = new Razorpay({ key_id: 'YOUR_KEY_ID', key_secret: 'YOUR_SECRET' })
instance.orders.create({
amount: 50000,
currency: "INR",
receipt: "receipt#1",
notes: {
key1: "value3",
key2: "value2"
}
})
Upvotes: 0
Reputation: 647
Just a note if your id is wrong your razorpaySignature
too will not appear
Upvotes: 1
Reputation: 61
Please check the documentation we need to pass the order_id, here.
As per the documentation, once you pass the order_id
, then only after payment successful razorpay returns the
razorpay_order_id
,razorpay_payment_id
and razorpay_signature
.
After that you can compare the signature to get acknowledgement of payment success.
Upvotes: 1
Reputation: 81
hey as we can see in the above code options object that you are passing to the checkout you are not passing the order_id, you should pass the order_id as well. Since you are not passing the order_id the same is not getting returned to you after the payment is done. refer to the below link on how to create an order at your server-side. https://razorpay.com/docs/api/orders/ if you pass the order_id in the request param to the checkout you'll get the order_id and signature as well in the payment response.
Upvotes: 8