如何在 Stripe 付款对话框弹出窗口中预填充电子邮件
How to pre-populate email in the Stripe payments dialog popup
我似乎找不到在条带付款弹出窗口中预填充电子邮件地址的方法。然而这个周末我在使用条纹支付的网站上注册了两个账户,我意识到这些网站在条纹对话框 iframe 框中预填充了我的电子邮件。所以我知道一定有办法,但我不确定该怎么做。文档没有定义 属性。
有人可以解释一下这是如何使用 javascript API 和基本的 Stripe 对话框完成的吗?
如果您使用 Simple Checkout,您可以像这样在 data-email
中传递电子邮件:
<form action="/charge" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_6pRNASCoBOKtIshFeQd4XMUh"
data-image="/img/documentation/checkout/marketplace.png"
data-name="Stripe.com"
data-description="2 widgets"
data-amount="2000"
data-email="customer@email.com"
data-locale="auto">
</script>
</form>
如果您使用 Custom Checkout,请将 email
参数中的电子邮件传递给 handler.open()
:
handler.open({
name: 'Stripe.com',
description: '2 widgets',
amount: 2000,
email: "customer@email.com"
});
如果您想使用 js 动态设置电子邮件(用于 Simple Checkout ),您必须动态创建整个脚本元素以确保它正确加载。可以这样做:
//create our stipe script element
var stripescript = document.createElement('script'); //create script element
//dynamicaly load stripe checkout attributes
stripescript.setAttribute('src','https://checkout.stripe.com/checkout.js');
stripescript.setAttribute("data-key","[YOUR STRIPE TOKEN]" )
stripescript.setAttribute("data-amount","90" )
stripescript.setAttribute("data-locale","auto")
stripescript.setAttribute("class","stripe-button")
stripescript.setAttribute("data-billing-address",true)
stripescript.setAttribute("data-panel-label","Update")
stripescript.setAttribute("data-currency","gbp")
// any other attributes you want to add stripescript.setAttribute("[name]","[value]")
//insert script element inside of div or an other element
document.getElementById('[ID OF ELEMENT YOU WANT TO PUT THE FORM INTO]').appendChild(stripescript);
我似乎找不到在条带付款弹出窗口中预填充电子邮件地址的方法。然而这个周末我在使用条纹支付的网站上注册了两个账户,我意识到这些网站在条纹对话框 iframe 框中预填充了我的电子邮件。所以我知道一定有办法,但我不确定该怎么做。文档没有定义 属性。 有人可以解释一下这是如何使用 javascript API 和基本的 Stripe 对话框完成的吗?
如果您使用 Simple Checkout,您可以像这样在 data-email
中传递电子邮件:
<form action="/charge" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_6pRNASCoBOKtIshFeQd4XMUh"
data-image="/img/documentation/checkout/marketplace.png"
data-name="Stripe.com"
data-description="2 widgets"
data-amount="2000"
data-email="customer@email.com"
data-locale="auto">
</script>
</form>
如果您使用 Custom Checkout,请将 email
参数中的电子邮件传递给 handler.open()
:
handler.open({
name: 'Stripe.com',
description: '2 widgets',
amount: 2000,
email: "customer@email.com"
});
如果您想使用 js 动态设置电子邮件(用于 Simple Checkout ),您必须动态创建整个脚本元素以确保它正确加载。可以这样做:
//create our stipe script element
var stripescript = document.createElement('script'); //create script element
//dynamicaly load stripe checkout attributes
stripescript.setAttribute('src','https://checkout.stripe.com/checkout.js');
stripescript.setAttribute("data-key","[YOUR STRIPE TOKEN]" )
stripescript.setAttribute("data-amount","90" )
stripescript.setAttribute("data-locale","auto")
stripescript.setAttribute("class","stripe-button")
stripescript.setAttribute("data-billing-address",true)
stripescript.setAttribute("data-panel-label","Update")
stripescript.setAttribute("data-currency","gbp")
// any other attributes you want to add stripescript.setAttribute("[name]","[value]")
//insert script element inside of div or an other element
document.getElementById('[ID OF ELEMENT YOU WANT TO PUT THE FORM INTO]').appendChild(stripescript);