summaryrefslogtreecommitdiff
path: root/packages/taler-util/src/payto.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2021-11-16 13:59:53 -0300
committerSebastian <sebasjm@gmail.com>2021-11-16 14:01:38 -0300
commita994009d2f094c4d9c12da68dac3abb28bdef4b3 (patch)
treee403a58663f81889982635ffb324f9739e6976b3 /packages/taler-util/src/payto.ts
parentc33ed919719845f518d6491ef37df6ae16820dd0 (diff)
downloadwallet-core-a994009d2f094c4d9c12da68dac3abb28bdef4b3.tar.gz
wallet-core-a994009d2f094c4d9c12da68dac3abb28bdef4b3.tar.bz2
wallet-core-a994009d2f094c4d9c12da68dac3abb28bdef4b3.zip
reserveCreated new design
Diffstat (limited to 'packages/taler-util/src/payto.ts')
-rw-r--r--packages/taler-util/src/payto.ts45
1 files changed, 44 insertions, 1 deletions
diff --git a/packages/taler-util/src/payto.ts b/packages/taler-util/src/payto.ts
index 504db533b..fc3380555 100644
--- a/packages/taler-util/src/payto.ts
+++ b/packages/taler-util/src/payto.ts
@@ -16,12 +16,31 @@
import { URLSearchParams } from "./url.js";
-interface PaytoUri {
+export type PaytoUri = PaytoUriUnknown | PaytoUriIBAN | PaytoUriTalerBank;
+
+interface PaytoUriGeneric {
targetType: string;
targetPath: string;
params: { [name: string]: string };
}
+interface PaytoUriUnknown extends PaytoUriGeneric {
+ isKnown: false;
+}
+
+interface PaytoUriIBAN extends PaytoUriGeneric {
+ isKnown: true;
+ targetType: 'iban',
+ iban: string;
+}
+
+interface PaytoUriTalerBank extends PaytoUriGeneric {
+ isKnown: true;
+ targetType: 'x-taler-bank',
+ host: string;
+ account: string;
+}
+
const paytoPfx = "payto://";
/**
@@ -63,9 +82,33 @@ export function parsePaytoUri(s: string): PaytoUri | undefined {
params[v] = k;
});
+ if (targetType === 'x-taler-bank') {
+ const parts = targetPath.split('/')
+ const host = parts[0]
+ const account = parts[1]
+ return {
+ targetPath,
+ targetType,
+ params,
+ isKnown: true,
+ host, account,
+ };
+
+ }
+ if (targetType === 'iban') {
+ return {
+ isKnown: true,
+ targetPath,
+ targetType,
+ params,
+ iban: targetPath
+ };
+
+ }
return {
targetPath,
targetType,
params,
+ isKnown: false
};
}