鴻蒙接入

拉卡拉支付 4個(gè)月前 ( 11-09 ) 229

本文介紹客戶方APP嵌入拉卡拉提供的webview或者LKLWebObject方法類:

示例代碼

class WebSdk {
controller: webview.WebviewController = new webview.WebviewController()
//去支付寶支付
jumpAlipay(val: string) {
this.openAlipays(val)
}
//打開支付寶
openAlipays(uri: string) {
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
let link: string = uri;
let openlinkOptions: OpenLinkOptions = {
appLinkingOnly: false
}
try {
context.openLink(link, openlinkOptions)
.then(() => {
console.log('lkldemo--- 打開成功')
})
.catch((err: BusinessError) => {
console.log('lkldemo--- 打開失敗1' + JSON.stringify(err))
})
} catch (paramError) {
console.log('lkldemo--- 打開失敗0' + JSON.stringify(paramError))
}
}
//關(guān)閉web頁面
closeWindow() {
router.back()
}
//去微信支付
jumpWxApplet(userName: string, path: string, programType: number) {
let finished=false;
try {
let appId: string = "wx000000000xxxxxx"; // 填移動(dòng)應(yīng)用(App)的 AppId,非小程序的 AppID
let WXApi = wxopensdk.WXAPIFactory.createWXAPI(appId);
let launchMiniProgramReq = new wxopensdk.LaunchMiniProgramReq;
launchMiniProgramReq.userName = userName ; //拉起的小程序的原始id
launchMiniProgramReq.path =path ; //拉起小程序頁面的可帶參路徑,不填默認(rèn)拉起小程序首頁,對(duì)于小游戲,可以只傳入 query 部分,來實(shí)現(xiàn)傳參效果,如:傳入 "?foo=bar"。
launchMiniProgramReq.miniprogramType = programType ; //拉起小程序的類型 0-正式版 1-開發(fā)版 2-體驗(yàn)版
finished = await WXApi.sendReq(getContext(this) as common.UIAbilityContext , launchMiniProgramReq);
console.log('send jump WxMiniProgram request finished: ' + finished);
} catch (error) {
console.log("jump WxMiniProgram error", error.message, null);
}
}
}復(fù)制

closeWindow方法觸發(fā)條件

> 收銀臺(tái)模板配置支付完成頁標(biāo)識(shí)為直接跳至客戶上送的地址,且收銀臺(tái)下單接口不上送callback_url;收銀臺(tái)H5查詢到訂單狀態(tài)為終態(tài)時(shí)觸發(fā);
>> 訂單終態(tài):付款成功、已過期、支付失敗
> 注意:訂單支付狀態(tài)APP應(yīng)以自行查詢后臺(tái)接口為準(zhǔn)**
收銀臺(tái)下單
webview 打開收銀臺(tái)H5頁面
收銀臺(tái)H5獲取商戶支付權(quán)限
選擇支付寶支付
收銀臺(tái)H5預(yù)下單
收銀臺(tái)H5調(diào)用webview提供的 jumpAlipay 方法打開支付寶付款(scheme方式)
選擇微信支付
收銀臺(tái) H5 調(diào)用webview 提供的 jumpWxApplet 方法打開拉卡拉收款寶小程序[微信官方文檔](https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Launching_a_Mini_Program/Launching_a_Mini_Program.html)
收款寶小程序做預(yù)下單付款復(fù)制

代碼下載

[LKLPayWebPage.ets]



The End