my.crossPay

Call the API to enable the cashier payment process and start a payment transaction.

System requirement

Follow the system requirements below based on your wallet app:

  • For Alipay China: Alipay China 10.2.38 or above. If the version is earlier, we recommend you try to implement compatibility.
  • For other wallet apps, contact the technical support of your wallet.

Sample code

Check the sample payment URL in the following code:

copy
my.crossPay({
  paymentUrl: 'https%3A%2F%2Fglobal.alipay.com%2F281002040098XXgE6IgaG0bb3N9h9B049Bz4',
  success: (res) => {
    my.alert({
      content: JSON.stringify(res),
    });
  },
  fail: (res) => {
    my.alert({
      content: JSON.stringify(res),
    });
  }
});

Parameters

Property

Data Type

Required

Description

paymentUrl

String

No

The URL of the payment page

tradeNO

String

No

The trade number

orderStr

String

No

A string of complete payment parameters, which is recommended to be obtained from the server.

success

Function

No

Callback function upon call success

fail

Function

No

Callback function upon call failure

complete

Function

No

Callback function upon call completion (to be executed upon either call success or failure).

Note: The tradeNO, orderStr, and paymentUrl parameters are different ways to start a payment transaction. The mini program should use either one of them to start a payment transaction according to the payment service provided by the host app.

Success callback function

The incoming parameter is of the Object type with the following attribute:

Property

Type

Required

Description

resultCode

String

Yes

The result code of the payment process.

Note:

  • For the mini programs launched to Alipay China, the result code of the payment can only be 8000 (Trade is processing). To learn more, refer to the Alipay China cashier payment solution.
  • For the mini programs launched to other wallet apps, the result code is based on the actual payment result.

An example of a successfully returned message is as follows:

copy
{
    "resultCode":"8000"
}

Result code

resultCode

Description

9000

Payment is successful.

8000

Trade is processing.

4000

Payment is failed.

6001

User cancels to pay.

6002

Network exception.

6004

Unknown payment result, which may be success.