merchant

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

commit ee590a7301bd9696ea3ae13cfa2d30256486d83e
parent b76c77637a0782bccafddbbccac707b2abc962c6
Author: Florian Dold <florian@dold.me>
Date:   Tue,  7 Jan 2025 20:00:11 +0100

report undeposited coins when aborting a payment

Diffstat:
Msrc/backend/taler-merchant-httpd_post-orders-ID-abort.c | 44++++++++++++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 8 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c @@ -115,6 +115,10 @@ struct RefundDetails */ bool processed; + /** + * Did we find the deposit in our own database? + */ + bool found_deposit; }; @@ -362,13 +366,25 @@ generate_success_response (struct AbortContext *ac) struct RefundDetails *rdi = &ac->rd[i]; json_t *detail; - if ( ( (MHD_HTTP_BAD_REQUEST <= rdi->http_status) && - (MHD_HTTP_NOT_FOUND != rdi->http_status) && - (MHD_HTTP_GONE != rdi->http_status) ) || - (0 == rdi->http_status) || - (NULL == rdi->exchange_reply) ) - hc = MHD_HTTP_BAD_GATEWAY; - if (MHD_HTTP_OK != rdi->http_status) + if (rdi->found_deposit) + { + if ( ( (MHD_HTTP_BAD_REQUEST <= rdi->http_status) && + (MHD_HTTP_NOT_FOUND != rdi->http_status) && + (MHD_HTTP_GONE != rdi->http_status) ) || + (0 == rdi->http_status) || + (NULL == rdi->exchange_reply) ) + { + hc = MHD_HTTP_BAD_GATEWAY; + } + } + if (! rdi->found_deposit) + { + detail = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("type", + "undeposited")); + } + else if (MHD_HTTP_OK != rdi->http_status) + { detail = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("type", "failure"), @@ -384,7 +400,9 @@ generate_success_response (struct AbortContext *ac) GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_object_incref ("exchange_reply", rdi->exchange_reply))); - else + } + else if (rdi->found_deposit) + { detail = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("type", "success"), @@ -394,6 +412,7 @@ generate_success_response (struct AbortContext *ac) &rdi->exchange_sig), GNUNET_JSON_pack_data_auto ("exchange_pub", &rdi->exchange_pub)); + } GNUNET_assert (0 == json_array_append_new (refunds, detail)); @@ -535,6 +554,11 @@ process_abort_with_exchange (void *cls, continue; rdi->processed = true; ac->pending--; + if (! rdi->found_deposit) + { + /* Coin wasn't even deposited yet, we do not need to refund it. */ + continue; + } rdi->rh = TALER_EXCHANGE_refund ( TMH_curl_ctx, ac->current_exchange, @@ -557,6 +581,9 @@ process_abort_with_exchange (void *cls, } ac->pending_at_ce++; } + /* Still continue if no coins for this exchange were deposited. */ + if (0 == ac->pending_at_ce) + find_next_exchange (ac); } @@ -648,6 +675,7 @@ refund_coins (void *cls, strcmp (exchange_url, rdi->exchange_url)) ) continue; /* not in request */ + rdi->found_deposit = true; rdi->amount_with_fee = *amount_with_fee; /* Store refund in DB */ qs = TMH_db->refund_coin (TMH_db->cls,