diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-10-01 20:45:36 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-10-01 20:46:22 +0200 |
commit | 1a23fbcb4fdad661feb9ea923761f7e02d7f6e8d (patch) | |
tree | b34c72c43f69cd755b1aa5acff8a52345628bd3e /src | |
parent | 831d27c4df6412a6e1920341cbe6770a994a5804 (diff) |
adapt to instance changes
Diffstat (limited to 'src')
-rw-r--r-- | src/headless/integrationtest.ts | 2 | ||||
-rw-r--r-- | src/headless/merchant.ts | 4 | ||||
-rw-r--r-- | src/headless/taler-wallet-cli.ts | 11 | ||||
-rw-r--r-- | src/taleruri-test.ts | 31 | ||||
-rw-r--r-- | src/taleruri.ts | 15 | ||||
-rw-r--r-- | src/wallet.ts | 5 |
6 files changed, 39 insertions, 29 deletions
diff --git a/src/headless/integrationtest.ts b/src/headless/integrationtest.ts index a692cabd0..6b3286904 100644 --- a/src/headless/integrationtest.ts +++ b/src/headless/integrationtest.ts @@ -28,7 +28,6 @@ export async function runIntegrationTest(args: { bankBaseUrl: string; merchantBaseUrl: string; merchantApiKey: string; - merchantInstance: string; amountToWithdraw: string; amountToSpend: string; }) { @@ -42,7 +41,6 @@ export async function runIntegrationTest(args: { const myMerchant = new MerchantBackendConnection( args.merchantBaseUrl, - args.merchantInstance, args.merchantApiKey, ); diff --git a/src/headless/merchant.ts b/src/headless/merchant.ts index 4861a7d2a..889eb2d6a 100644 --- a/src/headless/merchant.ts +++ b/src/headless/merchant.ts @@ -32,7 +32,6 @@ import URI = require("urijs"); export class MerchantBackendConnection { constructor( public merchantBaseUrl: string, - public merchantInstance: string, public apiKey: string, ) {} @@ -47,7 +46,6 @@ export class MerchantBackendConnection { amount, summary, fulfillment_url: fulfillmentUrl, - instance: this.merchantInstance, }, }; const resp = await axios({ @@ -76,7 +74,7 @@ export class MerchantBackendConnection { const resp = await axios({ method: "get", url: reqUrl, - params: { order_id: orderId, instance: this.merchantInstance }, + params: { order_id: orderId }, responseType: "json", headers: { Authorization: `ApiKey ${this.apiKey}`, diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts index 7d4acb2f8..8c31e67d8 100644 --- a/src/headless/taler-wallet-cli.ts +++ b/src/headless/taler-wallet-cli.ts @@ -114,8 +114,7 @@ program applyVerbose(program.verbose); console.log("creating order"); const merchantBackend = new MerchantBackendConnection( - "https://backend.test.taler.net", - "default", + "https://backend.test.taler.net/", "sandbox", ); const orderResp = await merchantBackend.createOrder( @@ -289,12 +288,7 @@ program "https://backend.test.taler.net/", ) .option( - "-m, --merchant-instance <merchant-instance>", - "merchant instance", - "default", - ) - .option( - "-m, --merchant-api-key <merchant-api-key>", + "-k, --merchant-api-key <merchant-api-key>", "merchant API key", "sandbox", ) @@ -321,7 +315,6 @@ program exchangeBaseUrl: cmdObj.exchange, merchantApiKey: cmdObj.merchantApiKey, merchantBaseUrl: cmdObj.merchant, - merchantInstance: cmdObj.merchantInstance, }).catch(err => { console.error("Failed with exception:"); console.error(err); diff --git a/src/taleruri-test.ts b/src/taleruri-test.ts index 27cd7d18b..8b5828b7f 100644 --- a/src/taleruri-test.ts +++ b/src/taleruri-test.ts @@ -53,7 +53,7 @@ test("taler pay url parsing: defaults", (t) => { t.fail(); return; } - t.is(r1.downloadUrl, "https://example.com/public/proposal?instance=default&order_id=myorder"); + t.is(r1.downloadUrl, "https://example.com/public/proposal?order_id=myorder"); t.is(r1.sessionId, undefined); const url2 = "taler://pay/example.com/-/-/myorder/mysession"; @@ -62,7 +62,7 @@ test("taler pay url parsing: defaults", (t) => { t.fail(); return; } - t.is(r2.downloadUrl, "https://example.com/public/proposal?instance=default&order_id=myorder"); + t.is(r2.downloadUrl, "https://example.com/public/proposal?order_id=myorder"); t.is(r2.sessionId, "mysession"); }); @@ -74,10 +74,33 @@ test("taler pay url parsing: trailing parts", (t) => { t.fail(); return; } - t.is(r1.downloadUrl, "https://example.com/public/proposal?instance=default&order_id=myorder"); + t.is(r1.downloadUrl, "https://example.com/public/proposal?order_id=myorder"); t.is(r1.sessionId, "mysession"); }); + +test("taler pay url parsing: instance", (t) => { + const url1 = "taler://pay/example.com/-/myinst/myorder"; + const r1 = parsePayUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.downloadUrl, "https://example.com/instances/myinst/public/proposal?order_id=myorder"); +}); + + +test("taler pay url parsing: path prefix and instance", (t) => { + const url1 = "taler://pay/example.com/mypfx/myinst/myorder"; + const r1 = parsePayUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.downloadUrl, "https://example.com/mypfx/instances/myinst/public/proposal?order_id=myorder"); +}); + + test("taler withdraw uri parsing", (t) => { const url1 = "taler://withdraw/bank.example.com/-/12345"; const r1 = parseWithdrawUri(url1); @@ -86,4 +109,4 @@ test("taler withdraw uri parsing", (t) => { return; } t.is(r1.statusUrl, "https://bank.example.com/api/withdraw-operation/12345"); -});
\ No newline at end of file +}); diff --git a/src/taleruri.ts b/src/taleruri.ts index bd01abb65..0d68621b9 100644 --- a/src/taleruri.ts +++ b/src/taleruri.ts @@ -96,18 +96,19 @@ export function parsePayUri(s: string): PayUriResult | undefined { } if (maybePath === "-") { - maybePath = "public/proposal"; + maybePath = ""; } else { - maybePath = decodeURIComponent(maybePath); + maybePath = decodeURIComponent(maybePath) + "/"; } - if (maybeInstance === "-") { - maybeInstance = "default"; + let maybeInstancePath = ""; + if (maybeInstance !== "-") { + maybeInstancePath = `instances/${maybeInstance}/`; } const downloadUrl = new URI( - "https://" + host + "/" + decodeURIComponent(maybePath), + "https://" + host + "/" + decodeURIComponent(maybePath) + maybeInstancePath + "public/proposal", ) - .addQuery({ instance: maybeInstance, order_id: orderId }) + .addQuery({ order_id: orderId }) .href(); return { @@ -207,4 +208,4 @@ export function parseRefundUri(s: string): RefundUriResult | undefined { return { refundUrl, }; -}
\ No newline at end of file +} diff --git a/src/wallet.ts b/src/wallet.ts index 175a6dba1..25857870c 100644 --- a/src/wallet.ts +++ b/src/wallet.ts @@ -3467,10 +3467,7 @@ export class Wallet { } const tipStatusUrl = new URI(res.tipPickupUrl) - .addQuery({ - instance: res.merchantInstance, - tip_id: res.tipId, - }) + .addQuery({ tip_id: res.tipId }) .href(); console.log("checking tip status from", tipStatusUrl); const merchantResp = await this.http.get(tipStatusUrl); |