简体   繁体   English

如何更新条带付款数据属性

[英]How to update stripe payment data attribute

I am trying to update data attribute from input value. 我正在尝试从输入值更新数据属性。 i am trying this way but not work data-description=$("#stripeAmount").val(); 我正在尝试这种方式,但不能正常工作data-description=$("#stripeAmount").val();

    <form action="paymentStrip" method="POST">
    <input type="hidden" name="stripeAmount" id="stripeAmount" value="35" />        
    <input type="hidden" name="itemid" id="itemid" value="" />
    <input type="hidden" name="business_category" id="business_category" value="1" />
    <script
           src="https://checkout.stripe.com/checkout.js" class="stripe-button"
           data-key="pk_test_pa9c33hPMCuAV941sMktI5Mw"
           data-image="http://www.phpgang.com/wp-content/themes/PHPGang_v2/img/logo.png"
          data-name="PHPGang.com"
           data-description=$("#stripeAmount").val();>
   </script>

   </form>

To change the value on change use: 要更改更改值,请使用:

$('#stripeAmount').change(function () {
   $('#stripeScript').attr('data-description', $(this).val())
});

You also have to add id="stripeScript" to the stripe <script> tag. 您还必须将id="stripeScript"添加到条纹<script>标记中。

NOTE : that being said, I am not sure if this actually does anything. 注意 :话虽这么说,我不确定这是否真的起作用。 You may have to remove the stripe script and create it for it to have effect. 您可能必须删除条纹脚本并对其进行创建才能生效。 I am not familiar with the stripe API 我不熟悉Stripe API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM