Closed SHAHRUKH-KHAN closed 2 years ago
Can you try this once, to generate signature
expected_signature = razorpay_invoice_id + '|' +
razorpay_invoice_receipt + '|' +
razorpay_invoice_status + '|' +
razorpay_payment_id;
@umanghome Can we expect an update on this?
I am getting undefined values of razorpayOrderId and razorpaySignature from the handler response while working on test mode. So the payment verification fails in the backend. I have been stuck at this for over a day now. Any help is highly appreciated.
This is my code snippet:
` const launchRazorpay = async () => { const order = await axios.post"http://localhost:8081/api/subscription/pay");
const { amount, id: order_id, currency } = order.data;
console.log(order);
const options = {
key: "rzp_test_asdfg345dfCVBN",
amount: amount,
currency: currency,
name: "Razorpay",
description: "PAY YOUR SUBSCRIPTION FEES",
image: `${process.env.PUBLIC_URL}/assets/images/logo.png`,
orderId: order_id,
handler: function (response) {
alert(response.razorpay_payment_id);// pay_asd1234
alert(response.razorpay_order_id);// undefined
alert(response.razorpay_signature);// undefined
},
prefill: {
name: "abc",
email: "abc@gmail.com",
contact: "+911234567890",
},
};
console.log("====================================");
console.log(options.orderId === order_id); // true
console.log(response.razorpay_order_id === order_id);// false
console.log("====================================");
const paymentObject = new window.Razorpay(options);
paymentObject.open();
};
`
@DibyajyotiMishra were you able to fix this.I am facing the same issue in live mode but works fine in test
yes. The function should be async.
handler: async function (response) {
const data = {
orderId: order_id,
doneBy: authState.userId,
institutionType: authState.userType,
razorpayPaymentId: response.razorpay_payment_id,
razorpayOrderId: response.razorpay_order_id,
razorpaySignature: response.razorpay_signature,
};
console.log(data);
Hope it helps.
@SHAHRUKH-KHAN @DibyajyotiMishra Sorry for the delay . the sdk is updated now for payment signature you can use this code snippet
var { validatePaymentVerification } = require('razorpay/dist/utils/razorpay-utils');
const respBody = { 'subscription_id':'sub_ID6MOhgkcoHj9I', 'payment_id':'pay_IDZNwZZFtnjyym' }
const correctSignature = '601f383334975c714c91a7d97dd723eb56520318355863dcf3821c0d07a17693'
secret = 'EnLs21M47BllR3X8PSFtjtbd';
validatePaymentVerification(respBody, correctSignature, secret)
you can also use this doc
I am closing this issue for now. If you are still facing the same issue, please do not hesitate to reopen it. Please feel free to add any other suggestions you may have.
Hi Team,
This is related to the closed issue.
The signature is generated which is not matched. variables used above:
+1 if you face the same. Razorpay Team - Please look into this.