adapt to instance changes
This commit is contained in:
parent
831d27c4df
commit
1a23fbcb4f
2
Makefile
2
Makefile
@ -41,7 +41,7 @@ clean:
|
||||
|
||||
.PHONY: check
|
||||
check: tsc yarn-install
|
||||
$(ava) 'dist/node/**/*-test.js'
|
||||
find dist/node -name '*-test.js' | xargs $(ava)
|
||||
|
||||
.PHONY: coverage
|
||||
coverage: tsc yarn-install
|
||||
|
@ -18,7 +18,7 @@
|
||||
"devDependencies": {
|
||||
"@types/react": "^16.4.0",
|
||||
"@types/react-dom": "^16.0.0",
|
||||
"ava": "^2.3.0",
|
||||
"ava": "^2.4.0",
|
||||
"awesome-typescript-loader": "^5.2.1",
|
||||
"glob": "^7.1.1",
|
||||
"gulp": "^4.0.0",
|
||||
|
@ -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,
|
||||
);
|
||||
|
||||
|
@ -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}`,
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
});
|
||||
});
|
||||
|
@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
100
yarn.lock
100
yarn.lock
@ -33,18 +33,18 @@
|
||||
dependencies:
|
||||
"@babel/highlight" "^7.0.0"
|
||||
|
||||
"@babel/core@^7.5.5":
|
||||
version "7.5.5"
|
||||
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.5.5.tgz#17b2686ef0d6bc58f963dddd68ab669755582c30"
|
||||
integrity sha512-i4qoSr2KTtce0DmkuuQBV4AuQgGPUcPXMr9L5MyYAtk06z068lQ10a4O009fe5OB/DfNV+h+qqT7ddNV8UnRjg==
|
||||
"@babel/core@^7.6.0":
|
||||
version "7.6.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.6.2.tgz#069a776e8d5e9eefff76236bc8845566bd31dd91"
|
||||
integrity sha512-l8zto/fuoZIbncm+01p8zPSDZu/VuuJhAfA7d/AbzM09WR7iVhavvfNDYCNpo1VvLk6E6xgAoP9P+/EMJHuRkQ==
|
||||
dependencies:
|
||||
"@babel/code-frame" "^7.5.5"
|
||||
"@babel/generator" "^7.5.5"
|
||||
"@babel/helpers" "^7.5.5"
|
||||
"@babel/parser" "^7.5.5"
|
||||
"@babel/template" "^7.4.4"
|
||||
"@babel/traverse" "^7.5.5"
|
||||
"@babel/types" "^7.5.5"
|
||||
"@babel/generator" "^7.6.2"
|
||||
"@babel/helpers" "^7.6.2"
|
||||
"@babel/parser" "^7.6.2"
|
||||
"@babel/template" "^7.6.0"
|
||||
"@babel/traverse" "^7.6.2"
|
||||
"@babel/types" "^7.6.0"
|
||||
convert-source-map "^1.1.0"
|
||||
debug "^4.1.0"
|
||||
json5 "^2.1.0"
|
||||
@ -64,6 +64,16 @@
|
||||
source-map "^0.5.0"
|
||||
trim-right "^1.0.1"
|
||||
|
||||
"@babel/generator@^7.6.0", "@babel/generator@^7.6.2":
|
||||
version "7.6.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.6.2.tgz#dac8a3c2df118334c2a29ff3446da1636a8f8c03"
|
||||
integrity sha512-j8iHaIW4gGPnViaIHI7e9t/Hl8qLjERI6DcV9kEpAIDJsAOrcnXqRS7t+QbhL76pwbtqP+QCQLL0z1CyVmtjjQ==
|
||||
dependencies:
|
||||
"@babel/types" "^7.6.0"
|
||||
jsesc "^2.5.1"
|
||||
lodash "^4.17.13"
|
||||
source-map "^0.5.0"
|
||||
|
||||
"@babel/helper-annotate-as-pure@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz#323d39dd0b50e10c7c06ca7d7638e6864d8c5c32"
|
||||
@ -154,14 +164,14 @@
|
||||
"@babel/traverse" "^7.1.0"
|
||||
"@babel/types" "^7.2.0"
|
||||
|
||||
"@babel/helpers@^7.5.5":
|
||||
version "7.5.5"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.5.5.tgz#63908d2a73942229d1e6685bc2a0e730dde3b75e"
|
||||
integrity sha512-nRq2BUhxZFnfEn/ciJuhklHvFOqjJUD5wpx+1bxUF2axL9C+v4DE/dmp5sT2dKnpOs4orZWzpAZqlCy8QqE/7g==
|
||||
"@babel/helpers@^7.6.2":
|
||||
version "7.6.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.6.2.tgz#681ffe489ea4dcc55f23ce469e58e59c1c045153"
|
||||
integrity sha512-3/bAUL8zZxYs1cdX2ilEE0WobqbCmKWr/889lf2SS0PpDcpEIY8pb1CCyz0pEcX3pEb+MCbks1jIokz2xLtGTA==
|
||||
dependencies:
|
||||
"@babel/template" "^7.4.4"
|
||||
"@babel/traverse" "^7.5.5"
|
||||
"@babel/types" "^7.5.5"
|
||||
"@babel/template" "^7.6.0"
|
||||
"@babel/traverse" "^7.6.2"
|
||||
"@babel/types" "^7.6.0"
|
||||
|
||||
"@babel/highlight@^7.0.0":
|
||||
version "7.5.0"
|
||||
@ -177,6 +187,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.5.5.tgz#02f077ac8817d3df4a832ef59de67565e71cca4b"
|
||||
integrity sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==
|
||||
|
||||
"@babel/parser@^7.6.0", "@babel/parser@^7.6.2":
|
||||
version "7.6.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.6.2.tgz#205e9c95e16ba3b8b96090677a67c9d6075b70a1"
|
||||
integrity sha512-mdFqWrSPCmikBoaBYMuBulzTIKuXVPtEISFbRRVNwMWpCms/hmE2kRq0bblUHaNRKrjRlmVbx1sDHmjmRgD2Xg==
|
||||
|
||||
"@babel/plugin-proposal-async-generator-functions@^7.2.0":
|
||||
version "7.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.2.0.tgz#b289b306669dce4ad20b0252889a15768c9d417e"
|
||||
@ -251,7 +266,16 @@
|
||||
"@babel/parser" "^7.4.4"
|
||||
"@babel/types" "^7.4.4"
|
||||
|
||||
"@babel/traverse@^7.1.0", "@babel/traverse@^7.4.3", "@babel/traverse@^7.5.5":
|
||||
"@babel/template@^7.6.0":
|
||||
version "7.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.6.0.tgz#7f0159c7f5012230dad64cca42ec9bdb5c9536e6"
|
||||
integrity sha512-5AEH2EXD8euCk446b7edmgFdub/qfH1SN6Nii3+fyXP807QRx9Q73A2N5hNwRRslC2H9sNzaFhsPubkS4L8oNQ==
|
||||
dependencies:
|
||||
"@babel/code-frame" "^7.0.0"
|
||||
"@babel/parser" "^7.6.0"
|
||||
"@babel/types" "^7.6.0"
|
||||
|
||||
"@babel/traverse@^7.1.0", "@babel/traverse@^7.4.3":
|
||||
version "7.5.5"
|
||||
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.5.5.tgz#f664f8f368ed32988cd648da9f72d5ca70f165bb"
|
||||
integrity sha512-MqB0782whsfffYfSjH4TM+LMjrJnhCNEDMDIjeTpl+ASaUvxcjoiVCo/sM1GhS1pHOXYfWVCYneLjMckuUxDaQ==
|
||||
@ -266,6 +290,21 @@
|
||||
globals "^11.1.0"
|
||||
lodash "^4.17.13"
|
||||
|
||||
"@babel/traverse@^7.6.2":
|
||||
version "7.6.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.6.2.tgz#b0e2bfd401d339ce0e6c05690206d1e11502ce2c"
|
||||
integrity sha512-8fRE76xNwNttVEF2TwxJDGBLWthUkHWSldmfuBzVRmEDWOtu4XdINTgN7TDWzuLg4bbeIMLvfMFD9we5YcWkRQ==
|
||||
dependencies:
|
||||
"@babel/code-frame" "^7.5.5"
|
||||
"@babel/generator" "^7.6.2"
|
||||
"@babel/helper-function-name" "^7.1.0"
|
||||
"@babel/helper-split-export-declaration" "^7.4.4"
|
||||
"@babel/parser" "^7.6.2"
|
||||
"@babel/types" "^7.6.0"
|
||||
debug "^4.1.0"
|
||||
globals "^11.1.0"
|
||||
lodash "^4.17.13"
|
||||
|
||||
"@babel/types@^7.0.0", "@babel/types@^7.2.0", "@babel/types@^7.4.0", "@babel/types@^7.4.4", "@babel/types@^7.5.5":
|
||||
version "7.5.5"
|
||||
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.5.5.tgz#97b9f728e182785909aa4ab56264f090a028d18a"
|
||||
@ -275,6 +314,15 @@
|
||||
lodash "^4.17.13"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@babel/types@^7.6.0":
|
||||
version "7.6.1"
|
||||
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.6.1.tgz#53abf3308add3ac2a2884d539151c57c4b3ac648"
|
||||
integrity sha512-X7gdiuaCmA0uRjCmRtYJNAVCc/q+5xSgsfKJHqMN4iNLILX39677fJE1O40arPMh0TTtS9ItH67yre6c7k6t0g==
|
||||
dependencies:
|
||||
esutils "^2.0.2"
|
||||
lodash "^4.17.13"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@concordance/react@^2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@concordance/react/-/react-2.0.0.tgz#aef913f27474c53731f4fd79cc2f54897de90fde"
|
||||
@ -637,7 +685,7 @@ ansi-styles@^3.2.0, ansi-styles@^3.2.1:
|
||||
dependencies:
|
||||
color-convert "^1.9.0"
|
||||
|
||||
ansi-styles@^4.0.0:
|
||||
ansi-styles@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.1.0.tgz#d3ba8047b818293eaaa7978321dd61bff9842cfc"
|
||||
integrity sha512-Qts4KCLKG+waHc9C4m07weIY8qyeixoS0h6RnbsNVD6Fw+pEZGW3vTyObL3WXpE09Mq4Oi7/lBEyLmOiLtlYWQ==
|
||||
@ -919,18 +967,18 @@ atob@^2.1.1:
|
||||
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
|
||||
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
|
||||
|
||||
ava@^2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/ava/-/ava-2.3.0.tgz#cac4d7f0a30077a852c6bf5bc7c0bc78c3021e63"
|
||||
integrity sha512-4VaaSnl13vpTZmqW3aMqioSolT0/ozRkjQxTLi3p8wtyRONuX/uLKL3uF0j50w2BNRoLsJqztnkX2h8xeVp2lg==
|
||||
ava@^2.4.0:
|
||||
version "2.4.0"
|
||||
resolved "https://registry.yarnpkg.com/ava/-/ava-2.4.0.tgz#a3bd8b0e01d8826004c91de375eb2313ba5237c3"
|
||||
integrity sha512-CQWtzZZZeU2g4StojRv6MO9RIRi4sLxGSB9+3C3hv0ttUEG1tkJLTLyrBQeFS4WEeK12Z4ovE3f2iPVhSy8elA==
|
||||
dependencies:
|
||||
"@ava/babel-preset-stage-4" "^4.0.0"
|
||||
"@ava/babel-preset-transform-test-files" "^6.0.0"
|
||||
"@babel/core" "^7.5.5"
|
||||
"@babel/generator" "^7.5.5"
|
||||
"@babel/core" "^7.6.0"
|
||||
"@babel/generator" "^7.6.0"
|
||||
"@concordance/react" "^2.0.0"
|
||||
ansi-escapes "^4.2.1"
|
||||
ansi-styles "^4.0.0"
|
||||
ansi-styles "^4.1.0"
|
||||
arr-flatten "^1.1.0"
|
||||
array-union "^2.1.0"
|
||||
array-uniq "^2.1.0"
|
||||
|
Loading…
Reference in New Issue
Block a user