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 | 48 |
1 files changed, 43 insertions, 5 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 c821ed32..d274c1f6 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-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 @@ -29,6 +29,38 @@ #include "taler-merchant-httpd_post-orders-ID-paid.h" +/** + * Use database to notify other clients about the + * session being captured. + * + * @param session_id the captured session + * @param fulfillment_url the URL that is now paid for by @a session_id + */ +static void +trigger_session_notification (const char *session_id, + const char *fulfillment_url) +{ +#ifndef TALER_API_VERSION +#define TALER_DBEVENT_MERCHANT_SESSION_CAPTURED 1103 +#endif + struct TMH_SessionEvent session_eh = { + .header.size = htons (sizeof (session_eh)), + .header.type = htons (TALER_DBEVENT_MERCHANT_SESSION_CAPTURED) + }; + + GNUNET_CRYPTO_hash (session_id, + strlen (session_id), + &session_eh.h_session_id); + GNUNET_CRYPTO_hash (fulfillment_url, + strlen (fulfillment_url), + &session_eh.h_fulfillment_url); + TMH_db->event_notify (TMH_db->cls, + &session_eh.header, + NULL, + 0); +} + + MHD_RESULT TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, struct MHD_Connection *connection, @@ -145,7 +177,7 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, fulfillment_url = json_string_value (json_object_get (contract_terms, - "fulfillment_url")); + "fulfillment_url")); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Marking contract %s with %s/%s as paid\n", order_id, @@ -165,15 +197,21 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, TALER_EC_GENERIC_DB_STORE_FAILED, "mark_contract_paid"); } - - /* Wake everybody up who waits for this fulfillment_url and session_id */ + + /* Wake everybody up who waits for this fulfillment_url and session_id */ + if ( (NULL != fulfillment_url) && + (NULL != session_id) ) + trigger_session_notification (session_id, + fulfillment_url); if (NULL != fulfillment_url) TMH_long_poll_resume2 (session_id, fulfillment_url); /* fulfillment_url is part of the contract_terms */ json_decref (contract_terms); - /* Resume clients waiting on the order */ + /* Resume clients waiting on the order + (NOTE: should never be needed, as /pay + would have triggered those, right?) */ TMH_long_poll_resume (order_id, hc->instance, NULL, |