<div id="paytm-checkoutjs"></div>
<script type="application/html" crossorigin="anonymous" src="https://securegw-stage.paytm.in/merchantpgpui/checkoutjs/merchants/demoKey.js" onload="onScriptLoad();"> </script>
<script>
function onScriptLoad(){
var config = {
"root": "",
"flow": "DEFAULT",
"data": {
"orderId": "", /* update order id */
"token": "", /* update token value */
"tokenType": "TXN_TOKEN",
"amount": "" /* update amount */
},
"handler": {
"notifyMerchant": function(eventName,data){
console.log("notifyMerchant handler function called");
console.log("eventName => ",eventName);
console.log("data => ",data);
}
}
};
if(window.Paytm && window.Paytm.CheckoutJS){
window.Paytm.CheckoutJS.onLoad(function excecuteAfterCompleteLoad() {
// initialze configuration using init method
window.Paytm.CheckoutJS.init(config).then(function onSuccess() {
// after successfully updating configuration, invoke JS Checkout
window.Paytm.CheckoutJS.invoke();
}).catch(function onError(error){
console.log("error => ",error);
});
});
}
}
</script>选择付款选项后的表单如下所示。请让我知道如何从下面的表格到上面写的函数的值,并工作的支付网关。
<div class="container" style="padding-top:100px;">
<form action="" method="post">
<input type="hidden" id="CUST_ID" name="CUST_ID" value="<?php echo $txtMarketCode; ?>">
<input type="hidden" id="INDUSTRY_TYPE_ID" name="INDUSTRY_TYPE_ID" value="Retail">
<input type="hidden" id="CHANNEL_ID" name="CHANNEL_ID" value="WEB">
<div class="form-group">
<label>Order ID:</label>
<input type="text" class="form-control" id="ORDER_ID" name="ORDER_ID" size="20" maxlength="20" autocomplete="off" tabindex="1" value="<?php echo $txtTranID; ?>">
</div>
<div class="form-group">
<label>Amount to Pay:</label>
<input type="text" class="form-control" id="TXN_AMOUNT" name="TXN_AMOUNT" autocomplete="off" tabindex="5" value="<?php echo $txtTxnAmount; ?>">
</div>
<div class="form-group">
<input type="submit" name="submit" value="CheckOut" class="btn btn-success btn-lg" style="background-
color:#0000FF; margin-left: 37%;">
</div>
</form>
</div>
</body>我已经尝试添加JS Checkout为Paytm支付网关集成到我的网站。如何将值从我的php表单传递到上面的onScriptLoad()函数。请帮我合并这个功能。
发布于 2021-04-30 13:14:51
首先,您需要调用initiate transaction API,它将返回一个事务令牌。传递函数中获取的交易token,方法如下:
function onScriptLoad(){
var config = {
"root": "",
"flow": "DEFAULT",
"data": {
"orderId": "<?php echo $orderid;?>", /* update order id */
"token": "<?php echo $txn_token;?>", /* update token value */
"tokenType": "TXN_TOKEN",
"amount": "<?php echo $amount;?>" /* update amount */
},
"handler": {
"notifyMerchant": function(eventName,data){
console.log("n`enter code here`otifyMerchant handler function called");
console.log("eventName => ",eventName);
console.log("data => ",data);
}
}
};
if(window.Paytm && window.Paytm.CheckoutJS){
window.Paytm.CheckoutJS.onLoad(function excecuteAfterCompleteLoad() {
// initialze configuration using init method
window.Paytm.CheckoutJS.init(config).then(function onSuccess() {
// after successfully updating configuration, invoke JS Checkout
window.Paytm.CheckoutJS.invoke();
}).catch(function onError(error){
console.log("error => ",error);
});
});
}
}如果仍然不能解决您的问题,请向"Paytm开发人员支持“提出疑问。
https://stackoverflow.com/questions/67311182
复制相似问题