merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit c3d513011bbe09a154289abd2cf6d4d238fa2a07
parent 8fa68943041ede6f587a5feb23ca11e878cf91cb
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 21 Dec 2025 20:02:17 +0100

nicer code structure, include EC in 451 response on /pay

Diffstat:
Msrc/backend/taler-merchant-httpd_post-orders-ID-pay.c | 2++
Msrc/backend/taler-merchant-httpd_post-orders-ID-refund.c | 51+++++++++++++++++++++++++++------------------------
2 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -974,6 +974,8 @@ phase_fail_for_legal_reasons (struct PayContext *pc) TALER_MHD_REPLY_JSON_PACK ( pc->connection, MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS, + TALER_JSON_pack_ec ( + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_LEGALLY_REFUSED), GNUNET_JSON_pack_array_steal ("exchange_base_urls", exchanges))); } diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c @@ -400,33 +400,36 @@ refund_cb (void *cls, "Exchange refund status for coin %s is %u\n", TALER_B2S (&cr->coin_pub), hr->http_status); - if (MHD_HTTP_OK != hr->http_status) + switch (hr->http_status) { - cr->exchange_code = hr->ec; - cr->exchange_reply = json_incref ((json_t*) hr->reply); - } - else - { - enum GNUNET_DB_QueryStatus qs; - - cr->exchange_pub = rr->details.ok.exchange_pub; - cr->exchange_sig = rr->details.ok.exchange_sig; - qs = TMH_db->insert_refund_proof (TMH_db->cls, - cr->refund_serial, - &rr->details.ok.exchange_sig, - &rr->details.ok.exchange_pub); - if (0 >= qs) - { - /* generally, this is relatively harmless for the merchant, but let's at - least log this. */ - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to persist exchange response to /refund in database: %d\n", - qs); - } - else + case MHD_HTTP_OK: { - notify_refund_obtained (cr->prd); + enum GNUNET_DB_QueryStatus qs; + + cr->exchange_pub = rr->details.ok.exchange_pub; + cr->exchange_sig = rr->details.ok.exchange_sig; + qs = TMH_db->insert_refund_proof (TMH_db->cls, + cr->refund_serial, + &rr->details.ok.exchange_sig, + &rr->details.ok.exchange_pub); + if (0 >= qs) + { + /* generally, this is relatively harmless for the merchant, but let's at + least log this. */ + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Failed to persist exchange response to /refund in database: %d\n", + qs); + } + else + { + notify_refund_obtained (cr->prd); + } } + break; + default: + cr->exchange_code = hr->ec; + cr->exchange_reply = json_incref ((json_t*) hr->reply); + break; } check_resume_prd (cr->prd); }