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

jsapi:tradePay

Call this interface to evoke the cashier inside the Alipay application for the customer to 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

Request parameters

ParameterDescription

tradeNO

String Required

The Alipay trade number

Example:201xxxxxxxxxxx3221

fn

function

The result callback after the cashier is closed

Example:/

Asynchronous response

ParameterDescription

resultCode

String

Payment result with the following values:

  • 9000: The payment succeeds
  • 8000: The payment is in process
  • 4000: The payment fails
  • 6001: Cancelled by the user
  • 6002: Network connection error
  • 99: The user clicks "Forget the password" and exits, which only applies to iOS 9.5 or higher versions 

Example:9000

callbackUrl

String

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

Example: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

Success

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).

Sample

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>