简体   繁体   English

条纹支付集成-将.js [checkout.js]移出循环的方法是什么?

[英]Stripe payment integration - What is the way to move .js [checkout.js] outside of loop?

I'm creating stripe payment form according to their documentation. 我正在根据他们的文档创建条纹付款表格。 I need to use it in wordpress loop to it looks like: 我需要在wordpress循环中使用它,如下所示:

Start loop:
Item name
Item img
Item desc 
etc.

    <form action="/charge" method="POST">
  <script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="pk_test_23123123"
    data-amount="2000"
    data-name="name"
    data-description="2 widgets"
    data-locale="auto"
    data-zip-code="true"
    data-currency="eur">
  </script>
</form>
Stop loop

But there's a problem - after adding stripe code website works very slow. 但是有一个问题-添加条带代码后,网站工作非常缓慢。 I think it's about loading checkout.js multiple times. 我认为这是关于多次加载checkout.js的问题。 Is there a solution to move .js above the loop? 是否存在将.js移到循环上方的解决方案?

First, please note that Stripe's Checkout form does not process payments by itself -- it only collects a customer's card information and turns it into a token. 首先,请注意,Stripe的Checkout表单本身不会处理付款-它仅收集客户的卡信息并将其转换为令牌。 The token must then be sent to your backend server where it can be used to eg create a charge . 然后必须将令牌发送到您的后端服务器,在该服务器中可以使用它来创建费用

You can get around loading Checkout multiple times using a custom integration . 您可以使用自定义集成多次加载Checkout。 This way, Checkout's script would only be loaded once, and you would then call the configure() and open() methods on the StripeCheckout object to open the form with the parameters you want. 这样,Checkout的脚本将只加载一次,然后您将在StripeCheckout对象上调用configure()open()方法以使用所需的参数打开表单。

Since you're using WordPress, it might be simpler to use an already existing Stripe plugin. 由于您使用的是WordPress,因此使用现有的Stripe插件可能更简单。 You can find some of those plugins here: https://wordpress.org/plugins/search.php?q=stripe 您可以在这里找到其中一些插件: https : //wordpress.org/plugins/search.php?q=stripe

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Stripe Checkout.js 令牌回调会在付款处理之前阻止吗? - Does Stripe Checkout.js token callback block until payment processed? 数据完成事件在万事达卡支付网关 Checkout.js 集成中不起作用 - data-complete event not working in Mastercard Payment Gateway Checkout.js integration Stripe checkout.js - 将自定义参数传递给令牌回调 - Stripe checkout.js - passing custom params to token callback 如何设计类似于paypal或stripe的自己的checkout.js - How to design own checkout.js similar to paypal or stripe Stripe Checkout https://checkout.stripe.com/checkout.js 和 Elements https://js.stripe.com/v3/ 之间的区别 - Difference between Stripe Checkout https://checkout.stripe.com/checkout.js and Elements https://js.stripe.com/v3/ 如何从条纹 checkout.js 迁移到条纹元素? - how can I migrate from stripe checkout.js to stripe elements? 托管结帐交互页面 (Checkout.js) 的万事达卡支付网关服务 (MPGS) 问题 - Master Card Payment Gateway Services (MPGS) Issue With Hosted Checkout Interaction Page (Checkout.js) 万事达支付网关 checkout.js 方法未触发完整回调 function - MasterCard payment gateway checkout.js method not triggering complete Callback function 从 checkout.js 迁移到 JavaScript SDK,但在执行付款之前授权? - Migrating from checkout.js to JavaScript SDK, but authorising before executing the payment? PayPal checkout.js-获取付款ID和付款人ID - PayPal checkout.js - Get paymentID & payerID
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM