我完全是一个支付网关的初学者,不知道如何接近它。但我经历了Razorpay方面和所有其他堆叠溢出问题,从2天开始,我一直在努力将Razorpay网关集成到我的项目中。现在我正在使用JavaScript来接近支付网关。我的项目是一个基于java的在线购物网站,但我使用JavaScript来提供网站中的功能。
<script type="text/javascript" src="https://checkout.razorpay.com/v1/razorpay.js"></script>
</head>
<input type="button" id="razorGateway" name="submit" class="submit action-button"
value="Pay" />
<script type="text/javascript">
var options = {
"key": "rzp_test_1234567UHGSssj", // Enter the Key ID generated from the Dashboard
"amount": "50000", // Amount is in currency subunits. Default currency is INR. Hence, 50000 refers to 50000 paise or INR 500.
"currency": "INR",
"name": "Acme Corp",
"description": "Ecommerce",
"image": "image",
"order_id": "order_9A33XWu170gUtm",//This is a sample Order ID. Create an Order using Orders API. (https://razorpay.com/docs/payment-gateway/orders/integration/#step-1-create-an-order). Refer the Checkout form table given below
"handler": function (response){
alert(response.razorpay_payment_id);
},
"prefill": {
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9999999999"
},
"notes": {
"address": "note value"
},
"theme": {
"color": "#EA5B29"
}
};
var rzp1 = new window.Razorpay(options);
document.getElementById('razorGateway').onclick = function(e){
rzp1.open();
e.preventDefault();
}
</script>调试后,我将收到一条错误消息。rzp1.open()屏幕截图
当我无法与上述方法集成时,我采用了另一种方法。
<script>
// Single instance on page.
var razorpay = new Razorpay({
key: 'rzp_test_1234567UHGSssj',
// logo, displayed in the payment processing popup
image: 'https://i.imgur.com/n5tjHFD.png',
});
//Fetching the payment.
razorpay.once('ready', function(response) {
console.log(response.methods);
})
//Submitting the data.
var data = {
amount: 1000, // in currency subunits. Here 1000 = 1000 paise, which equals to ₹10
currency: "INR",// Default is INR. We support more than 90 currencies.
email: 'test.appmomos@gmail.com',
contact: '9123456780',
notes: {
address: 'Ground Floor, SJR Cyber, Laskar Hosur Road, Bengaluru',
},
// order_id: '123',
method: 'netbanking',
// method specific fields
bank: 'HDFC'
};
$("#razorGateway").click (function(){
alert("payment clicked");
// has to be placed within user initiated context, such as click, in order for popup to open.
razorpay.createPayment(data);
razorpay.on('payment.success', function(resp) {
alert("payment checking.");
alert(resp.razorpay_payment_id),
alert(resp.razorpay_order_id),
alert(resp.razorpay_signature)}); // will pass payment ID, order ID, and Razorpay signature to success handler.
razorpay.on('payment.error', function(resp){alert(resp.error.description)}); // will pass error object to error handler
})
</script>在这里,我可以点击剃须刀和弹出也是可见的,但由于它是硬编码,我无法得到各种选择的支付方法,因为它显示在演示。它直接给了我成功和失败的信息(网关的最后一页)。https://razorpay.com/demo
这个选项我没有得到。不同支付方式
如果我得到答案,或者我能够以任何方式或任何其他方式集成它,我就会站在第9位。也欢迎在Java中集成的选项。
发布于 2020-12-18 03:16:02
Hi,我认为您需要从服务器端生成一个实际的order_id,就像他们的docs 这里中提到的那样。而不是样本order id。
https://stackoverflow.com/questions/60201722
复制相似问题