diff options
author | Christian Blättler <blatc2@bfh.ch> | 2024-03-08 08:15:57 +0100 |
---|---|---|
committer | Christian Blättler <blatc2@bfh.ch> | 2024-03-08 08:15:57 +0100 |
commit | 1261d9053ca1971c6d3f99adbe51d64d93b02d1b (patch) | |
tree | fc97a7d056c42057e45c858ad28c37bc26b6cb35 /src | |
parent | a3635fbe2dac0d1827ee45504e3e3b1e08c392ce (diff) | |
download | merchant-1261d9053ca1971c6d3f99adbe51d64d93b02d1b.tar.gz merchant-1261d9053ca1971c6d3f99adbe51d64d93b02d1b.tar.bz2 merchant-1261d9053ca1971c6d3f99adbe51d64d93b02d1b.zip |
build merchant information in serialization phase
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-orders.c | 99 |
1 files changed, 51 insertions, 48 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c index d2159246..876ca476 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders.c +++ b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -322,7 +322,7 @@ struct OrderContext * * Information like name, website, email, etc. about the merchant. */ - json_t *merchant; + // json_t *merchant; /** * TODO: Maybe remove this and set it from settings where we serialize @@ -1298,8 +1298,57 @@ get_exchange_keys (void *cls, static void serialize_order (struct OrderContext *oc) { + const struct TALER_MERCHANTDB_InstanceSettings *settings = + &oc->hc->instance->settings; struct TALER_MerchantContractChoice *choice = oc->parse_order.choices; struct TALER_MerchantContractLimits *limits = oc->set_max_fee.limits; + json_t *merchant = NULL; + + { + 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; + + /* 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 (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 (merchant, + "jurisdiction", + juri)); + } + } + } // TODO: How to properly handle these cases / errors? GNUNET_assert (1 == oc->parse_order.choices_len && NULL != choice); @@ -1346,7 +1395,7 @@ serialize_order (struct OrderContext *oc) GNUNET_JSON_pack_string ("merchant_base_url", oc->parse_order.merchant_base_url), GNUNET_JSON_pack_object_incref ("merchant", - oc->parse_order.merchant), + merchant), GNUNET_JSON_pack_data_auto ("merchant_pub", &oc->hc->instance->merchant_pub), GNUNET_JSON_pack_array_incref ("exchanges", @@ -1889,52 +1938,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)) ) |