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
发布评论