[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant] 01/02: fill in missing proposal fields
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant] 01/02: fill in missing proposal fields |
Date: |
Wed, 10 Jan 2018 17:23:55 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository merchant.
commit e06b52d21a1494fe8662214c3ecfdb7e4203338a
Author: Florian Dold <address@hidden>
AuthorDate: Wed Jan 10 16:11:25 2018 +0100
fill in missing proposal fields
---
src/backend/taler-merchant-httpd.c | 11 +++++++++
src/backend/taler-merchant-httpd.h | 6 ++++-
src/backend/taler-merchant-httpd_proposal.c | 35 +++++++++++++++++++++++++++++
3 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/src/backend/taler-merchant-httpd.c
b/src/backend/taler-merchant-httpd.c
index f5705c8..2bf927d 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -557,6 +557,17 @@ instances_iterator_cb (void *cls,
mi = GNUNET_new (struct MerchantInstance);
if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (iic->config, section, "NAME",
&mi->name))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "NAME");
+ GNUNET_free (mi);
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+
+ if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (iic->config,
section,
"KEYFILE",
diff --git a/src/backend/taler-merchant-httpd.h
b/src/backend/taler-merchant-httpd.h
index 91dc7a2..1e917e7 100644
--- a/src/backend/taler-merchant-httpd.h
+++ b/src/backend/taler-merchant-httpd.h
@@ -87,6 +87,11 @@ struct MerchantInstance
char *id;
/**
+ * Legal name of the merchant.
+ */
+ char *name;
+
+ /**
* File holding the merchant's private key
*/
char *keyfile;
@@ -130,7 +135,6 @@ struct MerchantInstance
* Only valid if @e tip_exchange is non-null.
*/
struct TALER_ReservePrivateKeyP tip_reserve;
-
};
diff --git a/src/backend/taler-merchant-httpd_proposal.c
b/src/backend/taler-merchant-httpd_proposal.c
index f3fee47..bbd7d39 100644
--- a/src/backend/taler-merchant-httpd_proposal.c
+++ b/src/backend/taler-merchant-httpd_proposal.c
@@ -248,6 +248,41 @@ proposal_put (struct MHD_Connection *connection,
json_integer ((json_int_t)
default_wire_fee_amortization));
}
+ if (NULL == json_object_get (order, "pay_url"))
+ {
+ char *url;
+ url = TMH_make_absolute_backend_url (connection, "pay", NULL);
+ json_object_set_new (order, "pay_url", json_string (url));
+ }
+
+ if (NULL == json_object_get (order, "products"))
+ {
+ // FIXME: When there is no explicit product,
+ // should we create a singleton product list?
+ json_object_set_new (order, "products", json_object ());
+ }
+
+ const char *instance = json_string_value (json_object_get (order,
"instance"));
+ if (NULL != instance)
+ {
+ // The frontend either fully specifieds the "merchant" field, or just gives
+ // the backend the "instance" name and lets it fill out.
+ struct MerchantInstance *mi = TMH_lookup_instance (instance);
+ if (NULL == mi)
+ {
+ return TMH_RESPONSE_reply_internal_error (connection,
+
TALER_EC_PROPOSAL_ORDER_PARSE_ERROR,
+ "merchant instance not found");
+ }
+ json_t *merchant = json_object ();
+ 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 ("none"));
+ json_object_set_new (merchant, "address", json_string ("none"));
+ json_object_set_new (order, "merchant", merchant);
+ json_object_del (order, "instance");
+ }
+
/* extract fields we need to sign separately */
res = TMH_PARSE_json_data (connection,
order,
--
To stop receiving notification emails like this one, please contact
address@hidden