harness: get rid of deprecated merchant API client

This commit is contained in:
Florian Dold 2023-09-06 11:23:33 +02:00
parent c9a0d2eb96
commit 9a1a3b350d
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
27 changed files with 311 additions and 339 deletions

View File

@ -1364,6 +1364,9 @@ export const harnessHttpLib = createPlatformHttpLib({
enableThrottling: false,
});
/**
* FIXME: Move this out of the harness.
*/
export class MerchantApiClient {
/**
* Base URL for the particular instance that this merchant API client
@ -1513,95 +1516,32 @@ export class MerchantApiClient {
);
}
private makeAuthHeader(): Record<string, string> {
switch (this.auth.method) {
case "external":
return {};
case "token":
return {
Authorization: `Bearer ${this.auth.token}`,
};
}
}
}
/**
* FIXME: This should be deprecated in favor of MerchantApiClient
*
* @deprecated use MerchantApiClient instead
*/
export namespace MerchantPrivateApi {
export async function createOrder(
merchantService: MerchantServiceInterface,
instanceName: string,
req: MerchantPostOrderRequest,
withAuthorization: WithAuthorization = {},
): Promise<MerchantPostOrderResponse> {
const baseUrl = merchantService.makeInstanceBaseUrl(instanceName);
let url = new URL("private/orders", baseUrl);
const resp = await harnessHttpLib.fetch(url.href, {
method: "POST",
body: req,
headers: withAuthorization as Record<string, string>,
});
return readSuccessResponseJsonOrThrow(
resp,
codecForMerchantPostOrderResponse(),
);
}
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 harnessHttpLib.fetch(url.href, {
method: "POST",
body: req,
headers: withAuthorization as Record<string, string>,
});
if (resp.status !== 204) {
throw Error("failed to create template");
}
}
export async function queryPrivateOrderStatus(
merchantService: MerchantServiceInterface,
query: PrivateOrderStatusQuery,
withAuthorization: WithAuthorization = {},
): Promise<MerchantOrderPrivateStatusResponse> {
const reqUrl = new URL(
`private/orders/${query.orderId}`,
merchantService.makeInstanceBaseUrl(query.instance),
);
if (query.sessionId) {
reqUrl.searchParams.set("session_id", query.sessionId);
}
async giveTip(req: RewardCreateRequest): Promise<RewardCreateConfirmation> {
const reqUrl = new URL(`private/tips`, this.baseUrl);
const resp = await harnessHttpLib.fetch(reqUrl.href, {
headers: withAuthorization as Record<string, string>,
method: "POST",
body: req,
});
return readSuccessResponseJsonOrThrow(
resp,
codecForMerchantOrderPrivateStatusResponse(),
);
// FIXME: validate
return resp.json();
}
export async function giveRefund(
merchantService: MerchantServiceInterface,
r: {
async queryTippingReserves(): Promise<TippingReserveStatus> {
const reqUrl = new URL(`private/reserves`, this.baseUrl);
const resp = await harnessHttpLib.fetch(reqUrl.href, {
headers: this.makeAuthHeader(),
});
// FIXME: validate
return resp.json();
}
async giveRefund(r: {
instance: string;
orderId: string;
amount: string;
justification: string;
},
): Promise<{ talerRefundUri: string }> {
const reqUrl = new URL(
`private/orders/${r.orderId}/refund`,
merchantService.makeInstanceBaseUrl(r.instance),
);
}): Promise<{ talerRefundUri: string }> {
const reqUrl = new URL(`private/orders/${r.orderId}/refund`, this.baseUrl);
const resp = await harnessHttpLib.fetch(reqUrl.href, {
method: "POST",
body: {
@ -1615,34 +1555,27 @@ export namespace MerchantPrivateApi {
};
}
export async function queryTippingReserves(
merchantService: MerchantServiceInterface,
instance: string,
): Promise<TippingReserveStatus> {
const reqUrl = new URL(
`private/reserves`,
merchantService.makeInstanceBaseUrl(instance),
);
const resp = await harnessHttpLib.fetch(reqUrl.href);
// FIXME: validate
return resp.json();
}
export async function giveTip(
merchantService: MerchantServiceInterface,
instance: string,
req: RewardCreateRequest,
): Promise<RewardCreateConfirmation> {
const reqUrl = new URL(
`private/tips`,
merchantService.makeInstanceBaseUrl(instance),
);
const resp = await harnessHttpLib.fetch(reqUrl.href, {
async createTemplate(req: MerchantTemplateAddDetails) {
let url = new URL("private/templates", this.baseUrl);
const resp = await harnessHttpLib.fetch(url.href, {
method: "POST",
body: req,
headers: this.makeAuthHeader(),
});
// FIXME: validate
return resp.json();
if (resp.status !== 204) {
throw Error("failed to create template");
}
}
private makeAuthHeader(): Record<string, string> {
switch (this.auth.method) {
case "external":
return {};
case "token":
return {
Authorization: `Bearer ${this.auth.token}`,
};
}
}
}

View File

@ -54,7 +54,6 @@ import {
getPayto,
GlobalTestState,
MerchantApiClient,
MerchantPrivateApi,
MerchantService,
MerchantServiceInterface,
setupDb,

View File

@ -27,8 +27,6 @@ import {
getWireMethodForTest,
GlobalTestState,
MerchantApiClient,
MerchantPrivateApi,
WalletCli,
} from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
@ -214,7 +212,7 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
await exchange.runWirewatchOnce();
const tip = await MerchantPrivateApi.giveTip(merchant, "default", {
const tip = await merchantClient.giveTip({
amount: "TESTKUDOS:5",
justification: "why not?",
next_url: "https://example.com/after-tip",

View File

@ -19,7 +19,10 @@
*/
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { URL } from "url";
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import {
GlobalTestState,
MerchantApiClient,
} from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@ -44,8 +47,10 @@ export async function runClaimLoopTest(t: GlobalTestState) {
amount: "TESTKUDOS:20",
});
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Set up order.
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -54,12 +59,9 @@ export async function runClaimLoopTest(t: GlobalTestState) {
});
// Query private order status before claiming it.
let orderStatusBefore = await MerchantPrivateApi.queryPrivateOrderStatus(
merchant,
{
let orderStatusBefore = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
},
);
});
t.assertTrue(orderStatusBefore.order_status === "unpaid");
let statusUrlBefore = new URL(orderStatusBefore.order_status_url);
@ -71,12 +73,9 @@ export async function runClaimLoopTest(t: GlobalTestState) {
});
// Query private order status after claiming it.
let orderStatusAfter = await MerchantPrivateApi.queryPrivateOrderStatus(
merchant,
{
let orderStatusAfter = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
},
);
});
t.assertTrue(orderStatusAfter.order_status === "claimed");
await t.shutdown();

View File

@ -19,7 +19,10 @@
*/
import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import {
GlobalTestState,
MerchantApiClient,
} from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@ -62,11 +65,13 @@ export async function runDenomUnofferedTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
};
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
const orderResp = await merchantClient.createOrder({
order: order,
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});

View File

@ -35,10 +35,9 @@ import {
getPayto,
GlobalTestState,
harnessHttpLib,
MerchantPrivateApi,
MerchantApiClient,
MerchantService,
setupDb,
WalletCli,
} from "../harness/harness.js";
import {
createWalletDaemonWithClient,
@ -170,7 +169,9 @@ export async function runMerchantExchangeConfusionTest(t: GlobalTestState) {
const merchant = faultyMerchant;
let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
let orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -178,7 +179,7 @@ export async function runMerchantExchangeConfusionTest(t: GlobalTestState) {
},
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-one",
});
@ -233,12 +234,9 @@ export async function runMerchantExchangeConfusionTest(t: GlobalTestState) {
await publicOrderStatusResp.json(),
);
const confirmPayRes = await walletClient.call(
WalletApiOperation.ConfirmPay,
{
const confirmPayRes = await walletClient.call(WalletApiOperation.ConfirmPay, {
proposalId: proposalId,
},
);
});
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
}

View File

@ -24,12 +24,15 @@ import {
codecForMerchantOrderStatusUnpaid,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantPrivateApi, harnessHttpLib } from "../harness/harness.js";
import {
GlobalTestState,
MerchantApiClient,
harnessHttpLib,
} from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
} from "../harness/helpers.js";
import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
/**
* Run test for basic, bank-integrated withdrawal.
@ -50,6 +53,8 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
await wres.withdrawalFinishedCond;
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
/**
* =========================================================================
* Create an order and let the wallet pay under a session ID
@ -59,7 +64,7 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
* =========================================================================
*/
let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
let orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -68,7 +73,7 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
create_token: false,
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-one",
});
@ -81,7 +86,9 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
// First, request order status without longpolling
{
console.log("requesting", publicOrderStatusUrl.href);
let publicOrderStatusResp = await harnessHttpLib.fetch(publicOrderStatusUrl.href);
let publicOrderStatusResp = await harnessHttpLib.fetch(
publicOrderStatusUrl.href,
);
if (publicOrderStatusResp.status != 402) {
throw Error(
@ -94,7 +101,9 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
publicOrderStatusUrl.searchParams.set("timeout_ms", "500");
console.log("requesting", publicOrderStatusUrl.href);
let publicOrderStatusResp = await harnessHttpLib.fetch(publicOrderStatusUrl.href);
let publicOrderStatusResp = await harnessHttpLib.fetch(
publicOrderStatusUrl.href,
);
if (publicOrderStatusResp.status != 402) {
throw Error(
@ -129,7 +138,9 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
preparePayResp.contractTermsHash,
);
let publicOrderStatusPromise = harnessHttpLib.fetch(publicOrderStatusUrl.href);
let publicOrderStatusPromise = harnessHttpLib.fetch(
publicOrderStatusUrl.href,
);
t.assertTrue(preparePayResp.status === PreparePayResultType.PaymentPossible);

View File

@ -17,15 +17,13 @@
/**
* Imports.
*/
import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
import {
GlobalTestState,
MerchantPrivateApi,
MerchantServiceInterface,
WalletCli,
ExchangeServiceInterface,
harnessHttpLib,
WalletClient,
MerchantApiClient,
} from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
@ -51,10 +49,12 @@ async function testRefundApiWithFulfillmentUrl(
exchange: ExchangeServiceInterface;
},
): Promise<void> {
const { walletClient, bank, exchange, merchant } = env;
const { walletClient, merchant } = env;
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Set up order.
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -65,7 +65,7 @@ async function testRefundApiWithFulfillmentUrl(
),
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -93,7 +93,7 @@ async function testRefundApiWithFulfillmentUrl(
// Check if payment was successful.
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -110,14 +110,14 @@ async function testRefundApiWithFulfillmentUrl(
preparePayResult.status === PreparePayResultType.AlreadyConfirmed,
);
await MerchantPrivateApi.giveRefund(merchant, {
await merchantClient.giveRefund({
amount: "TESTKUDOS:5",
instance: "default",
justification: "foo",
orderId: orderResp.order_id,
});
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -165,10 +165,12 @@ async function testRefundApiWithFulfillmentMessage(
exchange: ExchangeServiceInterface;
},
): Promise<void> {
const { walletClient, bank, exchange, merchant } = env;
const { walletClient, merchant } = env;
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Set up order.
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -179,7 +181,7 @@ async function testRefundApiWithFulfillmentMessage(
),
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -207,7 +209,7 @@ async function testRefundApiWithFulfillmentMessage(
// Check if payment was successful.
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -224,14 +226,14 @@ async function testRefundApiWithFulfillmentMessage(
preparePayResult.status === PreparePayResultType.AlreadyConfirmed,
);
await MerchantPrivateApi.giveRefund(merchant, {
await merchantClient.giveRefund({
amount: "TESTKUDOS:5",
instance: "default",
justification: "foo",
orderId: orderResp.order_id,
});
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});

View File

@ -29,9 +29,8 @@ import {
BankService,
ExchangeService,
GlobalTestState,
MerchantPrivateApi,
MerchantApiClient,
MerchantService,
WalletCli,
harnessHttpLib,
} from "../harness/harness.js";
import {
@ -66,7 +65,8 @@ async function testWithClaimToken(
});
await wres.withdrawalFinishedCond;
const sessionId = "mysession";
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -255,18 +255,14 @@ async function testWithClaimToken(
t.assertTrue(confirmPayRes2.type === ConfirmPayResultType.Done);
// Create another order with identical fulfillment URL to test the "already paid" flow
const alreadyPaidOrderResp = await MerchantPrivateApi.createOrder(
merchant,
"default",
{
const alreadyPaidOrderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
fulfillment_url: "https://example.com/article42",
public_reorder_url: "https://example.com/article42-share",
},
},
);
});
const apOrderId = alreadyPaidOrderResp.order_id;
const apToken = alreadyPaidOrderResp.token;
@ -319,6 +315,7 @@ async function testWithoutClaimToken(
const sessionId = "mysession2";
const { bank, exchange } = c;
const { merchant, merchantBaseUrl } = c;
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
const wres = await withdrawViaBankV2(t, {
walletClient,
bank,
@ -326,7 +323,7 @@ async function testWithoutClaimToken(
amount: "TESTKUDOS:20",
});
await wres.withdrawalFinishedCond;
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -514,18 +511,14 @@ async function testWithoutClaimToken(
t.assertTrue(confirmPayRes2.type === ConfirmPayResultType.Done);
// Create another order with identical fulfillment URL to test the "already paid" flow
const alreadyPaidOrderResp = await MerchantPrivateApi.createOrder(
merchant,
"default",
{
const alreadyPaidOrderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
fulfillment_url: "https://example.com/article42",
public_reorder_url: "https://example.com/article42-share",
},
},
);
});
const apOrderId = alreadyPaidOrderResp.order_id;
const apToken = alreadyPaidOrderResp.token;

View File

@ -19,7 +19,7 @@
*/
import {
GlobalTestState,
MerchantPrivateApi,
MerchantApiClient,
harnessHttpLib,
} from "../harness/harness.js";
import {
@ -71,7 +71,9 @@ export async function runPayPaidTest(t: GlobalTestState) {
const merchant = faultyMerchant;
let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
let orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -80,7 +82,7 @@ export async function runPayPaidTest(t: GlobalTestState) {
},
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-one",
});
@ -127,12 +129,9 @@ export async function runPayPaidTest(t: GlobalTestState) {
publicOrderStatusResp.json(),
);
const confirmPayRes = await walletClient.call(
WalletApiOperation.ConfirmPay,
{
const confirmPayRes = await walletClient.call(WalletApiOperation.ConfirmPay, {
proposalId: proposalId,
},
);
});
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
@ -153,7 +152,7 @@ export async function runPayPaidTest(t: GlobalTestState) {
* =========================================================================
*/
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-two",
});
@ -180,7 +179,7 @@ export async function runPayPaidTest(t: GlobalTestState) {
},
});
let orderRespTwo = await MerchantPrivateApi.createOrder(merchant, "default", {
let orderRespTwo = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -189,13 +188,10 @@ export async function runPayPaidTest(t: GlobalTestState) {
},
});
let orderStatusTwo = await MerchantPrivateApi.queryPrivateOrderStatus(
merchant,
{
let orderStatusTwo = await merchantClient.queryPrivateOrderStatus({
orderId: orderRespTwo.order_id,
sessionId: "mysession-two",
},
);
});
t.assertTrue(orderStatusTwo.order_status === "unpaid");

View File

@ -19,7 +19,7 @@
*/
import {
GlobalTestState,
MerchantPrivateApi,
MerchantApiClient,
harnessHttpLib,
} from "../harness/harness.js";
import {
@ -55,7 +55,9 @@ export async function runPaymentAbortTest(t: GlobalTestState) {
const merchant = faultyMerchant;
let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
let orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -64,7 +66,7 @@ export async function runPaymentAbortTest(t: GlobalTestState) {
},
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-one",
});

View File

@ -19,11 +19,7 @@
*/
import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import {
GlobalTestState,
MerchantPrivateApi,
WalletCli,
} from "../harness/harness.js";
import { GlobalTestState, MerchantApiClient, WalletCli } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@ -38,6 +34,8 @@ export async function runPaymentClaimTest(t: GlobalTestState) {
const { walletClient, bank, exchange, merchant } =
await createSimpleTestkudosEnvironmentV2(t);
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
const walletTwo = new WalletCli(t, "two");
// Withdraw digital cash into the wallet.
@ -53,7 +51,7 @@ export async function runPaymentClaimTest(t: GlobalTestState) {
// Set up order.
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -61,7 +59,7 @@ export async function runPaymentClaimTest(t: GlobalTestState) {
},
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -94,7 +92,7 @@ export async function runPaymentClaimTest(t: GlobalTestState) {
// Check if payment was successful.
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});

View File

@ -28,8 +28,8 @@ import {
setupDb,
BankService,
WalletCli,
MerchantPrivateApi,
getPayto,
MerchantApiClient,
} from "../harness/harness.js";
import {
FaultInjectedExchangeService,
@ -120,6 +120,8 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
paytoUris: [getPayto("merchant-default")],
});
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
console.log("setup done!");
const wallet = new WalletCli(t);
@ -161,7 +163,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
// Set up order.
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -169,7 +171,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
},
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -218,7 +220,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
// Check if payment was successful.
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});

View File

@ -19,7 +19,7 @@
*/
import { PreparePayResultType } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@ -46,9 +46,11 @@ export async function runPaymentIdempotencyTest(t: GlobalTestState) {
await wres.withdrawalFinishedCond;
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Set up order.
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -56,7 +58,7 @@ export async function runPaymentIdempotencyTest(t: GlobalTestState) {
},
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -102,7 +104,7 @@ export async function runPaymentIdempotencyTest(t: GlobalTestState) {
// Check if payment was successful.
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});

View File

@ -23,9 +23,8 @@ import {
BankService,
ExchangeService,
MerchantService,
WalletCli,
MerchantPrivateApi,
getPayto,
MerchantApiClient,
} from "../harness/harness.js";
import { coin_ct10, coin_u1 } from "../harness/denomStructures.js";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
@ -120,6 +119,8 @@ export async function runPaymentMultipleTest(t: GlobalTestState) {
name: "default",
});
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Withdraw digital cash into the wallet.
await withdrawViaBankV2(t, {
@ -131,7 +132,7 @@ export async function runPaymentMultipleTest(t: GlobalTestState) {
// Set up order.
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:80",
@ -139,7 +140,7 @@ export async function runPaymentMultipleTest(t: GlobalTestState) {
},
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -157,7 +158,7 @@ export async function runPaymentMultipleTest(t: GlobalTestState) {
// Check if payment was successful.
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});

View File

@ -22,7 +22,7 @@ import {
PreparePayResultType,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
createWalletDaemonWithClient,
@ -41,6 +41,8 @@ export async function runPaymentShareTest(t: GlobalTestState) {
merchant,
} = await createSimpleTestkudosEnvironmentV2(t);
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Withdraw digital cash into the wallet.
await withdrawViaBankV2(t, {
walletClient: firstWallet,
@ -70,26 +72,16 @@ export async function runPaymentShareTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
};
const instance = "default";
const args = { order };
const auth = {};
const orderResp = await MerchantPrivateApi.createOrder(
merchant,
instance,
{
const orderResp = await merchantClient.createOrder({
order: args.order,
},
auth,
);
});
const orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
merchant,
{
const orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
},
auth,
);
});
t.assertTrue(orderStatus.order_status === "unpaid");
return { id: orderResp.order_id, uri: orderStatus.taler_pay_uri };

View File

@ -17,12 +17,16 @@
/**
* Imports.
*/
import { ConfirmPayResultType, Duration, PreparePayResultType } from "@gnu-taler/taler-util";
import {
ConfirmPayResultType,
Duration,
PreparePayResultType,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2
withdrawViaBankV2,
} from "../harness/helpers.js";
/**
@ -34,7 +38,9 @@ export async function runPaymentTemplateTest(t: GlobalTestState) {
const { walletClient, bank, exchange, merchant } =
await createSimpleTestkudosEnvironmentV2(t);
await MerchantPrivateApi.createTemplate(merchant, "default", {
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
await merchantClient.createTemplate({
template_id: "template1",
template_description: "my test template",
template_contract: {
@ -50,7 +56,12 @@ export async function runPaymentTemplateTest(t: GlobalTestState) {
// Withdraw digital cash into the wallet.
const wres = await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: "TESTKUDOS:20" });
const wres = await withdrawViaBankV2(t, {
walletClient,
bank,
exchange,
amount: "TESTKUDOS:20",
});
await wres.withdrawalFinishedCond;
// Request a template payment
@ -79,13 +90,10 @@ export async function runPaymentTemplateTest(t: GlobalTestState) {
// Check if payment was successful.
const orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
merchant,
{
const orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: preparePayResult.contractTerms.order_id,
instance: "default",
},
);
});
t.assertTrue(orderStatus.order_status === "paid");
await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});

View File

@ -27,12 +27,16 @@ import {
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { FaultInjectionResponseContext } from "../harness/faultInjection.js";
import { GlobalTestState, MerchantPrivateApi, harnessHttpLib } from "../harness/harness.js";
import {
createFaultInjectedMerchantTestkudosEnvironment, withdrawViaBankV2,
GlobalTestState,
MerchantApiClient,
harnessHttpLib,
} from "../harness/harness.js";
import {
createFaultInjectedMerchantTestkudosEnvironment,
withdrawViaBankV2,
} from "../harness/helpers.js";
/**
* Run test for a payment where the merchant has a transient
* failure in /pay
@ -40,9 +44,13 @@ import {
export async function runPaymentTransientTest(t: GlobalTestState) {
// Set up test environment
const { walletClient, bank, exchange, faultyMerchant, faultyExchange } =
const { walletClient, bank, faultyMerchant, faultyExchange } =
await createFaultInjectedMerchantTestkudosEnvironment(t);
const merchantClient = new MerchantApiClient(
faultyMerchant.makeInstanceBaseUrl(),
);
// Withdraw digital cash into the wallet.
await withdrawViaBankV2(t, {
@ -54,7 +62,7 @@ export async function runPaymentTransientTest(t: GlobalTestState) {
const merchant = faultyMerchant;
let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
let orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -63,7 +71,7 @@ export async function runPaymentTransientTest(t: GlobalTestState) {
},
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-one",
});

View File

@ -17,7 +17,11 @@
/**
* Imports.
*/
import { GlobalTestState, MerchantPrivateApi, harnessHttpLib } from "../harness/harness.js";
import {
GlobalTestState,
MerchantApiClient,
harnessHttpLib,
} from "../harness/harness.js";
import {
PreparePayResultType,
codecForMerchantOrderStatusUnpaid,
@ -39,6 +43,8 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
const { walletClient, bank, exchange, merchant } =
await createSimpleTestkudosEnvironmentV2(t);
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Withdraw digital cash into the wallet.
const wres = await withdrawViaBankV2(t, {
@ -59,7 +65,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
* =========================================================================
*/
let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
let orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -70,7 +76,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
const firstOrderId = orderResp.order_id;
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-one",
});
@ -82,7 +88,9 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
t.assertTrue(orderStatus.already_paid_order_id === undefined);
let publicOrderStatusUrl = new URL(orderStatus.order_status_url);
let publicOrderStatusResp = await harnessHttpLib.fetch(publicOrderStatusUrl.href);
let publicOrderStatusResp = await harnessHttpLib.fetch(
publicOrderStatusUrl.href,
);
if (publicOrderStatusResp.status != 402) {
throw Error(
@ -142,7 +150,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
* =========================================================================
*/
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
sessionId: "mysession-two",
});
@ -169,7 +177,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
* =========================================================================
*/
orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -181,7 +189,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
const secondOrderId = orderResp.order_id;
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: secondOrderId,
sessionId: "mysession-three",
});
@ -206,7 +214,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
// The first order should now be paid under "mysession-three",
// as the wallet did re-purchase detection
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: firstOrderId,
sessionId: "mysession-three",
});
@ -215,7 +223,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
// Check that with a completely new session ID, the status would NOT
// be paid.
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: firstOrderId,
sessionId: "mysession-four",
});

