summaryrefslogtreecommitdiff
path: root/src/types
diff options
context:
space:
mode:
Diffstat (limited to 'src/types')
-rw-r--r--src/types/dbTypes.ts22
-rw-r--r--src/types/talerTypes.ts94
-rw-r--r--src/types/transactions.ts128
3 files changed, 191 insertions, 53 deletions
diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts
index 37a66251a..79966eb34 100644
--- a/src/types/dbTypes.ts
+++ b/src/types/dbTypes.ts
@@ -31,6 +31,8 @@ import {
PayReq,
TipResponse,
ExchangeSignKeyJson,
+ MerchantInfo,
+ Product,
} from "./talerTypes";
import { Index, Store } from "../util/query";
@@ -216,6 +218,15 @@ export interface ReserveHistoryRecord {
reserveTransactions: WalletReserveHistoryItem[];
}
+export interface ReserveBankInfo {
+ statusUrl: string;
+ confirmUrl?: string;
+ amount: AmountJson;
+ bankWithdrawalGroupId: string;
+ withdrawalStarted: boolean;
+ denomSel: DenomSelectionState;
+}
+
/**
* A reserve record as stored in the wallet's database.
*/
@@ -278,13 +289,7 @@ export interface ReserveRecord {
* Extra state for when this is a withdrawal involving
* a Taler-integrated bank.
*/
- bankInfo?: {
- statusUrl: string;
- confirmUrl?: string;
- amount: AmountJson;
- bankWithdrawalGroupId: string;
- withdrawalStarted: boolean;
- };
+ bankInfo?: ReserveBankInfo;
reserveStatus: ReserveRecordStatus;
@@ -1179,10 +1184,13 @@ export interface AllowedExchangeInfo {
* processing in the wallet.
*/
export interface WalletContractData {
+ products?: Product[];
+ summaryI18n: { [lang_tag: string]: string } | undefined;
fulfillmentUrl: string;
contractTermsHash: string;
merchantSig: string;
merchantPub: string;
+ merchant: MerchantInfo;
amount: AmountJson;
orderId: string;
merchantBaseUrl: string;
diff --git a/src/types/talerTypes.ts b/src/types/talerTypes.ts
index 17d11eea8..eb10d6e1f 100644
--- a/src/types/talerTypes.ts
+++ b/src/types/talerTypes.ts
@@ -260,6 +260,55 @@ export class AuditorHandle {
url: string;
}
+export interface MerchantInfo {
+ name: string;
+ jurisdiction: string | undefined;
+ address: string | undefined;
+}
+
+export interface Tax {
+ // the name of the tax
+ name: string;
+
+ // amount paid in tax
+ tax: AmountString;
+}
+
+export interface Product {
+ // merchant-internal identifier for the product.
+ product_id?: string;
+
+ // Human-readable product description.
+ description: string;
+
+ // Map from IETF BCP 47 language tags to localized descriptions
+ description_i18n?: { [lang_tag: string]: string };
+
+ // The number of units of the product to deliver to the customer.
+ quantity?: number;
+
+ // The unit in which the product is measured (liters, kilograms, packages, etc.)
+ unit?: string;
+
+ // The price of the product; this is the total price for quantity times unit of this product.
+ price?: AmountString;
+
+ // An optional base64-encoded product image
+ image?: string;
+
+ // a list of taxes paid by the merchant for this product. Can be empty.
+ taxes?: Tax[];
+
+ // time indicating when this product should be delivered
+ delivery_date?: Timestamp;
+
+ // where to deliver this product. This may be an URL for online delivery
+ // (i.e. 'http://example.com/download' or 'mailto:customer@example.com'),
+ // or a location label defined inside the proposition's 'locations'.
+ // The presence of a colon (':') indicates the use of an URL.
+ delivery_location?: string;
+}
+
/**
* Contract terms from a merchant.
*/
@@ -284,6 +333,8 @@ export class ContractTerms {
*/
summary: string;
+ summary_i18n?: { [lang_tag: string]: string };
+
/**
* Nonce used to ensure freshness.
*/
@@ -317,7 +368,7 @@ export class ContractTerms {
/**
* Information about the merchant.
*/
- merchant: any;
+ merchant: MerchantInfo;
/**
* Public key of the merchant.
@@ -332,7 +383,7 @@ export class ContractTerms {
/**
* Products that are sold in this contract.
*/
- products?: any[];
+ products?: Product[];
/**
* Deadline for refunds.
@@ -805,6 +856,35 @@ export const codecForAuditorHandle = (): Codec<AuditorHandle> =>
.property("url", codecForString)
.build("AuditorHandle");
+export const codecForMerchantInfo = (): Codec<MerchantInfo> =>
+ makeCodecForObject<MerchantInfo>()
+ .property("name", codecForString)
+ .property("address", makeCodecOptional(codecForString))
+ .property("jurisdiction", makeCodecOptional(codecForString))
+ .build("MerchantInfo");
+
+export const codecForTax = (): Codec<Tax> =>
+ makeCodecForObject<Tax>()
+ .property("name", codecForString)
+ .property("tax", codecForString)
+ .build("Tax");
+
+
+export const codecForI18n = (): Codec<{ [lang_tag: string]: string }> =>
+ makeCodecForMap(codecForString)
+
+export const codecForProduct = (): Codec<Product> =>
+ makeCodecForObject<Product>()
+ .property("product_id", makeCodecOptional(codecForString))
+ .property("description", codecForString)
+ .property("description_i18n", makeCodecOptional(codecForI18n()))
+ .property("quantity", makeCodecOptional(codecForNumber))
+ .property("unit", makeCodecOptional(codecForString))
+ .property("price", makeCodecOptional(codecForString))
+ .property("delivery_date", makeCodecOptional(codecForTimestamp))
+ .property("delivery_location", makeCodecOptional(codecForString))
+ .build("Tax");
+
export const codecForContractTerms = (): Codec<ContractTerms> =>
makeCodecForObject<ContractTerms>()
.property("order_id", codecForString)
@@ -814,6 +894,7 @@ export const codecForContractTerms = (): Codec<ContractTerms> =>
.property("auto_refund", makeCodecOptional(codecForDuration))
.property("wire_method", codecForString)
.property("summary", codecForString)
+ .property("summary_i18n", makeCodecOptional(codecForI18n()))
.property("nonce", codecForString)
.property("amount", codecForString)
.property("auditors", makeCodecForList(codecForAuditorHandle()))
@@ -824,10 +905,10 @@ export const codecForContractTerms = (): Codec<ContractTerms> =>
.property("locations", codecForAny)
.property("max_fee", codecForString)
.property("max_wire_fee", makeCodecOptional(codecForString))
- .property("merchant", codecForAny)
+ .property("merchant", codecForMerchantInfo())
.property("merchant_pub", codecForString)
.property("exchanges", makeCodecForList(codecForExchangeHandle()))
- .property("products", makeCodecOptional(makeCodecForList(codecForAny)))
+ .property("products", makeCodecOptional(makeCodecForList(codecForProduct())))
.property("extra", codecForAny)
.build("ContractTerms");
@@ -852,10 +933,7 @@ export const codecForMerchantRefundResponse = (): Codec<
makeCodecForObject<MerchantRefundResponse>()
.property("merchant_pub", codecForString)
.property("h_contract_terms", codecForString)
- .property(
- "refunds",
- makeCodecForList(codecForMerchantRefundPermission()),
- )
+ .property("refunds", makeCodecForList(codecForMerchantRefundPermission()))
.build("MerchantRefundResponse");
export const codecForReserveSigSingleton = (): Codec<ReserveSigSingleton> =>
diff --git a/src/types/transactions.ts b/src/types/transactions.ts
index 263e08a4e..b1d033c09 100644
--- a/src/types/transactions.ts
+++ b/src/types/transactions.ts
@@ -16,13 +16,16 @@
/**
* Type and schema definitions for the wallet's transaction list.
+ *
+ * @author Florian Dold
+ * @author Torsten Grote
*/
/**
* Imports.
*/
import { Timestamp } from "../util/time";
-import { AmountString } from "./talerTypes";
+import { AmountString, Product } from "./talerTypes";
export interface TransactionsRequest {
/**
@@ -44,6 +47,24 @@ export interface TransactionsResponse {
transactions: Transaction[];
}
+interface TransactionError {
+ /**
+ * TALER_EC_* unique error code.
+ * The action(s) offered and message displayed on the transaction item depend on this code.
+ */
+ ec: number;
+
+ /**
+ * English-only error hint, if available.
+ */
+ hint?: string;
+
+ /**
+ * Error details specific to "ec", if applicable/available
+ */
+ details?: any;
+}
+
export interface TransactionCommon {
// opaque unique ID for the transaction, used as a starting point for paginating queries
// and for invoking actions on the transaction (e.g. deleting/hiding it from the history)
@@ -64,16 +85,17 @@ export interface TransactionCommon {
amountRaw: AmountString;
// Amount added or removed from the wallet's balance (including all fees and other costs)
- amountEffective?: AmountString;
+ amountEffective: AmountString;
+
+ error?: TransactionError;
}
-export type Transaction = (
- TransactionWithdrawal |
- TransactionPayment |
- TransactionRefund |
- TransactionTip |
- TransactionRefresh
-)
+export type Transaction =
+ | TransactionWithdrawal
+ | TransactionPayment
+ | TransactionRefund
+ | TransactionTip
+ | TransactionRefresh;
export const enum TransactionType {
Withdrawal = "withdrawal",
@@ -93,79 +115,109 @@ interface TransactionWithdrawal extends TransactionCommon {
*/
exchangeBaseUrl?: string;
- // true if the bank has confirmed the withdrawal, false if not.
- // An unconfirmed withdrawal usually requires user-input and should be highlighted in the UI.
- // See also bankConfirmationUrl below.
+ /**
+ * true if the bank has confirmed the withdrawal, false if not.
+ * An unconfirmed withdrawal usually requires user-input and should be highlighted in the UI.
+ * See also bankConfirmationUrl below.
+ */
confirmed: boolean;
- // If the withdrawal is unconfirmed, this can include a URL for user initiated confirmation.
+ /**
+ * If the withdrawal is unconfirmed, this can include a URL for user
+ * initiated confirmation.
+ */
bankConfirmationUrl?: string;
- // Amount that has been subtracted from the reserve's balance for this withdrawal.
+ /**
+ * Amount that got subtracted from the reserve balance.
+ */
amountRaw: AmountString;
/**
* Amount that actually was (or will be) added to the wallet's balance.
- * Only present if an exchange has already been selected.
*/
- amountEffective?: AmountString;
+ amountEffective: AmountString;
}
export const enum PaymentStatus {
- // Explicitly aborted after timeout / failure
+ /**
+ * Explicitly aborted after timeout / failure
+ */
Aborted = "aborted",
- // Payment failed, wallet will auto-retry.
- // User should be given the option to retry now / abort.
+ /**
+ * Payment failed, wallet will auto-retry.
+ * User should be given the option to retry now / abort.
+ */
Failed = "failed",
- // Paid successfully
+ /**
+ * Paid successfully
+ */
Paid = "paid",
- // Only offered, user must accept / decline
- Offered = "offered",
-
- // User accepted, payment is processing.
+ /**
+ * User accepted, payment is processing.
+ */
Accepted = "accepted",
}
export interface TransactionPayment extends TransactionCommon {
type: TransactionType.Payment;
- // Additional information about the payment.
+ /**
+ * Additional information about the payment.
+ */
info: PaymentShortInfo;
+ /**
+ * How far did the wallet get with processing the payment?
+ */
status: PaymentStatus;
- // Amount that must be paid for the contract
+ /**
+ * Amount that must be paid for the contract
+ */
amountRaw: AmountString;
- // Amount that was paid, including deposit, wire and refresh fees.
- amountEffective?: AmountString;
+ /**
+ * Amount that was paid, including deposit, wire and refresh fees.
+ */
+ amountEffective: AmountString;
}
-
interface PaymentShortInfo {
- // Order ID, uniquely identifies the order within a merchant instance
+ /**
+ * Order ID, uniquely identifies the order within a merchant instance
+ */
orderId: string;
- // More information about the merchant
+ /**
+ * More information about the merchant
+ */
merchant: any;
- // Summary of the order, given by the merchant
+ /**
+ * Summary of the order, given by the merchant
+ */
summary: string;
- // Map from IETF BCP 47 language tags to localized summaries
+ /**
+ * Map from IETF BCP 47 language tags to localized summaries
+ */
summary_i18n?: { [lang_tag: string]: string };
- // List of products that are part of the order
- products: any[];
+ /**
+ * List of products that are part of the order
+ */
+ products: Product[] | undefined;
- // URL of the fulfillment, given by the merchant
+ /**
+ * URL of the fulfillment, given by the merchant
+ */
fulfillmentUrl: string;
}
-
interface TransactionRefund extends TransactionCommon {
type: TransactionType.Refund;
@@ -221,4 +273,4 @@ interface TransactionRefresh extends TransactionCommon {
// Amount that will be paid as fees for the refresh
amountEffective: AmountString;
-} \ No newline at end of file
+}