4. Applying payment using jsapi:tradePay

Last updated: 4/4/2019

About the AlipayJSAPI

AlipayJSAPI is a set of APIs for external developers based on the AlipayJSBridge package. The goal is to unify the AlipayJSBridge interface naming, parameterization, processing of AlipayJSBridge faculties, reducing container development costs and customer service costs. Only compatible with Alipay APIs above 10.0 version10.0 (For APIs below version 10.0, you have to design ad hoc methods to use). 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.


On your H5 page, add the following code:

<script src="https://a.alipayobjects.com/g/h5-lib/alipayjsapi/3.0.3/alipayjsapi.min.js"></script>


AlipayJSBridge.call('tradePay', {
}, fn);

Request parameters:

Name Type Description Required Version
tradeNO string the Alipay Trade number Y 8.0
fn function The result callback after the cashier is closed. N

Response Parameters:

Callback function parameters: {resultCode, callbackUrl, memo, result}

Name Type Description Version
resultCode string Payment 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 "Foeget the password" and exits (only apply to iOS above version 9.5) 8.0
callbackUrl bool The URL to be redirected to after the trade succeeds. Null in most cases. 8.0
memo bool The memo string returned by the cashier server iOS 8.0, android 8.4
result bool The result string returned by the cashier server iOS 8.0, android 8.4


<a href="3rdpartryqrcode/javascript:void(0)" class="tradeno">交易号唤起</a>
function ready(callback) {
  // 如果jsbridge已经注入则直接调用
  if (window.AlipayJSBridge) {
    callback && callback();
  } else {
    // 如果没有注入则监听注入的事件
    document.addEventListener('AlipayJSBridgeReady', callback, false);
  document.querySelector('.tradeno').addEventListener('click', function(){
      tradeNO: "201209071234123221"
    }, function(result){

If you have any question, please contact us