diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-01 22:49:04 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-01 22:49:04 +0200 |
commit | 92b86cc5a7277de1a3b3ab55aaf37c83a649930e (patch) | |
tree | eef73525a65c6fe6825559f050b8ea971ca8302a /src/backend/taler-merchant-httpd_post-orders-ID-refund.c | |
parent | 4e18bf19dfed52aa448a0b0d8547c0be182ba36a (diff) | |
download | merchant-92b86cc5a7277de1a3b3ab55aaf37c83a649930e.tar.gz merchant-92b86cc5a7277de1a3b3ab55aaf37c83a649930e.tar.bz2 merchant-92b86cc5a7277de1a3b3ab55aaf37c83a649930e.zip |
finish implementing #6935
Diffstat (limited to 'src/backend/taler-merchant-httpd_post-orders-ID-refund.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_post-orders-ID-refund.c | 111 |
1 files changed, 55 insertions, 56 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c index 22c9f717..27622d63 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2020 Taler Systems SA + (C) 2020-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 @@ -738,60 +738,60 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, { if (NULL == cr->exchange_reply) { - refund = json_pack ("{s:s,s:I,s:I,s:o,s:o,s:o}", - "type", - "failure", - "exchange_status", - (json_int_t) cr->exchange_status, - "rtransaction_id", - (json_int_t) cr->rtransaction_id, - "coin_pub", - GNUNET_JSON_from_data_auto (&cr->coin_pub), - "refund_amount", - TALER_JSON_from_amount (&cr->refund_amount), - "execution_time", - GNUNET_JSON_from_time_abs (cr->execution_time)); + refund = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("type", + "failure"), + GNUNET_JSON_pack_uint64 ("exchange_status", + cr->exchange_status), + GNUNET_JSON_pack_uint64 ("rtransaction_id", + cr->rtransaction_id), + GNUNET_JSON_pack_data_auto ("coin_pub", + &cr->coin_pub), + TALER_JSON_pack_amount ("refund_amount", + &cr->refund_amount), + GNUNET_JSON_pack_time_abs ("execution_time", + cr->execution_time)); } else { - refund = json_pack ("{s:s,s:I,s:I,s:O,s:I,s:o,s:o,s:o}", - "type", - "failure", - "exchange_status", - (json_int_t) cr->exchange_status, - "exchange_code", - (json_int_t) cr->exchange_code, - "exchange_reply", - cr->exchange_reply, - "rtransaction_id", - (json_int_t) cr->rtransaction_id, - "coin_pub", - GNUNET_JSON_from_data_auto (&cr->coin_pub), - "refund_amount", - TALER_JSON_from_amount (&cr->refund_amount), - "execution_time", - GNUNET_JSON_from_time_abs (cr->execution_time)); + refund = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("type", + "failure"), + GNUNET_JSON_pack_uint64 ("exchange_status", + cr->exchange_status), + GNUNET_JSON_pack_uint64 ("exchange_code", + cr->exchange_code), + GNUNET_JSON_pack_object_incref ("exchange_reply", + cr->exchange_reply), + GNUNET_JSON_pack_uint64 ("rtransaction_id", + cr->rtransaction_id), + GNUNET_JSON_pack_data_auto ("coin_pub", + &cr->coin_pub), + TALER_JSON_pack_amount ("refund_amount", + &cr->refund_amount), + GNUNET_JSON_pack_time_abs ("execution_time", + cr->execution_time)); } } else { - refund = json_pack ("{s:s,s:I,s:o,s:o,s:I,s:o,s:o,s:o}", - "type", - "success", - "exchange_status", - (json_int_t) cr->exchange_status, - "exchange_sig", - GNUNET_JSON_from_data_auto (&cr->exchange_sig), - "exchange_pub", - GNUNET_JSON_from_data_auto (&cr->exchange_pub), - "rtransaction_id", - (json_int_t) cr->rtransaction_id, - "coin_pub", - GNUNET_JSON_from_data_auto (&cr->coin_pub), - "refund_amount", - TALER_JSON_from_amount (&cr->refund_amount), - "execution_time", - GNUNET_JSON_from_time_abs (cr->execution_time)); + refund = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("type", + "success"), + GNUNET_JSON_pack_uint64 ("exchange_status", + cr->exchange_status), + GNUNET_JSON_pack_data_auto ("exchange_sig", + &cr->exchange_sig), + GNUNET_JSON_pack_data_auto ("exchange_pub", + &cr->exchange_pub), + GNUNET_JSON_pack_uint64 ("rtransaction_id", + cr->rtransaction_id), + GNUNET_JSON_pack_data_auto ("coin_pub", + &cr->coin_pub), + TALER_JSON_pack_amount ("refund_amount", + &cr->refund_amount), + GNUNET_JSON_pack_time_abs ("execution_time", + cr->execution_time)); } GNUNET_assert ( 0 == @@ -799,16 +799,15 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, refund)); } - return TALER_MHD_reply_json_pack ( + return TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_OK, - "{s:o, s:o, s:o}", - "refund_amount", - TALER_JSON_from_amount (&prd->refund_amount), - "refunds", - ra, - "merchant_pub", - GNUNET_JSON_from_data_auto (&hc->instance->merchant_pub)); + TALER_JSON_pack_amount ("refund_amount", + &prd->refund_amount), + GNUNET_JSON_pack_array_steal ("refunds", + ra), + GNUNET_JSON_pack_data_auto ("merchant_pub", + &hc->instance->merchant_pub)); } return MHD_YES; |