summaryrefslogtreecommitdiff
path: root/packages/taler-util
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-util')
-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
};
}