joshnuss / svelte-stripe

Everything you need to add Stripe Elements to your Svelte project
https://sveltestripe.com
MIT License
423 stars 41 forks source link

Alipay and WeChat Payment Types #11

Closed WeAreELIC closed 3 years ago

WeAreELIC commented 3 years ago

I would love to see Alipay and WeChat payment types supported so our China customers can easily pay. Thanks!

joshnuss commented 3 years ago

Hi @WeAreELIC,

I'm not too familiar with WeChat and AliPay, but I believe a custom Svelte component isn't needed for these because the payment is completed with a redirect, so any button will do.

From reading the docs, the flow works like this:

  1. Add a button "Pay with WeChat" or "Pay with AliPay"
  2. When the button is clicked, POST to server to create the PaymentIntent (using payment_method_types: ["alipay"] or payment_method_types: ["wechat_pay"] and then return the PaymentIntent's client_secret
  3. Using that client_secret, call stripe.confirmWechatPayPayment(client_secret) or stripe.confirmAlipayPayment(client_secret). That will redirect the user to their wallet.

Stripe's docs:

Let me know if you have questions