aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_post-orders-ID-paid.c
diff options
context:
space:
mode:
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.c48
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 @@
1/* 1/*
2 This file is part of TALER 2 This file is part of TALER
3 (C) 2014-2020 Taler Systems SA 3 (C) 2014-2021 Taler Systems SA
4 4
5 TALER is free software; you can redistribute it and/or modify 5 TALER is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Affero General Public License as 6 it under the terms of the GNU Affero General Public License as
@@ -29,6 +29,38 @@
29#include "taler-merchant-httpd_post-orders-ID-paid.h" 29#include "taler-merchant-httpd_post-orders-ID-paid.h"
30 30
31 31
32/**
33 * Use database to notify other clients about the
34 * session being captured.
35 *
36 * @param session_id the captured session
37 * @param fulfillment_url the URL that is now paid for by @a session_id
38 */
39static void
40trigger_session_notification (const char *session_id,
41 const char *fulfillment_url)
42{
43#ifndef TALER_API_VERSION
44#define TALER_DBEVENT_MERCHANT_SESSION_CAPTURED 1103
45#endif
46 struct TMH_SessionEvent session_eh = {
47 .header.size = htons (sizeof (session_eh)),
48 .header.type = htons (TALER_DBEVENT_MERCHANT_SESSION_CAPTURED)
49 };
50
51 GNUNET_CRYPTO_hash (session_id,
52 strlen (session_id),
53 &session_eh.h_session_id);
54 GNUNET_CRYPTO_hash (fulfillment_url,
55 strlen (fulfillment_url),
56 &session_eh.h_fulfillment_url);
57 TMH_db->event_notify (TMH_db->cls,
58 &session_eh.header,
59 NULL,
60 0);
61}
62
63
32MHD_RESULT 64MHD_RESULT
33TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, 65TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh,
34 struct MHD_Connection *connection, 66 struct MHD_Connection *connection,
@@ -145,7 +177,7 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh,
145 177
146 fulfillment_url 178 fulfillment_url
147 = json_string_value (json_object_get (contract_terms, 179 = json_string_value (json_object_get (contract_terms,
148 "fulfillment_url")); 180 "fulfillment_url"));
149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
150 "Marking contract %s with %s/%s as paid\n", 182 "Marking contract %s with %s/%s as paid\n",
151 order_id, 183 order_id,
@@ -165,15 +197,21 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh,
165 TALER_EC_GENERIC_DB_STORE_FAILED, 197 TALER_EC_GENERIC_DB_STORE_FAILED,
166 "mark_contract_paid"); 198 "mark_contract_paid");
167 } 199 }
168 200
169 /* Wake everybody up who waits for this fulfillment_url and session_id */ 201 /* Wake everybody up who waits for this fulfillment_url and session_id */
202 if ( (NULL != fulfillment_url) &&
203 (NULL != session_id) )
204 trigger_session_notification (session_id,
205 fulfillment_url);
170 if (NULL != fulfillment_url) 206 if (NULL != fulfillment_url)
171 TMH_long_poll_resume2 (session_id, 207 TMH_long_poll_resume2 (session_id,
172 fulfillment_url); 208 fulfillment_url);
173 209
174 /* fulfillment_url is part of the contract_terms */ 210 /* fulfillment_url is part of the contract_terms */
175 json_decref (contract_terms); 211 json_decref (contract_terms);
176 /* Resume clients waiting on the order */ 212 /* Resume clients waiting on the order
213 (NOTE: should never be needed, as /pay
214 would have triggered those, right?) */
177 TMH_long_poll_resume (order_id, 215 TMH_long_poll_resume (order_id,
178 hc->instance, 216 hc->instance,
179 NULL, 217 NULL,