summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/withdraw.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-07-21 17:09:04 -0300
committerSebastian <sebasjm@gmail.com>2023-07-21 17:09:04 -0300
commit9c17b7cd92c7c016097b64335076edd63893138b (patch)
treec1a4641e93d093d773d689c32237db32e1ecdd80 /packages/taler-wallet-core/src/operations/withdraw.ts
parent7e37b347447b6fc418f11160d439a7596b039680 (diff)
downloadwallet-core-9c17b7cd92c7c016097b64335076edd63893138b.tar.gz
wallet-core-9c17b7cd92c7c016097b64335076edd63893138b.tar.bz2
wallet-core-9c17b7cd92c7c016097b64335076edd63893138b.zip
add missing kyc url for manual withdrawal and add support for 451 case: aml-required
Diffstat (limited to 'packages/taler-wallet-core/src/operations/withdraw.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts
index a56a1a100..a1cb29e07 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -725,6 +725,9 @@ interface WithdrawalBatchResult {
coinIdxs: number[];
batchResp: ExchangeWithdrawBatchResponse;
}
+enum AmlStatus {
+ normal= 0, pending = 1, fronzen = 2,
+}
async function handleKycRequired(
ws: InternalWalletState,
@@ -757,6 +760,7 @@ async function handleKycRequired(
method: "GET",
});
let kycUrl: string;
+ let amlStatus: AmlStatus | undefined;
if (
kycStatusRes.status === HttpStatusCode.Ok ||
//FIXME: NoContent is not expected https://docs.taler.net/core/api-exchange.html#post--purses-$PURSE_PUB-merge
@@ -769,6 +773,10 @@ async function handleKycRequired(
const kycStatus = await kycStatusRes.json();
logger.info(`kyc status: ${j2s(kycStatus)}`);
kycUrl = kycStatus.kyc_url;
+ } else if (kycStatusRes.status === HttpStatusCode.UnavailableForLegalReasons) {
+ const kycStatus = await kycStatusRes.json();
+ logger.info(`aml status: ${j2s(kycStatus)}`);
+ amlStatus = kycStatus.aml_status;
} else {
throw Error(`unexpected response from kyc-check (${kycStatusRes.status})`);
}
@@ -801,7 +809,11 @@ async function handleKycRequired(
requirementRow: uuidResp.requirement_row,
};
wg2.kycUrl = kycUrl;
- wg2.status = WithdrawalGroupStatus.PendingKyc;
+ wg2.status = amlStatus === AmlStatus.normal || amlStatus === undefined ? WithdrawalGroupStatus.PendingKyc :
+ amlStatus === AmlStatus.pending ? WithdrawalGroupStatus.PendingAml :
+ amlStatus === AmlStatus.fronzen ? WithdrawalGroupStatus.SuspendedAml :
+ assertUnreachable(amlStatus);
+
await tx.withdrawalGroups.put(wg2);
const newTxState = computeWithdrawalTransactionStatus(wg2);
return {
@@ -1428,7 +1440,6 @@ async function processWithdrawalGroupPendingKyc(
url.searchParams.set("timeout_ms", "30000");
const retryTag = TaskIdentifiers.forWithdrawal(withdrawalGroup);
-
runLongpollAsync(ws, retryTag, async (cancellationToken) => {
logger.info(`long-polling for withdrawal KYC status via ${url.href}`);
const kycStatusRes = await ws.http.fetch(url.href, {
@@ -1451,6 +1462,10 @@ async function processWithdrawalGroupPendingKyc(
logger.info(`kyc status: ${j2s(kycStatus)}`);
// FIXME: do we need to update the KYC url, or does it always stay constant?
return { ready: false };
+ } else if (kycStatusRes.status === HttpStatusCode.UnavailableForLegalReasons) {
+ const kycStatus = await kycStatusRes.json();
+ logger.info(`aml status: ${j2s(kycStatus)}`);
+ return {ready : false}
} else {
throw Error(
`unexpected response from kyc-check (${kycStatusRes.status})`,