move merchant API client to taler-util

This commit is contained in:
Florian Dold 2023-09-06 11:44:07 +02:00
parent 9a1a3b350d
commit 324d9f871c
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
35 changed files with 145 additions and 475 deletions

View File

@ -57,6 +57,8 @@ import {
WalletNotification, WalletNotification,
codecForAny, codecForAny,
AccountAddDetails, AccountAddDetails,
MerchantInstanceConfig,
PartialMerchantInstanceConfig,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { import {
createPlatformHttpLib, createPlatformHttpLib,
@ -1339,23 +1341,12 @@ export interface MerchantConfig {
overrideTestDir?: string; overrideTestDir?: string;
} }
export interface PrivateOrderStatusQuery {
instance?: string;
orderId: string;
sessionId?: string;
}
export interface MerchantServiceInterface { export interface MerchantServiceInterface {
makeInstanceBaseUrl(instanceName?: string): string; makeInstanceBaseUrl(instanceName?: string): string;
readonly port: number; readonly port: number;
readonly name: string; readonly name: string;
} }
export interface DeleteTippingReserveArgs {
reservePub: string;
purge?: boolean;
}
/** /**
* Default HTTP client handle for the integration test harness. * Default HTTP client handle for the integration test harness.
*/ */
@ -1364,232 +1355,6 @@ export const harnessHttpLib = createPlatformHttpLib({
enableThrottling: false, enableThrottling: false,
}); });
/**
* FIXME: Move this out of the harness.
*/
export class MerchantApiClient {
/**
* Base URL for the particular instance that this merchant API client
* is for.
*/
private baseUrl: string;
readonly auth: MerchantAuthConfiguration;
constructor(baseUrl: string, auth?: MerchantAuthConfiguration) {
this.baseUrl = baseUrl;
this.auth = auth ?? {
method: "external",
};
}
httpClient = createPlatformHttpLib({
allowHttp: true,
enableThrottling: false,
});
async changeAuth(auth: MerchantAuthConfiguration): Promise<void> {
const url = new URL("private/auth", this.baseUrl);
const res = await this.httpClient.fetch(url.href, {
method: "POST",
body: auth,
headers: this.makeAuthHeader(),
});
await expectSuccessResponseOrThrow(res);
}
async deleteTippingReserve(req: DeleteTippingReserveArgs): Promise<void> {
const url = new URL(`private/reserves/${req.reservePub}`, this.baseUrl);
if (req.purge) {
url.searchParams.set("purge", "YES");
}
const resp = await this.httpClient.fetch(url.href, {
method: "DELETE",
headers: this.makeAuthHeader(),
});
logger.info(`delete status: ${resp.status}`);
return;
}
async createTippingReserve(
req: CreateMerchantTippingReserveRequest,
): Promise<MerchantReserveCreateConfirmation> {
const url = new URL("private/reserves", this.baseUrl);
const resp = await this.httpClient.fetch(url.href, {
method: "POST",
body: req,
headers: this.makeAuthHeader(),
});
const respData = readSuccessResponseJsonOrThrow(
resp,
codecForMerchantReserveCreateConfirmation(),
);
return respData;
}
async getPrivateInstanceInfo(): Promise<any> {
const url = new URL("private", this.baseUrl);
const resp = await this.httpClient.fetch(url.href, {
method: "GET",
headers: this.makeAuthHeader(),
});
return await resp.json();
}
async getPrivateTipReserves(): Promise<TippingReserveStatus> {
const url = new URL("private/reserves", this.baseUrl);
const resp = await this.httpClient.fetch(url.href, {
method: "GET",
headers: this.makeAuthHeader(),
});
// FIXME: Validate!
return await resp.json();
}
async deleteInstance(instanceId: string) {
const url = new URL(`management/instances/${instanceId}`, this.baseUrl);
const resp = await this.httpClient.fetch(url.href, {
method: "DELETE",
headers: this.makeAuthHeader(),
});
await expectSuccessResponseOrThrow(resp);
}
async createInstance(req: MerchantInstanceConfig): Promise<void> {
const url = new URL("management/instances", this.baseUrl);
await this.httpClient.fetch(url.href, {
method: "POST",
body: req,
headers: this.makeAuthHeader(),
});
}
async getInstances(): Promise<MerchantInstancesResponse> {
const url = new URL("management/instances", this.baseUrl);
const resp = await this.httpClient.fetch(url.href, {
headers: this.makeAuthHeader(),
});
return resp.json();
}
async getInstanceFullDetails(instanceId: string): Promise<any> {
const url = new URL(`management/instances/${instanceId}`, this.baseUrl);
try {
const resp = await this.httpClient.fetch(url.href, {
headers: this.makeAuthHeader(),
});
return resp.json();
} catch (e) {
throw e;
}
}
async createOrder(
req: MerchantPostOrderRequest,
): Promise<MerchantPostOrderResponse> {
let url = new URL("private/orders", this.baseUrl);
const resp = await harnessHttpLib.fetch(url.href, {
method: "POST",
body: req,
headers: this.makeAuthHeader(),
});
return readSuccessResponseJsonOrThrow(
resp,
codecForMerchantPostOrderResponse(),
);
}
async queryPrivateOrderStatus(
query: PrivateOrderStatusQuery,
): Promise<MerchantOrderPrivateStatusResponse> {
const reqUrl = new URL(`private/orders/${query.orderId}`, this.baseUrl);
if (query.sessionId) {
reqUrl.searchParams.set("session_id", query.sessionId);
}
const resp = await harnessHttpLib.fetch(reqUrl.href, {
headers: this.makeAuthHeader(),
});
return readSuccessResponseJsonOrThrow(
resp,
codecForMerchantOrderPrivateStatusResponse(),
);
}
async giveTip(req: RewardCreateRequest): Promise<RewardCreateConfirmation> {
const reqUrl = new URL(`private/tips`, this.baseUrl);
const resp = await harnessHttpLib.fetch(reqUrl.href, {
method: "POST",
body: req,
});
// FIXME: validate
return resp.json();
}
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`, this.baseUrl);
const resp = await harnessHttpLib.fetch(reqUrl.href, {
method: "POST",
body: {
refund: r.amount,
reason: r.justification,
},
});
const respBody = await resp.json();
return {
talerRefundUri: respBody.taler_refund_uri,
};
}
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(),
});
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}`,
};
}
}
}
export interface CreateMerchantTippingReserveRequest {
// Amount that the merchant promises to put into the reserve
initial_balance: AmountString;
// Exchange the merchant intends to use for tipping
exchange_url: string;
// Desired wire method, for example "iban" or "x-taler-bank"
wire_method: string;
}
export class MerchantService implements MerchantServiceInterface { export class MerchantService implements MerchantServiceInterface {
static fromExistingConfig( static fromExistingConfig(
gc: GlobalTestState, gc: GlobalTestState,
@ -1814,66 +1579,6 @@ export class MerchantService implements MerchantServiceInterface {
} }
} }
export interface MerchantAuthConfiguration {
method: "external" | "token";
token?: string;
}
// FIXME: Why do we need this? Describe / fix!
export interface PartialMerchantInstanceConfig {
auth?: MerchantAuthConfiguration;
id: string;
name: string;
paytoUris: string[];
address?: unknown;
jurisdiction?: unknown;
defaultWireTransferDelay?: TalerProtocolDuration;
defaultPayDelay?: TalerProtocolDuration;
}
// FIXME: Move all these types into merchant-api-types.ts!
type FacadeCredentials = NoFacadeCredentials | BasicAuthFacadeCredentials;
interface NoFacadeCredentials {
type: "none";
}
interface BasicAuthFacadeCredentials {
type: "basic";
// Username to use to authenticate
username: string;
// Password to use to authenticate
password: string;
}
interface MerchantBankAccount {
// The payto:// URI where the wallet will send coins.
payto_uri: string;
// Optional base URL for a facade where the
// merchant backend can see incoming wire
// transfers to reconcile its accounting
// with that of the exchange. Used by
// taler-merchant-wirewatch.
credit_facade_url?: string;
// Credentials for accessing the credit facade.
credit_facade_credentials?: FacadeCredentials;
}
export interface MerchantInstanceConfig {
accounts: MerchantBankAccount[];
auth: MerchantAuthConfiguration;
id: string;
name: string;
address: unknown;
jurisdiction: unknown;
use_stefan: boolean;
default_wire_transfer_delay: TalerProtocolDuration;
default_pay_delay: TalerProtocolDuration;
}
type TestStatus = "pass" | "fail" | "skip"; type TestStatus = "pass" | "fail" | "skip";
export interface TestRunResult { export interface TestRunResult {

View File

@ -33,6 +33,7 @@ import {
WalletNotification, WalletNotification,
TransactionMajorState, TransactionMajorState,
Logger, Logger,
MerchantApiClient,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { import {
BankAccessApi, BankAccessApi,
@ -53,7 +54,6 @@ import {
FakebankService, FakebankService,
getPayto, getPayto,
GlobalTestState, GlobalTestState,
MerchantApiClient,
MerchantService, MerchantService,
MerchantServiceInterface, MerchantServiceInterface,
setupDb, setupDb,

View File

@ -24,6 +24,7 @@ import {
decodeCrock, decodeCrock,
j2s, j2s,
Logger, Logger,
MerchantApiClient,
rsaBlind, rsaBlind,
setGlobalLogLevelFromString, setGlobalLogLevelFromString,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
@ -45,11 +46,7 @@ import { runBench2 } from "./bench2.js";
import { runBench3 } from "./bench3.js"; import { runBench3 } from "./bench3.js";
import { runEnvFull } from "./env-full.js"; import { runEnvFull } from "./env-full.js";
import { runEnv1 } from "./env1.js"; import { runEnv1 } from "./env1.js";
import { import { GlobalTestState, runTestWithState } from "./harness/harness.js";
GlobalTestState,
MerchantApiClient,
runTestWithState,
} from "./harness/harness.js";
import { getTestInfo, runTests } from "./integrationtests/testrunner.js"; import { getTestInfo, runTests } from "./integrationtests/testrunner.js";
import { lintExchangeDeployment } from "./lint.js"; import { lintExchangeDeployment } from "./lint.js";

View File

@ -1,6 +1,6 @@
/* /*
This file is part of GNU Taler This file is part of GNU Taler
(C) 2022 Taler Systems S.A. (C) 2022-2023 Taler Systems S.A.
GNU Taler is free software; you can redistribute it and/or modify it under the 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 terms of the GNU General Public License as published by the Free Software
@ -23,17 +23,14 @@ import {
WireGatewayApiClient, WireGatewayApiClient,
} from "@gnu-taler/taler-wallet-core"; } from "@gnu-taler/taler-wallet-core";
import { defaultCoinConfig } from "../harness/denomStructures.js"; import { defaultCoinConfig } from "../harness/denomStructures.js";
import { import { getWireMethodForTest, GlobalTestState } from "../harness/harness.js";
getWireMethodForTest,
GlobalTestState,
MerchantApiClient,
} from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
createWalletDaemonWithClient, createWalletDaemonWithClient,
makeTestPaymentV2, makeTestPaymentV2,
withdrawViaBankV2, withdrawViaBankV2,
} from "../harness/helpers.js"; } from "../harness/helpers.js";
import { MerchantApiClient } from "@gnu-taler/taler-util";
/** /**
* Run test for basic, bank-integrated withdrawal and payment. * Run test for basic, bank-integrated withdrawal and payment.
@ -57,9 +54,6 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
const merchantClient = new MerchantApiClient( const merchantClient = new MerchantApiClient(
merchant.makeInstanceBaseUrl("default"), merchant.makeInstanceBaseUrl("default"),
{
method: "external",
},
); );
const { walletClient: walletClientTwo } = await createWalletDaemonWithClient( const { walletClient: walletClientTwo } = await createWalletDaemonWithClient(

View File

@ -19,14 +19,12 @@
*/ */
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { URL } from "url"; import { URL } from "url";
import { import { GlobalTestState } from "../harness/harness.js";
GlobalTestState,
MerchantApiClient,
} from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,
} from "../harness/helpers.js"; } from "../harness/helpers.js";
import { MerchantApiClient } from "@gnu-taler/taler-util";
/** /**
* Run test for the merchant's order lifecycle. * Run test for the merchant's order lifecycle.

View File

@ -17,12 +17,13 @@
/** /**
* Imports. * Imports.
*/ */
import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { import {
GlobalTestState,
MerchantApiClient, MerchantApiClient,
} from "../harness/harness.js"; PreparePayResultType,
TalerErrorCode,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState } from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,

View File

@ -26,11 +26,13 @@ import {
TransactionMinorState, TransactionMinorState,
TransactionType, TransactionType,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
import { import {
BankAccessApi, BankAccessApi,
BankApi, BankApi,
WalletApiOperation, WalletApiOperation,
} from "@gnu-taler/taler-wallet-core"; } from "@gnu-taler/taler-wallet-core";
import * as http from "node:http";
import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
import { import {
BankService, BankService,
@ -43,8 +45,6 @@ import {
WalletService, WalletService,
} from "../harness/harness.js"; } from "../harness/harness.js";
import { EnvOptions, SimpleTestEnvironmentNg } from "../harness/helpers.js"; import { EnvOptions, SimpleTestEnvironmentNg } from "../harness/helpers.js";
import * as http from "node:http";
import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
const logger = new Logger("test-kyc.ts"); const logger = new Logger("test-kyc.ts");

View File

@ -20,6 +20,7 @@
import { import {
codecForMerchantOrderStatusUnpaid, codecForMerchantOrderStatusUnpaid,
ConfirmPayResultType, ConfirmPayResultType,
MerchantApiClient,
PreparePayResultType, PreparePayResultType,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
@ -35,7 +36,6 @@ import {
getPayto, getPayto,
GlobalTestState, GlobalTestState,
harnessHttpLib, harnessHttpLib,
MerchantApiClient,
MerchantService, MerchantService,
setupDb, setupDb,
} from "../harness/harness.js"; } from "../harness/harness.js";

View File

@ -17,17 +17,15 @@
/** /**
* Imports. * Imports.
*/ */
import { TalerError, URL } from "@gnu-taler/taler-util"; import { MerchantApiClient, TalerError, URL } from "@gnu-taler/taler-util";
import { import {
ExchangeService, ExchangeService,
GlobalTestState, GlobalTestState,
MerchantApiClient,
MerchantService, MerchantService,
setupDb,
getPayto, getPayto,
harnessHttpLib, harnessHttpLib,
setupDb,
} from "../harness/harness.js"; } from "../harness/harness.js";
import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
/** /**
* Test instance deletion and authentication for it * Test instance deletion and authentication for it
@ -69,7 +67,9 @@ export async function runMerchantInstancesDeleteTest(t: GlobalTestState) {
// Instances should initially be empty // Instances should initially be empty
{ {
const r = await harnessHttpLib.fetch(new URL("management/instances", baseUrl).href); const r = await harnessHttpLib.fetch(
new URL("management/instances", baseUrl).href,
);
const data = await r.json(); const data = await r.json();
t.assertDeepEqual(data.instances, []); t.assertDeepEqual(data.instances, []);
} }

View File

@ -17,17 +17,15 @@
/** /**
* Imports. * Imports.
*/ */
import { Duration } from "@gnu-taler/taler-util"; import { Duration, MerchantApiClient } from "@gnu-taler/taler-util";
import { import {
ExchangeService, ExchangeService,
GlobalTestState, GlobalTestState,
MerchantApiClient,
MerchantService, MerchantService,
setupDb,
getPayto, getPayto,
harnessHttpLib, harnessHttpLib,
setupDb,
} from "../harness/harness.js"; } from "../harness/harness.js";
import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
/** /**
* Do basic checks on instance management and authentication. * Do basic checks on instance management and authentication.

View File

@ -17,17 +17,15 @@
/** /**
* Imports. * Imports.
*/ */
import { URL } from "@gnu-taler/taler-util"; import { MerchantApiClient, URL } from "@gnu-taler/taler-util";
import { import {
ExchangeService, ExchangeService,
GlobalTestState, GlobalTestState,
MerchantApiClient,
MerchantService, MerchantService,
setupDb, setupDb,
getPayto, getPayto,
harnessHttpLib, harnessHttpLib,
} from "../harness/harness.js"; } from "../harness/harness.js";
import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
/** /**
* Do basic checks on instance management and authentication. * Do basic checks on instance management and authentication.

View File

@ -19,16 +19,13 @@
*/ */
import { import {
ConfirmPayResultType, ConfirmPayResultType,
MerchantApiClient,
PreparePayResultType, PreparePayResultType,
URL, URL,
codecForMerchantOrderStatusUnpaid, codecForMerchantOrderStatusUnpaid,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { import { GlobalTestState, harnessHttpLib } from "../harness/harness.js";
GlobalTestState,
MerchantApiClient,
harnessHttpLib,
} from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,

View File

@ -18,27 +18,27 @@
* Imports. * Imports.
*/ */
import { import {
Duration,
MerchantApiClient,
PreparePayResultType,
URL,
durationFromSpec,
} from "@gnu-taler/taler-util";
import {
BankServiceHandle,
WalletApiOperation,
} from "@gnu-taler/taler-wallet-core";
import {
ExchangeServiceInterface,
GlobalTestState, GlobalTestState,
MerchantServiceInterface, MerchantServiceInterface,
ExchangeServiceInterface,
harnessHttpLib,
WalletClient, WalletClient,
MerchantApiClient, harnessHttpLib,
} from "../harness/harness.js"; } from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,
} from "../harness/helpers.js"; } from "../harness/helpers.js";
import {
URL,
durationFromSpec,
PreparePayResultType,
Duration,
} from "@gnu-taler/taler-util";
import {
WalletApiOperation,
BankServiceHandle,
} from "@gnu-taler/taler-wallet-core";
async function testRefundApiWithFulfillmentUrl( async function testRefundApiWithFulfillmentUrl(
t: GlobalTestState, t: GlobalTestState,

View File

@ -19,6 +19,7 @@
*/ */
import { import {
ConfirmPayResultType, ConfirmPayResultType,
MerchantApiClient,
PreparePayResultType, PreparePayResultType,
URL, URL,
encodeCrock, encodeCrock,
@ -29,7 +30,6 @@ import {
BankService, BankService,
ExchangeService, ExchangeService,
GlobalTestState, GlobalTestState,
MerchantApiClient,
MerchantService, MerchantService,
harnessHttpLib, harnessHttpLib,
} from "../harness/harness.js"; } from "../harness/harness.js";

View File

@ -18,22 +18,19 @@
* Imports. * Imports.
*/ */
import { import {
GlobalTestState, ConfirmPayResultType,
MerchantApiClient, MerchantApiClient,
harnessHttpLib, PreparePayResultType,
} from "../harness/harness.js"; URL,
codecForMerchantOrderStatusUnpaid,
} 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 { import {
createFaultInjectedMerchantTestkudosEnvironment, createFaultInjectedMerchantTestkudosEnvironment,
withdrawViaBankV2, withdrawViaBankV2,
} from "../harness/helpers.js"; } from "../harness/helpers.js";
import {
PreparePayResultType,
codecForMerchantOrderStatusUnpaid,
ConfirmPayResultType,
URL,
} from "@gnu-taler/taler-util";
import { FaultInjectionRequestContext } from "../harness/faultInjection.js";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/** /**
* Run test for the wallets repurchase detection mechanism * Run test for the wallets repurchase detection mechanism

View File

@ -18,25 +18,22 @@
* Imports. * Imports.
*/ */
import { import {
GlobalTestState,
MerchantApiClient,
harnessHttpLib,
} from "../harness/harness.js";
import {
createFaultInjectedMerchantTestkudosEnvironment,
withdrawViaBankV2,
} from "../harness/helpers.js";
import { FaultInjectionRequestContext } from "../harness/faultInjection.js";
import {
codecForMerchantOrderStatusUnpaid,
ConfirmPayResultType, ConfirmPayResultType,
j2s, MerchantApiClient,
PreparePayResultType, PreparePayResultType,
TalerErrorCode, TalerErrorCode,
TalerErrorDetail, TalerErrorDetail,
URL, URL,
codecForMerchantOrderStatusUnpaid,
j2s,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; 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/helpers.js";
export async function runPaymentAbortTest(t: GlobalTestState) { export async function runPaymentAbortTest(t: GlobalTestState) {
// Set up test environment // Set up test environment

View File

@ -17,9 +17,13 @@
/** /**
* Imports. * Imports.
*/ */
import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util"; import {
MerchantApiClient,
PreparePayResultType,
TalerErrorCode,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantApiClient, WalletCli } from "../harness/harness.js"; import { GlobalTestState, WalletCli } from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,

View File

@ -17,21 +17,22 @@
/** /**
* Imports. * Imports.
*/ */
import {
AbsoluteTime,
ConfirmPayResultType,
Duration,
MerchantApiClient,
MerchantContractTerms,
PreparePayResultType,
j2s,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; import { GlobalTestState } from "../harness/harness.js";
import { import {
applyTimeTravelV2, applyTimeTravelV2,
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,
} from "../harness/helpers.js"; } from "../harness/helpers.js";
import {
AbsoluteTime,
ConfirmPayResultType,
Duration,
MerchantContractTerms,
PreparePayResultType,
j2s,
} from "@gnu-taler/taler-util";
/** /**
* Run a test for the following scenario: * Run a test for the following scenario:

View File

@ -21,28 +21,27 @@
/** /**
* Imports. * Imports.
*/ */
import { CoreApiResponse, MerchantApiClient } from "@gnu-taler/taler-util";
import { import {
GlobalTestState, BankAccessApi,
MerchantService, BankApi,
ExchangeService, WalletApiOperation,
setupDb, } from "@gnu-taler/taler-wallet-core";
BankService, import { defaultCoinConfig } from "../harness/denomStructures.js";
WalletCli,
getPayto,
MerchantApiClient,
} from "../harness/harness.js";
import { import {
FaultInjectedExchangeService, FaultInjectedExchangeService,
FaultInjectionRequestContext, FaultInjectionRequestContext,
FaultInjectionResponseContext, FaultInjectionResponseContext,
} from "../harness/faultInjection.js"; } from "../harness/faultInjection.js";
import { CoreApiResponse } from "@gnu-taler/taler-util";
import { defaultCoinConfig } from "../harness/denomStructures.js";
import { import {
WalletApiOperation, BankService,
BankApi, ExchangeService,
BankAccessApi, GlobalTestState,
} from "@gnu-taler/taler-wallet-core"; MerchantService,
WalletCli,
getPayto,
setupDb,
} from "../harness/harness.js";
/** /**
* Run test for basic, bank-integrated withdrawal. * Run test for basic, bank-integrated withdrawal.

View File

@ -17,9 +17,9 @@
/** /**
* Imports. * Imports.
*/ */
import { PreparePayResultType } from "@gnu-taler/taler-util"; import { MerchantApiClient, PreparePayResultType } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; import { GlobalTestState } from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,

View File

@ -17,17 +17,17 @@
/** /**
* Imports. * Imports.
*/ */
import { MerchantApiClient } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { coin_ct10, coin_u1 } from "../harness/denomStructures.js";
import { import {
GlobalTestState,
setupDb,
BankService, BankService,
ExchangeService, ExchangeService,
GlobalTestState,
MerchantService, MerchantService,
getPayto, getPayto,
MerchantApiClient, setupDb,
} from "../harness/harness.js"; } from "../harness/harness.js";
import { coin_ct10, coin_u1 } from "../harness/denomStructures.js";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { import {
createWalletDaemonWithClient, createWalletDaemonWithClient,
withdrawViaBankV2, withdrawViaBankV2,

View File

@ -19,10 +19,11 @@
*/ */
import { import {
ConfirmPayResultType, ConfirmPayResultType,
MerchantApiClient,
PreparePayResultType, PreparePayResultType,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; import { GlobalTestState } from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
createWalletDaemonWithClient, createWalletDaemonWithClient,

View File

@ -20,10 +20,11 @@
import { import {
ConfirmPayResultType, ConfirmPayResultType,
Duration, Duration,
MerchantApiClient,
PreparePayResultType, PreparePayResultType,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; import { GlobalTestState } from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,

View File

@ -19,6 +19,7 @@
*/ */
import { import {
ConfirmPayResultType, ConfirmPayResultType,
MerchantApiClient,
PreparePayResultType, PreparePayResultType,
TalerErrorCode, TalerErrorCode,
TalerErrorDetail, TalerErrorDetail,
@ -27,11 +28,7 @@ import {
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { FaultInjectionResponseContext } from "../harness/faultInjection.js"; import { FaultInjectionResponseContext } from "../harness/faultInjection.js";
import { import { GlobalTestState, harnessHttpLib } from "../harness/harness.js";
GlobalTestState,
MerchantApiClient,
harnessHttpLib,
} from "../harness/harness.js";
import { import {
createFaultInjectedMerchantTestkudosEnvironment, createFaultInjectedMerchantTestkudosEnvironment,
withdrawViaBankV2, withdrawViaBankV2,

View File

@ -18,17 +18,14 @@
* Imports. * Imports.
*/ */
import { import {
GlobalTestState,
MerchantApiClient,
harnessHttpLib,
} from "../harness/harness.js";
import {
PreparePayResultType,
codecForMerchantOrderStatusUnpaid,
ConfirmPayResultType, ConfirmPayResultType,
MerchantApiClient,
PreparePayResultType,
URL, URL,
codecForMerchantOrderStatusUnpaid,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, harnessHttpLib } from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,

View File

@ -17,9 +17,13 @@
/** /**
* Imports. * Imports.
*/ */
import { Duration, durationFromSpec } from "@gnu-taler/taler-util"; import {
Duration,
MerchantApiClient,
durationFromSpec,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; import { GlobalTestState } from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,

View File

@ -17,18 +17,19 @@
/** /**
* Imports. * Imports.
*/ */
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; import {
AbsoluteTime,
Duration,
MerchantApiClient,
durationFromSpec,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState } from "../harness/harness.js";
import { import {
applyTimeTravelV2, applyTimeTravelV2,
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,
} from "../harness/helpers.js"; } from "../harness/helpers.js";
import {
AbsoluteTime,
Duration,
durationFromSpec,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
/** /**
* Run test for basic, bank-integrated withdrawal. * Run test for basic, bank-integrated withdrawal.

View File

@ -20,15 +20,12 @@
import { import {
Amounts, Amounts,
Duration, Duration,
MerchantApiClient,
TransactionType, TransactionType,
durationFromSpec, durationFromSpec,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { import { GlobalTestState, delayMs } from "../harness/harness.js";
GlobalTestState,
MerchantApiClient,
delayMs,
} from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,

View File

@ -20,11 +20,12 @@
import { import {
Duration, Duration,
durationFromSpec, durationFromSpec,
MerchantApiClient,
NotificationType, NotificationType,
TransactionMajorState, TransactionMajorState,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; import { GlobalTestState } from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,

View File

@ -21,6 +21,7 @@ import {
ConfirmPayResultType, ConfirmPayResultType,
Duration, Duration,
durationFromSpec, durationFromSpec,
MerchantApiClient,
PreparePayResultType, PreparePayResultType,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { import {
@ -31,11 +32,10 @@ import { makeNoFeeCoinConfig } from "../harness/denomStructures.js";
import { import {
BankService, BankService,
ExchangeService, ExchangeService,
getPayto,
GlobalTestState, GlobalTestState,
MerchantService, MerchantService,
setupDb, setupDb,
getPayto,
MerchantApiClient,
} from "../harness/harness.js"; } from "../harness/harness.js";
import { import {
applyTimeTravelV2, applyTimeTravelV2,

View File

@ -17,18 +17,17 @@
/** /**
* Imports. * Imports.
*/ */
import {
MerchantApiClient,
TransactionMajorState,
} from "@gnu-taler/taler-util";
import { import {
BankAccessApiClient, BankAccessApiClient,
WalletApiOperation, WalletApiOperation,
WireGatewayApiClient, WireGatewayApiClient,
} from "@gnu-taler/taler-wallet-core"; } from "@gnu-taler/taler-wallet-core";
import { import { GlobalTestState, getWireMethodForTest } from "../harness/harness.js";
GlobalTestState,
MerchantApiClient,
getWireMethodForTest,
} from "../harness/harness.js";
import { createSimpleTestkudosEnvironmentV2 } from "../harness/helpers.js"; import { createSimpleTestkudosEnvironmentV2 } from "../harness/helpers.js";
import { TransactionMajorState } from "@gnu-taler/taler-util";
/** /**
* Run test for basic, bank-integrated withdrawal. * Run test for basic, bank-integrated withdrawal.

View File

@ -17,9 +17,9 @@
/** /**
* Imports. * Imports.
*/ */
import { PreparePayResultType } from "@gnu-taler/taler-util"; import { MerchantApiClient, PreparePayResultType } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; import { GlobalTestState } from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
createWalletDaemonWithClient, createWalletDaemonWithClient,
@ -126,11 +126,9 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
}, },
}); });
let orderStatus = await merchantClient.queryPrivateOrderStatus( let orderStatus = await merchantClient.queryPrivateOrderStatus({
{
orderId: orderResp.order_id, orderId: orderResp.order_id,
}, });
);
t.assertTrue(orderStatus.order_status === "unpaid"); t.assertTrue(orderStatus.order_status === "unpaid");

View File

@ -17,9 +17,13 @@
/** /**
* Imports. * Imports.
*/ */
import { Amounts, PreparePayResultType } from "@gnu-taler/taler-util"; import {
Amounts,
MerchantApiClient,
PreparePayResultType,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; import { GlobalTestState } from "../harness/harness.js";
import { import {
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,

View File

@ -39,3 +39,5 @@ export * from "./merchant-api-types.js";
export * from "./errors.js"; export * from "./errors.js";
export * from "./iban.js"; export * from "./iban.js";
export * from "./transaction-test-data.js"; export * from "./transaction-test-data.js";
export * from "./libeufin-api-types.js";
export * from "./MerchantApiClient.js";

View File

@ -47,7 +47,7 @@ import {
WireAccount, WireAccount,
codecForWireAccount, codecForWireAccount,
codecForList, codecForList,
HashCodeString, FacadeCredentials,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
export interface MerchantPostOrderRequest { export interface MerchantPostOrderRequest {
@ -401,21 +401,3 @@ export interface AccountAddDetails {
// To really delete credentials, set them to the type: "none". // To really delete credentials, set them to the type: "none".
credit_facade_credentials?: FacadeCredentials; credit_facade_credentials?: FacadeCredentials;
} }
export type FacadeCredentials =
| NoFacadeCredentials
| BasicAuthFacadeCredentials;
export interface NoFacadeCredentials {
type: "none";
}
export interface BasicAuthFacadeCredentials {
type: "basic";
// Username to use to authenticate
username: string;
// Password to use to authenticate
password: string;
}