diff options
author | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-07-25 16:24:20 -0400 |
---|---|---|
committer | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-07-25 16:24:20 -0400 |
commit | d78afeb1a0d5c45dcd64e27ff8b7e9ca73bfce21 (patch) | |
tree | 1529509a8c3b5067b5860997a051d6f5bcc192f7 /src/backend/taler-merchant-httpd_private-post-orders.c | |
parent | 469ea4f5c7a23ac89965bca8139e17d7bd26b9f0 (diff) | |
download | merchant-d78afeb1a0d5c45dcd64e27ff8b7e9ca73bfce21.tar.gz merchant-d78afeb1a0d5c45dcd64e27ff8b7e9ca73bfce21.tar.bz2 merchant-d78afeb1a0d5c45dcd64e27ff8b7e9ca73bfce21.zip |
move refund_delay to request body in POST /orders
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-post-orders.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-orders.c | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c index 64dcce4c..76126dd2 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders.c +++ b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -540,6 +540,7 @@ static MHD_RESULT patch_order (struct MHD_Connection *connection, struct TMH_HandlerContext *hc, json_t *order, + struct GNUNET_TIME_Relative refund_delay, unsigned int inventory_products_length, const struct InventoryProduct inventory_products[], unsigned int uuids_length, @@ -604,28 +605,8 @@ patch_order (struct MHD_Connection *connection, if (NULL == json_object_get (order, "refund_deadline")) { - const char *refdel_s; - struct GNUNET_TIME_Absolute rd = { 0 }; - - refdel_s = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - "refund_delay"); - if (NULL != refdel_s) - { - struct GNUNET_TIME_Relative r; - - if (GNUNET_OK != - GNUNET_STRINGS_fancy_time_to_relative (refdel_s, - &r)) - { - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, - "refund_delay"); - - } - rd = GNUNET_TIME_relative_to_absolute (r); - } + struct GNUNET_TIME_Absolute rd = + GNUNET_TIME_relative_to_absolute (refund_delay); GNUNET_assert (0 == json_object_set_new (order, "refund_deadline", @@ -831,6 +812,7 @@ static MHD_RESULT add_payment_details (struct MHD_Connection *connection, struct TMH_HandlerContext *hc, json_t *order, + struct GNUNET_TIME_Relative refund_delay, const char *payment_target, unsigned int inventory_products_length, const struct InventoryProduct inventory_products[], @@ -874,6 +856,7 @@ add_payment_details (struct MHD_Connection *connection, return patch_order (connection, hc, order, + refund_delay, inventory_products_length, inventory_products, uuids_length, @@ -899,6 +882,7 @@ static MHD_RESULT merge_inventory (struct MHD_Connection *connection, struct TMH_HandlerContext *hc, json_t *order, + struct GNUNET_TIME_Relative refund_delay, const char *payment_target, unsigned int inventory_products_length, const struct InventoryProduct inventory_products[], @@ -995,6 +979,7 @@ merge_inventory (struct MHD_Connection *connection, return add_payment_details (connection, hc, order, + refund_delay, payment_target, inventory_products_length, inventory_products, @@ -1019,6 +1004,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, struct TMH_HandlerContext *hc) { json_t *order; + struct GNUNET_TIME_Relative refund_delay; const char *payment_target = NULL; unsigned int ips_len = 0; struct InventoryProduct *ips = NULL; @@ -1035,7 +1021,29 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, TALER_EC_PARAMETER_MISSING, "order"); } + /* parse the refund_delay (optionally given) */ + if (NULL != json_object_get (hc->request_body, + "refund_delay")) + { + enum GNUNET_GenericReturnValue res; + struct GNUNET_JSON_Specification spec[] = { + TALER_JSON_spec_relative_time ("refund_delay", + &refund_delay), + GNUNET_JSON_spec_end () + }; + res = TALER_MHD_parse_json_data (connection, + hc->request_body, + spec); + if (GNUNET_OK != res) + return (GNUNET_NO == res) + ? MHD_YES + : MHD_NO; + } + else + { + refund_delay.rel_value_us = 0; + } /* parse the payment_target (optionally given) */ { const json_t *pt; @@ -1171,6 +1179,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, res = merge_inventory (connection, hc, order, + refund_delay, payment_target, ips_len, ips, |