From 13f0442736479fb6ea8d1ecc7311cdac354a4de5 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 12 Feb 2023 19:30:59 +0100 Subject: harness: finish kyc test We mock the KYC gateway now, use the new notification-based wallet API and the test is not experimental anymore. --- .../taler-wallet-core/src/operations/withdraw.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/withdraw.ts') diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index 5c9854c0f..28754c77e 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -1250,12 +1250,7 @@ export async function processWithdrawalGroup( if (numKycRequired > 0) { if (kycInfo) { - await checkKycStatus( - ws, - withdrawalGroup.exchangeBaseUrl, - kycInfo, - "individual", - ); + await checkWithdrawalKycStatus(ws, withdrawalGroup, kycInfo, "individual"); return { type: OperationAttemptResultType.Pending, result: undefined, @@ -1293,12 +1288,13 @@ export async function processWithdrawalGroup( }; } -export async function checkKycStatus( +export async function checkWithdrawalKycStatus( ws: InternalWalletState, - exchangeUrl: string, + wg: WithdrawalGroupRecord, kycInfo: KycPendingInfo, userType: KycUserType, ): Promise { + const exchangeUrl = wg.exchangeBaseUrl; const url = new URL( `kyc-check/${kycInfo.requirementRow}/${kycInfo.paytoHash}/${userType}`, exchangeUrl, @@ -1307,12 +1303,20 @@ export async function checkKycStatus( const kycStatusReq = await ws.http.fetch(url.href, { method: "GET", }); - logger.warn("kyc requested, but already fulfilled"); if (kycStatusReq.status === HttpStatusCode.Ok) { + logger.warn("kyc requested, but already fulfilled"); return; } else if (kycStatusReq.status === HttpStatusCode.Accepted) { const kycStatus = await kycStatusReq.json(); logger.info(`kyc status: ${j2s(kycStatus)}`); + ws.notify({ + type: NotificationType.WithdrawalKycRequested, + kycUrl: kycStatus.kyc_url, + transactionId: makeTransactionId( + TransactionType.Withdrawal, + wg.withdrawalGroupId, + ), + }); throw TalerError.fromDetail( TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED, { -- cgit v1.2.3