From 9b053802d49703fc1918c3621095e369beaaf604 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 3 Aug 2020 12:55:11 +0200 Subject: test for refund available --- src/backend/taler-merchant-httpd_get-orders-ID.c | 18 +++++++++++++++--- .../taler-merchant-httpd_private-get-orders-ID.c | 4 +++- src/backend/taler-merchant-httpd_private-get-orders.c | 4 +++- 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 'src/backend') diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c index d587745c..fb189d37 100644 --- a/src/backend/taler-merchant-httpd_get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_get-orders-ID.c @@ -237,6 +237,12 @@ struct GetOrderData */ bool refunded; + /** + * Set to true if a refund is still available for the + * wallet for this payment. + */ + bool refund_available; + /** * Set to true if the client requested HTML, otherwise * we generate JSON. @@ -682,6 +688,7 @@ exchange_found_cb (void *cls, * @param rtransaction_id identificator of the refund * @param reason human-readable explanation of the refund * @param refund_amount refund amount which is being taken from @a coin_pub + * @param pending true if the this refund was not yet processed by the wallet/exchange */ static void process_refunds_cb (void *cls, @@ -691,7 +698,8 @@ process_refunds_cb (void *cls, const char *exchange_url, uint64_t rtransaction_id, const char *reason, - const struct TALER_Amount *refund_amount) + const struct TALER_Amount *refund_amount, + bool pending) { struct GetOrderData *god = cls; struct CoinRefund *cr; @@ -722,6 +730,7 @@ process_refunds_cb (void *cls, } god->refund_amount = *refund_amount; god->refunded = true; + god->refund_available |= pending; } @@ -1307,7 +1316,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, { enum GNUNET_GenericReturnValue res; - if (god->refunded) // FIXME: don't check for refunded, but for PENDING refund! + if (god->refund_available) { char *qr; char *uri; @@ -1320,7 +1329,10 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, { GNUNET_break (0); GNUNET_free (uri); - return MHD_NO; // FIXME: add nicer error reply... + return TALER_MHD_reply_with_error (god->sc.con, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_ALLOCATION_FAILURE, + "during QR code generation"); } { struct KVC kvc[] = { diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c index 7fdeeed6..7823837f 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -628,6 +628,7 @@ gorc_cleanup (void *cls) * @param reason human-readable explanation of the refund * @param timestamp when was the refund made * @param refund_amount refund amount which is being taken from @a coin_pub + * @param pending true if the this refund was not yet processed by the wallet/exchange */ static void process_refunds_cb (void *cls, @@ -637,7 +638,8 @@ process_refunds_cb (void *cls, const char *exchange_url, uint64_t rtransaction_id, const char *reason, - const struct TALER_Amount *refund_amount) + const struct TALER_Amount *refund_amount, + bool pending) { struct GetOrderRequestContext *gorc = cls; diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c index dc4901c3..41f5be48 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders.c +++ b/src/backend/taler-merchant-httpd_private-get-orders.c @@ -222,6 +222,7 @@ cleanup (void *ctx) * @param reason human-readable explanation of the refund * @param timestamp when was the refund made * @param refund_amount refund amount which is being taken from @a coin_pub + * @param pending true if the this refund was not yet processed by the wallet/exchange */ static void process_refunds_cb (void *cls, @@ -231,7 +232,8 @@ process_refunds_cb (void *cls, const char *exchange_url, uint64_t rtransaction_id, const char *reason, - const struct TALER_Amount *refund_amount) + const struct TALER_Amount *refund_amount, + bool pending) { struct TALER_Amount *total_refund_amount = cls; -- cgit v1.2.3