diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-02-02 17:29:09 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-02-02 17:29:09 +0100 |
commit | b9b9e1e26be74c97a5f17ed30b55410430a974dc (patch) | |
tree | 2e1131adaf5badec155771c68eb5cdaf66b3026a /src | |
parent | 3e2fe5b67a85113d6c977c97c524b96679b4d045 (diff) | |
download | merchant-b9b9e1e26be74c97a5f17ed30b55410430a974dc.tar.gz merchant-b9b9e1e26be74c97a5f17ed30b55410430a974dc.tar.bz2 merchant-b9b9e1e26be74c97a5f17ed30b55410430a974dc.zip |
only fill out merchant info if not given
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/taler-merchant-httpd_proposal.c | 96 |
1 files changed, 51 insertions, 45 deletions
diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c index 17b75786..4026625b 100644 --- a/src/backend/taler-merchant-httpd_proposal.c +++ b/src/backend/taler-merchant-httpd_proposal.c @@ -276,8 +276,11 @@ proposal_put (struct MHD_Connection *connection, "instance")); if (NULL == instance) + { instance = "default"; + } + // Fill in merchant information if necessary { // The frontend either fully specifieds the "merchant" field, or just gives // the backend the "instance" name and lets it fill out. @@ -293,54 +296,57 @@ proposal_put (struct MHD_Connection *connection, TALER_EC_PROPOSAL_ORDER_PARSE_ERROR, "merchant instance not found"); } - merchant = json_object (); - /* FIXME: should the 'instance' field really be included in the - contract? This is really internal to the business! */ - json_object_set_new (merchant, - "instance", - json_string (instance)); - json_object_set_new (merchant, - "name", - json_string (mi->name)); - json_object_set_new (merchant, - "jurisdiction", - json_string ("_mj")); - json_object_set_new (merchant, - "address", - json_string ("_ma")); - json_object_set_new (order, - "merchant", - merchant); - json_object_del (order, - "instance"); - - locations = json_object_get (order, - "locations"); - if (NULL == locations) + if (NULL == json_object_get (order, "merchant")) { - locations = json_object (); + merchant = json_object (); + /* FIXME: should the 'instance' field really be included in the + contract? This is really internal to the business! */ + json_object_set_new (merchant, + "instance", + json_string (instance)); + json_object_set_new (merchant, + "name", + json_string (mi->name)); + json_object_set_new (merchant, + "jurisdiction", + json_string ("_mj")); + json_object_set_new (merchant, + "address", + json_string ("_ma")); json_object_set_new (order, - "locations", - locations); + "merchant", + merchant); + json_object_del (order, + "instance"); + + locations = json_object_get (order, + "locations"); + if (NULL == locations) + { + locations = json_object (); + json_object_set_new (order, + "locations", + locations); + } + + GNUNET_assert (0 < GNUNET_asprintf (&label, "%s-address", mi->id)); + loc = json_object_get (default_locations, label); + if (NULL == loc) + loc = json_object (); + else + loc = json_deep_copy (loc); + json_object_set_new (locations, "_ma", loc); + GNUNET_free (label); + + GNUNET_assert (0 < GNUNET_asprintf (&label, "%s-jurisdiction", mi->id)); + loc = json_object_get (default_locations, label); + if (NULL == loc) + loc = json_object (); + else + loc = json_deep_copy (loc); + json_object_set_new (locations, "_mj", loc); + GNUNET_free (label); } - - GNUNET_assert (0 < GNUNET_asprintf (&label, "%s-address", mi->id)); - loc = json_object_get (default_locations, label); - if (NULL == loc) - loc = json_object (); - else - loc = json_deep_copy (loc); - json_object_set_new (locations, "_ma", loc); - GNUNET_free (label); - - GNUNET_assert (0 < GNUNET_asprintf (&label, "%s-jurisdiction", mi->id)); - loc = json_object_get (default_locations, label); - if (NULL == loc) - loc = json_object (); - else - loc = json_deep_copy (loc); - json_object_set_new (locations, "_mj", loc); - GNUNET_free (label); } /* extract fields we need to sign separately */ |