commit a5df06c1c53ae28f2526a10a500e236de5e79c9a
parent 1d7f15a524fdeca2304d1fa5bf13dcf0decd8ecc
Author: Christian Grothoff <christian@grothoff.org>
Date: Fri, 27 Dec 2024 14:37:59 +0100
-fix built issues
Diffstat:
1 file changed, 584 insertions(+), 0 deletions(-)
diff --git a/src/include/taler_merchant_util.h b/src/include/taler_merchant_util.h
@@ -22,6 +22,9 @@
#define TALER_MERCHANT_UTIL_H
#include <gnunet/gnunet_util_lib.h>
+#include <taler/taler_util.h>
+#include <jansson.h>
+
/**
* Return default project data used by Taler merchant.
@@ -29,4 +32,585 @@
const struct GNUNET_OS_ProjectData *
TALER_MERCHANT_project_data (void);
+
+/**
+ * Possible versions of the contract terms.
+ */
+enum TALER_MERCHANT_ContractVersion
+{
+
+ /**
+ * Version 0
+ */
+ TALER_MERCHANT_CONTRACT_VERSION_0 = 0,
+
+ /**
+ * Version 1
+ */
+ TALER_MERCHANT_CONTRACT_VERSION_1 = 1
+};
+
+/**
+ * Possible token kinds.
+ */
+enum TALER_MERCHANT_ContractTokenKind
+{
+
+ /**
+ * Subscription token kind
+ */
+ TALER_MERCHANT_CONTRACT_TOKEN_KIND_SUBSCRIPTION = 0,
+
+ /**
+ * Discount token kind
+ */
+ TALER_MERCHANT_CONTRACT_TOKEN_KIND_DISCOUNT = 1
+};
+
+/**
+ * Possible input types for the contract terms.
+ */
+enum TALER_MERCHANT_ContractInputType
+{
+
+ /**
+ * Input type invalid
+ */
+ TALER_MERCHANT_CONTRACT_INPUT_TYPE_INVALID = 0,
+
+ /**
+ * Input type coin
+ */
+ TALER_MERCHANT_CONTRACT_INPUT_TYPE_COIN = 1,
+
+ /**
+ * Input type token
+ */
+ TALER_MERCHANT_CONTRACT_INPUT_TYPE_TOKEN = 2
+};
+
+/**
+ * Contract input (part of the v1 contract terms).
+ */
+struct TALER_MERCHANT_ContractInput
+{
+ /**
+ * Type of the input.
+ */
+ enum TALER_MERCHANT_ContractInputType type;
+
+ union
+ {
+#if FUTURE
+ /**
+ * Coin-based input (ration). (Future work, only here for reference)
+ */
+ struct
+ {
+ /**
+ * Price to be paid.
+ */
+ struct TALER_Amount price;
+
+ /**
+ * Base URL of the ration authority.
+ */
+ const char *ration_authority_url;
+ } coin;
+#endif
+ /**
+ * Token-based input.
+ */
+ struct
+ {
+ /**
+ * Slug of the token family to be used.
+ */
+ const char *token_family_slug;
+
+ /**
+ * Number of tokens of this type required. Defaults to one if the
+ * field is not provided.
+ */
+ unsigned int count;
+ } token;
+ } details;
+};
+
+/**
+ * Possible output types for the contract terms.
+ */
+enum TALER_MERCHANT_ContractOutputType
+{
+
+ /**
+ * Invalid output type
+ */
+ TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_INVALID = 0,
+
+ /**
+ * Output type token
+ */
+ TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_TOKEN = 1,
+
+ /**
+ * Output type donation-receipt
+ */
+ TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_DONATION_RECEIPT = 2,
+#if FUTURE
+ /**
+ * Output type coin
+ */
+ TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_COIN = 3
+#endif
+
+};
+
+/**
+ * Contract output (part of the v1 contract terms).
+ */
+struct TALER_MERCHANT_ContractOutput
+{
+ /**
+ * Type of the output.
+ */
+ enum TALER_MERCHANT_ContractOutputType type;
+
+ union
+ {
+ /**
+ * Coin-based output.
+ */
+ struct
+ {
+ /**
+ * Coins that will be yielded. This excludes any applicable withdraw fees.
+ */
+ struct TALER_Amount brutto_yield;
+
+ /**
+ * Base URL of the exchange that will issue the coins.
+ */
+ char *exchange_url;
+
+ } coin;
+
+ /**
+ * DONAU-receipt output.
+ */
+ struct
+ {
+ /**
+ * Amount of the donation. (optional)
+ */
+ struct TALER_Amount amount;
+
+ /**
+ * TODO: Check if this block is possible to opperate without default placeholder...
+ * Is the donation receipt required?
+ */
+ bool receipt_required;
+
+ /**
+ * Base URLs of the donation authorities that will issue the tax receipt.
+ */
+ // FIXME
+ // const char *donau_url;
+ } donation_receipt;
+
+ /**
+ * Token-based output.
+ */
+ struct
+ {
+ /**
+ * Slug of the token family to be issued.
+ */
+ char *token_family_slug;
+
+ /**
+ * Index of the public key in the @a token_family_slug's token family
+ * ``keys`` array that this output token will have.
+ */
+ unsigned int key_index;
+
+ /**
+ * Number of tokens of this type required. Defaults to one if the
+ * field is not provided.
+ */
+ unsigned int count;
+
+ // FIXME: add support for clients picking a validity
+ // period in the future for output tokens!
+
+ } token;
+
+ } details;
+
+};
+
+/**
+ * Contract choice (part of the v1 contract terms).
+ */
+struct TALER_MERCHANT_ContractChoice
+{
+
+ /**
+ * Amount to be paid for this choice.
+ */
+ struct TALER_Amount amount;
+
+ /**
+ * Maximum fee the merchant is willing to pay for this choice.
+ * Set to an invalid amount to use instance defaults (zero or STEFAN).
+ */
+ struct TALER_Amount max_fee;
+
+ /**
+ * List of inputs the wallet must provision (all of them) to satisfy the
+ * conditions for the contract.
+ */
+ struct TALER_MERCHANT_ContractInput *inputs;
+
+ /**
+ * Length of the @e inputs array.
+ */
+ unsigned int inputs_len;
+
+ /**
+ * List of outputs the merchant promises to yield (all of them) once
+ * the contract is paid.
+ */
+ struct TALER_MERCHANT_ContractOutput *outputs;
+
+ /**
+ * Length of the @e outputs array.
+ */
+ unsigned int outputs_len;
+};
+
+/**
+ * Public key and corresponding metadata for a token family.
+ */
+struct TALER_MERCHANT_ContractTokenFamilyKey
+{
+ /**
+ * Public key.
+ */
+ struct TALER_TokenIssuePublicKey pub;
+
+ /**
+ * Start time of the token family duration.
+ */
+ struct GNUNET_TIME_Timestamp valid_after;
+
+ /**
+ * Tokens signed by this key will be valid until this time.
+ */
+ struct GNUNET_TIME_Timestamp valid_before;
+};
+
+
+/**
+ * Represents a family of tokens issued by merchants that can be used in contracts.
+ */
+struct TALER_MERCHANT_ContractTokenFamily
+{
+ /**
+ * Slug of the token family.
+ */
+ char *slug;
+
+ /**
+ * Human-readable name of the token family.
+ */
+ char *name;
+
+ /**
+ * Human-readable description of the semantics of the tokens issued by
+ * this token family.
+ */
+ char *description;
+
+ /**
+ * Map from IETF BCP 47 language tags to localized description.
+ */
+ json_t *description_i18n;
+
+ /**
+ * Relevant public keys of this token family for the given contract.
+ */
+ struct TALER_MERCHANT_ContractTokenFamilyKey *keys;
+
+ /**
+ * Length of the @e keys array.
+ */
+ unsigned int keys_len;
+
+ /**
+ * Must a wallet understand this token type to process contracts that
+ * consume or yield it?
+ */
+ bool critical;
+
+ /**
+ * Kind of the token family.
+ */
+ enum TALER_MERCHANT_ContractTokenKind kind;
+
+ /**
+ * Kind-specific information about the token.
+ */
+ union
+ {
+ /**
+ * Subscription token.
+ */
+ struct
+ {
+ /**
+ * Array of domain names where this subscription can be safely used
+ * (e.g. the issuer warrants that these sites will re-issue tokens of
+ * this type if the respective contract says so). May contain "*" for
+ * any domain or subdomain.
+ */
+ char **trusted_domains;
+
+ /**
+ * Length of the @e trusted_domains array.
+ */
+ size_t trusted_domains_len;
+ } subscription;
+
+ /**
+ * Discount token.
+ */
+ struct
+ {
+ /**
+ * Array of domain names where this discount token is intended to be
+ * used. May contain "*" for any domain or subdomain. Users should be
+ * warned about sites proposing to consume discount tokens of this
+ * type that are not in this list that the merchant is accepting a
+ * coupon from a competitor and thus may be attaching different
+ * semantics (like get 20% discount for my competitors 30% discount
+ * token).
+ */
+ char **expected_domains;
+
+ /**
+ * Length of the @e expected_domains array.
+ */
+ unsigned int expected_domains_len;
+
+ } discount;
+ } details;
+};
+
+
+/**
+ * Struct to hold contract terms.
+ */
+struct TALER_MERCHANT_Contract
+{
+ /**
+ * URL where the same contract could be ordered again (if available).
+ */
+ char *public_reorder_url;
+
+ /**
+ * Our order ID.
+ */
+ char *order_id;
+
+ /**
+ * Merchant base URL.
+ */
+ char *merchant_base_url;
+
+ /**
+ * Merchant information.
+ */
+ struct
+ {
+ /**
+ * Legal name of the instance
+ */
+ char *name;
+
+ /**
+ * Merchant's site url
+ */
+ char *website;
+
+ /**
+ * Email contact for customers
+ */
+ char *email;
+
+ /**
+ * merchant's logo data uri
+ */
+ char *logo;
+
+ /**
+ * Merchant address
+ */
+ json_t *address;
+
+ /**
+ * Jurisdiction of the business
+ */
+ json_t *jurisdiction;
+
+ } merchant;
+
+ /**
+ * Summary of the contract.
+ */
+ char *summary;
+
+ /**
+ * Internationalized summary.
+ */
+ json_t *summary_i18n;
+
+ /**
+ * URL that will show that the contract was successful
+ * after it has been paid for.
+ */
+ char *fulfillment_url;
+
+ /**
+ * Message shown to the customer after paying for the contract.
+ * Either fulfillment_url or fulfillment_message must be specified.
+ */
+ char *fulfillment_message;
+
+ /**
+ * Map from IETF BCP 47 language tags to localized fulfillment messages.
+ */
+ json_t *fulfillment_message_i18n;
+
+ /**
+ * Array of products that are part of the purchase.
+ */
+ json_t *products;
+
+ /**
+ * Timestamp of the contract.
+ */
+ struct GNUNET_TIME_Timestamp timestamp;
+
+ /**
+ * Deadline for refunds.
+ */
+ struct GNUNET_TIME_Timestamp refund_deadline;
+
+ /**
+ * Specifies for how long the wallet should try to get an
+ * automatic refund for the purchase.
+ */
+ struct GNUNET_TIME_Relative auto_refund;
+
+ /**
+ * Payment deadline.
+ */
+ struct GNUNET_TIME_Timestamp pay_deadline;
+
+ /**
+ * Wire transfer deadline.
+ */
+ struct GNUNET_TIME_Timestamp wire_deadline;
+
+ /**
+ * Delivery date.
+ */
+ struct GNUNET_TIME_Timestamp delivery_date;
+
+ /**
+ * Delivery location.
+ */
+ json_t *delivery_location;
+
+ /**
+ * Nonce generated by the wallet and echoed by the merchant
+ * in this field when the proposal is generated.
+ */
+ char *nonce;
+
+ /**
+ * Extra data that is only interpreted by the merchant frontend.
+ */
+ json_t *extra;
+
+ /**
+ * Specified version of the contract.
+ */
+ enum TALER_MERCHANT_ContractVersion version;
+
+ /**
+ * Details depending on the @e version.
+ */
+ union
+ {
+
+ /**
+ * Details for v0 contracts.
+ */
+ struct
+ {
+
+ /**
+ * Price to be paid for the transaction. Could be 0. The price is in addition
+ * to other instruments, such as rations and tokens.
+ * The exchange will subtract deposit fees from that amount
+ * before transferring it to the merchant.
+ */
+ struct TALER_Amount brutto;
+
+ /**
+ * Maximum fee as given by the client request.
+ */
+ struct TALER_Amount max_fee;
+
+ } v0;
+
+ /**
+ * Details for v1 contracts.
+ */
+ struct
+ {
+
+ /**
+ * Array of possible specific contracts the wallet/customer may choose
+ * from by selecting the respective index when signing the deposit
+ * confirmation.
+ */
+ struct TALER_MERCHANT_ContractChoice *choices;
+
+ /**
+ * Length of the @e choices array.
+ */
+ unsigned int choices_len;
+
+ /**
+ * Array of token authorities.
+ */
+ struct TALER_MERCHANT_ContractTokenFamily *token_authorities;
+
+ /**
+ * Length of the @e token_authorities array.
+ */
+ unsigned int token_authorities_len;
+
+ } v1;
+
+ } details;
+
+ // FIXME: Add exchanges array?
+
+};
+
+
#endif