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
Client-side
Server-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 our 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 iOS SDK is open source, fully documented, and compatible with apps supporting iOS 13 or above.

To install the SDK, follow these steps:

  1. In Xcode, select File > Add Package Dependencies… and enter https://github.com/stripe/stripe-ios-spm as the repository URL.
  2. Select the latest version number from our releases page.
  3. Add the StripePaymentsUI product to the target of your app.

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 on app start. This enables your app to make requests to the Stripe API.

AppDelegate.swift
Swift
import UIKit import StripePaymentsUI @main class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { StripeAPI.defaultPublishableKey =
"pk_test_TYooMQauvdEDq54NiTphI7jx"
// do any other necessary launch configuration return true } }

Note

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

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

Register a custom URL scheme for your app by going to the Info tab of your app target settings.

Setting up a custom URL scheme in Xcode

The Alipay app opens this URL to return to your app after the customer completes the payment. Forward the URL to the Stripe SDK in your UISceneDelegate or UIApplicationDelegate:

SceneDelegate.swift
Swift
// This method handles opening custom URL schemes (for example, "your-app://stripe-redirect") func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { guard let url = URLContexts.first?.url else { return } let stripeHandled = StripeAPI.handleURLCallback(with: url) if (!stripeHandled) { // This was not a Stripe url – handle the URL normally as you would } }

When the customer taps to pay with Alipay, confirm the PaymentIntent using STPPaymentHandler confirmPayment. This launches the Alipay app or displays a webview if the Alipay app isn’t installed.

CheckoutViewController.swift
Swift
import UIKit import StripePayments class CheckoutViewController: UIViewController { // ... func pay() { let clientSecret = ... // The client secret of the PaymentIntent let paymentIntentParams = STPPaymentIntentParams(clientSecret: clientSecret) paymentIntentParams.paymentMethodParams = STPPaymentMethodParams(alipay: STPPaymentMethodAlipayParams(), billingDetails: nil, metadata: nil) paymentIntentParams.paymentMethodOptions = STPConfirmPaymentMethodOptions() paymentIntentParams.paymentMethodOptions?.alipayOptions = STPConfirmAlipayOptions() paymentIntentParams.returnURL = "{{URL SCHEME}}://safepay/" // Replace {{URL SCHEME}} with your own custom URL scheme. STPPaymentHandler.shared().confirmPayment(paymentIntentParams, with: self) { (status, intent, error) in switch status { case .canceled: // Payment was canceled case .failed: // Payment failed case .succeeded: // Payment was successful @unknown default: fatalError() } } } } extension CheckoutViewController: STPAuthenticationContext { func authenticationPresentingViewController() -> UIViewController { return self } }

Alipay opens the return URL with safepay/ as the host. For example, if your custom URL scheme is myapp, your return URL must be myapp://safepay/.

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