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
Parameter | Description |
tradeNO String | The Alipay trade number
|
fn function | The result callback after the cashier is closed
|
Asynchronous response
Parameter | Description |
resultCode String | Payment result with the following values:
|
callbackUrl String | The URL to be redirected to after the trade succeeds. Null in most cases.
|
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
<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>