【问题标题】:i want to show jquery variable data in stripe amount我想以条带量显示 jquery 变量数据
【发布时间】:2019-07-20 00:25:14
【问题描述】:

我正在处理条带,并希望将 jquery 可变选定数据作为条带数量。

<form action="" method="post">
                    <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
                            data-key="<?php echo $publishable_key; ?>"
                            data-name="name"
                            data-description="testing"
                            data-image="test"
                            data-amount="<?php echo $plugin_price; ?>"
                            data-locale="auto"></script>
                    <?php /* you can pass parameters to php file in hidden fields, for example - plugin ID */ ?>
                    <input type="hidden" name="plugin_id" value="<?php echo $plugin_id; ?>">
                </form>

我的 jquery 代码

jQuery(function ($) {
                            $(document).ready(function () {
                                $("#next_btn1").click(function () {
                                    var favorite = [];
                                    var second = [];
                                    $.each($("input[name='check_list[]']:checked"), function () {
                                        favorite.push($(this).val());
                                        second.push($(this).data('value1'));
                                        //$("#content").append("<tr><td>" + parseFloat(favorite).toFixed(1) + "</td><td>" + second+ "</td></tr>");

                                    });
                                    alert("data: " + favorite.join(", "));
                                    alert("data1: " + second.join(", "));

                                    $('#test1').text(favorite);

                                    $('#service').text(second);
                                    //$('#datavalue').html(favorite,second);


                                });
                            });

                        });

我想获取它有价格的复选框数据,并希望这些数据在数据量中以条带形式显示

我不知道该怎么做

【问题讨论】:

    标签: jquery stripe-payments


    【解决方案1】:

    如果您想传递可变金额以显示在 Stripe 的结帐中,您需要使用他们的 custom Checkout integration,而不是简单的 data-amount 属性。

    在此处查看完整示例,https://jsfiddle.net/ywain/g2ufa8xr/

    $('#customButton').on('click', function(e) {
      // gets amount from a form input
      var amountInCents = Math.floor($("#amountInDollars").val() * 100);
    
      // Open Checkout with further options
      handler.open({
        name: 'Demo Site',
        amount: amountInCents,
      });
      e.preventDefault();
    });
    

    【讨论】:

    • 我正在获取日志,但我没有收到条带付款
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-22
    • 2021-11-25
    • 2016-02-04
    • 1970-01-01
    相关资源
    最近更新 更多