【问题标题】:For Paytm JS Checkoput对于 Paytm JS 结帐
【发布时间】:2021-04-29 04:48:05
【问题描述】:
<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>

我已尝试将用于 Paytm 支付网关集成的 JS Checkout 添加到我的网站。如何将值从我的 php 表单传递到上面的 onScriptLoad() 函数。请帮我加入这个功能。

【问题讨论】:

    标签: payment paytm


    【解决方案1】:

    首先,您需要调用发起交易 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 开发者支持”中提出查询

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-01
      • 2021-07-08
      • 1970-01-01
      • 2022-07-18
      • 1970-01-01
      • 2014-08-30
      • 1970-01-01
      • 2017-05-20
      相关资源
      最近更新 更多