Setting data attribute on stripe button(在条纹按钮上设置数据属性)
问题描述
我想不通.我检查了有关设置数据属性的其他问题,似乎是一件很棘手的事情.
I can't figure this out. I checked other questions regarding setting data attributes, seems to be a tricky enough thing.
条纹按钮数量纯粹是为了美观,每次用户更新数量选择框时,我都会尝试设置它('data-amount').
The stripe button amount is purely for aesthetics, I'm trying to set it ('data-amount') each time a user updates the quantity select box.
每次我更改数量时,选择一个警报都会给出正确的数量,如果我检查 dom,'data-amount' 属性似乎设置正确,但是当我单击条纹按钮时,模式显示默认数据量,即什么都没有.
Every time I change the quantity select an alert gives the correct amount and if I inspect the dom the 'data-amount' attribute appears to be set correctly but when I click the stripe button the modal shows the default data-amount, i.e nothing.
有人知道怎么做吗?
查看(表单,选择输入未显示)
view (form, select input not shown)
<div class="stripe-controls" align="center">
<script src="https://button.stripe.com/v1/button.js" class="stripe-button"
data-key="ENV['STRIPE_PUBLIC_KEY'] %>" data-amount="">
</script>
</div>
咖啡脚本
$ ->
$('#order_quantity').click(orderTotal)
orderTotal()
orderTotal = ->
quantity = $('#order_quantity').val()
price = $('#ticket-price').data('url')
total = quantity * price
$('.stripe-button').attr('data-amount', total)
alert total
推荐答案
使用 StripeCheckout 指定自定义金额.open()
.
注意:我在 Stripe 工作.
Note: I work at Stripe.
这篇关于在条纹按钮上设置数据属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在条纹按钮上设置数据属性


基础教程推荐
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 动态更新多个选择框 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01