commit 2560bde8fab087289af3aaafa45a9db83ac983c5
parent 6c60ee2c41a34dec46d3cc91f401f04822c63c13
Author: Florian Dold <florian@dold.me>
Date: Thu, 27 Nov 2025 17:32:18 +0100
extend test
Diffstat:
2 files changed, 76 insertions(+), 38 deletions(-)
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-wire.ts b/packages/taler-harness/src/integrationtests/test-merchant-wire.ts
@@ -19,6 +19,7 @@
*/
import {
AbsoluteTime,
+ AmountString,
Duration,
PreparePayResultType,
TalerMerchantApi,
@@ -137,16 +138,54 @@ export async function runMerchantWireTest(t: GlobalTestState) {
await merchant.runReconciliationOnce();
+ let incomingAmount: AmountString;
+ let incomingWtid: string;
+ let incomingPayto: string;
{
const resp = succeedOrThrow(
await merchantClient.listIncomingWireTransfers(merchantAdminAccessToken),
);
console.log(j2s(resp));
t.assertDeepEqual(resp.incoming.length, 1);
- t.assertAmountEquals(
- resp.incoming[0].expected_credit_amount!,
- "TESTKUDOS:4.79",
+ const det = resp.incoming[0];
+ t.assertTrue(det.expected_credit_amount != null);
+ t.assertAmountEquals(det.expected_credit_amount, "TESTKUDOS:4.79");
+ incomingAmount = det.expected_credit_amount;
+ incomingWtid = det.wtid;
+ incomingPayto = det.payto_uri;
+ }
+
+ {
+ const resp = succeedOrThrow(
+ await merchantClient.listConfirmedWireTransfers(merchantAdminAccessToken),
+ );
+ console.log(j2s(resp));
+ t.assertDeepEqual(resp.transfers.length, 0);
+ }
+
+ {
+ const resp = succeedOrThrow(
+ await merchantClient.listConfirmedWireTransfers(merchantAdminAccessToken),
);
+ console.log(j2s(resp));
+ t.assertDeepEqual(resp.transfers.length, 0);
+ }
+
+ succeedOrThrow(
+ await merchantClient.informWireTransfer(merchantAdminAccessToken, {
+ credit_amount: incomingAmount,
+ exchange_url: exchange.baseUrl,
+ payto_uri: incomingPayto,
+ wtid: incomingWtid,
+ }),
+ );
+
+ {
+ const resp = succeedOrThrow(
+ await merchantClient.listConfirmedWireTransfers(merchantAdminAccessToken),
+ );
+ console.log(j2s(resp));
+ t.assertDeepEqual(resp.transfers.length, 1);
}
}
diff --git a/packages/taler-util/src/http-client/merchant.ts b/packages/taler-util/src/http-client/merchant.ts
@@ -1716,43 +1716,42 @@ export class TalerMerchantInstanceHttpClient {
// Wire Transfer
//
- // /**
- // * https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCE]-private-transfers
- // * @deprecated
- // */
- // async informWireTransfer(
- // token: AccessToken | undefined,
- // body: TalerMerchantApi.TransferInformation,
- // ) {
- // const url = new URL(`private/transfers`, this.baseUrl);
+ /**
+ * https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCE]-private-transfers
+ */
+ async informWireTransfer(
+ token: AccessToken | undefined,
+ body: TalerMerchantApi.TransferInformation,
+ ) {
+ const url = new URL(`private/transfers`, this.baseUrl);
- // const headers: Record<string, string> = {};
- // if (token) {
- // headers.Authorization = makeBearerTokenAuthHeader(token);
- // }
- // const resp = await this.httpLib.fetch(url.href, {
- // method: "POST",
- // body,
- // headers,
- // });
+ const headers: Record<string, string> = {};
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token);
+ }
+ const resp = await this.httpLib.fetch(url.href, {
+ method: "POST",
+ body,
+ headers,
+ });
- // switch (resp.status) {
- // case HttpStatusCode.NoContent: {
- // this.cacheEvictor.notifySuccess(
- // TalerMerchantInstanceCacheEviction.CREATE_TRANSFER,
- // );
- // return opEmptySuccess();
- // }
- // case HttpStatusCode.Unauthorized: // FIXME: missing in docs
- // return opKnownHttpFailure(resp.status, resp);
- // case HttpStatusCode.NotFound:
- // return opKnownHttpFailure(resp.status, resp);
- // case HttpStatusCode.Conflict:
- // return opKnownHttpFailure(resp.status, resp);
- // default:
- // return opUnknownHttpFailure(resp);
- // }
- // }
+ switch (resp.status) {
+ case HttpStatusCode.NoContent: {
+ this.cacheEvictor.notifySuccess(
+ TalerMerchantInstanceCacheEviction.CREATE_TRANSFER,
+ );
+ return opEmptySuccess();
+ }
+ case HttpStatusCode.Unauthorized: // FIXME: missing in docs
+ return opKnownHttpFailure(resp.status, resp);
+ case HttpStatusCode.NotFound:
+ return opKnownHttpFailure(resp.status, resp);
+ case HttpStatusCode.Conflict:
+ return opKnownHttpFailure(resp.status, resp);
+ default:
+ return opUnknownHttpFailure(resp);
+ }
+ }
/**
* https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-transfers