diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_post-orders-ID-paid.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_post-orders-ID-paid.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-paid.c b/src/backend/taler-merchant-httpd_post-orders-ID-paid.c index ee00b973..4eb7280f 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-paid.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-paid.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2014-2021 Taler Systems SA + (C) 2014-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -31,6 +31,26 @@ /** + * Function called with information about a refund. + * Sets the boolean in @a cls to true when called. + * + * @param cls closure, a `bool *` + * @param coin_pub public coin from which the refund comes from + * @param refund_amount refund amount which is being taken from @a coin_pub + */ +static void +refund_cb ( + void *cls, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_Amount *refund_amount) +{ + bool *refunded = cls; + + *refunded = true; +} + + +/** * Use database to notify other clients about the * session being captured. * @@ -99,7 +119,6 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, } } - if (GNUNET_OK != TALER_merchant_pay_verify (&hct, &hc->instance->merchant_pub, @@ -115,14 +134,12 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, TMH_db->preflight (TMH_db->cls); { uint64_t order_serial; - bool paid; qs = TMH_db->lookup_contract_terms (TMH_db->cls, hc->instance->settings.id, order_id, &contract_terms, &order_serial, - &paid, NULL); } if (0 > qs) @@ -173,7 +190,6 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, } } - fulfillment_url = json_string_value (json_object_get (contract_terms, "fulfillment_url")); @@ -204,12 +220,21 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, session_id, fulfillment_url); /* fulfillment_url is part of the contract_terms */ - json_decref (contract_terms); - return TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); + { + bool refunded = false; + + qs = TMH_db->lookup_refunds (TMH_db->cls, + hc->instance->settings.id, + &hct, + &refund_cb, + &refunded); + json_decref (contract_terms); + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_bool ("refunded", + refunded)); + } } |