首页 > 解决方案 > 我想以条带量显示 jquery 变量数据

问题描述

我正在研究条带,并希望将 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);


                                });
                            });

                        });

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

我不知道该怎么做

标签: jquerystripe-payments

解决方案


如果您想传递可变金额以显示在 Stripe 的 Checkout 中,则需要使用他们的自定义 Checkout 集成,而不是简单的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();
});

推荐阅读