gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: implement #6467


From: gnunet
Subject: [taler-merchant] branch master updated: implement #6467
Date: Sun, 09 Aug 2020 15:01:53 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new ac7d956  implement #6467
ac7d956 is described below

commit ac7d956ad8d233bf25698c2abbf55d9202dfdf67
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Aug 9 15:01:50 2020 +0200

    implement #6467
---
 .../taler-merchant-httpd_private-post-orders.c     | 56 +++++++++++++++++++---
 1 file changed, 50 insertions(+), 6 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c 
b/src/backend/taler-merchant-httpd_private-post-orders.c
index 6fd65ae..3c4e91e 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -588,11 +588,12 @@ patch_order (struct MHD_Connection *connection,
 {
   const struct TALER_MERCHANTDB_InstanceSettings *settings =
     &hc->instance->settings;
+  const char *order_id;
 
   /* Add order_id if it doesn't exist. */
-  if (NULL ==
-      json_string_value (json_object_get (order,
-                                          "order_id")))
+  order_id = json_string_value (json_object_get (order,
+                                                 "order_id"));
+  if (NULL == order_id)
   {
     char buf[256];
     time_t timer;
@@ -600,6 +601,7 @@ patch_order (struct MHD_Connection *connection,
     size_t off;
     uint64_t rand;
     char *last;
+    json_t *jbuf;
 
     time (&timer);
     tm_info = localtime (&timer);
@@ -623,9 +625,51 @@ patch_order (struct MHD_Connection *connection,
                                           &buf[off],
                                           sizeof (buf) - off);
     *last = '\0';
-    json_object_set_new (order,
-                         "order_id",
-                         json_string (buf));
+    jbuf = json_string (buf);
+    GNUNET_break (0 ==
+                  json_object_set_new (order,
+                                       "order_id",
+                                       jbuf));
+    order_id = json_string_value (jbuf);
+    GNUNET_assert (NULL != order_id);
+  }
+
+  /* Patch fulfillment URL with order_id (implements #6467). */
+  {
+    const char *fulfillment_url;
+
+    fulfillment_url = json_string_value (json_object_get (order,
+                                                          "fulfillment_url"));
+    if (NULL != fulfillment_url)
+    /* The above condition should always be true; if not we do the error
+       handling later in execute_order() and just skip the logic here. */
+    {
+      const char *pos;
+
+      pos = strstr (fulfillment_url,
+                    "${ORDER_ID}");
+      if (NULL != pos)
+      {
+        /* replace ${ORDER_ID} with the real order_id */
+        char *nurl;
+
+        GNUNET_asprintf (&nurl,
+                         "%.*s%s%s",
+                         /* first output URL until ${ORDER_ID} */
+                         (int) (pos - fulfillment_url),
+                         fulfillment_url,
+                         /* replace ${ORDER_ID} with the right order_id */
+                         order_id,
+                         /* append rest of original URL */
+                         pos + strlen ("${ORDER_ID}"));
+        /* replace in JSON of the order */
+        GNUNET_break (0 ==
+                      json_object_set_new (order,
+                                           "fulfillment_url",
+                                           json_string (nurl)));
+        GNUNET_free (nurl);
+      }
+    }
   }
 
   /* Add timestamp if it doesn't exist */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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