summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_private-post-orders.c
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-06-29 13:48:40 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-06-29 13:48:40 -0400
commitb637514b36e6c0f44505fca510f3033b85c932ff (patch)
tree4e6487c244efd1818221a6afe010465bb0c6906a /src/backend/taler-merchant-httpd_private-post-orders.c
parenta118bd2c4951fa7b60737e3cca69e62266a1bcef (diff)
downloadmerchant-b637514b36e6c0f44505fca510f3033b85c932ff.tar.gz
merchant-b637514b36e6c0f44505fca510f3033b85c932ff.tar.bz2
merchant-b637514b36e6c0f44505fca510f3033b85c932ff.zip
long polling test for GET /private/orders
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-post-orders.c')
-rw-r--r--src/backend/taler-merchant-httpd_private-post-orders.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
index e7b04e3d..2772aef5 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -30,6 +30,7 @@
#include "taler-merchant-httpd_private-post-orders.h"
#include "taler-merchant-httpd_auditors.h"
#include "taler-merchant-httpd_exchanges.h"
+#include "taler-merchant-httpd_private-get-orders.h"
/**
@@ -198,6 +199,8 @@ execute_transaction (struct TMH_HandlerContext *hc,
const struct GNUNET_Uuid uuids[])
{
enum GNUNET_DB_QueryStatus qs;
+ struct GNUNET_TIME_Absolute timestamp;
+ uint64_t order_serial;
if (GNUNET_OK !=
TMH_db->start (TMH_db->cls,
@@ -249,11 +252,37 @@ execute_transaction (struct TMH_HandlerContext *hc,
return qs;
}
}
+ /* Get the order serial and timestamp for the order we just created to
+ update long-poll clients. */
+ qs = TMH_db->lookup_order_summary (TMH_db->cls,
+ hc->instance->settings.id,
+ order_id,
+ &timestamp,
+ &order_serial);
+ if (1 != qs)
+ {
+ TMH_db->rollback (TMH_db->cls);
+ return qs;
+ }
/* finally, commit transaction (note: if it fails, we ALSO re-acquire
the UUID locks, which is exactly what we want) */
qs = TMH_db->commit (TMH_db->cls);
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+ {
+ /* Notify clients that have been waiting for the payment to succeed */
+ TMH_long_poll_resume (order_id,
+ hc->instance,
+ NULL);
+ TMH_notify_order_change (hc->instance,
+ order_id,
+ false, /* paid */
+ false, /* refunded */
+ false, /* wired */
+ timestamp,
+ order_serial);
+
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; /* 1 == success! */
+ }
return qs;
}