commit a02f30c618222c5c1ecaab34e7a2b03de280ab18
parent 852713fa4dc25a5a8fff90497ab02c965e904f5d
Author: Iván Ávalos <avalos@disroot.org>
Date: Mon, 14 Apr 2025 21:55:20 +0200
Revert merchant types in "new PostOrder api"
This reverts commit 8c1ace014422fb8e0abae1921b015646dc633019.
Diffstat:
1 file changed, 5 insertions(+), 182 deletions(-)
diff --git a/packages/taler-util/src/types-taler-merchant.ts b/packages/taler-util/src/types-taler-merchant.ts
@@ -2190,139 +2190,16 @@ export interface PostOrderRequest {
otp_id?: string;
}
-export type Order = (OrderV1 | OrderV0) & OrderCommon;
-
-// export interface MinimalOrderDetail {
-// // Amount to be paid by the customer.
-// amount: AmountString;
-
-// // Short summary of the order.
-// summary: string;
-
-// // See documentation of fulfillment_url in ContractTerms.
-// // Either fulfillment_url or fulfillment_message must be specified.
-// // When creating an order, the fulfillment URL can
-// // contain ${ORDER_ID} which will be substituted with the
-// // order ID of the newly created order.
-// fulfillment_url?: string;
-
-// // See documentation of fulfillment_message in ContractTerms.
-// // Either fulfillment_url or fulfillment_message must be specified.
-// fulfillment_message?: string;
-// }
-
-export interface OrderV1 {
- // Version 1 order support discounts and subscriptions.
- // https://docs.taler.net/design-documents/046-mumimo-contracts.html
- // @since protocol **vSUBSCRIBE**
- version: 1;
-
- // List of contract choices that the customer can select from.
- // @since protocol **vSUBSCRIBE**
- choices?: OrderChoice[];
-}
+export type Order = MinimalOrderDetail & Partial<ContractTerms>;
-export interface OrderV0 {
- // Optional, defaults to 0 if not set.
- version?: 0;
-
- // Total price for the transaction. The exchange will subtract deposit
- // fees from that amount before transferring it to the merchant.
+export interface MinimalOrderDetail {
+ // Amount to be paid by the customer.
amount: AmountString;
- // Maximum total deposit fee accepted by the merchant for this contract.
- // Overrides defaults of the merchant instance.
- max_fee?: AmountString;
-}
-
-export interface OrderChoice {
- // Total price for the choice. The exchange will subtract deposit
- // fees from that amount before transferring it to the merchant.
- amount: AmountString;
-
- // Inputs that must be provided by the customer, if this choice is selected.
- // Defaults to empty array if not specified.
- inputs?: OrderInput[];
-
- // Outputs provided by the merchant, if this choice is selected.
- // Defaults to empty array if not specified.
- outputs?: OrderOutput[];
-
- // Maximum total deposit fee accepted by the merchant for this contract.
- // Overrides defaults of the merchant instance.
- max_fee?: AmountString;
-}
-
-// For now, only token inputs are supported.
-export type OrderInput = OrderInputToken;
-
-export interface OrderInputToken {
- // Token input.
- type: "token";
-
- // Token family slug as configured in the merchant backend. Slug is unique
- // across all configured tokens of a merchant.
- token_family_slug: string;
-
- // How many units of the input are required.
- // Defaults to 1 if not specified. Output with count == 0 are ignored by
- // the merchant backend.
- count?: Integer;
-}
-
-export type OrderOutput = OrderOutputToken | OrderOutputTaxReceipt;
-
-export interface OrderOutputToken {
- // Token output.
- type: "token";
-
- // Token family slug as configured in the merchant backend. Slug is unique
- // across all configured tokens of a merchant.
- token_family_slug: string;
-
- // How many units of the output are issued by the merchant.
- // Defaults to 1 if not specified. Output with count == 0 are ignored by
- // the merchant backend.
- count?: Integer;
-
- // When should the output token be valid. Can be specified if the
- // desired validity period should be in the future (like selling
- // a subscription for the next month). Optional. If not given,
- // the validity is supposed to be "now" (time of order creation).
- valid_at?: Timestamp;
-}
-
-export interface OrderOutputTaxReceipt {
- // Tax receipt output.
- type: "tax-receipt";
-
- // Total amount that will be on the tax receipt.
- // Optional, if missing the full amount will be on the receipt.
- amount?: AmountString;
-}
-export interface OrderCommon {
- // Human-readable description of the whole purchase.
+ // Short summary of the order.
summary: string;
- // Map from IETF BCP 47 language tags to localized summaries.
- summary_i18n?: { [lang_tag: string]: string };
-
- // Unique identifier for the order. Only characters
- // allowed are "A-Za-z0-9" and ".:_-".
- // Must be unique within a merchant instance.
- // For merchants that do not store proposals in their DB
- // before the customer paid for them, the order_id can be used
- // by the frontend to restore a proposal from the information
- // encoded in it (such as a short product identifier and timestamp).
- order_id?: string;
-
- // URL where the same contract could be ordered again (if
- // available). Returned also at the public order endpoint
- // for people other than the actual buyer (hence public,
- // in case order IDs are guessable).
- public_reorder_url?: string;
-
- // See documentation of fulfillment_url field in ContractTerms.
+ // See documentation of fulfillment_url in ContractTerms.
// Either fulfillment_url or fulfillment_message must be specified.
// When creating an order, the fulfillment URL can
// contain ${ORDER_ID} which will be substituted with the
@@ -2332,60 +2209,6 @@ export interface OrderCommon {
// See documentation of fulfillment_message in ContractTerms.
// Either fulfillment_url or fulfillment_message must be specified.
fulfillment_message?: string;
-
- // Map from IETF BCP 47 language tags to localized fulfillment
- // messages.
- fulfillment_message_i18n?: { [lang_tag: string]: string };
-
- // Minimum age the buyer must have to buy.
- minimum_age?: Integer;
-
- // List of products that are part of the purchase.
- products?: Product[];
-
- // Time when this contract was generated. If null, defaults to current
- // time of merchant backend.
- timestamp?: Timestamp;
-
- // After this deadline has passed, no refunds will be accepted.
- // Overrides deadline calculated from refund_delay in
- // PostOrderRequest.
- refund_deadline?: Timestamp;
-
- // After this deadline, the merchant won't accept payments for the contract.
- // Overrides deadline calculated from default pay delay configured in
- // merchant backend.
- pay_deadline?: Timestamp;
-
- // Transfer deadline for the exchange. Must be in the deposit permissions
- // of coins used to pay for this order.
- // Overrides deadline calculated from default wire transfer delay
- // configured in merchant backend. Must be after refund deadline.
- wire_transfer_deadline?: Timestamp;
-
- // Base URL of the (public!) merchant backend API.
- // Must be an absolute URL that ends with a slash.
- // Defaults to the base URL this request was made to.
- merchant_base_url?: string;
-
- // Delivery location for (all!) products.
- delivery_location?: Location;
-
- // Time indicating when the order should be delivered.
- // May be overwritten by individual products.
- // Must be in the future.
- delivery_date?: Timestamp;
-
- // See documentation of auto_refund in ContractTerms.
- // Specifies for how long the wallet should try to get an
- // automatic refund for the purchase.
- auto_refund?: RelativeTime;
-
- // Extra data that is only interpreted by the merchant frontend.
- // Useful when the merchant needs to store extra information on a
- // contract without storing it separately in their database.
- // Must really be an Object (not a string, integer, float or array).
- extra?: Object;
}
export interface MinimalInventoryProduct {