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.
这篇关于在条纹按钮上设置数据属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在条纹按钮上设置数据属性


基础教程推荐
- fetch 是否支持原生多文件上传? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01