aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/http-client/bank-integration.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-util/src/http-client/bank-integration.ts')
-rw-r--r--packages/taler-util/src/http-client/bank-integration.ts14
1 files changed, 9 insertions, 5 deletions
diff --git a/packages/taler-util/src/http-client/bank-integration.ts b/packages/taler-util/src/http-client/bank-integration.ts
index b526805df..d552d3b76 100644
--- a/packages/taler-util/src/http-client/bank-integration.ts
+++ b/packages/taler-util/src/http-client/bank-integration.ts
@@ -43,13 +43,17 @@ export class TalerBankIntegrationHttpClient {
}
/**
- * https://docs.taler.net/core/api-bank-integration.html#get-$BANK_API_BASE_URL-withdrawal-operation-$wopid
+ * https://docs.taler.net/core/api-bank-integration.html#get--withdrawal-operation-$WITHDRAWAL_ID
*
*/
- async getWithdrawalOperationById(woid: string, timeoutMs?: number) {
+ async getWithdrawalOperationById(woid: string, wait?: {
+ old_state?: "pending" | "selected" | "aborted" | "confirmed",
+ timeoutMs: number
+ }) {
const url = new URL(`withdrawal-operation/${woid}`, this.baseUrl);
- if (timeoutMs) {
- url.searchParams.set("long_poll_ms", String(timeoutMs))
+ if (wait) {
+ url.searchParams.set("long_poll_ms", String(wait.timeoutMs))
+ url.searchParams.set("old_state", !wait.old_state ? "pending" : wait.old_state)
}
const resp = await this.httpLib.fetch(url.href, {
method: "GET"
@@ -80,7 +84,7 @@ export class TalerBankIntegrationHttpClient {
switch (details.code) {
case TalerErrorCode.BANK_WITHDRAWAL_OPERATION_RESERVE_SELECTION_CONFLICT: return opKnownFailure("already-selected", resp);
case TalerErrorCode.BANK_DUPLICATE_RESERVE_PUB_SUBJECT: return opKnownFailure("duplicated-reserve-id", resp);
- // case TalerErrorCode.BANK_ACCOUNT_NOT_FOUND: return opKnownFailure("account-not-found", resp);
+ case TalerErrorCode.BANK_UNKNOWN_ACCOUNT: return opKnownFailure("account-not-found", resp);
case TalerErrorCode.BANK_ACCOUNT_IS_NOT_EXCHANGE: return opKnownFailure("account-not-exchange", resp);
default: return opUnknownFailure(resp, body)
}