Alipay

Alipay is a digital wallet in China that has more than a billion active users worldwide. Alipay users can pay on the web or on a mobile device using login credentials or their Alipay app. Alipay has a low dispute rate and reduces fraud by authenticating payments using the customer’s login credentials.

Features #

Customer locationsChinese consumers
Overseas Chinese
Chinese travelers
Processing currenciesCNY, GBP, USD, EUR, HKD
Settlement currenciesGBP,HKD,EUR
Minimum transaction amount0.01 CNY
Maximum transaction amountNo limit
Refunds
Partial Refunds
Multiple partial refund
Chargeback

Prohibited business categories Both WooshPay and Alipay Plus maintain a list of prohibited businesses that aren’t allowed to use their services. To use Alipay Plus on WooshPay, your business can’t be restricted from using or appear on Alipay’s prohibited business list. If you’re not sure if your business is a prohibited business, or have questions about how these requirements apply to you, please contact support@wooshpay.com.

Subproducts #

ProductPayment scenarios description
Web PaymentOn Desktop browser, after selecting Alipay as a payment method merchant checkout, a QR code appears. The shopper then opens Alipay app on their mobile phone and scans the barcode displayed on the browser page to complete the payment.
APP PaymentOn the mobile browser, a shopper selects Alipay as a payment method on Merchant checkout, and as redirected from the browser into the Alipay app to complete the payment before being redirected back to the Merchant browser.

Payment flow #

Web Payment #

pic_1.png

APP Payment #

pic_2.png

Integration Method #

Payment method enumeration values: alipay

There are two integration methods for Alipay

  1. Direct API
  2. Checkout
Integration methodpayment scenariosterminal_type enumeration values
Direct APIWeb PaymentWEB
Direct APIAPP paymentAPP
CheckoutWeb PaymentYou don’t need to identify the terminal_type in checkout. Checkout will automatically generate a QR code or redirect to Alipay app based on their device.
CheckoutAPP paymentYou don’t need to identify the terminal_type in checkout. Checkout will automatically generate a QR code or redirect to Alipay app based on their device.

Direct API #

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.

Create a PaymentIntent #

For direct API integration, you can create PaymentIntent and get url in only one step. The following is the demo of creating payment intents:

  • Web Payment
  • APP payment

You can control the payment scenarios generated in Payment Intent by changing the enumeration values of the terminal type:payemen_method_options.alipay.terminal_type

Web Payment #

Request

{
    "amount": 20,
    "currency": "CNY",
    "confirm": true,
    "payment_method_options": {
        "alipay": {
            "client_ip": "192.168.0.1",
            "terminal_type": "WEB",
            "os_type": "IOS"
        }
    },
    "payment_method_data": {
        "type": "alipay"
    },
    "payment_method_types": [
        "alipay"
    ],
    "return_url": "https://wooshpay.com"
}

Response

{
    "id": "pi_1666729870215872512",
    "object": "payment_intent",
    "created": 1686214342000,
    "currency": "CNY",
    "amount": 20,
    "status": "requires_action",
    "livemode": true,
    "client_secret": "pi_1666729870215872512_secret_jmGL6NBNInPx5zdjIJ2utli4",
    "next_action": {
        "type": "redirect_to_url",
        "alipay_handle_redirect": {
            "url": "https://open-sea.alipayplus.com/api/open/v1/ac/cashier/self/codevalue/checkout.htm?codeValue=28166604009zSv0130nTr0bKfhzSwT08YvSW"
        }
    },
    "payment_method_types": [
        "alipay"
    ],
    "confirmation_method": "automatic",
    "payment_method_options": {
        "alipay": {
            "terminal_type": "WEB",
            "os_type": "IOS",
            "client_ip": "192.168.0.1"
        }
    },
    "return_url": "https://wooshpay.com",
    "payment_method": "pm_1666729870102626304",
    "capture_method": "automatic"
}

The url from next_action can be opened, from the link, the customer will be redirect to Alipay’s checkout page. The customner can scan the QR code or login to the wallet to pay.

APP payment #

Request

{
    "amount": 20,
    "currency": "CNY",
    "confirm": true,
    "payment_method_options": {
        "alipay": {
            "client_ip": "192.168.0.1",
            "terminal_type": "APP",
            "os_type": "IOS"
        }
    },
    "payment_method_data": {
        "type": "alipay"
    },
    "payment_method_types": [
        "alipay"
    ],
    "return_url": "https://wooshpay.com"
}

Response

