aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_contract.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd_contract.h')
-rw-r--r--src/backend/taler-merchant-httpd_contract.h402
1 files changed, 191 insertions, 211 deletions
diff --git a/src/backend/taler-merchant-httpd_contract.h b/src/backend/taler-merchant-httpd_contract.h
index 5df47bc9..d4b174a9 100644
--- a/src/backend/taler-merchant-httpd_contract.h
+++ b/src/backend/taler-merchant-httpd_contract.h
@@ -40,58 +40,26 @@ enum TALER_MerchantContractVersion
};
/**
-* Contract fields specific to v0 contract format.
+* Possible token classes.
*/
-struct TALER_MerchantContractV0
+enum TALER_MerchantContractTokenClass
{
- /**
- * Summary of the order.
- */
- const char *summary;
-
- /**
- * Internationalized summary.
- */
- json_t *summary_i18n;
-
- /**
- * URL that will show that the order was successful
- * after it has been paid for.
- */
- const char *fulfillment_url;
/**
- * Message shown to the customer after paying for the order.
- * Either fulfillment_url or fulfillment_message must be specified.
- */
- const 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.
- */
- const json_t *products;
-
- /**
- * Gross amount value of the contract. Used to
- * compute @e max_stefan_fee.
- */
- struct TALER_Amount brutto;
+ * Token class subscription
+ */
+ TALER_MCTC_SUBSCRIPTION = 0,
/**
- * Maximum fee as given by the client request.
- */
- struct TALER_Amount max_fee;
+ * Token class discount
+ */
+ TALER_MCTC_DISCOUNT = 1
};
/**
* Possible input types for the contract terms.
*/
-enum TALER_MerchantContractV1InputType
+enum TALER_MerchantContractInputType
{
/**
@@ -108,17 +76,17 @@ enum TALER_MerchantContractV1InputType
/**
* Contract input (part of the v1 contract terms).
*/
-struct TALER_MerchantContractV1Input
+struct TALER_MerchantContractInput
{
/**
* Type of the input.
*/
- enum TALER_MerchantContractV1InputType type;
+ enum TALER_MerchantContractInputType type;
union
{
/**
- * Coin-based input.
+ * Coin-based input (ration).
*/
struct
{
@@ -126,6 +94,11 @@ struct TALER_MerchantContractV1Input
* Price to be paid.
*/
struct TALER_Amount price;
+
+ /**
+ * Base URL of the ration authority.
+ */
+ const char *ration_authority_url;
} coin;
/**
@@ -134,10 +107,10 @@ struct TALER_MerchantContractV1Input
struct
{
/**
- * Hash over the public key used to sign the type of subscription
- * token required.
+ * Label of the token authority in the 'token_authorities'
+ * array on the top-level.
*/
- struct TALER_TokenFamilyPublicKeyHash h_issuer;
+ const char *token_authority_label;
/**
* Number of tokens of this type required. Defaults to one if the
@@ -151,7 +124,7 @@ struct TALER_MerchantContractV1Input
/**
* Possible output types for the contract terms.
*/
-enum TALER_MerchantContractV1OutputType
+enum TALER_MerchantContractOutputType
{
/**
@@ -172,31 +145,14 @@ enum TALER_MerchantContractV1OutputType
};
/**
-* Possible token output classes.
-*/
-enum TALER_MerchantContractV1OutputTokenClass
-{
-
- /**
- * Token class subscription
- */
- TALER_MCOTC_SUBSCRIPTION = 0,
-
- /**
- * Token class discount
- */
- TALER_MCOTC_DISCOUNT = 1
-};
-
-/**
* Contract output (part of the v1 contract terms).
*/
-struct TALER_MerchantContractV1Output
+struct TALER_MerchantContractOutput
{
/**
* Type of the output.
*/
- enum TALER_MerchantContractV1OutputType type;
+ enum TALER_MerchantContractOutputType type;
union
{
@@ -232,78 +188,16 @@ struct TALER_MerchantContractV1Output
struct
{
/**
- * Label of the token authority in the 'token_authorities' array on the top-level.
+ * Label of the token authority in the 'token_authorities'
+ * array on the top-level.
*/
const char *token_authority_label;
/**
- * Must a wallet understand this token type to process contracts that
- * consume or yield it?
- */
- bool critical;
-
- /**
- * Class of token that will be yielded.
- */
- enum TALER_MerchantContractV1OutputTokenClass token_class;
-
- /**
- * Information about the class of token that will be yielded.
+ * Number of tokens of this type required. Defaults to one if the
+ * field is not provided.
*/
- union
- {
- /**
- * Subscription token.
- */
- struct
- {
- /**
- * When does the subscription period start?
- */
- struct GNUNET_TIME_Absolute start_date;
-
- /**
- * When does the subscription period end?
- */
- struct GNUNET_TIME_Absolute end_date;
-
- /**
- * 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.
- */
- const char **trusted_domains;
-
- /**
- * Length of the @e trusted_domains array.
- */
- unsigned int 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).
- */
- const char **expected_domains;
-
- /**
- * Length of the @e expected_domains array.
- */
- unsigned int expected_domains_len;
-
- } discount;
- } details;
+ unsigned int number;
} token;
} details;
};
@@ -311,7 +205,7 @@ struct TALER_MerchantContractV1Output
/**
* Contract choice (part of the v1 contract terms).
*/
-struct TALER_MerchantContractV1Choice
+struct TALER_MerchantContractChoice
{
/**
* Summary of the order.
@@ -343,13 +237,21 @@ struct TALER_MerchantContractV1Choice
/**
* Array of products that are part of the purchase.
*/
- const json_t *products;
+ json_t *products;
+
+ /**
+ * 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 price;
/**
* List of inputs the wallet must provision (all of them) to satisfy the
* conditions for the contract.
*/
- struct TALER_MerchantContractV1Input *inputs;
+ struct TALER_MerchantContractInput *inputs;
/**
* Length of the @e inputs array.
@@ -360,7 +262,7 @@ struct TALER_MerchantContractV1Choice
* List of outputs the merchant promises to yield (all of them) once
* the contract is paid.
*/
- struct TALER_MerchantContractV1Output *ouputs;
+ struct TALER_MerchantContractOutput *ouputs;
/**
* Length of the @e outputs array.
@@ -369,71 +271,9 @@ struct TALER_MerchantContractV1Choice
};
/**
-* Contract fields specific to v1 contract format.
-*/
-struct TALER_MerchantContractV1
-{
- /**
- * Array of possible specific contracts the wallet/customer may choose
- * from by selecting the respective index when signing the deposit
- * confirmation.
- */
- struct TALER_MerchantContractV1Choice *choices;
-
- /**
- * Length of the @e choices array.
- */
- unsigned int choices_len;
-
- /**
- * TODO: This was moved out a level: Change design document according to this.
- * Array of token authorities.
- */
- struct
- {
- /**
- * Label of the token authority.
- */
- const char *label;
-
- /**
- * Human-readable description of the semantics of the tokens issued by
- * this authority.
- */
- const char *summary;
-
- /**
- * Map from IETF BCP 47 language tags to localized summaries.
- */
- json_t *summary_i18n;
-
- /**
- * Public key used to validate tokens signed by this authority.
- */
- struct TALER_TokenFamilyPublicKey key;
-
- /**
- * When will tokens signed by this key expire?
- */
- struct GNUNET_TIME_Timestamp token_expiration;
-
- } *token_authorities;
-
- /**
- * Length of the @e token_authorities array.
- */
- unsigned int token_authorities_len;
-
- /**
- * TODO: Model this
- * Fee limits and wire account details by currency.
- * limits: { [currency:string] : CurrencyLimit };
- */
-};
-
-/**
-* Struct to hold contract terms in v0 and v1 format. Shared fields are on the
-* top level, while version specific fields are in the respective sub-structs.
+* Struct to hold contract terms in v0 and v1 format. v0 contracts are mdoelled
+* as a v1 contract with a single choice and no inputs and outputs. Use the
+* version field to explicitly differentiate between v0 and v1 contracts.
*/
struct TALER_MerchantContract
{
@@ -500,19 +340,162 @@ struct TALER_MerchantContract
const json_t *extra;
/**
- * Specified version of the order.
+ * Specified version of the contract.
*/
enum TALER_MerchantContractVersion version;
/**
- * Contract information in v0 format.
+ * Array of possible specific contracts the wallet/customer may choose
+ * from by selecting the respective index when signing the deposit
+ * confirmation.
+ */
+ struct TALER_MerchantContractChoice *choices;
+
+ /**
+ * Length of the @e choices array.
+ */
+ unsigned int choices_len;
+
+ /**
+ * Array of token authorities.
+ */
+ struct
+ {
+ /**
+ * Label of the token authority.
+ */
+ const char *label;
+
+ /**
+ * Human-readable description of the semantics of the tokens issued by
+ * this authority.
+ */
+ const char *summary;
+
+ /**
+ * Map from IETF BCP 47 language tags to localized summaries.
+ */
+ json_t *summary_i18n;
+
+ /**
+ * Public key used to validate tokens signed by this authority.
+ */
+ struct TALER_TokenFamilyPublicKey key;
+
+ /**
+ * When will tokens signed by this key expire?
+ */
+ struct GNUNET_TIME_Timestamp token_expiration;
+
+ /**
+ * Must a wallet understand this token type to process contracts that
+ * consume or yield it?
+ */
+ bool critical;
+
+ /**
+ * Class of token the token.
+ */
+ enum TALER_MerchantContractTokenClass token_class;
+
+ /**
+ * Class-specific information about the token.
+ */
+ union
+ {
+ /**
+ * Subscription token.
+ */
+ struct
+ {
+ /**
+ * When does the subscription period start?
+ */
+ struct GNUNET_TIME_Absolute start_date;
+
+ /**
+ * When does the subscription period end?
+ */
+ struct GNUNET_TIME_Absolute end_date;
+
+ /**
+ * 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.
+ */
+ const char **trusted_domains;
+
+ /**
+ * Length of the @e trusted_domains array.
+ */
+ unsigned int 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).
+ */
+ const char **expected_domains;
+
+ /**
+ * Length of the @e expected_domains array.
+ */
+ unsigned int expected_domains_len;
+
+ } discount;
+ } details;
+
+ } *token_authorities;
+
+ /**
+ * Length of the @e token_authorities array.
+ */
+ unsigned int token_authorities_len;
+
+ /**
+ * Fee limits and wire account details by currency.
*/
- struct TALER_MerchantContractV0 v0;
+ struct
+ {
+ /**
+ * Currency these limits are for.
+ */
+ char currency[TALER_CURRENCY_LEN];
+
+ /**
+ * The hash of the merchant instance's wire details.
+ */
+ struct TALER_MerchantWireHashP h_wire;
+
+ /**
+ * Wire transfer method identifier for the wire method associated with ``h_wire``.
+ * The wallet may only select exchanges via a matching auditor if the
+ * exchange also supports this wire method.
+ * The wire transfer fees must be added based on this wire transfer method.
+ */
+ char *wire_method;
+
+ /**
+ * Maximum total deposit fee accepted by the merchant for this contract.
+ */
+ struct TALER_Amount max_fee;
+ } *limits;
/**
- * Order information passed in in v1 format.
+ * Length of the @e limits array;
*/
- struct TALER_MerchantContractV1 v1;
+ unsigned int limits_len;
};
/**
@@ -532,10 +515,7 @@ TMH_serialize_contract (const struct TALER_MerchantContract *contract,
enum GNUNET_GenericReturnValue
TMH_serialize_contract_v0 (const struct TALER_MerchantContract *contract,
const struct TMH_MerchantInstance *instance,
- const struct TMH_WireMethod *wm,
json_t *exchanges,
- json_t *products,
- struct TALER_Amount *max_fee,
json_t **out);
enum GNUNET_GenericReturnValue