gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: emit claim token in URI


From: gnunet
Subject: [taler-merchant] branch master updated: emit claim token in URI
Date: Thu, 30 Jul 2020 12:43:46 +0200

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 b78ea88  emit claim token in URI
b78ea88 is described below

commit b78ea88377e8bad13d2a85cc357db37ca640d332
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Thu Jul 30 16:13:41 2020 +0530

    emit claim token in URI
---
 src/backend/taler-merchant-httpd_get-orders-ID.c      | 19 ++++++++++++++++---
 src/backend/taler-merchant-httpd_get-orders-ID.h      |  5 ++++-
 .../taler-merchant-httpd_private-get-orders-ID.c      | 10 +++++++---
 src/testing/test_merchant_api.conf                    |  1 -
 src/testing/testing_api_helpers.c                     |  3 ++-
 5 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c 
b/src/backend/taler-merchant-httpd_get-orders-ID.c
index a6912b7..8d75bbf 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -626,13 +626,15 @@ suspend_god (struct GetOrderData *god)
  * @param order_id the order id
  * @param session_id session, may be NULL
  * @param instance_id instance, may be "default"
+ * @param claim_token claim token for the order, may be NULL
  * @return corresponding taler://pay/ URI, or NULL on missing "host"
  */
 char *
 TMH_make_taler_pay_uri (struct MHD_Connection *con,
                         const char *order_id,
                         const char *session_id,
-                        const char *instance_id)
+                        const char *instance_id,
+                        struct TALER_ClaimTokenP *claim_token)
 {
   const char *host;
   const char *forwarded_host;
@@ -686,6 +688,15 @@ TMH_make_taler_pay_uri (struct MHD_Connection *con,
                             order_id);
   GNUNET_buffer_write_path (&buf,
                             (session_id == NULL) ? "" : session_id);
+  if ((NULL != claim_token) &&
+      (GNUNET_NO == GNUNET_is_zero (claim_token)))
+  {
+    GNUNET_buffer_write_str (&buf,
+                             "&c=");
+    GNUNET_buffer_write_data_encoded (&buf,
+                                      (char *) claim_token,
+                                      sizeof (struct TALER_ClaimTokenP));
+  }
 
   return GNUNET_buffer_reap_str (&buf);
 }
@@ -724,7 +735,8 @@ send_pay_request (struct GetOrderData *god,
   taler_pay_uri = TMH_make_taler_pay_uri (god->sc.con,
                                           god->order_id,
                                           god->session_id,
-                                          god->hc->instance->settings.id);
+                                          god->hc->instance->settings.id,
+                                          &god->claim_token);
   if (god->generate_html)
   {
     struct MHD_Response *reply;
@@ -799,7 +811,8 @@ send_pay_request (struct GetOrderData *god,
     ret = TALER_MHD_reply_json_pack (god->sc.con,
                                      MHD_HTTP_PAYMENT_REQUIRED,
                                      "{s:s, s:s?}",
-                                     "taler_pay_uri", taler_pay_uri,
+                                     "taler_pay_uri",
+                                     taler_pay_uri,
                                      "already_paid_order_id",
                                      already_paid_order_id);
   }
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.h 
b/src/backend/taler-merchant-httpd_get-orders-ID.h
index 1d2d61f..6f1e773 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.h
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.h
@@ -32,13 +32,16 @@
  * @param order_id the order id
  * @param session_id session, may be NULL
  * @param instance_id instance, may be "default"
+ * @param claim_token claim token for the order, may be NULL
  * @return corresponding taler://pay/ URI, or NULL on missing "host"
  */
 char *
 TMH_make_taler_pay_uri (struct MHD_Connection *con,
                         const char *order_id,
                         const char *session_id,
-                        const char *instance_id);
+                        const char *instance_id,
+                        struct TALER_ClaimTokenP *claim_token);
+
 
 
 /**
diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c 
b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
index 3d6c930..2752703 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -753,6 +753,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler 
*rh,
   bool paid;
   bool wired;
   bool order_only = false;
+  struct TALER_ClaimTokenP claim_token = { 0 };
 
   if (NULL == gorc)
   {
@@ -832,7 +833,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler 
*rh,
       qs = TMH_db->lookup_order (TMH_db->cls,
                                  hc->instance->settings.id,
                                  hc->infix,
-                                 NULL,
+                                 &claim_token,
                                  &gorc->contract_terms);
       order_only = true;
     }
@@ -965,10 +966,12 @@ TMH_private_get_orders_ID (const struct 
TMH_RequestHandler *rh,
       char *taler_pay_uri;
       MHD_RESULT ret;
 
+      /* Claim token is NULL, as order has already been claimed anyway. */
       taler_pay_uri = TMH_make_taler_pay_uri (connection,
                                               hc->infix,
                                               gorc->session_id,
-                                              hc->instance->settings.id);
+                                              hc->instance->settings.id,
+                                              &claim_token);
       ret = TALER_MHD_reply_json_pack (connection,
                                        MHD_HTTP_OK,
                                        "{s:s, s:s, s:s}",
@@ -1035,7 +1038,8 @@ TMH_private_get_orders_ID (const struct 
TMH_RequestHandler *rh,
     taler_pay_uri = TMH_make_taler_pay_uri (connection,
                                             hc->infix,
                                             gorc->session_id,
-                                            hc->instance->settings.id);
+                                            hc->instance->settings.id,
+                                            &claim_token);
     ret = TALER_MHD_reply_json_pack (connection,
                                      MHD_HTTP_OK,
                                      "{s:s, s:O, s:s}",
diff --git a/src/testing/test_merchant_api.conf 
b/src/testing/test_merchant_api.conf
index 955f5c6..9dbaf4e 100644
--- a/src/testing/test_merchant_api.conf
+++ b/src/testing/test_merchant_api.conf
@@ -33,7 +33,6 @@ PORT = 8080
 # Which plugin (backend) do we use for the DB.
 DB = postgres
 
-
 # This specifies which database the postgres backend uses.
 [merchantdb-postgres]
 CONFIG = postgres:///talercheck
diff --git a/src/testing/testing_api_helpers.c 
b/src/testing/testing_api_helpers.c
index 2564c72..5160d62 100644
--- a/src/testing/testing_api_helpers.c
+++ b/src/testing/testing_api_helpers.c
@@ -51,7 +51,8 @@ TALER_TESTING_run_merchant (const char *config_filename,
   merchant_proc
     = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
                                NULL, NULL, NULL,
-                               "taler-merchant-httpd",
+                               "valgrind",
+                               "valgrind",
                                "taler-merchant-httpd",
                                "--log=INFO",
                                "-c", config_filename,

-- 
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]