Razorpay 结帐 window 未在 WordPress 中打开
Razorpay checkout window is not opening in WordPress
由于某些原因,我没有使用 WordPress 中提供的 razorpay 插件,而是编写了自己的插件,我在其中创建了一个表单,提交后我想将其重定向到 Razorpay 结帐 window。我已经为相同的代码编写了以下代码 -
<html>
<body>
<form action="" method=POST>
<label>Full Name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label>Mob Number:</label>
<input type="text" name="mobnum" id="mobnum"><br><br>
<label>Address:</label>
<input type="text" name="add" id="add"><br><br>
<input type="submit" name="submit" value="Submit" onclick="myFunction()">
</form>
</body>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
function myFunction() {
var name = document.getElementById("fname");
var mob = document.getElementById("mobnum");
var add = document.getElementById("add");
var options = {
"key": "*********",
"data-amount": "100", // 2000 paise = INR 20
"data-currency": "INR",
"data-id": "<?php echo 'OID'.rand(10,100).'END';?>",
"data-name": "Plugin Test",
"data-description": "Plugin Testing Training",
"handler": function (response){
alert(JSON.stringify(response));
},
"prefill": {
"name": "XYZ",
"email": "xyz@gmail.com"
},
"theme": {
"color": "#F37254"
}
};
var rzp1 = new Razorpay(options);
rzp1.open();
}
</script>
</html>
但这里的问题是 razorpay checkout window 没有打开并且它抛出如下错误 -
"serviceworker" must be a dictionary in your web app manifest.
谁能帮帮我?提前致谢。
问题似乎出在表格 'POST' 上。
所以也许你可以删除 POST 并调用 myFunction() onclick。
示例 - onClick = " myFunction()"
这个
此问题已在 jQuery 的帮助下得到解决。我添加了 jQuery 脚本并对代码进行了以下更改 -
<html>
<body>
<form action="" method=POST>
<label>Full Name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label>Mob Number:</label>
<input type="text" name="mobnum" id="mobnum"><br><br>
<label>Address:</label>
<input type="text" name="add" id="add"><br><br>
<input type="submit" name="submit" id="submit" value="Submit">
</form>
</body>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script src ="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
jQuery('#submit').on('click', function(e) {
e.preventDefault();
var name = document.getElementById("fname");
var mob = document.getElementById("mobnum");
var add = document.getElementById("add");
var options = {
"key": "*********",
"data-amount": "100", // 2000 paise = INR 20
"data-currency": "INR",
"data-id": "<?php echo 'OID'.rand(10,100).'END';?>",
"data-name": "Plugin Test",
"data-description": "Plugin Testing Training",
"handler": function (response){
alert(JSON.stringify(response));
},
"prefill": {
"name": "XYZ",
"email": "xyz@gmail.com"
},
"theme": {
"color": "#F37254"
}
};
var rzp1 = new Razorpay(options);
rzp1.open();
});
</script>
</html>
由于某些原因,我没有使用 WordPress 中提供的 razorpay 插件,而是编写了自己的插件,我在其中创建了一个表单,提交后我想将其重定向到 Razorpay 结帐 window。我已经为相同的代码编写了以下代码 -
<html>
<body>
<form action="" method=POST>
<label>Full Name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label>Mob Number:</label>
<input type="text" name="mobnum" id="mobnum"><br><br>
<label>Address:</label>
<input type="text" name="add" id="add"><br><br>
<input type="submit" name="submit" value="Submit" onclick="myFunction()">
</form>
</body>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
function myFunction() {
var name = document.getElementById("fname");
var mob = document.getElementById("mobnum");
var add = document.getElementById("add");
var options = {
"key": "*********",
"data-amount": "100", // 2000 paise = INR 20
"data-currency": "INR",
"data-id": "<?php echo 'OID'.rand(10,100).'END';?>",
"data-name": "Plugin Test",
"data-description": "Plugin Testing Training",
"handler": function (response){
alert(JSON.stringify(response));
},
"prefill": {
"name": "XYZ",
"email": "xyz@gmail.com"
},
"theme": {
"color": "#F37254"
}
};
var rzp1 = new Razorpay(options);
rzp1.open();
}
</script>
</html>
但这里的问题是 razorpay checkout window 没有打开并且它抛出如下错误 -
"serviceworker" must be a dictionary in your web app manifest.
谁能帮帮我?提前致谢。
问题似乎出在表格 'POST' 上。
所以也许你可以删除 POST 并调用 myFunction() onclick。
示例 - onClick = " myFunction()"
这个
此问题已在 jQuery 的帮助下得到解决。我添加了 jQuery 脚本并对代码进行了以下更改 -
<html>
<body>
<form action="" method=POST>
<label>Full Name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label>Mob Number:</label>
<input type="text" name="mobnum" id="mobnum"><br><br>
<label>Address:</label>
<input type="text" name="add" id="add"><br><br>
<input type="submit" name="submit" id="submit" value="Submit">
</form>
</body>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script src ="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
jQuery('#submit').on('click', function(e) {
e.preventDefault();
var name = document.getElementById("fname");
var mob = document.getElementById("mobnum");
var add = document.getElementById("add");
var options = {
"key": "*********",
"data-amount": "100", // 2000 paise = INR 20
"data-currency": "INR",
"data-id": "<?php echo 'OID'.rand(10,100).'END';?>",
"data-name": "Plugin Test",
"data-description": "Plugin Testing Training",
"handler": function (response){
alert(JSON.stringify(response));
},
"prefill": {
"name": "XYZ",
"email": "xyz@gmail.com"
},
"theme": {
"color": "#F37254"
}
};
var rzp1 = new Razorpay(options);
rzp1.open();
});
</script>
</html>