完善ios内购
This commit is contained in:
parent
db4b6da5f3
commit
0ed31320cb
@ -130,7 +130,7 @@ export class PaySvr {
|
|||||||
public async queryIOSPurchases() {
|
public async queryIOSPurchases() {
|
||||||
let result = await new NativeSvr().queryPurchase();
|
let result = await new NativeSvr().queryPurchase();
|
||||||
let data = JSON.parse(result + '');
|
let data = JSON.parse(result + '');
|
||||||
console.log('query purchase result:: ' + data);
|
console.log('query apple purchase result:: ' + result);
|
||||||
if (data.length === 0) {
|
if (data.length === 0) {
|
||||||
throw new ZError(10, 'no records');
|
throw new ZError(10, 'no records');
|
||||||
}
|
}
|
||||||
@ -148,7 +148,21 @@ export class PaySvr {
|
|||||||
|
|
||||||
public async beginIOSPurchase(productId: string, orderId: string) {
|
public async beginIOSPurchase(productId: string, orderId: string) {
|
||||||
let result = await new NativeSvr().buyProduct(productId, orderId);
|
let result = await new NativeSvr().buyProduct(productId, orderId);
|
||||||
return result;
|
let data = JSON.parse(result + '');
|
||||||
|
console.log('apple purchase result:: ' + result);
|
||||||
|
if (data.length === 0) {
|
||||||
|
throw new ZError(10, 'no records');
|
||||||
|
}
|
||||||
|
let res = await verifyApplePay({ list: data });
|
||||||
|
if (res.errcode) {
|
||||||
|
throw new ZError(res.errcode, res.errmsg);
|
||||||
|
}
|
||||||
|
if (res.data.length > 0) {
|
||||||
|
for (let i = 0; i < res.data.length; i++) {
|
||||||
|
await new NativeSvr().finishTransaction(res.data[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
// end of iOS purchase
|
// end of iOS purchase
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user