drsc10888 2015-11-07 04:15
浏览 41
已采纳

如何在支付网关中设置iframe的金额字段

Because we are not PCI compliant, the payment gateway providers gave us <iframe> to make payments. The issue is I cannot set the amount field inside the iframe with my cart total(19.00).

check out page:

check out page

payment page:

payment page

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){   

   $('#myiframe').load(function(){

        var iframe = $('#myiframe').contents();               

        iframe.find("#amount").val(<?php echo total; ?>);
        iframe.find("#firstname").attr('readonly','readonly');
   });
});
</script>
</head>
<body>

<iframe id="myiframe" src="paymentgateway.com">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

The above code does not work as negete.net/sys/checkout.php is in one domain and payment form in another domain. Reason is problem with Cross-Origin Resource Sharing (CORS).

I tried to solve this, but nothing worked. If anyone has encountered issues like this, your help is much appreciated. Given below are some links which I found related to CORS.

  • 写回答

1条回答 默认 最新

  • duanchi8836 2015-11-11 08:57
    关注

    I got a way to tackle the above issue. Actually it is in payment gateway issuer's documentation which I missed. The solution is you can pass the amount as an query string in iframe url .

    <iframe id="myiframe" src="paymentgateway.com?amount=50">
      <p>Your browser does not support iframes.</p>
    </iframe>
    

    Thanks for the help.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像