From 0ed31320cbf98374e1ba75bf0e33f5d848501f27 Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Thu, 10 Aug 2023 17:08:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84ios=E5=86=85=E8=B4=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/PaySvr.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 }