Stripe payments 如何在条带付款对话框弹出窗口中预填充电子邮件

Stripe payments 如何在条带付款对话框弹出窗口中预填充电子邮件,stripe-payments,Stripe Payments,我似乎找不到在条带支付弹出窗口中预填充电子邮件地址的方法。然而,这个周末我在使用条带支付的网站上注册了两个帐户,我意识到这些网站在条带对话框iframe中预先填充了我的电子邮件。所以我知道一定有办法,但我不确定怎么做。文档没有定义该属性。 有人能解释一下如何使用javascript API和“基本条带”对话框完成此操作吗?如果您正在使用,请在数据电子邮件中传递电子邮件,如下所示: <form action="/charge" method="POST"> <script

我似乎找不到在条带支付弹出窗口中预填充电子邮件地址的方法。然而,这个周末我在使用条带支付的网站上注册了两个帐户,我意识到这些网站在条带对话框iframe中预先填充了我的电子邮件。所以我知道一定有办法,但我不确定怎么做。文档没有定义该属性。 有人能解释一下如何使用javascript API和“基本条带”对话框完成此操作吗?

如果您正在使用,请在
数据电子邮件中传递电子邮件,如下所示:

<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>
//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);

如果要使用js动态设置电子邮件(用于简单签出),则必须动态创建整个脚本元素以确保其正确加载。可以这样做:

<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>
//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);

是否可以使用条带Apple Pay预填充电子邮件?如果您传递的电子邮件地址无效(如“admin”),则不会预填充。请不要忘记第二行到最后一行末尾的逗号。(就像我刚才做的那样)