{
    "id": "pi_1666732544285999104",
    "object": "payment_intent",
    "created": 1686214980000,
    "currency": "CNY",
    "amount": 20,
    "status": "requires_action",
    "livemode": true,
    "client_secret": "pi_1666732544285999104_secret_NRUV59FL6qtFyz2bXVeDyLD4",
    "next_action": {
        "type": "redirect_to_url",
        "alipay_handle_redirect": {
            "url": "https://render.alipay.com/p/s/i/?scheme=alipays%3A%2F%2Fplatformapi%2FstartApp%3FappId%3D10000007%26actionType%3Droute%26qrcode%3D281666040092tD6e6GlEzzTlQl6HrEqv3kOI%26externalThrough%3D%257B%2522acTerminalType%2522%253A%2522WAP%2522%257D"
        }
    },
    "payment_method_types": [
        "alipay"
    ],
    "confirmation_method": "automatic",
    "payment_method_options": {
        "alipay": {
            "terminal_type": "APP",
            "os_type": "IOS",
            "client_ip": "192.168.0.1"
        }
    },
    "return_url": "https://wooshpay.com",
    "payment_method": "pm_1666732544155975680",
    "capture_method": "automatic"
}

Checkout #

To support Alipay payments, a Checkout Session must satisfy all of the following conditions:

  • Prices for all line items must be in the same currency. If you have line items in different currencies, create separate Checkout Sessions for each currency.
  • You can only use one-time line items.

Enable Alipay as a payment method

When creating a new Checkout Session, you need to:

Add Alipayplus to the list of payment_method_types. Make sure all line_items use the same currency.

Create a Session #

You don’t need to identify the terminal_type when you create a checkout session. Checkout will automatically generate a QR code or redirect to Alipay App based on their device.

Request

{
    "cancel_url": "www.baidu.com",
    "mode": "payment",
    "success_url": "https://wooshpay.com/",
    "payment_method_types": [
        "alipay"
    ],
    "line_items": [
        {
            "price_data": {
                "currency": "CNY",
                "unit_amount": 100000,
                "active": true,
                "product_data": {
                    "name": "taiwan fengli"
                },
                "billing_scheme": "testscheme",
                "lookup_key": "test_lookup_key"
            },
            "quantity": 1
        }
    ]
}

Response

{
    "id": "cs_1666733999608823808",
    "object": "checkout.session",
    "created": 1686215327000,
    "currency": "CNY",
    "customer": "",
    "mode": "payment",
    "livemode": true,
    "status": "open",
    "url": "https://checkout.wooshpay.com/pay/cs_1666733999608823808?key=pk_live_dGVzdDpKeEQzUXhpWDJyYkFRZEo1QWtWN0dHUFo=",
    "cancel_url": "www.baidu.com",
    "line_items": {
        "object": "list",
        "data": [
            {
                "id": "li_1666733999642378240",
                "object": "item",
                "currency": "CNY",
                "description": "taiwan fengli",
                "price": {
                    "id": "price_1666733999659155456",
                    "object": "price",
                    "created": 1686215327000,
                    "active": true,
                    "currency": "CNY",
                    "product": {
                        "id": "prod_1666733999675932672",
                        "object": "product",
                        "created": 1686215327000,
                        "active": true,
                        "name": "taiwan fengli",
                        "livemode": true,
                        "updated": 1686215327000
                    },
                    "type": "one_time",
                    "livemode": true,
                    "unit_amount": 100000,
                    "billing_scheme": "per_unit",
                    "lookup_key": "test_lookup_key"
                },
                "quantity": 1,
                "amount_subtotal": 100000,
                "amount_total": 100000
            }
        ]
    },
    "payment_intent": "pi_1666733999864676352",
    "payment_method_types": [
        "alipay"
    ],
    "payment_status": "unpaid",
    "success_url": "https://wooshpay.com/",
    "amount_subtotal": 100000,
    "amount_total": 100000,
    "billing_address_collection": "auto",
    "expires_at": 1686301726587,
    "payment_link": "",
    "client_secret": "pi_1666733999864676352_secret_5S1FMaseZU6gfIZjl2QlOdY7"
}

The url from next_action can be opened, from the link, the customer will be redirect to Alipay’s checkout page. The customner can scan the QR code or login to the wallet to pay.

Next step #

You can add more features to your integration as needed

Create a Webhook #

Listen to events on your WooshPay account so your integration can automatically trigger reactions. Create a webhook that mainly focuses on enabled_events and url.

Create a Refund #

Create a refund to repay funds to your customer. You can also perform partial refunds, but not every payment method supports them. A partial refund is when you refund only part of the original transaction amount.

What are your feelings
Updated on August 8, 2023