更新记录
1.3.0(2023-07-22)
1、解决订阅异常问题
1.2.2(2023-06-25)
1、解决doPayAll方法支付成功没有回调问题 2、新增查询历史支付订单记录方法:doQueryPurchaseHistory
1.2.0(2023-01-30)
1、新增支付方法,支持更多参数
查看更多平台兼容性
Android | Android CPU类型 | iOS |
---|---|---|
适用版本区间:4.4 - 12.0 | armeabi-v7a:未测试,arm64-v8a:未测试,x86:未测试 | × |
原生插件通用使用流程:
- 购买插件,选择该插件绑定的项目。
- 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
- 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
- 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
- 开发完毕后正式云打包
付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios
注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择
Google Pay,谷歌支付插件Google(插件有问题请联系QQ:1684729125)
插件仅支持Android版本
插件提供的方法 -- 详情请参考demo
-
doInit
- 初始化
-
doQuerySku
- 查询sku
-
doPay
- 支付
-
doPayAll
- 支付,支持更多参数
-
doConsume
- 确认交易--消耗品
-
doAcknowledgePurchase
- 确认交易--非消耗品
-
doQueryPurchases
- 查询当前购买记录
-
doQueryPurchaseHistory
- 查询历史记录
使用插件代码如下,更多代码请参考Demo
/**
* 初始化
*/
doInit() {
let that = this;
googlePay.doInit({}, e => {
if (e.code == 200) {
that.showToast('初始化成功');
} else {
that.showToast('初始化失败');
}
});
},
/**
* 查询sku
*/
doQuerySku() {
let that = this;
googlePay.doQuerySku(
{
inapp: ['inapp_test', '10000'] // 与subs二选一
// subs: ["sub_test", "10000"],
},
e => {
console.log('查询结果:', e);
that.showToast('查询结果:' + JSON.stringify(e));
if (e.code == 200) {
console.log('查询成功: ', e.list);
that.prdList = e.list;
} else {
console.log('查询失败');
}
}
);
},
/**
* 发起支付
* 支付参数为查询sku结果的某一项
*/
doPay() {
let that = this;
if (that.prdList == null || that.prdList.length == 0) {
that.showToast('产品列表为空,不可支付');
return;
}
googlePay.doPay(that.prdList[0], e => {
console.log('支付结果:', e);
that.showToast('支付结果:' + JSON.stringify(e));
if (e.code == 200) {
console.log('支付成功: ', e);
if (e && e.data) {
that.payList = e.data;
}
} else {
console.log('支付失败: ', e);
}
});
},
/**
* 发起支付2
* 支付参数为查询sku结果的某一项
*/
doPayAll() {
let that = this;
console.log('do pay function.');
if (that.prdList == null || that.prdList.length == 0) {
that.showToast('产品列表为空,不可支付');
return;
}
googlePay.doPayAll({
sku: that.prdList[0],
accountId: "", // 可选参数
profileId: "", // 可选参数
}, e => {
console.log('支付结果:', e);
that.showToast('支付结果:' + JSON.stringify(e));
if (e.code == 200) {
// 支付成功
// that.showToast("支付成功");
console.log('支付成功: ', e);
if (e && e.data) {
that.payList = e.data;
}
} else {
// 支付失败
// that.showToast("支付失败");
console.log('支付失败: ', e);
}
});
},
/**
* 确认交易,消耗品
*/
doConsume() {
let that = this;
console.log('do pay function.');
if (that.payList == null || that.payList.length == 0) {
that.showToast('支付信息不能为空');
return;
}
googlePay.doConsume(that.payList[0], e => {
console.log('Consume结果:', e);
that.showToast('Consume结果:' + JSON.stringify(e));
if (e.code == 200) {
console.log('Consume成功');
} else {
console.log('Consume失败');
}
});
},
/**
* 确认交易,非消耗品
*/
doAcknowledgePurchase() {
let that = this;
console.log('do pay function.');
if (that.payList == null || that.payList.length == 0) {
that.showToast('支付信息不能为空');
return;
}
googlePay.doAcknowledgePurchase(that.payList[0], e => {
console.log('acknowledgePurchase结果:', e);
that.showToast('acknowledgePurchase结果:' + JSON.stringify(e));
if (e.code == 200) {
console.log('acknowledgePurchase成功');
} else {
console.log('acknowledgePurchase失败');
}
});
},
/**
* 查询当前购买记录
*/
doQueryPurchases() {
let that = this;
console.log('do pay function.');
googlePay.doQueryPurchases(
{
skuType: 'inapp' // subs 或 inapp
},
e => {
console.log('queryPurchases结果:', e);
that.showToast('queryPurchases结果:' + JSON.stringify(e));
if (e.code == 200) {
console.log('queryPurchases成功');
} else {
console.log('queryPurchases失败');
}
}
);
},
/**
* 查询历史记录
*/
doQueryPurchaseHistory(){
let that = this;
console.log('do doQueryPurchaseHistory function.');
//参数inapp或subs
googlePay.doQueryPurchaseHistory('subs',res => {
console.log('doQueryPurchaseHistory result: ',res);
that.showToast('queryPurchaseHistory结果:' + JSON.stringify(res));
});
},