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

jsapi:tradePay

The merchant can use this interface to evoke the cashier inside the Alipay application and the customer can confirm the payment and complete the transaction.

AlipayJSAPI provides a wealth of Alipay native APIs, you can easily use Alipay's ability to realize the experience of native applications, such as page jump, payment function.

Request parameters

Parameter

Type(length)

Description

Required

Example

tradeNO

String

The Alipay trade number

Y

201xxxxxxxxxxx3221

fn

function

The result callback after the cashier is closed

N

/

Asynchronous response

ParameterType (length)DescriptionExample
resultCodeStringPayment result. ‘9000’: The payment succeeds; ‘8000’:The payment is in process; ‘4000’: The payment fails; ‘6001’: Canceled by the uer; ‘6002’: Network connection error; ‘99’: The user clicks "Forget the password" and exits (only apply to iOS above version 9.5)9000

callbackUrl

String

The URL to be redirected to after the trade succeeds. Null in most cases.

www.alipay.com

memo

String

Description returned by the cashier server

result

String

Process result returned by the cashier server

Result code

resultCode

Description

9000

Succeed to pay

8000

The trade is processing

4000

Failed to pay

6001

Cancel the payment

6002

Network exception

6004

Unknown payment result, might be success

99

Users click the forget password button, and quit the pay page (iOS only)

Request sample 

copy
<h1>Trigger the payment page for users to pay</h1>
<a href="javascript:void(0)" class="tradeno">call the transaction number</a>
<script>
function ready(callback) {
  if (window.AlipayJSBridge) {
    callback && callback();
  } else {
    document.addEventListener('AlipayJSBridgeReady', callback, false);
  }
}
ready(function(){
  document.querySelector('.tradeno').addEventListener('click', function(){
    AlipayJSBridge.call("tradePay",{
      tradeNO: "201xxxxxxxxxxx3221"
    }, function(result){
      alert(JSON.stringify(result));
    });
  });
});
</script>