diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_post-orders-ID-refund.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_post-orders-ID-refund.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c index 6eeb4182..ff64d9a2 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c | |||
@@ -23,9 +23,11 @@ | |||
23 | * @author Jonathan Buchanan | 23 | * @author Jonathan Buchanan |
24 | */ | 24 | */ |
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include <taler/taler_dbevents.h> | ||
26 | #include <taler/taler_signatures.h> | 27 | #include <taler/taler_signatures.h> |
27 | #include <taler/taler_json_lib.h> | 28 | #include <taler/taler_json_lib.h> |
28 | #include <taler/taler_exchange_service.h> | 29 | #include <taler/taler_exchange_service.h> |
30 | #include "taler-merchant-httpd.h" | ||
29 | #include "taler-merchant-httpd_auditors.h" | 31 | #include "taler-merchant-httpd_auditors.h" |
30 | #include "taler-merchant-httpd_exchanges.h" | 32 | #include "taler-merchant-httpd_exchanges.h" |
31 | #include "taler-merchant-httpd_post-orders-ID-refund.h" | 33 | #include "taler-merchant-httpd_post-orders-ID-refund.h" |
@@ -166,11 +168,6 @@ struct PostRefundData | |||
166 | struct TMH_SuspendedConnection sc; | 168 | struct TMH_SuspendedConnection sc; |
167 | 169 | ||
168 | /** | 170 | /** |
169 | * Which merchant instance is this for? | ||
170 | */ | ||
171 | struct MerchantInstance *mi; | ||
172 | |||
173 | /** | ||
174 | * order ID for the payment | 171 | * order ID for the payment |
175 | */ | 172 | */ |
176 | const char *order_id; | 173 | const char *order_id; |
@@ -288,9 +285,7 @@ refund_cleanup (void *ctx) | |||
288 | } | 285 | } |
289 | GNUNET_free (cr); | 286 | GNUNET_free (cr); |
290 | } | 287 | } |
291 | |||
292 | json_decref (prd->contract_terms); | 288 | json_decref (prd->contract_terms); |
293 | |||
294 | GNUNET_free (prd); | 289 | GNUNET_free (prd); |
295 | } | 290 | } |
296 | 291 | ||
@@ -358,6 +353,31 @@ check_resume_prd (struct PostRefundData *prd) | |||
358 | 353 | ||
359 | 354 | ||
360 | /** | 355 | /** |
356 | * Notify applications waiting for a client to obtain | ||
357 | * a refund. | ||
358 | * | ||
359 | * @param prd refund request with the change | ||
360 | */ | ||
361 | static void | ||
362 | notify_refund_obtained (struct PostRefundData *prd) | ||
363 | { | ||
364 | struct TMH_OrderPayEventP refund_eh = { | ||
365 | .header.size = htons (sizeof (refund_eh)), | ||
366 | .header.type = htons (TALER_DBEVENT_MERCHANT_REFUND_OBTAINED), | ||
367 | .merchant_pub = prd->hc->instance->merchant_pub | ||
368 | }; | ||
369 | |||
370 | GNUNET_CRYPTO_hash (prd->order_id, | ||
371 | strlen (prd->order_id), | ||
372 | &refund_eh.h_order_id); | ||
373 | TMH_db->event_notify (TMH_db->cls, | ||
374 | &refund_eh.header, | ||
375 | NULL, | ||
376 | 0); | ||
377 | } | ||
378 | |||
379 | |||
380 | /** | ||
361 | * Callbacks of this type are used to serve the result of submitting a | 381 | * Callbacks of this type are used to serve the result of submitting a |
362 | * refund request to an exchange. | 382 | * refund request to an exchange. |
363 | * | 383 | * |
@@ -403,6 +423,10 @@ refund_cb (void *cls, | |||
403 | "Failed to persist exchange response to /refund in database: %d\n", | 423 | "Failed to persist exchange response to /refund in database: %d\n", |
404 | qs); | 424 | qs); |
405 | } | 425 | } |
426 | else | ||
427 | { | ||
428 | notify_refund_obtained (cr->prd); | ||
429 | } | ||
406 | } | 430 | } |
407 | check_resume_prd (cr->prd); | 431 | check_resume_prd (cr->prd); |
408 | } | 432 | } |
@@ -691,11 +715,6 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, | |||
691 | if (NULL == cr->exchange_reply) | 715 | if (NULL == cr->exchange_reply) |
692 | { | 716 | { |
693 | /* We need to talk to the exchange */ | 717 | /* We need to talk to the exchange */ |
694 | /* Notify clients waiting for the refund to be obtained. */ | ||
695 | TMH_long_poll_resume (hc->infix, | ||
696 | hc->instance, | ||
697 | &prd->refund_amount, | ||
698 | true); | ||
699 | cr->fo = TMH_EXCHANGES_find_exchange (cr->exchange_url, | 718 | cr->fo = TMH_EXCHANGES_find_exchange (cr->exchange_url, |
700 | NULL, | 719 | NULL, |
701 | GNUNET_NO, | 720 | GNUNET_NO, |