diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-25 07:58:27 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-25 07:58:27 +0200 |
commit | 5672080efcaca68ed2d301adf1673d45f7638a16 (patch) | |
tree | 12767bfb5996765f70f6b421c1179c0e56e8bc3c /src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c | |
parent | 0c78255cba8bc6ed6c8042995292f02d4980e714 (diff) | |
download | merchant-5672080efcaca68ed2d301adf1673d45f7638a16.tar.gz merchant-5672080efcaca68ed2d301adf1673d45f7638a16.tar.bz2 merchant-5672080efcaca68ed2d301adf1673d45f7638a16.zip |
-add more events
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c index 903b542d..46f30668 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c +++ b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2014-2020 Taler Systems SA + (C) 2014-2021 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 published by the Free Software @@ -21,6 +21,7 @@ */ #include "platform.h" #include <jansson.h> +#include <taler/taler_dbevents.h> #include <taler/taler_signatures.h> #include <taler/taler_json_lib.h> #include "taler-merchant-httpd_private-post-orders-ID-refund.h" @@ -35,6 +36,34 @@ /** + * Use database to notify other clients about the + * @a order_id being refunded + * + * @param order_id the order receiving a refund + * @param amount the (total) refunded amount + */ +static void +trigger_refund_notification (const char *order_id, + const struct TALER_Amount *amount) +{ + const char *as; + struct TMH_OrderRefundEvent refund_eh = { + .header.size = htons (sizeof (refund_eh)), + .header.type = htons (TALER_DBEVENT_MERCHANT_ORDER_REFUND) + }; + + as = TALER_amount2s (amount); + GNUNET_CRYPTO_hash (order_id, + strlen (order_id), + &refund_eh.h_order_id); + TMH_db->event_notify (TMH_db->cls, + &refund_eh.header, + as, + strlen (as)); +} + + +/** * Make a taler://refund URI * * @param connection MHD connection to take host and path from @@ -86,7 +115,7 @@ make_taler_refund_uri (struct MHD_Connection *connection, } GNUNET_buffer_write_path (&buf, order_id); GNUNET_buffer_write_path (&buf, - ""); // Trailing slash + ""); /* Trailing slash */ return GNUNET_buffer_reap_str (&buf); } @@ -222,6 +251,8 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, { enum GNUNET_DB_QueryStatus qs; + trigger_refund_notification (hc->infix, + &refund); qs = TMH_db->commit (TMH_db->cls); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { |