summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Blättler <blatc2@bfh.ch>2024-02-29 15:21:08 +0100
committerChristian Blättler <blatc2@bfh.ch>2024-02-29 15:21:08 +0100
commit48ebda9a68b01780cfb7de802f4eee3dbe708e80 (patch)
treeac1d903915a2bbf5f48b15245c1f7c53de2522d8 /src
parentca9274bae258f32639b411021e2c304f95813985 (diff)
downloadmerchant-48ebda9a68b01780cfb7de802f4eee3dbe708e80.tar.gz
merchant-48ebda9a68b01780cfb7de802f4eee3dbe708e80.tar.bz2
merchant-48ebda9a68b01780cfb7de802f4eee3dbe708e80.zip
serialize v0 contract
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_contract.c164
-rw-r--r--src/backend/taler-merchant-httpd_contract.h250
-rw-r--r--src/backend/taler-merchant-httpd_private-post-orders.c340
3 files changed, 414 insertions, 340 deletions
diff --git a/src/backend/taler-merchant-httpd_contract.c b/src/backend/taler-merchant-httpd_contract.c
index e69de29b..01186bef 100644
--- a/src/backend/taler-merchant-httpd_contract.c
+++ b/src/backend/taler-merchant-httpd_contract.c
@@ -0,0 +1,164 @@
+/*
+ This file is part of TALER
+ (C) 2024 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file taler-merchant-httpd_contract.c
+ * @brief shared logic for contract terms handling
+ * @author Christian Blättler
+ */
+#include "platform.h"
+#include <jansson.h>
+#include "taler-merchant-httpd_contract.h"
+
+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)
+{
+ json_t *merchant;
+
+ {
+ merchant = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("name",
+ instance->settings.name),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("website",
+ instance->settings.website)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("email",
+ instance->settings.email)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("logo",
+ instance->settings.logo)));
+ GNUNET_assert (NULL != merchant);
+ {
+ json_t *loca;
+
+ /* Handle merchant address */
+ loca = instance->settings.address;
+ if (NULL != loca)
+ {
+ loca = json_deep_copy (loca);
+ GNUNET_assert (NULL != loca);
+ GNUNET_assert (0 ==
+ json_object_set_new (merchant,
+ "address",
+ loca));
+ }
+ }
+ {
+ json_t *juri;
+
+ /* Handle merchant jurisdiction */
+ juri = instance->settings.jurisdiction;
+ if (NULL != juri)
+ {
+ juri = json_deep_copy (juri);
+ GNUNET_assert (NULL != juri);
+ GNUNET_assert (0 ==
+ json_object_set_new (merchant,
+ "jurisdiction",
+ juri));
+ }
+ }
+ }
+
+ *out = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("summary",
+ contract->v0.summary),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_object_incref ("summary_i18n",
+ contract->v0.summary_i18n)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("public_reorder_url",
+ contract->public_reorder_url)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("fulfillment_message",
+ contract->v0.fulfillment_message)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_object_incref ("fulfillment_message_i18n",
+ contract->v0.fulfillment_message_i18n)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("fulfillment_url",
+ contract->v0.fulfillment_url)),
+ GNUNET_JSON_pack_array_incref ("products",
+ products),
+ GNUNET_JSON_pack_data_auto ("h_wire",
+ &wm->h_wire),
+ GNUNET_JSON_pack_string ("wire_method",
+ wm->wire_method),
+ GNUNET_JSON_pack_string ("order_id",
+ contract->order_id),
+ GNUNET_JSON_pack_timestamp ("timestamp",
+ contract->timestamp),
+ GNUNET_JSON_pack_timestamp ("pay_deadline",
+ contract->pay_deadline),
+ GNUNET_JSON_pack_timestamp ("wire_transfer_deadline",
+ contract->wire_deadline),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_timestamp ("delivery_date",
+ contract->delivery_date)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_object_incref ("delivery_location",
+ contract->delivery_location)),
+ GNUNET_JSON_pack_string ("merchant_base_url",
+ contract->merchant_base_url),
+ GNUNET_JSON_pack_object_incref ("merchant",
+ merchant),
+ GNUNET_JSON_pack_data_auto ("merchant_pub",
+ &instance->merchant_pub),
+ GNUNET_JSON_pack_array_incref ("exchanges",
+ exchanges),
+ TALER_JSON_pack_amount ("max_fee",
+ max_fee),
+ TALER_JSON_pack_amount ("amount",
+ &contract->v0.brutto),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_object_incref ("extra",
+ (json_t *) contract->extra))
+ );
+
+ /* Pack does not work here, because it doesn't set zero-values for timestamps */
+ GNUNET_assert (0 ==
+ json_object_set_new (*out,
+ "refund_deadline",
+ GNUNET_JSON_from_timestamp (
+ contract->refund_deadline)));
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_INFO,
+ "Refund deadline for contact is %llu\n",
+ (unsigned long long) contract->refund_deadline.abs_time.abs_value_us);
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_INFO,
+ "Wallet timestamp for contact is %llu\n",
+ (unsigned long long) contract->timestamp.abs_time.abs_value_us);
+
+ /* Pack does not work here, because it sets zero-values for relative times */
+ /* auto_refund should only be set if it is not 0 */
+ if (! GNUNET_TIME_relative_is_zero (contract->auto_refund))
+ {
+ GNUNET_assert (0 ==
+ json_object_set_new (*out,
+ "auto_refund",
+ GNUNET_JSON_from_time_rel (
+ contract->auto_refund)));
+ }
+
+ return GNUNET_OK;
+};
diff --git a/src/backend/taler-merchant-httpd_contract.h b/src/backend/taler-merchant-httpd_contract.h
index ed5fe4ad..5df47bc9 100644
--- a/src/backend/taler-merchant-httpd_contract.h
+++ b/src/backend/taler-merchant-httpd_contract.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2023 Taler Systems SA
+ (C) 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free Software
@@ -19,6 +19,7 @@
* @author Christian Blättler
*/
#include "taler-merchant-httpd.h"
+#include <jansson.h>
/**
@@ -39,9 +40,58 @@ enum TALER_MerchantContractVersion
};
/**
+* Contract fields specific to v0 contract format.
+*/
+struct TALER_MerchantContractV0
+{
+ /**
+ * 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;
+
+ /**
+ * Maximum fee as given by the client request.
+ */
+ struct TALER_Amount max_fee;
+};
+
+/**
* Possible input types for the contract terms.
*/
-enum TALER_MerchantContractInputType
+enum TALER_MerchantContractV1InputType
{
/**
@@ -58,12 +108,12 @@ enum TALER_MerchantContractInputType
/**
* Contract input (part of the v1 contract terms).
*/
-struct TALER_MerchantContractInput
+struct TALER_MerchantContractV1Input
{
/**
* Type of the input.
*/
- enum TALER_MerchantContractInputType type;
+ enum TALER_MerchantContractV1InputType type;
union
{
@@ -101,7 +151,7 @@ struct TALER_MerchantContractInput
/**
* Possible output types for the contract terms.
*/
-enum TALER_MerchantContractOutputType
+enum TALER_MerchantContractV1OutputType
{
/**
@@ -124,7 +174,7 @@ enum TALER_MerchantContractOutputType
/**
* Possible token output classes.
*/
-enum TALER_MerchantContractOutputTokenClass
+enum TALER_MerchantContractV1OutputTokenClass
{
/**
@@ -141,12 +191,12 @@ enum TALER_MerchantContractOutputTokenClass
/**
* Contract output (part of the v1 contract terms).
*/
-struct TALER_MerchantContractOutput
+struct TALER_MerchantContractV1Output
{
/**
* Type of the output.
*/
- enum TALER_MerchantContractOutputType type;
+ enum TALER_MerchantContractV1OutputType type;
union
{
@@ -195,7 +245,7 @@ struct TALER_MerchantContractOutput
/**
* Class of token that will be yielded.
*/
- enum TALER_MerchantContractOutputTokenClass token_class;
+ enum TALER_MerchantContractV1OutputTokenClass token_class;
/**
* Information about the class of token that will be yielded.
@@ -261,7 +311,7 @@ struct TALER_MerchantContractOutput
/**
* Contract choice (part of the v1 contract terms).
*/
-struct TALER_MerchantContractChoice
+struct TALER_MerchantContractV1Choice
{
/**
* Summary of the order.
@@ -299,7 +349,7 @@ struct TALER_MerchantContractChoice
* List of inputs the wallet must provision (all of them) to satisfy the
* conditions for the contract.
*/
- struct TALER_MerchantContractInput *inputs;
+ struct TALER_MerchantContractV1Input *inputs;
/**
* Length of the @e inputs array.
@@ -310,10 +360,184 @@ struct TALER_MerchantContractChoice
* List of outputs the merchant promises to yield (all of them) once
* the contract is paid.
*/
- struct TALER_MerchantContractOutput *ouputs;
+ struct TALER_MerchantContractV1Output *ouputs;
/**
* Length of the @e outputs array.
*/
unsigned int outputs_len;
-} \ No newline at end of file
+};
+
+/**
+* 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 TALER_MerchantContract
+{
+ /**
+ * URL where the same contract could be ordered again (if available).
+ */
+ const char *public_reorder_url;
+
+ /**
+ * Our order ID.
+ */
+ const char *order_id;
+
+ /**
+ * Merchant base URL.
+ */
+ char *merchant_base_url;
+
+ /**
+ * Timestamp of the order.
+ */
+ 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.
+ */
+ const char *nonce;
+
+ /**
+ * Extra data that is only interpreted by the merchant frontend.
+ */
+ const json_t *extra;
+
+ /**
+ * Specified version of the order.
+ */
+ enum TALER_MerchantContractVersion version;
+
+ /**
+ * Contract information in v0 format.
+ */
+ struct TALER_MerchantContractV0 v0;
+
+ /**
+ * Order information passed in in v1 format.
+ */
+ struct TALER_MerchantContractV1 v1;
+};
+
+/**
+ * Serialize @a contract to a JSON object, ready to be stored in the database.
+ * The @a contract can be of v0 or v1.
+ *
+ * @param[in] contract contract struct to serialize
+ * @param[out] out serialized contract as JSON object
+ * @return #GNUNET_OK on success
+ * #GNUNET_NO if @a contract was not valid
+ * #GNUNET_SYSERR on failure
+ */
+enum GNUNET_GenericReturnValue
+TMH_serialize_contract (const struct TALER_MerchantContract *contract,
+ json_t **out);
+
+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
+TMH_serialize_contract_v1 (const struct TALER_MerchantContract *contract,
+ json_t **out); \ No newline at end of file
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
index f886d9f2..1440dcc4 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -226,201 +226,7 @@ struct OrderContext
*/
struct
{
- /**
- * Specified version of the order.
- */
- enum TALER_MerchantContractVersion version;
-
- /**
- * URL where the same contract could be ordered again (if available).
- */
- const char *public_reorder_url;
-
- /**
- * Our order ID.
- */
- const char *order_id;
-
- /**
- * Merchant base URL.
- */
- char *merchant_base_url;
-
- /**
- * TODO: Maybe remove this and set it from settings where we serialize
- * the order to JSON?
- *
- * Merchant's public key
- */
- struct TALER_MerchantPublicKeyP merchant_pub;
-
- /**
- * TODO: Maybe remove this and set it from settings where we serialize
- * the order to JSON?
- *
- * Information like name, website, email, etc. about the merchant.
- */
- json_t *merchant;
-
- /**
- * Timestamp of the order.
- */
- 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.
- */
- const char *nonce;
-
- /**
- * Extra data that is only interpreted by the merchant frontend.
- */
- const json_t *extra;
-
- /**
- * Order information in v0 format.
- */
- struct
- {
- /**
- * 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;
-
- /**
- * Maximum fee as given by the client request.
- */
- struct TALER_Amount max_fee;
- } v0;
-
- /**
- * Order information passed in in v1 format.
- */
- struct
- {
- /**
- * 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;
-
- /**
- * 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 };
- */
- } v1;
-
+ struct TALER_MerchantContract contract;
} parse_order;
/**
@@ -677,11 +483,6 @@ clean_order (void *cls)
json_decref (oc->set_exchanges.exchanges);
oc->set_exchanges.exchanges = NULL;
}
- if (NULL != oc->parse_order.merchant)
- {
- json_decref (oc->parse_order.merchant);
- oc->parse_order.merchant = NULL;
- }
if (NULL != oc->parse_order.fulfillment_message_i18n)
{
json_decref (oc->parse_order.fulfillment_message_i18n);
@@ -1336,86 +1137,18 @@ get_exchange_keys (void *cls,
static void
serialize_order (struct OrderContext *oc)
{
- oc->serialize_order.contract = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("summary",
- oc->parse_order.summary),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_object_incref ("summary_i18n",
- oc->parse_order.summary_i18n)),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string ("public_reorder_url",
- oc->parse_order.public_reorder_url)),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string ("fulfillment_message",
- oc->parse_order.fulfillment_message)),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_object_incref ("fulfillment_message_i18n",
- oc->parse_order.fulfillment_message_i18n)),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string ("fulfillment_url",
- oc->parse_order.fulfillment_url)),
- GNUNET_JSON_pack_array_incref ("products",
- oc->merge_inventory.products),
- GNUNET_JSON_pack_data_auto ("h_wire",
- &oc->add_payment_details.wm->h_wire),
- GNUNET_JSON_pack_string ("wire_method",
- oc->add_payment_details.wm->wire_method),
- GNUNET_JSON_pack_string ("order_id",
- oc->parse_order.order_id),
- GNUNET_JSON_pack_timestamp ("timestamp",
- oc->parse_order.timestamp),
- GNUNET_JSON_pack_timestamp ("pay_deadline",
- oc->parse_order.pay_deadline),
- GNUNET_JSON_pack_timestamp ("wire_transfer_deadline",
- oc->parse_order.wire_deadline),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_timestamp ("delivery_date",
- oc->parse_order.delivery_date)),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_object_incref ("delivery_location",
- oc->parse_order.delivery_location)),
- GNUNET_JSON_pack_string ("merchant_base_url",
- oc->parse_order.merchant_base_url),
- GNUNET_JSON_pack_object_incref ("merchant",
- oc->parse_order.merchant),
- GNUNET_JSON_pack_data_auto ("merchant_pub",
- &oc->hc->instance->merchant_pub),
- GNUNET_JSON_pack_array_incref ("exchanges",
- oc->set_exchanges.exchanges),
- TALER_JSON_pack_amount ("max_fee",
- &oc->set_max_fee.max_fee),
- TALER_JSON_pack_amount ("amount",
- &oc->parse_order.brutto),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_object_incref ("extra",
- (json_t *) oc->parse_order.extra))
- );
-
- /* Pack does not work here, because it doesn't set zero-values for timestamps */
- GNUNET_assert (0 ==
- json_object_set_new (oc->serialize_order.contract,
- "refund_deadline",
- GNUNET_JSON_from_timestamp (
- oc->parse_order.refund_deadline)));
- GNUNET_log (
- GNUNET_ERROR_TYPE_INFO,
- "Refund deadline for contact is %llu\n",
- (unsigned long long) oc->parse_order.refund_deadline.abs_time.abs_value_us);
- GNUNET_log (
- GNUNET_ERROR_TYPE_INFO,
- "Wallet timestamp for contact is %llu\n",
- (unsigned long long) oc->parse_order.timestamp.abs_time.abs_value_us);
-
- /* Pack does not work here, because it sets zero-values for relative times */
- /* auto_refund should only be set if it is not 0 */
- if (! GNUNET_TIME_relative_is_zero (oc->parse_order.auto_refund))
- {
- GNUNET_assert (0 ==
- json_object_set_new (oc->serialize_order.contract,
- "auto_refund",
- GNUNET_JSON_from_time_rel (
- oc->parse_order.auto_refund)));
- }
+ const struct TALER_MERCHANTDB_InstanceSettings *settings =
+ &oc->hc->instance->settings;
+
+ ret = TMH_serialize_contract_v0(
+ oc->parse_order.contract,
+ oc->hc->instance,
+ oc->add_payment_details.wm,
+ oc->set_exchanges.exchanges,
+ oc->merge_inventory.products,
+ oc->set_max_fee.max_fee,
+ oc->serialize_order.contract
+ );
oc->phase++;
}
@@ -1929,53 +1662,6 @@ parse_order_v0 (struct OrderContext *oc)
return;
}
- {
- oc->parse_order.merchant = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("name",
- settings->name),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string ("website",
- settings->website)),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string ("email",
- settings->email)),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string ("logo",
- settings->logo)));
- GNUNET_assert (NULL != oc->parse_order.merchant);
- {
- json_t *loca;
-
- /* Handle merchant address */
- loca = settings->address;
- if (NULL != loca)
- {
- loca = json_deep_copy (loca);
- GNUNET_assert (NULL != loca);
- GNUNET_assert (0 ==
- json_object_set_new (oc->parse_order.merchant,
- "address",
- loca));
- }
- }
- {
- json_t *juri;
-
- /* Handle merchant jurisdiction */
- juri = settings->jurisdiction;
- if (NULL != juri)
- {
- juri = json_deep_copy (juri);
- GNUNET_assert (NULL != juri);
- GNUNET_assert (0 ==
- json_object_set_new (oc->parse_order.merchant,
- "jurisdiction",
- juri));
- }
- }
- }
-
- oc->parse_order.merchant_pub = oc->hc->instance->merchant_pub;
if ( (NULL != oc->parse_order.delivery_location) &&
(! TMH_location_object_valid (oc->parse_order.delivery_location)) )
{