diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_post-tips-ID-pickup.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_post-tips-ID-pickup.c | 82 |
1 files changed, 29 insertions, 53 deletions
diff --git a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c index 2bdef2bc..bd327b56 100644 --- a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c +++ b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2017-2020 Taler Systems SA + (C) 2017-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -25,6 +25,7 @@ #include <taler/taler_signatures.h> #include "taler-merchant-httpd.h" #include "taler-merchant-httpd_mhd.h" +#include "taler-merchant-httpd_helper.h" #include "taler-merchant-httpd_exchanges.h" #include "taler-merchant-httpd_post-tips-ID-pickup.h" @@ -292,12 +293,9 @@ withdraw_cb (void *cls, stop_operations (pc); pc->http_status = MHD_HTTP_BAD_GATEWAY; pc->response = - TALER_MHD_make_json_pack ( - "{s:I, s:I, s:I, s:O}", - "code", (json_int_t) TALER_EC_MERCHANT_TIP_PICKUP_EXCHANGE_ERROR, - "exchange_code", (json_int_t) hr->ec, - "exchange_http_status", (json_int_t) hr->http_status, - "exchange_reply", hr->reply); + TALER_MHD_MAKE_JSON_PACK ( + TALER_JSON_pack_ec (TALER_EC_MERCHANT_TIP_PICKUP_EXCHANGE_ERROR), + TMH_pack_exchange_reply (hr)); MHD_resume_connection (pc->connection); TMH_trigger_daemon (); /* we resumed, kick MHD */ return; @@ -359,13 +357,9 @@ do_withdraw (void *cls, po); GNUNET_free (po); pc->http_status = MHD_HTTP_GATEWAY_TIMEOUT; - pc->response = TALER_MHD_make_json_pack ( - "{s:s, s:I}", - "hint", - TALER_ErrorCode_get_hint ( - TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT), - "code", - (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT); + pc->response = TALER_MHD_MAKE_JSON_PACK ( + TALER_JSON_pack_ec ( + TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT)); MHD_resume_connection (pc->connection); TMH_trigger_daemon (); /* we resumed, kick MHD */ return; @@ -379,14 +373,10 @@ do_withdraw (void *cls, GNUNET_free (po); pc->http_status = MHD_HTTP_BAD_GATEWAY; pc->response = - TALER_MHD_make_json_pack ( - "{s:s, s:I, s:I, s:I, s:O?}", - "hint", TALER_ErrorCode_get_hint ( + TALER_MHD_MAKE_JSON_PACK ( + TALER_JSON_pack_ec ( TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE), - "code", (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE, - "exchange_code", (json_int_t) hr->ec, - "exchange_http_status", (json_int_t) hr->http_status, - "exchange_reply", hr->reply); + TMH_pack_exchange_reply (hr)); MHD_resume_connection (pc->connection); TMH_trigger_daemon (); /* we resumed, kick MHD */ return; @@ -485,10 +475,8 @@ compute_total_requested (void *cls, if (NULL == hr) { pc->http_status = MHD_HTTP_GATEWAY_TIMEOUT; - pc->response = TALER_MHD_make_json_pack ( - "{s:I, s:s}", - "code", (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT, - "hint", TALER_ErrorCode_get_hint ( + pc->response = TALER_MHD_MAKE_JSON_PACK ( + TALER_JSON_pack_ec ( TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT)); MHD_resume_connection (pc->connection); TMH_trigger_daemon (); /* we resumed, kick MHD */ @@ -498,14 +486,10 @@ compute_total_requested (void *cls, { pc->http_status = MHD_HTTP_BAD_GATEWAY; pc->response = - TALER_MHD_make_json_pack ( - "{s:I, s:s, s:I, s:I, s:O}", - "code", (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE, - "hint", TALER_ErrorCode_get_hint ( + TALER_MHD_MAKE_JSON_PACK ( + TALER_JSON_pack_ec ( TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE), - "exchange_code", (json_int_t) hr->ec, - "exchange_http_status", (json_int_t) hr->http_status, - "exchange_reply", hr->reply); + TMH_pack_exchange_reply (hr)); MHD_resume_connection (pc->connection); TMH_trigger_daemon (); /* we resumed, kick MHD */ return; @@ -514,14 +498,10 @@ compute_total_requested (void *cls, { pc->http_status = MHD_HTTP_BAD_GATEWAY; pc->response = - TALER_MHD_make_json_pack ( - "{s:I, s:s, s:I, s:I, s:O}", - "code", (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE, - "hint", TALER_ErrorCode_get_hint ( + TALER_MHD_MAKE_JSON_PACK ( + TALER_JSON_pack_ec ( TALER_EC_MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE), - "exchange_code", (json_int_t) hr->ec, - "exchange_http_status", (json_int_t) hr->http_status, - "exchange_reply", hr->reply); + TMH_pack_exchange_reply (hr)); MHD_resume_connection (pc->connection); TMH_trigger_daemon (); /* we resumed, kick MHD */ return; @@ -540,13 +520,10 @@ compute_total_requested (void *cls, { pc->http_status = MHD_HTTP_CONFLICT; pc->response = - TALER_MHD_make_json_pack ( - "{s:I, s:I, s:I, s:O}", - "code", - (json_int_t) TALER_EC_MERCHANT_TIP_PICKUP_DENOMINATION_UNKNOWN, - "exchange_code", (json_int_t) hr->ec, - "exchange_http_status", (json_int_t) hr->http_status, - "exchange_reply", hr->reply); + TALER_MHD_MAKE_JSON_PACK ( + TALER_JSON_pack_ec ( + TALER_EC_MERCHANT_TIP_PICKUP_DENOMINATION_UNKNOWN), + TMH_pack_exchange_reply (hr)); MHD_resume_connection (pc->connection); TMH_trigger_daemon (); /* we resumed, kick MHD */ return; @@ -869,17 +846,16 @@ RETRY: GNUNET_assert (0 == json_array_append_new ( blind_sigs, - json_pack ("{s:o}", - "blind_sig", - GNUNET_JSON_from_rsa_signature ( - sigs[i])))); + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_rsa_signature ("blind_sig", + sigs[i])))); GNUNET_CRYPTO_rsa_signature_free (sigs[i]); } - return TALER_MHD_reply_json_pack ( + return TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_OK, - "{s:o}", - "blind_sigs", blind_sigs); + GNUNET_JSON_pack_array_steal ("blind_sigs", + blind_sigs)); } break; case GNUNET_DB_STATUS_SOFT_ERROR: |