Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solution

my.tradePay

This API is used to initiate the payment in the mini program. The end user will be redirected to the payment page. Then, the user can check the payment details and complete the payment by entering the payment password or finish equivalent security measures.

Sample code

copy
my.tradePay({
  orderStr: 'method=\"mobile.securitypay.pay\"&partner=\"2088101568358171\"&seller_id=\"2088101568358171\"&out_trade_no=\"ALIPAYTEST2016081622560194853\"&subject=\"商品名稱\"&body=\"商品描述信息\"&total_fee=\"0.1\"&notify_url=\"http://www.xxx.com\"&payment_type=\"1\"&_input_charset=\"utf-8\"&it_b_pay=\"30m\"&return_url=\"m.alipay.com\"&payment_inst=\"ALIPAYHK\"&currency=\"HKD\"&product_code=\"NEW_WAP_OVERSEAS_SELLER\"&forex_biz=\"FP\"&payment_type=\"1\"&sign=\"aueDw0PaUqVMvbiButPCmWy8VsNJIgNKRV4tDEz3mSgIpa5ODnZKVCd1GGCtu7hNzxnwLOiku+TRJUVM24aHkKWrdyBHECjkUBvrziWiZBESLCyJPwT1YHGnioRUhLvL1MqTTm85urPeqAUUir4UyxyWowHitjkxh3ru6nSLkLU\"=&sign_type=\"MD5\"', 
  success: (res) => {
    my.alert({
      content: JSON.stringify(res),
    });
  },
  fail: (res) => {
    my.alert({
      content: JSON.stringify(res),
    });
  }
});

Request parameters

Name

Type

Required

Description

orderStr

String

Y

A string consists of all payment parameters. The string can be obtained from the server side. For constructing the orderStr, see Construct orderStr for details.

success

Function

N

Callback function for the successful API call

fail

Function

N

Callback function for the failed API call

complete

Function

N

Callback function for the API call has finished. Both successful scenarios and failed scenarios will be called.

Response parameters

Name

Type

Description

resultCode

String

The result of the payment. See result codes below for details.

Result codes

resultCode

Description

9000

The order payment is successful.

8000

The order is being processed.

4000

The order payment failed.

6001

The user canceled the payment.

6002

Network connection error

99

The user clicks the forgotten password and then exits from the quick payment interface (for iOS only).