From 22e11d40868f0fe49350132e3c4f0a9ea926a643 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 1 Aug 2021 16:13:49 +0200 Subject: -more work on #6935 --- src/backend/taler-merchant-httpd_get-orders-ID.c | 96 ++++++++++++------------ 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c index b061ff43..75121207 100644 --- a/src/backend/taler-merchant-httpd_get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_get-orders-ID.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2014-2020 Taler Systems SA + (C) 2014-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 @@ -573,16 +573,15 @@ send_pay_request (struct GetOrderData *god, enum GNUNET_GenericReturnValue res; json_t *context; - context = json_pack ("{s:s, s:s, s:s, s:s}", - "taler_pay_uri", - taler_pay_uri, - "order_status_url", - order_status_url, - "taler_pay_qrcode_svg", - qr, - "order_summary", - get_order_summary (god)); - GNUNET_assert (NULL != context); + context = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("taler_pay_uri", + taler_pay_uri), + GNUNET_JSON_pack_string ("order_status_url", + order_status_url), + GNUNET_JSON_pack_string ("taler_pay_qrcode_svg", + qr), + GNUNET_JSON_pack_string ("order_summary", + get_order_summary (god))); res = TMH_return_from_template (god->sc.con, MHD_HTTP_PAYMENT_REQUIRED, "request_payment", @@ -605,15 +604,16 @@ send_pay_request (struct GetOrderData *god, } else /* end of 'generate HTML' */ { - ret = TALER_MHD_reply_json_pack (god->sc.con, - MHD_HTTP_PAYMENT_REQUIRED, - "{s:s, s:s?, s:s?}", - "taler_pay_uri", - taler_pay_uri, - "fulfillment_url", - god->fulfillment_url, - "already_paid_order_id", - already_paid_order_id); + ret = TALER_MHD_REPLY_JSON_PACK ( + god->sc.con, + MHD_HTTP_PAYMENT_REQUIRED, + GNUNET_JSON_pack_string ("taler_pay_uri", + taler_pay_uri), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_string ("fulfillment_url", + god->fulfillment_url)), + GNUNET_JSON_pack_string ("already_paid_order_id", + already_paid_order_id)); } GNUNET_free (taler_pay_uri); GNUNET_free (order_status_url); @@ -1020,11 +1020,11 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, return ret; } /* Need to generate JSON reply */ - return TALER_MHD_reply_json_pack (connection, - MHD_HTTP_ACCEPTED, - "{s:s}", - "public_reorder_url", - public_reorder_url); + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_ACCEPTED, + GNUNET_JSON_pack_string ("public_reorder_url", + public_reorder_url)); } if (god->unclaimed) @@ -1201,16 +1201,15 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, { json_t *context; - context = json_pack ("{s:s, s:s, s:s, s:s}", - "order_summary", - get_order_summary (god), - "refund_amount", - TALER_amount2s (&god->refund_amount), - "taler_refund_uri", - uri, - "taler_refund_qrcode_svg", - qr); - GNUNET_assert (NULL != context); + context = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("order_summary", + get_order_summary (god)), + TALER_JSON_pack_amount ("refund_amount", + &god->refund_amount), + GNUNET_JSON_pack_string ("taler_refund_uri", + uri), + GNUNET_JSON_pack_string ("taler_refund_qrcode_svg", + qr)); res = TMH_return_from_template (god->sc.con, MHD_HTTP_OK, "offer_refund", @@ -1226,14 +1225,13 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, { json_t *context; - context = json_pack ("{s:O, s:s, s:s}", - "contract_terms", - god->contract_terms, - "order_summary", - get_order_summary (god), - "refund_amount", - TALER_amount2s (&god->refund_amount)); - GNUNET_assert (NULL != context); + context = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_object_incref ("contract_terms", + god->contract_terms), + GNUNET_JSON_pack_string ("order_summary", + get_order_summary (god)), + TALER_JSON_pack_amount ("refund_amount", + &god->refund_amount)); res = TMH_return_from_template (god->sc.con, MHD_HTTP_OK, "show_order_details", @@ -1249,13 +1247,15 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, } return MHD_YES; } - return TALER_MHD_reply_json_pack ( + return TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_OK, - "{s:b, s:b, s:o}", - "refunded", god->refunded, - "refund_pending", god->refund_available, - "refund_amount", TALER_JSON_from_amount (&god->refund_amount)); + GNUNET_JSON_pack_bool ("refunded", + god->refunded), + GNUNET_JSON_pack_bool ("refund_pending", + god->refund_available), + TALER_JSON_pack_amount ("refund_amount", + &god->refund_amount)); } -- cgit v1.2.3