diff options
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 | 38 |
1 files changed, 16 insertions, 22 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 46f30668..ebbfdf0a 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 | |||
@@ -39,22 +39,28 @@ | |||
39 | * Use database to notify other clients about the | 39 | * Use database to notify other clients about the |
40 | * @a order_id being refunded | 40 | * @a order_id being refunded |
41 | * | 41 | * |
42 | * @param order_id the order receiving a refund | 42 | * @param hc handler context we operate in |
43 | * @param amount the (total) refunded amount | 43 | * @param amount the (total) refunded amount |
44 | */ | 44 | */ |
45 | static void | 45 | static void |
46 | trigger_refund_notification (const char *order_id, | 46 | trigger_refund_notification (struct TMH_HandlerContext *hc, |
47 | const struct TALER_Amount *amount) | 47 | const struct TALER_Amount *amount) |
48 | { | 48 | { |
49 | const char *as; | 49 | const char *as; |
50 | struct TMH_OrderRefundEvent refund_eh = { | 50 | struct TMH_OrderRefundEventP refund_eh = { |
51 | .header.size = htons (sizeof (refund_eh)), | 51 | .header.size = htons (sizeof (refund_eh)), |
52 | .header.type = htons (TALER_DBEVENT_MERCHANT_ORDER_REFUND) | 52 | .header.type = htons (TALER_DBEVENT_MERCHANT_ORDER_REFUND), |
53 | .merchant_pub = hc->instance->merchant_pub | ||
53 | }; | 54 | }; |
54 | 55 | ||
56 | /* Resume clients that may wait for this refund */ | ||
55 | as = TALER_amount2s (amount); | 57 | as = TALER_amount2s (amount); |
56 | GNUNET_CRYPTO_hash (order_id, | 58 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
57 | strlen (order_id), | 59 | "Awakening clients on %s waiting for refund of no more than %s\n", |
60 | hc->infix, | ||
61 | as); | ||
62 | GNUNET_CRYPTO_hash (hc->infix, | ||
63 | strlen (hc->infix), | ||
58 | &refund_eh.h_order_id); | 64 | &refund_eh.h_order_id); |
59 | TMH_db->event_notify (TMH_db->cls, | 65 | TMH_db->event_notify (TMH_db->cls, |
60 | &refund_eh.header, | 66 | &refund_eh.header, |
@@ -83,7 +89,6 @@ make_taler_refund_uri (struct MHD_Connection *connection, | |||
83 | 89 | ||
84 | GNUNET_assert (NULL != instance_id); | 90 | GNUNET_assert (NULL != instance_id); |
85 | GNUNET_assert (NULL != order_id); | 91 | GNUNET_assert (NULL != order_id); |
86 | |||
87 | host = MHD_lookup_connection_value (connection, | 92 | host = MHD_lookup_connection_value (connection, |
88 | MHD_HEADER_KIND, | 93 | MHD_HEADER_KIND, |
89 | "Host"); | 94 | "Host"); |
@@ -251,8 +256,6 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, | |||
251 | { | 256 | { |
252 | enum GNUNET_DB_QueryStatus qs; | 257 | enum GNUNET_DB_QueryStatus qs; |
253 | 258 | ||
254 | trigger_refund_notification (hc->infix, | ||
255 | &refund); | ||
256 | qs = TMH_db->commit (TMH_db->cls); | 259 | qs = TMH_db->commit (TMH_db->cls); |
257 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) | 260 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) |
258 | { | 261 | { |
@@ -262,6 +265,8 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, | |||
262 | } | 265 | } |
263 | if (GNUNET_DB_STATUS_SOFT_ERROR == qs) | 266 | if (GNUNET_DB_STATUS_SOFT_ERROR == qs) |
264 | continue; | 267 | continue; |
268 | trigger_refund_notification (hc, | ||
269 | &refund); | ||
265 | } | 270 | } |
266 | break; | 271 | break; |
267 | } /* retries loop */ | 272 | } /* retries loop */ |
@@ -329,15 +334,6 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, | |||
329 | break; | 334 | break; |
330 | } | 335 | } |
331 | 336 | ||
332 | /* Resume clients that may wait for this refund */ | ||
333 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
334 | "Awakeing clients on %s waiting for refund of less than %s\n", | ||
335 | hc->infix, | ||
336 | TALER_amount2s (&refund)); | ||
337 | TMH_long_poll_resume (hc->infix, | ||
338 | hc->instance, | ||
339 | &refund, | ||
340 | false); | ||
341 | { | 337 | { |
342 | struct GNUNET_TIME_Absolute timestamp; | 338 | struct GNUNET_TIME_Absolute timestamp; |
343 | uint64_t order_serial; | 339 | uint64_t order_serial; |
@@ -357,10 +353,8 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, | |||
357 | NULL); | 353 | NULL); |
358 | } | 354 | } |
359 | TMH_notify_order_change (hc->instance, | 355 | TMH_notify_order_change (hc->instance, |
360 | hc->infix, | 356 | TMH_OSF_PAID |
361 | true, /* paid */ | 357 | | TMH_OSF_REFUNDED, |
362 | true, /* refunded */ | ||
363 | false, /* wired, cannot be if we could still do refunds */ | ||
364 | timestamp, | 358 | timestamp, |
365 | order_serial); | 359 | order_serial); |
366 | } | 360 | } |