diff options
-rw-r--r-- | packages/taler-util/src/bank-api-client.ts | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/packages/taler-util/src/bank-api-client.ts b/packages/taler-util/src/bank-api-client.ts index 0e122d10b..9c35af948 100644 --- a/packages/taler-util/src/bank-api-client.ts +++ b/packages/taler-util/src/bank-api-client.ts @@ -29,10 +29,13 @@ import { codecForAny, codecForString, encodeCrock, - generateIban, getRandomBytes, + HttpStatusCode, j2s, Logger, + opEmptySuccess, + opKnownHttpFailure, + opUnknownFailure, stringToBytes, TalerError, TalerErrorCode, @@ -398,9 +401,9 @@ export class TalerCorebankApiClient { async confirmWithdrawalOperation( username: string, wopi: ConfirmWithdrawalArgs, - ): Promise<void> { + ) { const url = new URL( - `withdrawals/${wopi.withdrawalOperationId}/confirm`, + `accounts/${username}/withdrawals/${wopi.withdrawalOperationId}/confirm`, this.baseUrl, ); logger.info(`confirming withdrawal operation via ${url.href}`); @@ -410,10 +413,15 @@ export class TalerCorebankApiClient { headers: this.makeAuthHeader(), }); - logger.info(`response status ${resp.status}`); - // const respJson = await readSuccessResponseJsonOrThrow(resp, codecForAny()); - - // FIXME: We don't check the status here! + switch (resp.status) { + case HttpStatusCode.Ok: + case HttpStatusCode.NoContent: + return opEmptySuccess(resp); + case HttpStatusCode.NotFound: + return opKnownHttpFailure(resp.status, resp); + default: + return opUnknownFailure(resp, await resp.text()); + } } async abortWithdrawalOperation(wopi: WithdrawalOperationInfo): Promise<void> { |