taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit f85428e4244c0181e8c58f9292a41bb460c9c7c8
parent 70bd1230b3d0538f0bdb4965bf2d92730b44a808
Author: Florian Dold <florian@dold.me>
Date:   Tue,  7 Jan 2025 20:05:48 +0100

-fix test

Diffstat:
Mpackages/taler-harness/src/integrationtests/test-payment-abort.ts | 11++++++++---
Mpackages/taler-util/src/types-taler-merchant.ts | 23+++++++++++++++++++++--
Mpackages/taler-wallet-core/src/pay-merchant.ts | 3+++
Mpackages/taler-wallet-core/src/withdraw.ts | 4+++-
4 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-payment-abort.ts b/packages/taler-harness/src/integrationtests/test-payment-abort.ts @@ -28,12 +28,12 @@ import { j2s, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { FaultInjectionRequestContext } from "../harness/faultInjection.js"; -import { GlobalTestState, harnessHttpLib } from "../harness/harness.js"; import { createFaultInjectedMerchantTestkudosEnvironment, withdrawViaBankV2, } from "../harness/environments.js"; +import { FaultInjectionRequestContext } from "../harness/faultInjection.js"; +import { GlobalTestState, harnessHttpLib } from "../harness/harness.js"; export async function runPaymentAbortTest(t: GlobalTestState) { // Set up test environment @@ -155,7 +155,12 @@ export async function runPaymentAbortTest(t: GlobalTestState) { const txTypes = txns2.transactions.map((x) => x.type); console.log(txTypes); - t.assertDeepEqual(txTypes, ["withdrawal", "payment", "refund"]); + // No refund, as the deposit never reached the merchant. + t.assertDeepEqual(txTypes, ["withdrawal", "payment"]); + + // FIXME: check a case where there is indeed a refund! + // That's easiest to simulate with two exchanges, + // where only one of them works. // FIXME: also check extended transaction list for refresh. // FIXME: also check balance diff --git a/packages/taler-util/src/types-taler-merchant.ts b/packages/taler-util/src/types-taler-merchant.ts @@ -297,7 +297,13 @@ export interface AbortResponse { export type MerchantAbortPayRefundStatus = | MerchantAbortPayRefundSuccessStatus - | MerchantAbortPayRefundFailureStatus; + | MerchantAbortPayRefundFailureStatus + | MerchantAbortPayRefundUndepositedStatus; + +export interface MerchantAbortPayRefundUndepositedStatus { + // Used as tag for the sum type RefundStatus sum type. + type: "undeposited"; +} // Details about why a refund failed. export interface MerchantAbortPayRefundFailureStatus { @@ -2911,12 +2917,22 @@ export const codecForMerchantAbortPayRefundFailureStatus = .property("type", codecForConstString("failure")) .build("TalerMerchantApi.MerchantAbortPayRefundFailureStatus"); +export const codecForMerchantAbortPayRefundUndepositedStatus = + (): Codec<MerchantAbortPayRefundUndepositedStatus> => + buildCodecForObject<MerchantAbortPayRefundUndepositedStatus>() + .property("type", codecForConstString("undeposited")) + .build("TalerMerchantApi.MerchantAbortPayRefundUndepositedStatus"); + export const codecForMerchantAbortPayRefundStatus = (): Codec<MerchantAbortPayRefundStatus> => buildCodecForUnion<MerchantAbortPayRefundStatus>() .discriminateOn("type") .alternative("success", codecForMerchantAbortPayRefundSuccessStatus()) .alternative("failure", codecForMerchantAbortPayRefundFailureStatus()) + .alternative( + "undeposited", + codecForMerchantAbortPayRefundUndepositedStatus(), + ) .build("TalerMerchantApi.MerchantAbortPayRefundStatus"); export const codecForAbortResponse = (): Codec<AbortResponse> => @@ -3437,7 +3453,10 @@ export const codecForTokenFamilyDetails = (): Codec<TokenFamilyDetails> => .property("slug", codecForString()) .property("name", codecForString()) .property("description", codecForString()) - .property("description_i18n", codecOptional(codecForInternationalizedString())) + .property( + "description_i18n", + codecOptional(codecForInternationalizedString()), + ) .property("valid_after", codecForTimestamp) .property("valid_before", codecForTimestamp) .property("duration", codecForDuration) diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts @@ -3424,6 +3424,9 @@ async function processPurchaseAbortingRefund( for (let i = 0; i < abortResp.refunds.length; i++) { const r = abortResp.refunds[i]; + if (r.type === "undeposited") { + continue; + } refunds.push({ ...r, coin_pub: payCoinSelection.coinPubs[i], diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts @@ -3512,7 +3512,9 @@ export async function confirmWithdrawal( break; } if (!acceptable) { - throw Error("bank account not acceptable by the exchange"); + // Might be acceptable if it's a withdrawal from a + // foreign account that is not properly marked as such. + logger.warn("no account acceptable by the exchange"); } const bankAccountId = await wex.db.runReadWriteTx(