diff options
Diffstat (limited to 'src/lib/merchant_api_post_order_refund.c')
-rw-r--r-- | src/lib/merchant_api_post_order_refund.c | 65 |
1 files changed, 23 insertions, 42 deletions
diff --git a/src/lib/merchant_api_post_order_refund.c b/src/lib/merchant_api_post_order_refund.c index be996dc2..4414bd86 100644 --- a/src/lib/merchant_api_post_order_refund.c +++ b/src/lib/merchant_api_post_order_refund.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2021 Taler Systems SA + Copyright (C) 2014-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software @@ -85,30 +85,26 @@ handle_refund_finished (void *cls, { struct TALER_MERCHANT_OrderRefundHandle *orh = cls; const json_t *json = response; - struct TALER_MERCHANT_HttpResponse hr = { - .http_status = (unsigned int) response_code, - .reply = json + struct TALER_MERCHANT_RefundResponse rr = { + .hr.http_status = (unsigned int) response_code, + .hr.reply = json }; orh->job = NULL; switch (response_code) { case 0: - hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; - orh->cb (orh->cb_cls, - &hr, - NULL, - NULL); + rr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: { - const char *taler_refund_uri; - struct TALER_PrivateContractHashP h_contract; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_string ("taler_refund_uri", - &taler_refund_uri), - GNUNET_JSON_spec_fixed_auto ("h_contract", - &h_contract), + GNUNET_JSON_spec_string ( + "taler_refund_uri", + &rr.details.ok.taler_refund_uri), + GNUNET_JSON_spec_fixed_auto ( + "h_contract", + &rr.details.ok.h_contract), GNUNET_JSON_spec_end () }; @@ -118,51 +114,36 @@ handle_refund_finished (void *cls, NULL, NULL)) { GNUNET_break_op (0); - hr.http_status = 0; - hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; - orh->cb (orh->cb_cls, - &hr, - NULL, - NULL); + rr.hr.http_status = 0; + rr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } - orh->cb (orh->cb_cls, - &hr, - taler_refund_uri, - &h_contract); - GNUNET_JSON_parse_free (spec); + break; } - break; case MHD_HTTP_UNAUTHORIZED: - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + rr.hr.ec = TALER_JSON_get_error_code (json); + rr.hr.hint = TALER_JSON_get_error_hint (json); /* Nothing really to verify, merchant says we need to authenticate. */ break; case MHD_HTTP_FORBIDDEN: - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + rr.hr.ec = TALER_JSON_get_error_code (json); + rr.hr.hint = TALER_JSON_get_error_hint (json); /* Nothing really to verify, merchant says we need to authenticate. */ break; case MHD_HTTP_NOT_FOUND: case MHD_HTTP_CONFLICT: - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); - orh->cb (orh->cb_cls, - &hr, - NULL, - NULL); + rr.hr.ec = TALER_JSON_get_error_code (json); + rr.hr.hint = TALER_JSON_get_error_hint (json); break; default: GNUNET_break_op (0); /* unexpected status code */ TALER_MERCHANT_parse_error_details_ (json, response_code, - &hr); - orh->cb (orh->cb_cls, - &hr, - NULL, - NULL); + &rr.hr); break; } + orh->cb (orh->cb_cls, + &rr); TALER_MERCHANT_post_order_refund_cancel (orh); } |