diff options
author | Florian Dold <florian@dold.me> | 2023-02-11 14:24:29 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-02-11 14:24:29 +0100 |
commit | 04ab9f37801f6a42b85581cc79667239d3fc79e5 (patch) | |
tree | 7f5841f5a872a6374251137b75a17d00a258740e /packages/taler-harness/src/harness/harness.ts | |
parent | a9073a67971e56dc58e8633d10c5e0c7c3920c8a (diff) | |
download | wallet-core-04ab9f37801f6a42b85581cc79667239d3fc79e5.tar.xz |
wallet-core,harness: implement pay templating
Diffstat (limited to 'packages/taler-harness/src/harness/harness.ts')
-rw-r--r-- | packages/taler-harness/src/harness/harness.ts | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index 4e5d8238c..3659ea538 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -38,6 +38,7 @@ import { hash, j2s, Logger, + MerchantTemplateAddDetails, parsePaytoUri, stringToBytes, TalerProtocolDuration, @@ -66,15 +67,15 @@ import { CoinConfig } from "./denomStructures.js"; import { LibeufinNexusApi, LibeufinSandboxApi } from "./libeufin-apis.js"; import { codecForMerchantOrderPrivateStatusResponse, - codecForPostOrderResponse, + codecForMerchantPostOrderResponse, MerchantInstancesResponse, MerchantOrderPrivateStatusResponse, - PostOrderRequest, - PostOrderResponse, + MerchantPostOrderRequest, + MerchantPostOrderResponse, TipCreateConfirmation, TipCreateRequest, TippingReserveStatus, -} from "./merchantApiTypes.js"; +} from "@gnu-taler/taler-util"; import { createRemoteWallet, getClientFromRemoteWallet, @@ -1473,15 +1474,31 @@ export namespace MerchantPrivateApi { export async function createOrder( merchantService: MerchantServiceInterface, instanceName: string, - req: PostOrderRequest, + req: MerchantPostOrderRequest, withAuthorization: WithAuthorization = {}, - ): Promise<PostOrderResponse> { + ): Promise<MerchantPostOrderResponse> { const baseUrl = merchantService.makeInstanceBaseUrl(instanceName); let url = new URL("private/orders", baseUrl); const resp = await axios.post(url.href, req, { headers: withAuthorization as Record<string, string>, }); - return codecForPostOrderResponse().decode(resp.data); + return codecForMerchantPostOrderResponse().decode(resp.data); + } + + export async function createTemplate( + merchantService: MerchantServiceInterface, + instanceName: string, + req: MerchantTemplateAddDetails, + withAuthorization: WithAuthorization = {}, + ) { + const baseUrl = merchantService.makeInstanceBaseUrl(instanceName); + let url = new URL("private/templates", baseUrl); + const resp = await axios.post(url.href, req, { + headers: withAuthorization as Record<string, string>, + }); + if (resp.status !== 204) { + throw Error("failed to create template"); + } } export async function queryPrivateOrderStatus( |