diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-08-19 20:56:10 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-08-19 20:56:40 +0530 |
commit | d9b73a30c1ce67f611f9d605bdf163c3e868f2c2 (patch) | |
tree | ffdbf9d5e1556df5d1a57a8870fa8057c7ba4ef5 | |
parent | 082498b20d2a73009bb4193cd95ab409159fb972 (diff) |
test case for /paid API, implement fault-injected merchant
14 files changed, 423 insertions, 91 deletions
diff --git a/packages/taler-integrationtests/src/faultInjection.ts b/packages/taler-integrationtests/src/faultInjection.ts index 46ab1c5fe..a85b1dd7d 100644 --- a/packages/taler-integrationtests/src/faultInjection.ts +++ b/packages/taler-integrationtests/src/faultInjection.ts @@ -30,7 +30,15 @@ import { ExchangeService, BankService, ExchangeServiceInterface, + MerchantServiceInterface, + MerchantService, + PrivateOrderStatusQuery, } from "./harness"; +import { + PostOrderRequest, + PostOrderResponse, + MerchantOrderPrivateStatusResponse, +} from "./merchantApiTypes"; export interface FaultProxyConfig { inboundPort: number; @@ -220,3 +228,36 @@ export class FaultInjectedExchangeService implements ExchangeServiceInterface { this.port = proxyInboundPort; } } + +export class FaultInjectedMerchantService implements MerchantServiceInterface { + baseUrl: string; + port: number; + faultProxy: FaultProxy; + + get name(): string { + return this.innerMerchant.name; + } + + private innerMerchant: MerchantService; + private inboundPort: number; + + constructor( + t: GlobalTestState, + m: MerchantService, + proxyInboundPort: number, + ) { + this.innerMerchant = m; + this.faultProxy = new FaultProxy(t, { + inboundPort: proxyInboundPort, + targetPort: m.port, + }); + this.faultProxy.start(); + this.inboundPort = proxyInboundPort; + } + + makeInstanceBaseUrl(instanceName?: string | undefined): string { + const url = new URL(this.innerMerchant.makeInstanceBaseUrl(instanceName)); + url.port = `${this.inboundPort}`; + return url.href; + } +} diff --git a/packages/taler-integrationtests/src/harness.ts b/packages/taler-integrationtests/src/harness.ts index df2d9f2e7..77914af66 100644 --- a/packages/taler-integrationtests/src/harness.ts +++ b/packages/taler-integrationtests/src/harness.ts @@ -909,7 +909,62 @@ export interface PrivateOrderStatusQuery { sessionId?: string; } -export class MerchantService { +export interface MerchantServiceInterface { + makeInstanceBaseUrl(instanceName?: string): string; + readonly port: number; + readonly name: string; +} + +export namespace MerchantPrivateApi { + export async function createOrder( + merchantService: MerchantServiceInterface, + instanceName: string, + req: PostOrderRequest, + ): Promise<PostOrderResponse> { + const baseUrl = merchantService.makeInstanceBaseUrl(instanceName); + let url = new URL("private/orders", baseUrl); + const resp = await axios.post(url.href, req); + return codecForPostOrderResponse().decode(resp.data); + } + + export async function queryPrivateOrderStatus( + merchantService: MerchantServiceInterface, + query: PrivateOrderStatusQuery, + ): Promise<MerchantOrderPrivateStatusResponse> { + const reqUrl = new URL( + `private/orders/${query.orderId}`, + merchantService.makeInstanceBaseUrl(query.instance), + ); + if (query.sessionId) { + reqUrl.searchParams.set("session_id", query.sessionId); + } + const resp = await axios.get(reqUrl.href); + return codecForMerchantOrderPrivateStatusResponse().decode(resp.data); + } + + export async function giveRefund( + merchantService: MerchantServiceInterface, + 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), + ); + const resp = await axios.post(reqUrl.href, { + refund: r.amount, + reason: r.justification, + }); + return { + talerRefundUri: resp.data.taler_refund_uri, + }; + } +} + +export class MerchantService implements MerchantServiceInterface { static fromExistingConfig(gc: GlobalTestState, name: string) { const cfgFilename = gc.testDir + `/merchant-${name}.conf`; const config = Configuration.load(cfgFilename); @@ -930,6 +985,14 @@ export class MerchantService { private configFilename: string, ) {} + get port(): number { + return this.merchantConfig.httpPort; + } + + get name(): string { + return this.merchantConfig.name; + } + async start(): Promise<void> { await exec(`taler-merchant-dbinit -c "${this.configFilename}"`); @@ -1005,20 +1068,6 @@ export class MerchantService { }); } - async queryPrivateOrderStatus( - query: PrivateOrderStatusQuery, - ): Promise<MerchantOrderPrivateStatusResponse> { - const reqUrl = new URL( - `private/orders/${query.orderId}`, - this.makeInstanceBaseUrl(query.instance), - ); - if (query.sessionId) { - reqUrl.searchParams.set("session_id", query.sessionId); - } - const resp = await axios.get(reqUrl.href); - return codecForMerchantOrderPrivateStatusResponse().decode(resp.data); - } - makeInstanceBaseUrl(instanceName?: string): string { if (instanceName === undefined || instanceName === "default") { return `http://localhost:${this.merchantConfig.httpPort}/`; @@ -1027,39 +1076,6 @@ export class MerchantService { } } - async giveRefund(r: { - instance: string; - orderId: string; - amount: string; - justification: string; - }): Promise<{ talerRefundUri: string }> { - const reqUrl = new URL( - `private/orders/${r.orderId}/refund`, - this.makeInstanceBaseUrl(r.instance), - ); - const resp = await axios.post(reqUrl.href, { - refund: r.amount, - reason: r.justification, - }); - return { - talerRefundUri: resp.data.taler_refund_uri, - }; - } - - async createOrder( - instanceName: string, - req: PostOrderRequest, - ): Promise<PostOrderResponse> { - let url; - if (instanceName === "default") { - url = `http://localhost:${this.merchantConfig.httpPort}/private/orders`; - } else { - url = `http://localhost:${this.merchantConfig.httpPort}/instances/${instanceName}/private/orders`; - } - const resp = await axios.post(url, req); - return codecForPostOrderResponse().decode(resp.data); - } - async pingUntilAvailable(): Promise<void> { const url = `http://localhost:${this.merchantConfig.httpPort}/config`; await pingProc(this.proc, url, `merchant (${this.merchantConfig.name})`); diff --git a/packages/taler-integrationtests/src/helpers.ts b/packages/taler-integrationtests/src/helpers.ts index b37b6b96c..86f530e09 100644 --- a/packages/taler-integrationtests/src/helpers.ts +++ b/packages/taler-integrationtests/src/helpers.ts @@ -33,8 +33,10 @@ import { BankService, defaultCoinConfig, ExchangeBankAccount, + MerchantServiceInterface, } from "./harness"; import { AmountString } from "taler-wallet-core/lib/types/talerTypes"; +import { FaultInjectedMerchantService } from "./faultInjection"; export interface SimpleTestEnvironment { commonDb: DbInfo; @@ -123,6 +125,97 @@ export async function createSimpleTestkudosEnvironment( }; } +export interface FaultyMerchantTestEnvironment { + commonDb: DbInfo; + bank: BankService; + exchange: ExchangeService; + exchangeBankAccount: ExchangeBankAccount; + merchant: MerchantService; + faultyMerchant: FaultInjectedMerchantService; + wallet: WalletCli; +} + +/** + * Run a test case with a simple TESTKUDOS Taler environment, consisting + * of one exchange, one bank and one merchant. + */ +export async function createFaultInjectedMerchantTestkudosEnvironment( + t: GlobalTestState, +): Promise<FaultyMerchantTestEnvironment> { + const db = await setupDb(t); + + const bank = await BankService.create(t, { + allowRegistrations: true, + currency: "TESTKUDOS", + database: db.connStr, + httpPort: 8082, + }); + + const exchange = ExchangeService.create(t, { + name: "testexchange-1", + currency: "TESTKUDOS", + httpPort: 8081, + database: db.connStr, + }); + + const merchant = await MerchantService.create(t, { + name: "testmerchant-1", + currency: "TESTKUDOS", + httpPort: 8083, + database: db.connStr, + }); + + const faultyMerchant = new FaultInjectedMerchantService(t, merchant, 9083); + + const exchangeBankAccount = await bank.createExchangeAccount( + "MyExchange", + "x", + ); + exchange.addBankAccount("1", exchangeBankAccount); + + bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri); + + await bank.start(); + + await bank.pingUntilAvailable(); + + exchange.addOfferedCoins(defaultCoinConfig); + + await exchange.start(); + await exchange.pingUntilAvailable(); + + merchant.addExchange(exchange); + + await merchant.start(); + await merchant.pingUntilAvailable(); + + await merchant.addInstance({ + id: "minst1", + name: "minst1", + paytoUris: ["payto://x-taler-bank/minst1"], + }); + + await merchant.addInstance({ + id: "default", + name: "Default Instance", + paytoUris: [`payto://x-taler-bank/merchant-default`], + }); + + console.log("setup done!"); + + const wallet = new WalletCli(t); + + return { + commonDb: db, + exchange, + merchant, + wallet, + bank, + exchangeBankAccount, + faultyMerchant, + }; +} + /** * Withdraw balance. */ diff --git a/packages/taler-integrationtests/src/scenario-prompt-payment.ts b/packages/taler-integrationtests/src/scenario-prompt-payment.ts index 3e4bfc6c2..3c34075d1 100644 --- a/packages/taler-integrationtests/src/scenario-prompt-payment.ts +++ b/packages/taler-integrationtests/src/scenario-prompt-payment.ts @@ -17,7 +17,7 @@ /** * Imports. */ -import { runTest, GlobalTestState } from "./harness"; +import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; /** @@ -39,7 +39,7 @@ runTest(async (t: GlobalTestState) => { // Set up order. - const orderResp = await merchant.createOrder("default", { + const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", amount: "TESTKUDOS:5", @@ -47,7 +47,7 @@ runTest(async (t: GlobalTestState) => { }, }); - let orderStatus = await merchant.queryPrivateOrderStatus({ + let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); diff --git a/packages/taler-integrationtests/src/scenario-rerun-payment-multiple.ts b/packages/taler-integrationtests/src/scenario-rerun-payment-multiple.ts index 525ba9a25..3a98987b3 100644 --- a/packages/taler-integrationtests/src/scenario-rerun-payment-multiple.ts +++ b/packages/taler-integrationtests/src/scenario-rerun-payment-multiple.ts @@ -24,6 +24,7 @@ import { MerchantService, WalletCli, runTestWithState, + MerchantPrivateApi, } from "./harness"; import { withdrawViaBank } from "./helpers"; import fs from "fs"; @@ -52,7 +53,7 @@ async function withdrawAndPay( // Set up order. - const orderResp = await merchant.createOrder("default", { + const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", amount: "TESTKUDOS:80", @@ -60,7 +61,7 @@ async function withdrawAndPay( }, }); - let orderStatus = await merchant.queryPrivateOrderStatus({ + let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); @@ -81,7 +82,7 @@ async function withdrawAndPay( // Check if payment was successful. - orderStatus = await merchant.queryPrivateOrderStatus({ + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); diff --git a/packages/taler-integrationtests/src/test-merchant-longpolling.ts b/packages/taler-integrationtests/src/test-merchant-longpolling.ts index 664926c09..1470cadfe 100644 --- a/packages/taler-integrationtests/src/test-merchant-longpolling.ts +++ b/packages/taler-integrationtests/src/test-merchant-longpolling.ts @@ -17,7 +17,7 @@ /** * Imports. */ -import { runTest, GlobalTestState } from "./harness"; +import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; import { PreparePayResultType, @@ -53,7 +53,7 @@ runTest(async (t: GlobalTestState) => { * ========================================================================= */ - let orderResp = await merchant.createOrder("default", { + let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", amount: "TESTKUDOS:5", @@ -63,7 +63,7 @@ runTest(async (t: GlobalTestState) => { const firstOrderId = orderResp.order_id; - let orderStatus = await merchant.queryPrivateOrderStatus({ + let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, sessionId: "mysession-one", }); diff --git a/packages/taler-integrationtests/src/test-pay-paid.ts b/packages/taler-integrationtests/src/test-pay-paid.ts new file mode 100644 index 000000000..eb58fce30 --- /dev/null +++ b/packages/taler-integrationtests/src/test-pay-paid.ts @@ -0,0 +1,179 @@ +/* + This file is part of GNU Taler + (C) 2020 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +/** + * Imports. + */ +import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness"; +import { createSimpleTestkudosEnvironment, withdrawViaBank, createFaultInjectedMerchantTestkudosEnvironment } from "./helpers"; +import { + PreparePayResultType, + codecForMerchantOrderStatusUnpaid, + ConfirmPayResultType, + URL, +} from "taler-wallet-core"; +import axios from "axios"; +import { FaultInjectionRequestContext } from "./faultInjection"; + +/** + * Run test for basic, bank-integrated withdrawal. + */ +runTest(async (t: GlobalTestState) => { + // Set up test environment + + const { + wallet, + bank, + exchange, + faultyMerchant, + } = await createFaultInjectedMerchantTestkudosEnvironment(t); + + // Withdraw digital cash into the wallet. + + await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" }); + + /** + * ========================================================================= + * Create an order and let the wallet pay under a session ID + * + * We check along the way that the JSON response to /orders/{order_id} + * returns the right thing. + * ========================================================================= + */ + + const merchant = faultyMerchant; + + let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { + order: { + summary: "Buy me!", + amount: "TESTKUDOS:5", + fulfillment_url: "https://example.com/article42", + }, + }); + + + let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { + orderId: orderResp.order_id, + sessionId: "mysession-one", + }); + + t.assertTrue(orderStatus.order_status === "unpaid"); + + t.assertTrue(orderStatus.already_paid_order_id === undefined); + let publicOrderStatusUrl = orderStatus.order_status_url; + + let publicOrderStatusResp = await axios.get(publicOrderStatusUrl, { + validateStatus: () => true, + }); + + if (publicOrderStatusResp.status != 402) { + throw Error( + `expected status 402 (before claiming), but got ${publicOrderStatusResp.status}`, + ); + } + + let pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode( + publicOrderStatusResp.data, + ); + + console.log(pubUnpaidStatus); + + let preparePayResp = await wallet.preparePay({ + talerPayUri: pubUnpaidStatus.taler_pay_uri, + }); + + t.assertTrue(preparePayResp.status === PreparePayResultType.PaymentPossible); + + const proposalId = preparePayResp.proposalId; + + publicOrderStatusResp = await axios.get(publicOrderStatusUrl, { + validateStatus: () => true, + }); + + if (publicOrderStatusResp.status != 402) { + throw Error( + `expected status 402 (after claiming), but got ${publicOrderStatusResp.status}`, + ); + } + + pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode( + publicOrderStatusResp.data, + ); + + const confirmPayRes = await wallet.confirmPay({ + proposalId: proposalId, + }); + + t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done); + + publicOrderStatusResp = await axios.get(publicOrderStatusUrl, { + validateStatus: () => true, + }); + + console.log(publicOrderStatusResp.data); + + if (publicOrderStatusResp.status != 202) { + console.log(publicOrderStatusResp.data); + throw Error( + `expected status 202 (after paying), but got ${publicOrderStatusResp.status}`, + ); + } + + /** + * ========================================================================= + * Now change up the session ID and do payment re-play! + * ========================================================================= + */ + + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { + orderId: orderResp.order_id, + sessionId: "mysession-two", + }); + + // Should be unpaid because of a new session ID + t.assertTrue(orderStatus.order_status === "unpaid"); + + publicOrderStatusUrl = orderStatus.order_status_url; + + let numPayRequested = 0; + let numPaidRequested = 0; + + faultyMerchant.faultProxy.addFault({ + modifyRequest(ctx: FaultInjectionRequestContext) { + const url = new URL(ctx.requestUrl); + if (url.pathname.endsWith("/pay")) { + numPayRequested++; + } else if (url.pathname.endsWith("/paid")) { + numPaidRequested++; + } + } + }); + + // Pay with new taler://pay URI, which should + // have the new session ID! + // Wallet should now automatically re-play payment. + preparePayResp = await wallet.preparePay({ + talerPayUri: orderStatus.taler_pay_uri, + }); + + t.assertTrue(preparePayResp.status === PreparePayResultType.AlreadyConfirmed); + t.assertTrue(preparePayResp.paid); + + // Make sure the wallet is actually doing the replay properly. + t.assertTrue(numPaidRequested == 1); + t.assertTrue(numPayRequested == 0); + +}); diff --git a/packages/taler-integrationtests/src/test-payment-fault.ts b/packages/taler-integrationtests/src/test-payment-fault.ts index 4babdc500..8065b430c 100644 --- a/packages/taler-integrationtests/src/test-payment-fault.ts +++ b/packages/taler-integrationtests/src/test-payment-fault.ts @@ -30,6 +30,7 @@ import { BankService, WalletCli, defaultCoinConfig, + MerchantPrivateApi, } from "./harness"; import { FaultInjectedExchangeService, @@ -145,7 +146,7 @@ runTest(async (t: GlobalTestState) => { // Set up order. - const orderResp = await merchant.createOrder("default", { + const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", amount: "TESTKUDOS:5", @@ -153,7 +154,7 @@ runTest(async (t: GlobalTestState) => { }, }); - let orderStatus = await merchant.queryPrivateOrderStatus({ + let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); @@ -195,7 +196,7 @@ runTest(async (t: GlobalTestState) => { // Check if payment was successful. - orderStatus = await merchant.queryPrivateOrderStatus({ + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); diff --git a/packages/taler-integrationtests/src/test-payment-idempotency.ts b/packages/taler-integrationtests/src/test-payment-idempotency.ts index bc641a356..6c75de6b1 100644 --- a/packages/taler-integrationtests/src/test-payment-idempotency.ts +++ b/packages/taler-integrationtests/src/test-payment-idempotency.ts @@ -17,7 +17,7 @@ /** * Imports. */ -import { runTest, GlobalTestState } from "./harness"; +import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; import { PreparePayResultType } from "taler-wallet-core"; @@ -41,7 +41,7 @@ runTest(async (t: GlobalTestState) => { // Set up order. - const orderResp = await merchant.createOrder("default", { + const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", amount: "TESTKUDOS:5", @@ -49,7 +49,7 @@ runTest(async (t: GlobalTestState) => { }, }); - let orderStatus = await merchant.queryPrivateOrderStatus({ + let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); @@ -84,7 +84,7 @@ runTest(async (t: GlobalTestState) => { // Check if payment was successful. - orderStatus = await merchant.queryPrivateOrderStatus({ + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); diff --git a/packages/taler-integrationtests/src/test-payment-multiple.ts b/packages/taler-integrationtests/src/test-payment-multiple.ts index 00b3c0b69..8be8a90f5 100644 --- a/packages/taler-integrationtests/src/test-payment-multiple.ts +++ b/packages/taler-integrationtests/src/test-payment-multiple.ts @@ -27,6 +27,7 @@ import { WalletCli, coin_ct10, coin_u1, + MerchantPrivateApi, } from "./harness"; import { withdrawViaBank } from "./helpers"; @@ -122,7 +123,7 @@ runTest(async (t: GlobalTestState) => { // Set up order. - const orderResp = await merchant.createOrder("default", { + const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", amount: "TESTKUDOS:80", @@ -130,7 +131,7 @@ runTest(async (t: GlobalTestState) => { }, }); - let orderStatus = await merchant.queryPrivateOrderStatus({ + let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); @@ -151,7 +152,7 @@ runTest(async (t: GlobalTestState) => { // Check if payment was successful. - orderStatus = await merchant.queryPrivateOrderStatus({ + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); diff --git a/packages/taler-integrationtests/src/test-payment.ts b/packages/taler-integrationtests/src/test-payment.ts index 12b4267b7..d2cbb10f4 100644 --- a/packages/taler-integrationtests/src/test-payment.ts +++ b/packages/taler-integrationtests/src/test-payment.ts @@ -17,7 +17,7 @@ /** * Imports. */ -import { runTest, GlobalTestState } from "./harness"; +import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; import { PreparePayResultType } from "taler-wallet-core"; @@ -40,7 +40,7 @@ runTest(async (t: GlobalTestState) => { // Set up order. - const orderResp = await merchant.createOrder("default", { + const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", amount: "TESTKUDOS:5", @@ -48,7 +48,7 @@ runTest(async (t: GlobalTestState) => { }, }); - let orderStatus = await merchant.queryPrivateOrderStatus({ + let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); @@ -70,7 +70,7 @@ runTest(async (t: GlobalTestState) => { // Check if payment was successful. - orderStatus = await merchant.queryPrivateOrderStatus({ + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); diff --git a/packages/taler-integrationtests/src/test-paywall-flow.ts b/packages/taler-integrationtests/src/test-paywall-flow.ts index 74be96c8e..c4c5784ed 100644 --- a/packages/taler-integrationtests/src/test-paywall-flow.ts +++ b/packages/taler-integrationtests/src/test-paywall-flow.ts @@ -17,7 +17,7 @@ /** * Imports. */ -import { runTest, GlobalTestState } from "./harness"; +import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; import { PreparePayResultType, @@ -52,7 +52,7 @@ runTest(async (t: GlobalTestState) => { * ========================================================================= */ - let orderResp = await merchant.createOrder("default", { + let orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", amount: "TESTKUDOS:5", @@ -62,7 +62,7 @@ runTest(async (t: GlobalTestState) => { const firstOrderId = orderResp.order_id; - let orderStatus = await merchant.queryPrivateOrderStatus({ + let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, sessionId: "mysession-one", }); @@ -135,7 +135,7 @@ runTest(async (t: GlobalTestState) => { * ========================================================================= */ - orderStatus = await merchant.queryPrivateOrderStatus({ + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, sessionId: "mysession-two", }); @@ -161,7 +161,7 @@ runTest(async (t: GlobalTestState) => { * ========================================================================= */ - orderResp = await merchant.createOrder("default", { + orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", amount: "TESTKUDOS:5", @@ -172,7 +172,7 @@ runTest(async (t: GlobalTestState) => { const secondOrderId = orderResp.order_id; - orderStatus = await merchant.queryPrivateOrderStatus({ + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: secondOrderId, sessionId: "mysession-three", }); @@ -194,7 +194,7 @@ runTest(async (t: GlobalTestState) => { // The first order should now be paid under "mysession-three", // as the wallet did re-purchase detection - orderStatus = await merchant.queryPrivateOrderStatus({ + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: firstOrderId, sessionId: "mysession-three", }); @@ -203,7 +203,7 @@ runTest(async (t: GlobalTestState) => { // Check that with a completely new session ID, the status would NOT // be paid. - orderStatus = await merchant.queryPrivateOrderStatus({ + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: firstOrderId, sessionId: "mysession-four", }); diff --git a/packages/taler-integrationtests/src/test-refund-incremental.ts b/packages/taler-integrationtests/src/test-refund-incremental.ts index 59a36b942..c3d2b7834 100644 --- a/packages/taler-integrationtests/src/test-refund-incremental.ts +++ b/packages/taler-integrationtests/src/test-refund-incremental.ts @@ -17,7 +17,7 @@ /** * Imports. */ -import { runTest, GlobalTestState, delayMs } from "./harness"; +import { runTest, GlobalTestState, delayMs, MerchantPrivateApi } from "./harness"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; /** @@ -39,7 +39,7 @@ runTest(async (t: GlobalTestState) => { // Set up order. - const orderResp = await merchant.createOrder("default", { + const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", amount: "TESTKUDOS:5", @@ -47,7 +47,7 @@ runTest(async (t: GlobalTestState) => { }, }); - let orderStatus = await merchant.queryPrivateOrderStatus({ + let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); @@ -68,13 +68,13 @@ runTest(async (t: GlobalTestState) => { // Check if payment was successful. - orderStatus = await merchant.queryPrivateOrderStatus({ + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); t.assertTrue(orderStatus.order_status === "paid"); - let ref = await merchant.giveRefund({ + let ref = await MerchantPrivateApi.giveRefund(merchant, { amount: "TESTKUDOS:2.5", instance: "default", justification: "foo", @@ -87,7 +87,7 @@ runTest(async (t: GlobalTestState) => { // refund will be grouped with the previous one. await delayMs(1.2); - ref = await merchant.giveRefund({ + ref = await MerchantPrivateApi.giveRefund(merchant, { amount: "TESTKUDOS:5", instance: "default", justification: "bar", @@ -101,7 +101,7 @@ runTest(async (t: GlobalTestState) => { }); console.log(r); - orderStatus = await merchant.queryPrivateOrderStatus({ + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); diff --git a/packages/taler-integrationtests/src/test-refund.ts b/packages/taler-integrationtests/src/test-refund.ts index d0d0a0a05..f88a399b5 100644 --- a/packages/taler-integrationtests/src/test-refund.ts +++ b/packages/taler-integrationtests/src/test-refund.ts @@ -17,7 +17,7 @@ /** * Imports. */ -import { runTest, GlobalTestState } from "./harness"; +import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; /** @@ -39,7 +39,7 @@ runTest(async (t: GlobalTestState) => { // Set up order. - const orderResp = await merchant.createOrder("default", { + const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", amount: "TESTKUDOS:5", @@ -47,7 +47,7 @@ runTest(async (t: GlobalTestState) => { }, }); - let orderStatus = await merchant.queryPrivateOrderStatus({ + let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); @@ -68,13 +68,13 @@ runTest(async (t: GlobalTestState) => { // Check if payment was successful. - orderStatus = await merchant.queryPrivateOrderStatus({ + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { orderId: orderResp.order_id, }); t.assertTrue(orderStatus.order_status === "paid"); - const ref = await merchant.giveRefund({ + const ref = await MerchantPrivateApi.giveRefund(merchant, { amount: "TESTKUDOS:5", instance: "default", justification: "foo", |