summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd_post-orders-ID-pay.c')
-rw-r--r--src/backend/taler-merchant-httpd_post-orders-ID-pay.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
index 9c75e487..fd6cc7ab 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -199,6 +199,11 @@ struct PayContext
char *order_id;
/**
+ * Fulfillment URL from the contract, or NULL if we don't have one.
+ */
+ char *fulfillment_url;
+
+ /**
* Serial number of this order in the database (set once we did the lookup).
*/
uint64_t order_serial;
@@ -521,6 +526,7 @@ pay_context_cleanup (void *cls)
pc->response = NULL;
}
GNUNET_free (pc->order_id);
+ GNUNET_free (pc->fulfillment_url);
GNUNET_free (pc->session_id);
GNUNET_CONTAINER_DLL_remove (pc_head,
pc_tail,
@@ -1443,6 +1449,10 @@ begin_transaction (struct PayContext *pc)
}
/* Notify clients that have been waiting for the payment to succeed */
+ if ( (NULL != pc->session_id) &&
+ (NULL != pc->fulfillment_url) )
+ TMH_long_poll_resume2 (pc->session_id,
+ pc->fulfillment_url);
TMH_long_poll_resume (pc->order_id,
hc->instance,
NULL,
@@ -1729,10 +1739,16 @@ parse_pay (struct MHD_Connection *connection,
GNUNET_JSON_spec_end ()
};
enum GNUNET_GenericReturnValue res;
+ const char *fulfillment_url;
res = TALER_MHD_parse_internal_json_data (connection,
contract_terms,
espec);
+ fulfillment_url
+ = json_string_value (json_object_get (contract_terms,
+ "fulfillment_url"));
+ if (NULL != fulfillment_url)
+ pc->fulfillment_url = GNUNET_strdup (fulfillment_url);
json_decref (contract_terms);
if (GNUNET_YES != res)
{
@@ -1884,9 +1900,9 @@ TMH_post_orders_ID_pay (const struct TMH_RequestHandler *rh,
"Suspending pay handling while working with the exchange\n");
GNUNET_assert (NULL == pc->timeout_task);
pc->timeout_task =
- GNUNET_SCHEDULER_add_delayed (get_pay_timeout (pc->coins_cnt),
- &handle_pay_timeout,
- pc);
+ GNUNET_SCHEDULER_add_delayed (get_pay_timeout (pc->coins_cnt),
+ &handle_pay_timeout,
+ pc);
begin_transaction (pc);
return MHD_YES;
}