summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_proposal.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-06 18:21:45 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-06 18:21:45 +0100
commita4f578ba3da614a41fd4c31017f702b2db7d90dc (patch)
treea2aa03ea802c02fbbb57ba96186b12f4eecd0cf5 /src/backend/taler-merchant-httpd_proposal.c
parentd3e568e2d1c5dee55856d3ac44e77cb4af80b39f (diff)
downloadmerchant-a4f578ba3da614a41fd4c31017f702b2db7d90dc.tar.gz
merchant-a4f578ba3da614a41fd4c31017f702b2db7d90dc.tar.bz2
merchant-a4f578ba3da614a41fd4c31017f702b2db7d90dc.zip
implement #4935 (wire fee support)
Diffstat (limited to 'src/backend/taler-merchant-httpd_proposal.c')
-rw-r--r--src/backend/taler-merchant-httpd_proposal.c51
1 files changed, 42 insertions, 9 deletions
diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c
index 09b221ee..0d96a1f6 100644
--- a/src/backend/taler-merchant-httpd_proposal.c
+++ b/src/backend/taler-merchant-httpd_proposal.c
@@ -170,35 +170,67 @@ proposal_put (struct MHD_Connection *connection,
time (&timer);
tm_info = localtime (&timer);
- off = strftime (buf, sizeof (buf), "%H:%M:%S", tm_info);
+ off = strftime (buf,
+ sizeof (buf),
+ "%H:%M:%S",
+ tm_info);
snprintf (buf + off, sizeof (buf) - off,
"-%llX",
- (long long unsigned) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX));
- json_object_set (order, "order_id", json_string (buf));
+ (long long unsigned) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+ UINT64_MAX));
+ json_object_set (order,
+ "order_id",
+ json_string (buf));
}
- if (NULL == json_string_value (json_object_get (order, "timestamp")))
+ if (NULL == json_object_get (order,
+ "timestamp"))
{
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+
(void) GNUNET_TIME_round_abs (&now);
- json_object_set (order, "timestamp", GNUNET_JSON_from_time_abs (now));
+ json_object_set (order,
+ "timestamp",
+ GNUNET_JSON_from_time_abs (now));
}
- if (NULL == json_string_value (json_object_get (order, "refund_deadline")))
+ if (NULL == json_object_get (order,
+ "refund_deadline"))
{
struct GNUNET_TIME_Absolute zero = { 0 };
- json_object_set (order, "refund_deadline", GNUNET_JSON_from_time_abs (zero));
+
+ json_object_set (order,
+ "refund_deadline",
+ GNUNET_JSON_from_time_abs (zero));
}
- if (NULL == json_string_value (json_object_get (order, "pay_deadline")))
+ if (NULL == json_object_get (order,
+ "pay_deadline"))
{
struct GNUNET_TIME_Absolute t;
+
/* FIXME: read the delay for pay_deadline from config */
- t = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_HOURS);
+ t = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS);
(void) GNUNET_TIME_round_abs (&t);
json_object_set (order, "pay_deadline", GNUNET_JSON_from_time_abs (t));
}
+ if (NULL == json_object_get (order,
+ "max_wire_fee"))
+ {
+ json_object_set (order,
+ "max_wire_fee",
+ TALER_JSON_from_amount (&default_max_wire_fee));
+ }
+
+ if (NULL == json_object_get (order,
+ "wire_fee_amortization"))
+ {
+ json_object_set (order,
+ "wire_fee_amortization",
+ json_integer ((json_int_t) default_wire_fee_amortization));
+ }
+
/* extract fields we need to sign separately */
res = TMH_PARSE_json_data (connection, order, spec);
if (GNUNET_NO == res)
@@ -348,6 +380,7 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh,
return res;
}
+
/**
* Manage a GET /proposal request. Query the db and returns the
* proposal's data related to the transaction id given as the URL's