aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-util')
-rw-r--r--packages/taler-util/src/payto.ts11
-rw-r--r--packages/taler-util/src/taler-types.ts11
-rw-r--r--packages/taler-util/src/types-test.ts2
-rw-r--r--packages/taler-util/src/wallet-types.ts59
4 files changed, 61 insertions, 22 deletions
diff --git a/packages/taler-util/src/payto.ts b/packages/taler-util/src/payto.ts
index 3073b991c..8eb0b88a8 100644
--- a/packages/taler-util/src/payto.ts
+++ b/packages/taler-util/src/payto.ts
@@ -139,12 +139,13 @@ export function parsePaytoUri(s: string): PaytoUri | undefined {
let iban: string | undefined = undefined;
let bic: string | undefined = undefined;
if (parts.length === 1) {
- iban = parts[0]
- } if (parts.length === 2) {
- bic = parts[0]
- iban = parts[1]
+ iban = parts[0];
+ }
+ if (parts.length === 2) {
+ bic = parts[0];
+ iban = parts[1];
} else {
- iban = targetPath
+ iban = targetPath;
}
return {
isKnown: true,
diff --git a/packages/taler-util/src/taler-types.ts b/packages/taler-util/src/taler-types.ts
index d4f96f5cd..292ace94b 100644
--- a/packages/taler-util/src/taler-types.ts
+++ b/packages/taler-util/src/taler-types.ts
@@ -1297,7 +1297,7 @@ export const codecForProduct = (): Codec<Product> =>
.property("price", codecOptional(codecForString()))
.build("Tax");
-export const codecForContractTerms = (): Codec<MerchantContractTerms> =>
+export const codecForMerchantContractTerms = (): Codec<MerchantContractTerms> =>
buildCodecForObject<MerchantContractTerms>()
.property("order_id", codecForString())
.property("fulfillment_url", codecOptional(codecForString()))
@@ -1329,7 +1329,14 @@ export const codecForContractTerms = (): Codec<MerchantContractTerms> =>
.property("products", codecOptional(codecForList(codecForProduct())))
.property("extra", codecForAny())
.property("minimum_age", codecOptional(codecForNumber()))
- .build("ContractTerms");
+ .build("MerchantContractTerms");
+
+export const codecForPeerContractTerms = (): Codec<PeerContractTerms> =>
+ buildCodecForObject<PeerContractTerms>()
+ .property("summary", codecForString())
+ .property("amount", codecForString())
+ .property("purse_expiration", codecForTimestamp)
+ .build("PeerContractTerms");
export const codecForMerchantRefundPermission =
(): Codec<MerchantAbortPayRefundDetails> =>
diff --git a/packages/taler-util/src/types-test.ts b/packages/taler-util/src/types-test.ts
index 2915106c2..6acd2c26e 100644
--- a/packages/taler-util/src/types-test.ts
+++ b/packages/taler-util/src/types-test.ts
@@ -15,7 +15,7 @@
*/
import test from "ava";
-import { codecForContractTerms } from "./taler-types.js";
+import { codecForMerchantContractTerms as codecForContractTerms } from "./taler-types.js";
test("contract terms validation", (t) => {
const c = {
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index daeac73fd..4e1563e27 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -53,13 +53,15 @@ import { TalerErrorCode } from "./taler-error-codes.js";
import {
AmountString,
AuditorDenomSig,
- codecForContractTerms,
+ codecForMerchantContractTerms,
CoinEnvelope,
MerchantContractTerms,
+ PeerContractTerms,
DenominationPubKey,
DenomKeyType,
ExchangeAuditor,
UnblindedSignature,
+ codecForPeerContractTerms,
} from "./taler-types.js";
import {
AbsoluteTime,
@@ -253,7 +255,7 @@ export const codecForConfirmPayResultDone = (): Codec<ConfirmPayResultDone> =>
buildCodecForObject<ConfirmPayResultDone>()
.property("type", codecForConstString(ConfirmPayResultType.Done))
.property("transactionId", codecForString())
- .property("contractTerms", codecForContractTerms())
+ .property("contractTerms", codecForMerchantContractTerms())
.build("ConfirmPayResultDone");
export const codecForConfirmPayResult = (): Codec<ConfirmPayResult> =>
@@ -383,7 +385,7 @@ export const codecForPreparePayResultPaymentPossible =
buildCodecForObject<PreparePayResultPaymentPossible>()
.property("amountEffective", codecForAmountString())
.property("amountRaw", codecForAmountString())
- .property("contractTerms", codecForContractTerms())
+ .property("contractTerms", codecForMerchantContractTerms())
.property("proposalId", codecForString())
.property("contractTermsHash", codecForString())
.property("noncePriv", codecForString())
@@ -1738,9 +1740,26 @@ export interface PayCoinSelection {
customerDepositFees: AmountString;
}
-export interface InitiatePeerPushPaymentRequest {
+export interface PreparePeerPushPaymentRequest {
+ exchangeBaseUrl?: string;
amount: AmountString;
- partialContractTerms: any;
+}
+
+export const codecForPreparePeerPushPaymentRequest =
+ (): Codec<PreparePeerPushPaymentRequest> =>
+ buildCodecForObject<PreparePeerPushPaymentRequest>()
+ .property("exchangeBaseUrl", codecOptional(codecForString()))
+ .property("amount", codecForAmountString())
+ .build("InitiatePeerPushPaymentRequest");
+
+export interface PreparePeerPushPaymentResponse {
+ amountRaw: AmountString;
+ amountEffective: AmountString;
+}
+
+export interface InitiatePeerPushPaymentRequest {
+ exchangeBaseUrl?: string;
+ partialContractTerms: PeerContractTerms;
}
export interface InitiatePeerPushPaymentResponse {
@@ -1755,8 +1774,7 @@ export interface InitiatePeerPushPaymentResponse {
export const codecForInitiatePeerPushPaymentRequest =
(): Codec<InitiatePeerPushPaymentRequest> =>
buildCodecForObject<InitiatePeerPushPaymentRequest>()
- .property("amount", codecForAmountString())
- .property("partialContractTerms", codecForAny())
+ .property("partialContractTerms", codecForPeerContractTerms())
.build("InitiatePeerPushPaymentRequest");
export interface CheckPeerPushPaymentRequest {
@@ -1768,13 +1786,13 @@ export interface CheckPeerPullPaymentRequest {
}
export interface CheckPeerPushPaymentResponse {
- contractTerms: any;
+ contractTerms: PeerContractTerms;
amount: AmountString;
peerPushPaymentIncomingId: string;
}
export interface CheckPeerPullPaymentResponse {
- contractTerms: any;
+ contractTerms: PeerContractTerms;
amount: AmountString;
peerPullPaymentIncomingId: string;
}
@@ -1843,21 +1861,34 @@ export const codecForAcceptPeerPullPaymentRequest =
.property("peerPullPaymentIncomingId", codecForString())
.build("AcceptPeerPllPaymentRequest");
+export interface PreparePeerPullPaymentRequest {
+ exchangeBaseUrl: string;
+ amount: AmountString;
+}
+export const codecForPreparePeerPullPaymentRequest =
+ (): Codec<PreparePeerPullPaymentRequest> =>
+ buildCodecForObject<PreparePeerPullPaymentRequest>()
+ .property("amount", codecForAmountString())
+ .property("exchangeBaseUrl", codecForString())
+ .build("PreparePeerPullPaymentRequest");
+
+export interface PreparePeerPullPaymentResponse {
+ amountRaw: AmountString;
+ amountEffective: AmountString;
+}
export interface InitiatePeerPullPaymentRequest {
/**
* FIXME: Make this optional?
*/
exchangeBaseUrl: string;
- amount: AmountString;
- partialContractTerms: any;
+ partialContractTerms: PeerContractTerms;
}
export const codecForInitiatePeerPullPaymentRequest =
(): Codec<InitiatePeerPullPaymentRequest> =>
buildCodecForObject<InitiatePeerPullPaymentRequest>()
- .property("partialContractTerms", codecForAny())
- .property("amount", codecForAmountString())
- .property("exchangeBaseUrl", codecForAmountString())
+ .property("partialContractTerms", codecForPeerContractTerms())
+ .property("exchangeBaseUrl", codecForString())
.build("InitiatePeerPullPaymentRequest");
export interface InitiatePeerPullPaymentResponse {