在条带按钮中创建自定义金额(Create Custom Amount in Stripe Button)

编程入门 行业动态 更新时间:2024-10-27 20:28:03
条带按钮中创建自定义金额(Create Custom Amount in Stripe Button)

Stripe使用卡片按钮轻松付费。 我想破解它,所以我可以通过自定义金额。 (默认为20)

目前正在建设的网站是http://pecosselfstorage.com/testpayments.html

我需要客户能够投入他们想付出的很多钱。 是否在单击按钮后弹出窗口或按钮旁边的页面并不重要。 不过我更喜欢弹出窗口。

请不要只发布指向Stripe网站的链接,我已经完成了所有这些,但在那里找不到任何帮助。

欢迎任何想法。 谢谢!

Stripe has an easy pay with card button. I want to hack it so I can pass a custom amount to it. (It defaults to 20)

The site currently under construction is http://pecosselfstorage.com/testpayments.html

I need the customer to be able to put in however much they want to pay. Whether this is in the pop-up after they click the button, or on the page next to the button doesn't matter much. I'd prefer it to be in the pop-up however.

Please don't just post links to Stripe's site, I've been through all of that and can't find any help there.

Any thoughts are welcome. Thanks!

最满意答案

不需要黑客攻击。 Checkout没有“默认” - 无论你传入什么amount (或通过data-amount属性,基本版本)都是它所要求的。

如果您想让客户设置自己的价格,您只需要一个文本字段和一些JavaScript将该字段的内容注入您的Checkout调用(记住整数分数)。

可能最简单的方法是在主页面上放置一个文本字段,然后添加自己的按钮并通过其API调用Checkout。 它可以使用默认按钮,但您不必通过这种方式触摸DOM或监视文本字段以进行更改。

快速而又脏的jQuery- ish伪代码,假设一个按钮#payButton :

$('#payButton').click(function() { // prep goes here StripeCheckout.open({ // data goes here amount: $('#payAmount').val * 100, // rest of data goes here }); // etc });

No hacking needed. Checkout doesn't have a "default"—whatever you pass in as amount (or via the data-amount attribute, for the basic version) is what it bills.

If you want to let customers set their own price, you only need a text field and some JavaScript to inject the contents of that field into your Checkout call (in integer cents, remember).

Probably the easiest way to do this is to put a text field on the main page, then add your own button and call Checkout via its API. It'd be doable with the default button, but you don't have to touch the DOM or monitor the text field for changes this way.

Quick and dirty jQuery-ish pseudocode, assuming a button #payButton:

$('#payButton').click(function() { // prep goes here StripeCheckout.open({ // data goes here amount: $('#payAmount').val * 100, // rest of data goes here }); // etc });

更多推荐

Stripe,按钮,site,网站,电脑培训,计算机培训,IT培训"/> <meta name="description

本文发布于:2023-07-05 07:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034908.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:条带   自定义   金额   按钮   Create

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!