From 64be1fe4863900091a085e20630a8049d1ee37c0 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 6 Apr 2019 16:08:23 +0200 Subject: add non-X variants to payment trigger to provide future-compatibility --- src/backend/taler-merchant-httpd_trigger-pay.c | 74 +++++++++++++++++++++----- 1 file changed, 60 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/backend/taler-merchant-httpd_trigger-pay.c b/src/backend/taler-merchant-httpd_trigger-pay.c index 2187acbe..47c68157 100644 --- a/src/backend/taler-merchant-httpd_trigger-pay.c +++ b/src/backend/taler-merchant-httpd_trigger-pay.c @@ -42,8 +42,10 @@ * @param header_name name of the header to set */ static void -add_header_from_arg (struct MHD_Connection *connection, const char *arg_name, - struct MHD_Response *response, const char *header_name) +add_header_from_arg (struct MHD_Connection *connection, + const char *arg_name, + struct MHD_Response *response, + const char *header_name) { const char *arg = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, @@ -75,22 +77,66 @@ MH_handler_trigger_pay (struct TMH_RequestHandler *rh, size_t *upload_data_size) { struct MHD_Response *response; - - // FIXME: Taler wallet detection! char *data = "

Processing payment ...

"; - response = MHD_create_response_from_buffer (strlen (data), data, MHD_RESPMEM_PERSISTENT); + response = MHD_create_response_from_buffer (strlen (data), + data, + MHD_RESPMEM_PERSISTENT); + add_header_from_arg (connection, + "session_id", + response, + "Taler-Session-Id"); + add_header_from_arg (connection, + "contract_url", + response, + "Taler-Contract-Url"); + add_header_from_arg (connection, + "h_contract_terms", + response, + "Taler-Contract-Hash"); + add_header_from_arg (connection, + "tip_token", + response, + "Taler-Tip"); + add_header_from_arg (connection, + "refund_url", + response, + "Taler-Refund-Url"); + add_header_from_arg (connection, + "resource_url", + response, + "Taler-Resource-Url"); + /* FIXME: the X- variants should go away in the future, for now + preserved for backwards-compatibility only! */ + add_header_from_arg (connection, + "session_id", + response, + "X-Taler-Session-Id"); + add_header_from_arg (connection, + "contract_url", + response, + "X-Taler-Contract-Url"); + add_header_from_arg (connection, + "h_contract_terms", + response, + "X-Taler-Contract-Hash"); + add_header_from_arg (connection, + "tip_token", + response, + "X-Taler-Tip"); + add_header_from_arg (connection, + "refund_url", + response, + "X-Taler-Refund-Url"); + add_header_from_arg (connection, + "resource_url", + response, + "X-Taler-Resource-Url"); - add_header_from_arg (connection, "session_id", response, "X-Taler-Session-Id"); - add_header_from_arg (connection, "contract_url", response, "X-Taler-Contract-Url"); - add_header_from_arg (connection, "h_contract_terms", response, "X-Taler-Contract-Hash"); - add_header_from_arg (connection, "tip_token", response, "X-Taler-Tip"); - add_header_from_arg (connection, "refund_url", response, "X-Taler-Refund-Url"); - add_header_from_arg (connection, "resource_url", response, "X-Taler-Resource-Url"); - - MHD_queue_response (connection, 402, response); + MHD_queue_response (connection, + MHD_HTTP_PAYMENT_REQUIRED, + response); MHD_destroy_response (response); - return MHD_YES; } -- cgit v1.2.3