diff --git a/src/services/PaySvr.ts b/src/services/PaySvr.ts index f0c63be..ebd8daf 100644 --- a/src/services/PaySvr.ts +++ b/src/services/PaySvr.ts @@ -130,7 +130,7 @@ export class PaySvr { public async queryIOSPurchases() { let result = await new NativeSvr().queryPurchase(); let data = JSON.parse(result + ''); - console.log('query purchase result:: ' + data); + console.log('query apple purchase result:: ' + result); if (data.length === 0) { throw new ZError(10, 'no records'); } @@ -148,7 +148,21 @@ export class PaySvr { public async beginIOSPurchase(productId: string, orderId: string) { 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 }