Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Revenue
Platforms and marketplaces
Money management
Developer resources
Overview
About Stripe payments
Upgrade your integration
Payments analytics
Online payments
OverviewFind your use caseManaged Payments
Use Payment Links
Build a checkout page
Build an advanced integration
Build an in-app integration
Payment Methods
Add payment methods
    Overview
    Payment method integration options
    Manage default payment methods in the Dashboard
    Payment method types
    Cards
    Pay with Stripe balance
    Crypto
    Bank debits
    Bank redirects
    Bank transfers
    Credit transfers (Sources)
    Buy now, pay later
    Real-time payments
    Vouchers
    Wallets
      Alipay
        Accept a payment
      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
    Enable local payment methods by country
    Custom payment methods
Manage payment methods
Faster checkout with Link
Payment interfaces
Payment Links
Checkout
Web Elements
In-app Elements
Payment scenarios
Handle multiple currencies
Custom payment flows
Flexible acquiring
Orchestration
In-person payments
Terminal
Beyond payments
Incorporate your company
Crypto
Financial Connections
Climate
HomePaymentsAdd payment methodsWalletsAlipay

Accept an Alipay payment

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

Alipay is a single-use payment method where customers are required to authenticate their payment. Customers pay by redirecting from your website or app, authorise 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
Client-side

First, you need a Stripe account. Register now.

Server-side

This integration requires endpoints on your server that talk to the Stripe API. Use the official libraries for access to the Stripe API from your server:

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'

Client-side

The Stripe Android SDK is open source and fully documented.

To install the SDK, add stripe-android to the dependencies block of your app/build.gradle file:

build.gradle.kts
Kotlin
plugins { id("com.android.application") } android { ... } dependencies { // ... // Stripe Android SDK implementation("com.stripe:stripe-android:21.18.0") // Include the financial connections SDK to support US bank account as a payment method implementation("com.stripe:financial-connections:21.18.0") }

Note

For details on the latest SDK release and past versions, see the Releases page on GitHub. To receive notifications when a new release is published, watch releases for the repository.

Configure the SDK with your Stripe publishable key so that it can make requests to the Stripe API, such as in your Application subclass:

Kotlin
import com.stripe.android.PaymentConfiguration class MyApp : Application() { override fun onCreate() { super.onCreate() PaymentConfiguration.init( applicationContext,
"pk_test_TYooMQauvdEDq54NiTphI7jx"
) } }

Note

Use your test keys while you test and develop, and your live mode keys when you publish your app.

Stripe samples also use OkHttp and GSON to make HTTP requests to a server.

Integrate the Alipay SDK
Client-side

For in-app payments using Alipay’s app-to-app redirect flow, you must integrate the Alipay SDK. If you don’t want to integrate the Alipay SDK, the Stripe SDK uses a WebView to redirect customers to Alipay. Integrating the Alipay SDK provides a more seamless experience for your customers, but increases the overall size of your app. See Use a WebView for more details.

After unzipping the archive, add alipaySdk-{version}.aar to the libs directory of your app. Add the libs folder to your project’s dependency repository list:

build.gradle
allprojects { repositories { flatDir { dirs 'libs' } } }

Add the dependency to your app:

app/build.gradle
dependencies { // ... // Replace {version} with the version number of the Alipay SDK that you downloaded above implementation(name:"alipaySdk-{version}", ext:"aar") }

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

Redirect to the Alipay Wallet
Client-side

Request a PaymentIntent from your server and store its client secret.

Kotlin
class AlipayActivity : AppCompatActivity() { private lateinit var paymentIntentClientSecret: String override fun onCreate(savedInstanceState: Bundle?) { // ... fetchPaymentIntent() } private fun fetchPaymentIntent() { // Request a PaymentIntent from your server and store its client secret } }

When the customer taps to pay with Alipay, confirm the PaymentIntent using Stripe confirmAlipayPayment. You must supply an AlipayAuthenticator to pass data from the Stripe SDK to the Alipay SDK. The authenticator calls the Alipay payV2 method with the supplied data string. The Alipay SDK opens the Alipay app (if installed) or shows its own UI and communicates the result back to the Stripe SDK automatically.

Note

The Alipay Android SDK doesn’t support test payments. To fully test this integration, use live mode.

Kotlin
import com.alipay.sdk.app.PayTask class AlipayActivity : AppCompatActivity() { // ... private lateinit var paymentIntentClientSecret: String private val stripe: Stripe by lazy { Stripe( applicationContext, PaymentConfiguration.getInstance(applicationContext).publishableKey ) } // Call this function when the customer taps "Pay with Alipay" private fun startCheckout() { // ... lifecycleScope.launch { runCatching { stripe.confirmAlipayPayment( ConfirmPaymentIntentParams.createAlipay(paymentIntentClientSecret), { data -> PayTask(this@AlipayActivity).payV2(data, true) } ) }.fold( onSuccess = { result -> val paymentIntent = result.intent val status = paymentIntent.status when (status) { StripeIntent.Status.Succeeded -> { // Payment succeeded } StripeIntent.Status.RequiresAction -> { // Customer didn't complete the payment // You can try to confirm this Payment Intent again } else -> { // Payment failed/canceled } } }, onFailure = { // Payment failed } ) } } }

OptionalUse a WebView
Client-side

OptionalHandle 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.

Was this page helpful?
YesNo
Need help? Contact Support.
Join our early access programme.
Check out our changelog.
Questions? Contact Sales.
LLM? Read llms.txt.
Powered by Markdoc