diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-03-19 15:19:00 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-03-19 15:19:00 +0100 |
commit | 110b61ff12208ffbb022296097b85d28cc1cfe7e (patch) | |
tree | 414c0de1ffe90685effe7230883c085239f7ce46 /src/backend/taler-merchant-httpd_private-post-orders.c | |
parent | 88a23388c11a755fece7221579be1143e48d32c5 (diff) |
address TODOsCodeBlau-NGI-t2.7
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-post-orders.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-orders.c | 118 |
1 files changed, 45 insertions, 73 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c index 92d35b78..be8b8d1d 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders.c +++ b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -303,25 +303,9 @@ struct OrderContext const json_t *products; /** - * 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. + * Gross amount value of the contract. Used to + * compute @e max_stefan_fee. */ - json_t *merchant; - - /** - * 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; - - /** - * Gross amount value of the contract. Used to - * compute @e max_stefan_fee. - */ struct TALER_Amount brutto; /** @@ -620,11 +604,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); @@ -652,7 +631,6 @@ clean_order (void *cls) oc->parse_request.uuids_length, 0); json_decref (oc->parse_request.order); - /* TODO: Check that all other fields are cleaned up! */ json_decref (oc->serialize_order.contract); GNUNET_free (oc->parse_order.merchant_base_url); GNUNET_free (oc); @@ -1285,6 +1263,47 @@ get_exchange_keys (void *cls, static void serialize_order (struct OrderContext *oc) { + const struct TALER_MERCHANTDB_InstanceSettings *settings = + &oc->hc->instance->settings; + json_t *merchant; + + 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 != merchant); + { + json_t *loca = settings->address; + + if (NULL != loca) + { + GNUNET_assert (0 == + json_object_set (merchant, + "address", + loca)); + } + } + { + json_t *juri = settings->jurisdiction; + + /* Handle merchant jurisdiction */ + if (NULL != juri) + { + GNUNET_assert (0 == + json_object_set (merchant, + "jurisdiction", + juri)); + } + } + oc->serialize_order.contract = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("summary", oc->parse_order.summary), @@ -1325,8 +1344,8 @@ serialize_order (struct OrderContext *oc) 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_object_steal ("merchant", + merchant), GNUNET_JSON_pack_data_auto ("merchant_pub", &oc->hc->instance->merchant_pub), GNUNET_JSON_pack_array_incref ("exchanges", @@ -1857,53 +1876,6 @@ parse_order (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)) ) { |