taler-typescript-core

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

commit 401a7ec80766108edc929df1dfc53daa7e7ca948
parent 12eda956ef0203639bbc055cd56e2d8dcde60659
Author: Florian Dold <florian@dold.me>
Date:   Thu, 27 Nov 2025 14:20:58 +0100

harness: add test for merchant wire transfer APIs

Diffstat:
Mpackages/taler-harness/src/integrationtests/test-deposit.ts | 1-
Apackages/taler-harness/src/integrationtests/test-merchant-wire.ts | 132+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpackages/taler-harness/src/integrationtests/testrunner.ts | 2++
3 files changed, 134 insertions(+), 1 deletion(-)

diff --git a/packages/taler-harness/src/integrationtests/test-deposit.ts b/packages/taler-harness/src/integrationtests/test-deposit.ts @@ -19,7 +19,6 @@ */ import { AmountString, - NotificationType, TransactionMajorState, TransactionMinorState, j2s, diff --git a/packages/taler-harness/src/integrationtests/test-merchant-wire.ts b/packages/taler-harness/src/integrationtests/test-merchant-wire.ts @@ -0,0 +1,132 @@ +/* + This file is part of GNU Taler + (C) 2020 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +/** + * Imports. + */ +import { + AbsoluteTime, + Duration, + PreparePayResultType, + TalerMerchantApi, + TalerMerchantInstanceHttpClient, + j2s, + succeedOrThrow, +} from "@gnu-taler/taler-util"; +import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { + applyTimeTravelV2, + createSimpleTestkudosEnvironmentV3, + withdrawViaBankV3, +} from "../harness/environments.js"; +import { GlobalTestState } from "../harness/harness.js"; + +/** + * Test APIs related to merchant wire transfers. + */ +export async function runMerchantWireTest(t: GlobalTestState) { + // Set up test environment + + const { + walletClient, + bankClient, + exchange, + merchant, + merchantAdminAccessToken, + } = await createSimpleTestkudosEnvironmentV3(t); + + // Withdraw digital cash into the wallet. + + await withdrawViaBankV3(t, { + walletClient, + bankClient, + exchange, + amount: "TESTKUDOS:20", + }); + + await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); + + // Order that can only be paid within five minutes. + const order: TalerMerchantApi.Order = { + summary: "Buy me!", + amount: "TESTKUDOS:5", + fulfillment_url: "taler://fulfillment-success/thx", + pay_deadline: AbsoluteTime.toProtocolTimestamp( + AbsoluteTime.addDuration( + AbsoluteTime.now(), + Duration.fromSpec({ minutes: 5 }), + ), + ), + wire_transfer_deadline: AbsoluteTime.toProtocolTimestamp( + AbsoluteTime.addDuration( + AbsoluteTime.now(), + Duration.fromSpec({ minutes: 10 }), + ), + ), + }; + + const merchantClient = new TalerMerchantInstanceHttpClient( + merchant.makeInstanceBaseUrl(), + ); + + const orderResp = succeedOrThrow( + await merchantClient.createOrder(merchantAdminAccessToken, { + order, + }), + ); + + let orderStatus = succeedOrThrow( + await merchantClient.getOrderDetails( + merchantAdminAccessToken, + orderResp.order_id, + ), + ); + + t.assertTrue(orderStatus.order_status === "unpaid"); + + const preparePayResult = await walletClient.call( + WalletApiOperation.PreparePayForUri, + { + talerPayUri: orderStatus.taler_pay_uri, + }, + ); + + t.assertDeepEqual( + preparePayResult.status, + PreparePayResultType.PaymentPossible, + ); + + const confirmPayResult = await walletClient.call( + WalletApiOperation.ConfirmPay, + { transactionId: preparePayResult.transactionId }, + ); + console.log("confirm pay result:"); + console.log(j2s(confirmPayResult)); + await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); + + await applyTimeTravelV2( + Duration.toMilliseconds(Duration.fromSpec({ hours: 2 })), + { walletClient, exchange, merchant }, + ); + + const resp = succeedOrThrow( + await merchantClient.listIncomingWireTransfers(merchantAdminAccessToken), + ); + + console.log(j2s(resp)); +} + +runMerchantWireTest.suites = ["wallet"]; diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts @@ -115,6 +115,7 @@ import { runMerchantSelfProvisionActivationTest } from "./test-merchant-self-pro import { runMerchantSelfProvisionForgotPasswordTest } from "./test-merchant-self-provision-forgot-password.js"; import { runMerchantSelfProvisionInactiveAccountPermissionsTest } from "./test-merchant-self-provision-inactive-account-permissions.js"; import { runMerchantSpecPublicOrdersTest } from "./test-merchant-spec-public-orders.js"; +import { runMerchantWireTest } from "./test-merchant-wire.js"; import { runMultiExchangeTest } from "./test-multiexchange.js"; import { runOtpTest } from "./test-otp.js"; import { runPayPaidTest } from "./test-pay-paid.js"; @@ -401,6 +402,7 @@ const allTests: TestMainFunction[] = [ runDonauIdempotencyTest, runDonauKeychangeTest, runTopsAmlPdfTest, + runMerchantWireTest, ]; export interface TestRunSpec {