diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-get-orders.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-orders.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c index 3504105c..5b1ab934 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders.c +++ b/src/backend/taler-merchant-httpd_private-get-orders.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2019, 2020 Taler Systems SA + (C) 2019-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -266,8 +266,10 @@ add_order (void *cls, json_t *contract_terms; struct GNUNET_HashCode h_contract_terms; enum GNUNET_DB_QueryStatus qs; + const char *summary; bool refundable = false; bool paid; + struct TALER_Amount order_amount; qs = TMH_db->lookup_order_status (TMH_db->cls, po->instance_id, @@ -317,7 +319,6 @@ add_order (void *cls, } { - struct TALER_Amount order_amount; struct GNUNET_TIME_Absolute rd; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount ("amount", @@ -325,6 +326,8 @@ add_order (void *cls, &order_amount), GNUNET_JSON_spec_absolute_time ("refund_deadline", &rd), + GNUNET_JSON_spec_string ("summary", + &summary), GNUNET_JSON_spec_end () }; @@ -368,24 +371,21 @@ add_order (void *cls, GNUNET_assert (0 == json_array_append_new ( po->pa, - json_pack ( - "{s:s, s:I, s:o, s:O, s:O, s:b, s:b}", - "order_id", - order_id, - "row_id", - (json_int_t) order_serial, - "timestamp", - GNUNET_JSON_from_time_abs (creation_time), - "amount", - json_object_get (contract_terms, - "amount"), - "summary", - json_object_get (contract_terms, - "summary"), - "refundable", - refundable, - "paid", - paid))); + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("order_id", + order_id), + GNUNET_JSON_pack_uint64 ("row_id", + order_serial), + GNUNET_JSON_pack_time_abs ("timestamp", + creation_time), + TALER_JSON_pack_amount ("amount", + &order_amount), + GNUNET_JSON_pack_string ("summary", + summary), + GNUNET_JSON_pack_bool ("refundable", + refundable), + GNUNET_JSON_pack_bool ("paid", + paid)))); json_decref (contract_terms); } @@ -487,10 +487,11 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, po->result, NULL); } - return TALER_MHD_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:O}", - "orders", po->pa); + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_incref ("orders", + po->pa)); } if (! (TALER_arg_to_yna (connection, @@ -738,10 +739,11 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, } return MHD_YES; } - return TALER_MHD_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:O}", - "orders", po->pa); + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_incref ("orders", + po->pa)); } |