This content originally appeared on DEV Community and was authored by HarmonyOS Magician
HarmonyOS 5 , and the app market is gradually enriching. Many apps are preparing to integrate Alipay for payment functions. Currently, there are three ways to launch Alipay: through the Alipay SDK, using OpenLink, or passing the Alipay package name with startAbility. The above three launching methods all refer to Next apps and do not include Abilities, which have their own ecological restrictions and temporarily do not support launching third-party apps.
I. Launching via Alipay SDK
The OpenHarmony third-party repository includes Alipay’s SDK:
Repository Address: https://ohpm.openharmony.cn/#/cn/detail/@cashier_alipay%2Fcashiersdk
Official Demo Address: https://alidocs.dingtalk.com/i/nodes/qnYMoO1rWxrkmoj2IOpZR6yaJ47Z3je9?iframeQuery=utm_source%3Dportal%26utm_medium%3Dportal_recent&rnd=0.2928087218087806
The official demo requires logging in to DingTalk to request authorization, which is generally accessible.
Code Implementation:
onAlipay() {
// All values in this payment information object should be returned by the server
let obj = new PayInfo();
obj.appId = "1111111111111";
obj.orderId = "1111111111";
obj.productName = "1年VIP";
obj.amount = 10;
obj.notifyUrl = 'https://www.huawei.com';
obj.rsaPrivate = "MIICXQIBAAKBgQC...";
OrderInfoUtil.getOrderInfo(obj).then(orderInfo => {
// orderInfo
generated by the server
new Pay().pay(orderInfo, true).then(result => {
let message =
resultStatus: ${result.get('resultStatus')} memo: ${result.get('memo')} result: ${result.get('result')}
;
console.log("Payment result: " + message);
if (result.get('resultStatus') === '9000') {
console.log("Payment successful");
} else {
console.log("Payment failed");
}
}).catch((error: BusinessError) => {
LogUtil.e("aLiParSdk:", error);
});
});
}
For the complete code, refer to the Git repository below. Detailed explanations can also be found in another blogger’s article:
博客链接: HarmonyOS Next — Alipay SDK Integration Tutorial
Complete Code Repository: https://gitee.com/qq1963861722/AliPayDemo.git
Effect Diagram:
II. Launching Alipay via OpenLink
OpenLink can be used to achieve inter-app navigation. Specifically for Alipay, you can refer to the browser-launch example.
API Used: UIAbilityContext.openLink
Reference: https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/deep-linking-startup-V5#使用openlink打开浏览器页面
Code Example:
let context = getContext(this) as common.UIAbilityContext;
let link = 'alipays://platformapi/startapp';
let openLinkOptions: OpenLinkOptions = {
appLinkingOnly: false,
parameters: { demo_key: 'demo_value' }
};
context.openLink(link, openLinkOptions, (err, result) => {
LogUtil.e(TAG, openLink error: ${JSON.stringify(err)}
);
LogUtil.i(TAG, openLink result: ${JSON.stringify(result.resultCode)}
);
LogUtil.i(TAG, openLink data: ${JSON.stringify(result.want)}
);
}).then(() => {
LogUtil.i(TAG, openLink success.
);
}).catch((err: BusinessError) => {
LogUtil.e(TAG, openLink failed, errCode ${err.code}
);
});
Complete Code Repository: https://gitee.com/qq1963861722/AliPayDemo.git
Effect Reference:
III. Launching Alipay with startAbility
In HarmonyOS 5, if you know an app’s bundle name, you can launch it using startAbility by passing a Want with that bundle name.
API Used: UIAbilityContext.startAbility
Reference: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-inner-application-uiabilitycontext-V5#uiabilitycontextstartability
How to Obtain Alipay’s Bundle Name
Via hdc Command:
hdc shell aa dump -l
hdc Tool Usage
Via Device File Browser: Path: /data/app/el2/100/database/com.alipay.mobile.client
Code Example:
const context = getContext(this) as common.UIAbilityContext;
let want: Want = {
deviceId: '',
bundleName: 'com.alipay.mobile.client',
abilityName: 'EntryAbility',
flags: wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
parameters: { /* custom parameters */ }
};
context.startAbility(want);
Complete Code Repository: https://gitee.com/qq1963861722/AliPayDemo.git
Effect Implementation:
These are three common ways to launch Alipay in HarmonyOS 5. We hope this helps other developers. If there are any shortcomings in the article, please forgive us and point them out.
This content originally appeared on DEV Community and was authored by HarmonyOS Magician

HarmonyOS Magician | Sciencx (2025-05-15T07:37:57+00:00) HarmonyOS 5 – Three Ways to Launch Alipay – Tutorial. Retrieved from https://www.scien.cx/2025/05/15/harmonyos-5-three-ways-to-launch-alipay-tutorial/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.