芝麻信用免押金接口源碼demo開發php和java流程,如何開發支付寶免押金接口功能
1 小程序選擇商品
2 小程序請求創建訂單
見小程序官方示例demo源碼目錄page\API\request
httpRequest() {
my.httpRequest({
url: 'http://httpbin.org/post',
method: 'POST',
data: {
from: '支付寶',
production: 'AlipayJSAPI',
},
dataType: 'json',
success: function(res) {
my.alert({content: JSON.stringify(res)});
},
fail: function(res) {
my.alert({content: JSON.stringify(res)});
},
complete: function(res) {
// my.alert({title: 'complete'});
}
});
}
3 服務端 創建預授權訂單,並返回結果
https://docs.open.alipay.com/20180417160701241302/vo4kv7/ 接口參數示例
https://docs.open.alipay.com/11157 參數說明
4 小程序收到返回的結果數據,將數據填充到tradePay接口,並拉起支付寶客戶端支付。
tradePay() {
my.tradePay({
orderStr: 'xxx', //完整的支付參數拼接成的字符串,從服務端獲取,具體是方法請參考小程序開發文檔
success: (res) => {
my.alert({
title: res.resultCode,
});
},
fail: (res) => {
my.alert({
content: JSON.stringify(res),
});
},
});
}
5 服務端收到回調結果,並更新訂單狀態(是否支付)
6 授權轉支付(到期)
https://docs.open.alipay.com/20180417160701241302/qca164/
7 租賃結束,同步訂單狀態(履約,取消,違約)
https://docs.open.alipay.com/api_1/alipay.trade.orderinfo.sync