summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_post-orders-ID-refund.c
diff options
context:
space:
mode:
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.c43
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 @@
* @author Jonathan Buchanan
*/
#include "platform.h"
+#include <taler/taler_dbevents.h>
#include <taler/taler_signatures.h>
#include <taler/taler_json_lib.h>
#include <taler/taler_exchange_service.h>
+#include "taler-merchant-httpd.h"
#include "taler-merchant-httpd_auditors.h"
#include "taler-merchant-httpd_exchanges.h"
#include "taler-merchant-httpd_post-orders-ID-refund.h"
@@ -166,11 +168,6 @@ struct PostRefundData
struct TMH_SuspendedConnection sc;
/**
- * Which merchant instance is this for?
- */
- struct MerchantInstance *mi;
-
- /**
* order ID for the payment
*/
const char *order_id;
@@ -288,9 +285,7 @@ refund_cleanup (void *ctx)
}
GNUNET_free (cr);
}
-
json_decref (prd->contract_terms);
-
GNUNET_free (prd);
}
@@ -358,6 +353,31 @@ check_resume_prd (struct PostRefundData *prd)
/**
+ * Notify applications waiting for a client to obtain
+ * a refund.
+ *
+ * @param prd refund request with the change
+ */
+static void
+notify_refund_obtained (struct PostRefundData *prd)
+{
+ struct TMH_OrderPayEventP refund_eh = {
+ .header.size = htons (sizeof (refund_eh)),
+ .header.type = htons (TALER_DBEVENT_MERCHANT_REFUND_OBTAINED),
+ .merchant_pub = prd->hc->instance->merchant_pub
+ };
+
+ GNUNET_CRYPTO_hash (prd->order_id,
+ strlen (prd->order_id),
+ &refund_eh.h_order_id);
+ TMH_db->event_notify (TMH_db->cls,
+ &refund_eh.header,
+ NULL,
+ 0);
+}
+
+
+/**
* Callbacks of this type are used to serve the result of submitting a
* refund request to an exchange.
*
@@ -403,6 +423,10 @@ refund_cb (void *cls,
"Failed to persist exchange response to /refund in database: %d\n",
qs);
}
+ else
+ {
+ notify_refund_obtained (cr->prd);
+ }
}
check_resume_prd (cr->prd);
}
@@ -691,11 +715,6 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh,
if (NULL == cr->exchange_reply)
{
/* We need to talk to the exchange */
- /* Notify clients waiting for the refund to be obtained. */
- TMH_long_poll_resume (hc->infix,
- hc->instance,
- &prd->refund_amount,
- true);
cr->fo = TMH_EXCHANGES_find_exchange (cr->exchange_url,
NULL,
GNUNET_NO,