View File

@ -19,7 +19,7 @@
*/
import { Duration, durationFromSpec } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@ -34,6 +34,8 @@ export async function runRefundAutoTest(t: GlobalTestState) {
const { walletClient, bank, exchange, merchant } =
await createSimpleTestkudosEnvironmentV2(t);
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Withdraw digital cash into the wallet.
const wres = await withdrawViaBankV2(t, {
@ -46,7 +48,7 @@ export async function runRefundAutoTest(t: GlobalTestState) {
await wres.withdrawalFinishedCond;
// Set up order.
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -60,7 +62,7 @@ export async function runRefundAutoTest(t: GlobalTestState) {
),
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -78,13 +80,13 @@ export async function runRefundAutoTest(t: GlobalTestState) {
// Check if payment was successful.
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
t.assertTrue(orderStatus.order_status === "paid");
const ref = await MerchantPrivateApi.giveRefund(merchant, {
const ref = await merchantClient.giveRefund({
amount: "TESTKUDOS:5",
instance: "default",
justification: "foo",

View File

@ -17,7 +17,7 @@
/**
* Imports.
*/
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js";
import {
applyTimeTravelV2,
createSimpleTestkudosEnvironmentV2,
@ -39,6 +39,8 @@ export async function runRefundGoneTest(t: GlobalTestState) {
const { walletClient, bank, exchange, merchant } =
await createSimpleTestkudosEnvironmentV2(t);
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Withdraw digital cash into the wallet.
await withdrawViaBankV2(t, {
@ -50,7 +52,7 @@ export async function runRefundGoneTest(t: GlobalTestState) {
// Set up order.
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -69,7 +71,7 @@ export async function runRefundGoneTest(t: GlobalTestState) {
),
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -82,12 +84,12 @@ export async function runRefundGoneTest(t: GlobalTestState) {
});
const r2 = await walletClient.call(WalletApiOperation.ConfirmPay, {
proposalId: r1.proposalId,
transactionId: r1.transactionId,
});
// Check if payment was successful.
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -102,7 +104,7 @@ export async function runRefundGoneTest(t: GlobalTestState) {
await exchange.runAggregatorOnce();
const ref = await MerchantPrivateApi.giveRefund(merchant, {
const ref = await merchantClient.giveRefund({
amount: "TESTKUDOS:5",
instance: "default",
justification: "foo",

View File

@ -26,7 +26,7 @@ import {
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import {
GlobalTestState,
MerchantPrivateApi,
MerchantApiClient,
delayMs,
} from "../harness/harness.js";
import {
@ -43,6 +43,8 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
const { walletClient, bank, exchange, merchant } =
await createSimpleTestkudosEnvironmentV2(t);
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Withdraw digital cash into the wallet.
const wres = await withdrawViaBankV2(t, {
@ -56,7 +58,7 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
// Set up order.
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:10",
@ -67,7 +69,7 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
),
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -85,13 +87,13 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
// Check if payment was successful.
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
t.assertTrue(orderStatus.order_status === "paid");
let ref = await MerchantPrivateApi.giveRefund(merchant, {
let ref = await merchantClient.giveRefund({
amount: "TESTKUDOS:2.5",
instance: "default",
justification: "foo",
@ -120,7 +122,7 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
// refund will be grouped with the previous one.
await delayMs(1200);
ref = await MerchantPrivateApi.giveRefund(merchant, {
ref = await merchantClient.giveRefund({
amount: "TESTKUDOS:5",
instance: "default",
justification: "bar",
@ -133,7 +135,7 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
// refund will be grouped with the previous one.
await delayMs(1200);
ref = await MerchantPrivateApi.giveRefund(merchant, {
ref = await merchantClient.giveRefund({
amount: "TESTKUDOS:10",
instance: "default",
justification: "bar",
@ -153,7 +155,7 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
console.log(wr);
}
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});

View File

@ -24,7 +24,7 @@ import {
TransactionMajorState,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@ -43,6 +43,8 @@ export async function runRefundTest(t: GlobalTestState) {
merchant,
} = await createSimpleTestkudosEnvironmentV2(t);
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Withdraw digital cash into the wallet.
const withdrawalRes = await withdrawViaBankV2(t, {
@ -56,7 +58,7 @@ export async function runRefundTest(t: GlobalTestState) {
// Set up order.
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
summary: "Buy me!",
amount: "TESTKUDOS:5",
@ -67,7 +69,7 @@ export async function runRefundTest(t: GlobalTestState) {
),
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
@ -85,13 +87,13 @@ export async function runRefundTest(t: GlobalTestState) {
// Check if payment was successful.
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});
t.assertTrue(orderStatus.order_status === "paid");
const ref = await MerchantPrivateApi.giveRefund(merchant, {
const ref = await merchantClient.giveRefund({
amount: "TESTKUDOS:5",
instance: "default",
justification: "foo",

View File

@ -32,14 +32,16 @@ import {
BankService,
ExchangeService,
GlobalTestState,
MerchantPrivateApi,
MerchantService,
setupDb,
WalletCli,
getPayto,
MerchantApiClient,
} from "../harness/harness.js";
import { applyTimeTravelV2, createWalletDaemonWithClient, withdrawViaBankV2 } from "../harness/helpers.js";
import {
applyTimeTravelV2,
createWalletDaemonWithClient,
withdrawViaBankV2,
} from "../harness/helpers.js";
/**
* Basic time travel test.
@ -110,19 +112,29 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
name: "w1",
});
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Withdraw digital cash into the wallet.
const wres = await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: "TESTKUDOS:15" });
const wres = await withdrawViaBankV2(t, {
walletClient,
bank,
exchange,
amount: "TESTKUDOS:15",
});
await wres.withdrawalFinishedCond;
// Travel into the future, the deposit expiration is two years
// into the future.
console.log("applying first time travel");
await applyTimeTravelV2(Duration.toMilliseconds(durationFromSpec({ days: 400 })), {
await applyTimeTravelV2(
Duration.toMilliseconds(durationFromSpec({ days: 400 })),
{
walletClient,
exchange,
merchant,
});
},
);
await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
@ -144,11 +156,14 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
// Travel into the future, the deposit expiration is two years
// into the future.
console.log("applying second time travel");
await applyTimeTravelV2(Duration.toMilliseconds(durationFromSpec({ years: 2, months: 6 })), {
await applyTimeTravelV2(
Duration.toMilliseconds(durationFromSpec({ years: 2, months: 6 })),
{
walletClient,
exchange,
merchant,
});
},
);
// At this point, the original coins should've been refreshed.
// It would be too late to refresh them now, as we're past
@ -156,7 +171,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order: {
fulfillment_url: "http://example.com",
summary: "foo",
@ -164,13 +179,10 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
},
});
const orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
merchant,
{
const orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
instance: "default",
},
);
});
t.assertTrue(orderStatus.order_status === "unpaid");

View File

@ -25,7 +25,6 @@ import {
import {
GlobalTestState,
MerchantApiClient,
MerchantPrivateApi,
getWireMethodForTest,
} from "../harness/harness.js";
import { createSimpleTestkudosEnvironmentV2 } from "../harness/helpers.js";
@ -46,12 +45,7 @@ export async function runTippingTest(t: GlobalTestState) {
});
const mbu = await bankAccessApiClient.createRandomBankUser();
const merchantClient = new MerchantApiClient(
merchant.makeInstanceBaseUrl("default"),
{
method: "external",
},
);
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
const tipReserveResp = await merchantClient.createTippingReserve({
exchange_url: exchange.baseUrl,
@ -85,7 +79,7 @@ export async function runTippingTest(t: GlobalTestState) {
await merchant.start();
await merchant.pingUntilAvailable();
const r = await MerchantPrivateApi.queryTippingReserves(merchant, "default");
const r = await merchantClient.queryTippingReserves();
console.log("tipping reserves:", JSON.stringify(r, undefined, 2));
t.assertTrue(r.reserves.length === 1);
@ -94,7 +88,7 @@ export async function runTippingTest(t: GlobalTestState) {
r.reserves[0].merchant_initial_amount,
);
const tip = await MerchantPrivateApi.giveTip(merchant, "default", {
const tip = await merchantClient.giveTip({
amount: "TESTKUDOS:5",
justification: "why not?",
next_url: "https://example.com/after-tip",

View File

@ -19,7 +19,7 @@
*/
import { PreparePayResultType } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
createWalletDaemonWithClient,
@ -34,6 +34,8 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
const { commonDb, merchant, walletClient, bank, exchange } =
await createSimpleTestkudosEnvironmentV2(t);
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
const sync = await SyncService.create(t, {
currency: "TESTKUDOS",
annualFee: "TESTKUDOS:0.5",
@ -116,7 +118,7 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
{
const instance = "default";
const orderResp = await MerchantPrivateApi.createOrder(merchant, instance, {
const orderResp = await merchantClient.createOrder({
order: {
amount: "TESTKUDOS:8",
summary: "bla",
@ -124,8 +126,7 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
},
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
merchant,
let orderStatus = await merchantClient.queryPrivateOrderStatus(
{
orderId: orderResp.order_id,
},

View File

@ -19,7 +19,7 @@
*/
import { Amounts, PreparePayResultType } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
@ -37,6 +37,8 @@ export async function runWalletBalanceTest(t: GlobalTestState) {
const { merchant, walletClient, exchange, bank } =
await createSimpleTestkudosEnvironmentV2(t);
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
// Withdraw digital cash into the wallet.
const wres = await withdrawViaBankV2(t, {
@ -54,11 +56,11 @@ export async function runWalletBalanceTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
};
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
const orderResp = await merchantClient.createOrder({
order,
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
let orderStatus = await merchantClient.queryPrivateOrderStatus({
orderId: orderResp.order_id,
});