gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated: merchant_base_url instead of pay


From: gnunet
Subject: [taler-merchant] branch master updated: merchant_base_url instead of pay_url
Date: Fri, 01 Nov 2019 16:16:42 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new d09d828  merchant_base_url instead of pay_url
d09d828 is described below

commit d09d8282981437e5031e2ef145cd3a2b75ded9e1
Author: Florian Dold <address@hidden>
AuthorDate: Fri Nov 1 16:16:28 2019 +0100

    merchant_base_url instead of pay_url
---
 src/backend/taler-merchant-httpd_proposal.c | 62 ++++++++++++++++++++++++++---
 1 file changed, 56 insertions(+), 6 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_proposal.c 
b/src/backend/taler-merchant-httpd_proposal.c
index aa56e61..06788f0 100644
--- a/src/backend/taler-merchant-httpd_proposal.c
+++ b/src/backend/taler-merchant-httpd_proposal.c
@@ -138,6 +138,59 @@ json_parse_cleanup (struct TM_HandlerContext *hc)
 }
 
 
+/**
+ * Generate the base URL for the given merchant instance.
+ *
+ * @param connection the MHD connection
+ * @param instance_id the merchant instance ID
+ * @returns the merchant instance's base URL
+ */
+static char *
+make_merchant_base_url (struct MHD_Connection *connection, const
+                        char *instance_id)
+{
+  const char *host;
+  const char *forwarded_host;
+  const char *uri_path;
+  struct TALER_Buffer buf = { 0 };
+
+  if (GNUNET_YES == TALER_mhd_is_https (connection))
+    TALER_buffer_write_str (&buf, "https://";);
+  else
+    TALER_buffer_write_str (&buf, "http://";);
+
+
+  host = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "Host");
+  forwarded_host = MHD_lookup_connection_value (connection, MHD_HEADER_KIND,
+                                                "X-Forwarded-Host");
+
+  if (NULL != forwarded_host)
+  {
+    TALER_buffer_write_str (&buf, forwarded_host);
+  }
+  else
+  {
+    GNUNET_assert (NULL != host);
+    TALER_buffer_write_str (&buf, host);
+  }
+
+  uri_path = MHD_lookup_connection_value (connection, MHD_HEADER_KIND,
+                                          "X-Forwarded-Prefix");
+
+  if (NULL != uri_path)
+    TALER_buffer_write_path (&buf, uri_path);
+
+  if (0 != strcmp (instance_id, "default"))
+  {
+    TALER_buffer_write_path (&buf, "/instance/");
+    TALER_buffer_write_str (&buf, instance_id);
+  }
+  TALER_buffer_write_path (&buf, "");
+
+  return TALER_buffer_reap_str (&buf);
+}
+
+
 /**
  * Transform an order into a proposal and store it in the
  * database. Write the resulting proposal or an error message
@@ -286,16 +339,13 @@ proposal_put (struct MHD_Connection *connection,
   }
 
   if (NULL == json_object_get (order,
-                               "pay_url"))
+                               "merchant_base_url"))
   {
     char *url;
 
-    url = TALER_url_absolute_mhd (connection,
-                                  "/public/pay",
-                                  NULL);
-
+    url = make_merchant_base_url (connection, mi->id);
     json_object_set_new (order,
-                         "pay_url",
+                         "merchant_base_url",
                          json_string (url));
     GNUNET_free (url);
   }

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]