diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_check-payment.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_check-payment.c | 102 |
1 files changed, 4 insertions, 98 deletions
diff --git a/src/backend/taler-merchant-httpd_check-payment.c b/src/backend/taler-merchant-httpd_check-payment.c index ac73a90b..fad3fdc6 100644 --- a/src/backend/taler-merchant-httpd_check-payment.c +++ b/src/backend/taler-merchant-httpd_check-payment.c @@ -48,9 +48,6 @@ struct CheckPaymentRequestContext */ struct TM_HandlerContext hc; - /** - * Connection we are processing a request for. - */ struct MHD_Connection *connection; /** @@ -85,12 +82,6 @@ struct CheckPaymentRequestContext const char *fulfillment_url; /** - * At what time does this request expire? If set in the future, we - * may wait this long for a payment to arrive before responding. - */ - struct GNUNET_TIME_Absolute long_poll_timeout; - - /** * Contract terms of the payment we are checking. NULL when they * are not (yet) known. */ @@ -142,67 +133,6 @@ cprc_cleanup (struct TM_HandlerContext *hc) /** - * Make a taler://pay URI - * - * @param cprc payment request context - * @returns the URI, must be freed with #GNUNET_free - */ -static char * -make_taler_pay_uri (const struct CheckPaymentRequestContext *cprc) -{ - const char *host; - const char *forwarded_host; - const char *uri_path; - const char *uri_instance_id; - const char *query; - char *result; - - host = MHD_lookup_connection_value (cprc->connection, - MHD_HEADER_KIND, - "Host"); - forwarded_host = MHD_lookup_connection_value (cprc->connection, - MHD_HEADER_KIND, - "X-Forwarded-Host"); - - uri_path = MHD_lookup_connection_value (cprc->connection, - MHD_HEADER_KIND, - "X-Forwarded-Prefix"); - if (NULL == uri_path) - uri_path = "-"; - if (NULL != forwarded_host) - host = forwarded_host; - if (0 == strcmp (cprc->mi->id, - "default")) - uri_instance_id = "-"; - else - uri_instance_id = cprc->mi->id; - if (NULL == host) - { - /* Should never happen, at least the host header should be defined */ - GNUNET_break (0); - return NULL; - } - - if (GNUNET_YES == TALER_mhd_is_https (cprc->connection)) - query = ""; - else - query = "?insecure=1"; - GNUNET_assert (NULL != cprc->order_id); - GNUNET_assert (0 < GNUNET_asprintf (&result, - "taler://pay/%s/%s/%s/%s%s%s%s", - host, - uri_path, - uri_instance_id, - cprc->order_id, - (cprc->session_id == NULL) ? "" : "/", - (cprc->session_id == NULL) ? "" : - cprc->session_id, - query)); - return result; -} - - -/** * Function called with information about a refund. * It is responsible for summing up the refund amount. * @@ -274,7 +204,10 @@ send_pay_request (const struct CheckPaymentRequestContext *cprc) "db error fetching pay session info"); } } - taler_pay_uri = make_taler_pay_uri (cprc); + taler_pay_uri = TMH_make_taler_pay_uri (cprc->connection, + cprc->order_id, + cprc->session_id, + cprc->mi->id); ret = TMH_RESPONSE_reply_json_pack (cprc->connection, MHD_HTTP_OK, "{s:s, s:s, s:b, s:s?}", @@ -413,8 +346,6 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh, if (NULL == cprc) { /* First time here, parse request and check order is known */ - const char *long_poll_timeout_s; - cprc = GNUNET_new (struct CheckPaymentRequestContext); cprc->hc.cc = &cprc_cleanup; cprc->ret = GNUNET_SYSERR; @@ -433,31 +364,6 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh, TALER_EC_PARAMETER_MISSING, "order_id required"); } - long_poll_timeout_s = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - "timeout"); - if (NULL != long_poll_timeout_s) - { - unsigned int timeout; - - if (1 != sscanf (long_poll_timeout_s, - "%u", - &timeout)) - { - GNUNET_break_op (0); - return TMH_RESPONSE_reply_bad_request (connection, - TALER_EC_PARAMETER_MALFORMED, - "timeout must be non-negative number"); - } - cprc->long_poll_timeout - = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( - GNUNET_TIME_UNIT_SECONDS, - timeout)); - } - else - { - cprc->long_poll_timeout = GNUNET_TIME_UNIT_ZERO_ABS; - } cprc->contract_url = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "contract_url"); |