所以,我一直在尝试为我获取自定义条纹结帐表单 . 我无法使用简单版本,因为我需要能够更改要支付的金额以及每次购买的描述,其中标准条带结帐表单只设置了这两个无法更改的变量的值 . 但是,我不想使用自定义表单,我只想使用标准表单结帐 . 我的问题是尝试将这些数据发送到服务器,我已经尝试了许多不同的方法,但我似乎无法让它工作 . 这是我的代码:
<p><input id="buy-submit-button" class="button" type="submit" value="チェックアウト"></input></p>
<script>
var handler = StripeCheckout.configure({
key: 'pk_test_g6do5S237ekq10r65BnxO6S0',
locale: 'auto',
token: function(token) {
//don't know what needs to go here
}
});
document.getElementById("buy-submit-button").addEventListener('click', function(e) {
setTimeout(function(){
var totalCost = 0;
var totalCartLoad = "";
totalCost = localStorage.getItem('totalCartPrice');
totalCartLoad = localStorage.getItem('whatsInCart');
totalCartLoad = totalCartLoad.replace('undefined','');
// Open Checkout with further options:
handler.open({
name: "チェックアウト",
description: totalCartLoad,
shippingAddress: true,
billingAddress: true,
zipCode: true,
allowRememberMe: true,
currency: 'JPY',
amount: totalCost
});
e.preventDefault();
}, 500);
});
// Close Checkout on page navigation:
window.addEventListener('popstate', function() {
handler.close();
});
</script>
所以我再说一遍 . 我想要做的就是使用条纹默认表单,当您按下按钮然后将其提交给服务器时会弹出,执行此操作的正确方法是什么?
1 回答
我能够使用这里提供给另一个问题的答案来解决这个问题:make-stripe-data-amount-use-a-dynamic-with-a-variable