diff options
-rw-r--r-- | src/backend/taler-merchant-httpd_get-orders-ID.c | 44 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-orders-ID.c | 13 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-orders.c | 4 |
3 files changed, 51 insertions, 10 deletions
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c index e33093ec..28ba0785 100644 --- a/src/backend/taler-merchant-httpd_get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_get-orders-ID.c @@ -96,16 +96,23 @@ struct GetOrderData struct TMH_SuspendedConnection sc; /** - * Database event we are waiting on to be resuming. + * Database event we are waiting on to be resuming on payment. */ struct GNUNET_DB_EventHandler *pay_eh; /** - * Database event we are waiting on to be resuming. + * Database event we are waiting on to be resuming for refunds. */ struct GNUNET_DB_EventHandler *refund_eh; /** + * Database event we are waiting on to be resuming for repurchase + * detection updating some equivalent order (same fulfillment URL) + * to our session. + */ + struct GNUNET_DB_EventHandler *session_eh; + + /** * Which merchant instance is this for? */ struct MerchantInstance *mi; @@ -345,6 +352,11 @@ god_cleanup (void *cls) json_decref (god->contract_terms); god->contract_terms = NULL; } + if (NULL != god->session_eh) + { + TMH_db->event_listen_cancel (god->session_eh); + god->session_eh = NULL; + } if (NULL != god->refund_eh) { TMH_db->event_listen_cancel (god->refund_eh); @@ -555,6 +567,7 @@ phase_init (struct GetOrderData *god) &resume_by_event, god); } + } @@ -758,6 +771,33 @@ phase_parse_contract (struct GetOrderData *god) return; } god->contract_parsed = true; + if ( (NULL != god->session_id) && + (NULL != god->fulfillment_url) && + (NULL == god->session_eh) ) + { + struct TMH_SessionEventP session_eh = { + .header.size = htons (sizeof (session_eh)), + .header.type = htons (TALER_DBEVENT_MERCHANT_SESSION_CAPTURED), + .merchant_pub = god->hc->instance->merchant_pub + }; + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Subscribing to session triggers for %p\n", + god); + GNUNET_CRYPTO_hash (god->session_id, + strlen (god->session_id), + &session_eh.h_session_id); + GNUNET_CRYPTO_hash (god->fulfillment_url, + strlen (god->fulfillment_url), + &session_eh.h_fulfillment_url); + god->session_eh + = TMH_db->event_listen ( + TMH_db->cls, + &session_eh.header, + GNUNET_TIME_absolute_get_remaining (god->sc.long_poll_timeout), + &resume_by_event, + god); + } god->phase++; } diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c index 50626876..dc3328d4 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -1387,7 +1387,7 @@ phase_reply_result (struct GetOrderRequestContext *gorc) struct TMH_HandlerContext *hc = gorc->hc; MHD_RESULT ret; char *order_status_url; - json_t *choice_index = json_null(); + json_t *choice_index = json_null (); { struct TALER_PrivateContractHashP *h_contract = NULL; @@ -1415,7 +1415,8 @@ phase_reply_result (struct GetOrderRequestContext *gorc) TALER_amount_is_zero (&gorc->contract_amount)); gorc->last_payment = gorc->timestamp; } - if (-1 != gorc->choice_index) { + if (-1 != gorc->choice_index) + { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Choice index is %d\n", gorc->choice_index); @@ -1459,10 +1460,10 @@ phase_reply_result (struct GetOrderRequestContext *gorc) gorc->refund_details), GNUNET_JSON_pack_string ("order_status_url", order_status_url), - { - .field_name = "choice_index", - .object = choice_index, - }); + { + .field_name = "choice_index", + .object = choice_index, + }); GNUNET_free (order_status_url); gorc->wire_details = NULL; gorc->refund_details = NULL; diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c index cd8644e1..7053ac70 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders.c +++ b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -161,8 +161,8 @@ struct OrderContext json_t *order; /** - * Set to how long refunds will be allowed. - */ + * Set to how long refunds will be allowed. + */ struct GNUNET_TIME_Relative refund_delay; /** |