[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] branch master updated: report undeposited coins when ab
From: |
gnunet |
Subject: |
[taler-merchant] branch master updated: report undeposited coins when aborting a payment |
Date: |
Tue, 07 Jan 2025 20:00:31 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new ee590a73 report undeposited coins when aborting a payment
ee590a73 is described below
commit ee590a7301bd9696ea3ae13cfa2d30256486d83e
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Jan 7 20:00:11 2025 +0100
report undeposited coins when aborting a payment
---
.../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
index 8d7cc363..e5d428a6 100644
--- 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,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-merchant] branch master updated: report undeposited coins when aborting a payment,
gnunet <=