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

      4. Applying payment using jsapi:tradePay

      #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=""></script>

      #API'tradePay', {
      }, fn);

      Request parameters:

      tradeNOstringthe Alipay Trade numberY8.0
      fnfunctionThe result callback after the cashier is closed.N

      Response Parameters:

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

      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 "Foeget the password" and exits (only apply to iOS above version 9.5)8.0
      callbackUrlboolThe URL to be redirected to after the trade succeeds. Null in most cases.8.0
      memoboolThe memo string returned by the cashier serveriOS 8.0, android 8.4
      resultboolThe result string returned by the cashier serveriOS 8.0, android 8.4

      #DEMO Code

      <a href="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){