summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-08-25 17:23:35 +0200
committerChristian Grothoff <christian@grothoff.org>2021-08-25 17:23:35 +0200
commit696278ce80c7613e39c24e138dd6c99116080adb (patch)
tree31e85cf7bb872d79ac6f2c4d50dc7831a20d7692 /src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c
parent5672080efcaca68ed2d301adf1673d45f7638a16 (diff)
downloadmerchant-696278ce80c7613e39c24e138dd6c99116080adb.tar.gz
merchant-696278ce80c7613e39c24e138dd6c99116080adb.tar.bz2
merchant-696278ce80c7613e39c24e138dd6c99116080adb.zip
complete implementation of #6956: long polling triggers via database backend
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.c38
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 @@
* Use database to notify other clients about the
* @a order_id being refunded
*
- * @param order_id the order receiving a refund
+ * @param hc handler context we operate in
* @param amount the (total) refunded amount
*/
static void
-trigger_refund_notification (const char *order_id,
+trigger_refund_notification (struct TMH_HandlerContext *hc,
const struct TALER_Amount *amount)
{
const char *as;
- struct TMH_OrderRefundEvent refund_eh = {
+ struct TMH_OrderRefundEventP refund_eh = {
.header.size = htons (sizeof (refund_eh)),
- .header.type = htons (TALER_DBEVENT_MERCHANT_ORDER_REFUND)
+ .header.type = htons (TALER_DBEVENT_MERCHANT_ORDER_REFUND),
+ .merchant_pub = hc->instance->merchant_pub
};
+ /* Resume clients that may wait for this refund */
as = TALER_amount2s (amount);
- GNUNET_CRYPTO_hash (order_id,
- strlen (order_id),
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Awakening clients on %s waiting for refund of no more than %s\n",
+ hc->infix,
+ as);
+ GNUNET_CRYPTO_hash (hc->infix,
+ strlen (hc->infix),
&refund_eh.h_order_id);
TMH_db->event_notify (TMH_db->cls,
&refund_eh.header,
@@ -83,7 +89,6 @@ make_taler_refund_uri (struct MHD_Connection *connection,
GNUNET_assert (NULL != instance_id);
GNUNET_assert (NULL != order_id);
-
host = MHD_lookup_connection_value (connection,
MHD_HEADER_KIND,
"Host");
@@ -251,8 +256,6 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh,
{
enum GNUNET_DB_QueryStatus qs;
- trigger_refund_notification (hc->infix,
- &refund);
qs = TMH_db->commit (TMH_db->cls);
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
@@ -262,6 +265,8 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh,
}
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
continue;
+ trigger_refund_notification (hc,
+ &refund);
}
break;
} /* retries loop */
@@ -329,15 +334,6 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh,
break;
}
- /* Resume clients that may wait for this refund */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Awakeing clients on %s waiting for refund of less than %s\n",
- hc->infix,
- TALER_amount2s (&refund));
- TMH_long_poll_resume (hc->infix,
- hc->instance,
- &refund,
- false);
{
struct GNUNET_TIME_Absolute timestamp;
uint64_t order_serial;
@@ -357,10 +353,8 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh,
NULL);
}
TMH_notify_order_change (hc->instance,
- hc->infix,
- true, /* paid */
- true, /* refunded */
- false, /* wired, cannot be if we could still do refunds */
+ TMH_OSF_PAID
+ | TMH_OSF_REFUNDED,
timestamp,
order_serial);
}