Lewati ke konten
Buat akun
atau
Masuk
Logo Dokumen Stripe
/
Tanya AI
Buat akun
Masuk
Mulai
Pembayaran
Otomatisasi keuangan
Platform dan situs belanja online
Manajemen uang
Alat bantu pengembang
Mulai
Pembayaran
Otomatisasi keuangan
Mulai
Pembayaran
Otomatisasi keuangan
Platform dan situs belanja online
Manajemen uang
Gambaran Umum
Tentang pembayaran Stripe
Upgrade integrasi Anda
Analitik pembayaran
Pembayaran online
Gambaran umumTemukan contoh penggunaan AndaPembayaran Terkelola
Gunakan Payment Links
Buat halaman checkout
Bangun integrasi lanjutan
Bangun integrasi dalam aplikasi
Metode Pembayaran
Tambahkan metode pembayaran
    Gambaran umum
    Opsi integrasi metode pembayaran
    Kelola metode pembayaran default di Dashboard
    Tipe metode pembayaran
    Kartu
    Debit bank
    Halaman pembayaran bank
    Transfer bank
    Transfer kredit (Sumber)
    Beli sekarang, bayar nanti
    Pembayaran real-time
    Voucher
    Dompet
      Alipay
        Terima pembayaran
      Amazon Pay
      Apple Pay
      Cash App Pay
      Google Pay
      GrabPay
      Link
      MB WAY
      MobilePay
      PayPal
      PayPay
      Revolut Pay
      Satispay
      Secure Remote Commerce
      Vipps
      WeChat Pay
    Aktifkan metode pembayaran lokal menurut negara
    Metode pembayaran custom
Kelola metode pembayaran
Checkout lebih cepat dengan Link
Antarmuka pembayaran
Payment Links
Checkout
Web Elements
Elements dalam aplikasi
Skenario pembayaran
Alur pembayaran custom
Akuisisi fleksibel
Orkestrasi
Pembayaran di tempat
Terminal
Produk Stripe lainnya
Financial Connections
Kripto
Climate
BerandaPembayaranAdd payment methodsWalletsAlipay

Catatan

Halaman ini belum tersedia dalam bahasa ini. Kami sedang bekerja keras untuk membuat dokumentasi tersedia dalam lebih banyak bahasa dan akan menyediakan terjemahannya secepat mungkin.

Accept an Alipay payment

Learn how to accept Alipay payments, a digital wallet popular with customers from China.

Salin halaman

Alipay is a single-use payment method where customers are required to authenticate their payment. Customers pay by redirecting from your website or app, authorize the payment through Alipay, then return to your website or app where you get immediate notification on whether the payment succeeded or failed.

Set up Stripe
Server-side

First, you need a Stripe account. Register now.

Use our official libraries for access to the Stripe API from your application:

Command Line
Ruby
# Available as a gem sudo gem install stripe
Gemfile
Ruby
# If you use bundler, you can add this line to your Gemfile gem 'stripe'

Create a PaymentIntent
Server-side

A PaymentIntent is an object that represents your intent to collect payment from your customer and tracks the lifecycle of the payment process. Create a PaymentIntent on your server and specify the amount to collect and a supported currency. If you have an existing Payment Intents integration, add alipay to the list of payment method types.

Command Line
cURL
curl https://api.stripe.com/v1/payment_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d "payment_method_types[]"=alipay \ -d amount=1099 \ -d currency=hkd

Retrieve the client secret

The PaymentIntent includes a client secret that the client side uses to securely complete the payment process. You can use different approaches to pass the client secret to the client side.

Retrieve the client secret from an endpoint on your server, using the browser’s fetch function. This approach is best if your client side is a single-page application, particularly one built with a modern frontend framework like React. Create the server endpoint that serves the client secret:

main.rb
Ruby
get '/secret' do intent = # ... Create or retrieve the PaymentIntent {client_secret: intent.client_secret}.to_json end

And then fetch the client secret with JavaScript on the client side:

(async () => { const response = await fetch('/secret'); const {client_secret: clientSecret} = await response.json(); // Render the form using the clientSecret })();

Redirect to the Alipay Wallet
Client-side

When a customer clicks to pay with Alipay, use Stripe.js to submit the payment to Stripe. Stripe.js is the foundational JavaScript library for building payment flows. It automatically handles complexities like the redirect described below, and enables you to extend your integration to other payment methods. Include the Stripe.js script on your checkout page by adding it to the head of your HTML file.

checkout.html
<head> <title>Checkout</title> <script src="https://js.stripe.com/v3/"></script> </head>

Create an instance of Stripe.js with the following JavaScript on your checkout page.

client.js
// Set your publishable key. Remember to change this to your live publishable key in production! // See your keys here: https://dashboard.stripe.com/apikeys const stripe = Stripe(
'pk_test_TYooMQauvdEDq54NiTphI7jx'
);

Use the client secret of the PaymentIntent and call stripe.confirmAlipayPayment to handle the Alipay redirect. Add a return_url to determine where Stripe redirects the customer after they complete the payment.

client.js
const form = document.getElementById('payment-form'); form.addEventListener('submit', async function(event) { event.preventDefault(); // Set the clientSecret of the PaymentIntent const { error } = await stripe.confirmAlipayPayment(clientSecret, { // Return URL where the customer should be redirected after the authorization return_url: `${window.location.href}`, }); if (error) { // Inform the customer that there was an error. const errorElement = document.getElementById('error-message'); errorElement.textContent = error.message; } });

The return_url corresponds to a page on your website that displays the result of the payment. You can determine what to display by verifying the status of the PaymentIntent. To verify the status, the Stripe redirect to the return_url includes the following URL query parameters. You can also append your own query parameters to the return_url. They persist throughout the redirect process.

ParameterDescription
payment_intentThe unique identifier for the PaymentIntent.
payment_intent_client_secretThe client secret of the PaymentIntent object.

OpsionalHandle the redirect manually
Server-side

OpsionalHandle post-payment events

Supported currencies

You can create Alipay payments in the currencies that map to your country. The default local currency for Alipay is cny and customers also see their purchase amount in cny.

CurrencyCountry
cnyAny country
audAustralia
cadCanada
eurAustria, Belgium, Bulgaria, Cyprus, Czech Republic, Denmark, Estonia, Finland, France, Germany, Greece, Ireland, Italy, Latvia, Lithuania, Luxembourg, Malta, Netherlands, Norway, Portugal, Romania, Slovakia, Slovenia, Spain, Sweden, Switzerland
gbpUnited Kingdom
hkdHong Kong
jpyJapan
myrMalaysia
nzdNew Zealand
sgdSingapore
usdUnited States

If you have a bank account in another currency and would like to create an Alipay payment in that currency, you can contact support. Support for additional currencies is provided on a case-by-case basis.

Apakah halaman ini membantu?
YaTidak
Butuh bantuan? Hubungi Tim CS.
Bergabunglah dengan program akses awal kami.
Lihat log perubahan kami.
Ada pertanyaan? Hubungi Bagian Penjualan.
LLM? Baca llms.txt.
Dijalankan oleh Markdoc