gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: fix QR code generation


From: gnunet
Subject: [taler-merchant] branch master updated: fix QR code generation
Date: Wed, 29 Jul 2020 15:44:49 +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 c9aaad5  fix QR code generation
c9aaad5 is described below

commit c9aaad5fb787a339dab703331164e377b18b75fc
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Jul 29 15:44:47 2020 +0200

    fix QR code generation
---
 contrib/Makefile.am                              |  2 +
 contrib/request_payment.must                     |  2 +-
 src/backend/taler-merchant-httpd_get-orders-ID.c | 80 +++++++++++++++---------
 3 files changed, 55 insertions(+), 29 deletions(-)

diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 589b36f..17c8ea4 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -1,3 +1,5 @@
+pkgdatadir = $(prefix)/share/taler/merchant/
+
 dist_pkgdata_DATA = \
   request_payment.must \
   offer_refund.must
diff --git a/contrib/request_payment.must b/contrib/request_payment.must
index 89062b6..6ef7794 100644
--- a/contrib/request_payment.must
+++ b/contrib/request_payment.must
@@ -153,7 +153,7 @@ body {
   <p>
   You can use this QR code to pay with your mobile wallet:
   </p>
-  {{taler_pay_qrcode_svg}}
+  {{{taler_pay_qrcode_svg}}}
   <p>
   Click <a href="{{taler_pay_uri}}">this link</a> to open your system's
   Taler wallet if it exists.
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c 
b/src/backend/taler-merchant-httpd_get-orders-ID.c
index 2c7ec57..d906b89 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -318,6 +318,21 @@ m_enter (void *cls, const char *name)
 }
 
 
+/**
+ * Function called by mustach to activate the next item in the
+ * section. Does nothing, as we do not support sections.
+ *
+ * @param cls a `struct KVC[]` array
+ * @return 0 (no next item to activate)
+ */
+static int
+m_next (void *cls)
+{
+  (void) cls;
+  return 0;
+}
+
+
 /**
  * Function called by Mustach to leave the current section.
  * As we do not support sections, we should never be called.
@@ -359,6 +374,9 @@ m_get (void *cls,
       return MUSTACH_OK;
     }
   }
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+              "Template requires value for unexpected name `%s'\n",
+              name);
   return MUSTACH_ERROR_ITEM_NOT_FOUND;
 }
 
@@ -385,10 +403,11 @@ m_stop (void *cls,
  * Our 'universal' callbacks for mustach.
  */
 static struct mustach_itf itf = {
-  .enter = m_enter,
-  .leave = m_leave,
-  .get = m_get,
-  .stop = m_stop
+  .enter = &m_enter,
+  .next = &m_next,
+  .leave = &m_leave,
+  .get = &m_get,
+  .stop = &m_stop
 };
 
 
@@ -429,7 +448,7 @@ load_template (const char *name)
       return NULL;
     }
     GNUNET_asprintf (&fn,
-                     "%s/%s.must",
+                     "%s/merchant/%s.must",
                      path,
                      name);
     GNUNET_free (path);
@@ -533,7 +552,7 @@ create_qrcode (const char *uri)
   QRinput_free (qri);
   /* FIXME-Dold: generate <img> with inline SVG instead of <pre> here! */
   GNUNET_buffer_write_str (&buf,
-                           "<pre>\n\n\n\n        ");
+                           "<pre><br><br><br><br><br>        ");
   for (unsigned int y = 0; y<qrc->width; y++)
   {
     for (unsigned int x = 0; x<qrc->width; x++)
@@ -544,10 +563,10 @@ create_qrcode (const char *uri)
                                 (0 != (qrc->data[off] & 1)) ? "██" : "  ");
     }
     GNUNET_buffer_write_str (&buf,
-                             "\n        ");
+                             "<br>        ");
   }
   GNUNET_buffer_write_str (&buf,
-                           "\n\n\n\n</pre>");
+                           "<br><br><br><br></pre>");
   QRcode_free (qrc);
   return GNUNET_buffer_reap_str (&buf);
 }
@@ -712,26 +731,31 @@ send_pay_request (struct GetOrderData *god,
           GNUNET_strdup (taler_pay_uri) },
         { "taler_pay_qrcode_svg",
           qr },
+        { "order_summary",
+          GNUNET_strdup ("FIXME") },
         { NULL, NULL }
       };
       const char *tmpl;
+      int eno;
 
       tmpl = load_template ("request_payment");
       if (NULL == tmpl)
       {
-        GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
-                             "mustach");
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Failed to load template `%s'\n",
+                    "request_payment");
         return MHD_NO; // FIXME: add nicer error reply...
       }
       if (0 !=
-          mustach (tmpl,
-                   &itf,
-                   &kvc,
-                   &body,
-                   &body_size))
+          (eno = mustach (tmpl,
+                          &itf,
+                          &kvc,
+                          &body,
+                          &body_size)))
       {
-        GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
-                             "mustach");
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "mustach failed with error %d\n",
+                    eno);
         return MHD_NO;   // FIXME: add nicer error reply...
       }
     }
@@ -1233,13 +1257,12 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
     if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
     {
       struct TALER_ClaimTokenP db_claim_token;
-#if FIXME_6446
 
-      qs = TMH_db->lookup_order_token (TMH_db->cls,
-                                       hc->instance->settings.id,
-                                       order_id,
-                                       &god->contract_terms,
-                                       &db_claim_token);
+      qs = TMH_db->lookup_order (TMH_db->cls,
+                                 hc->instance->settings.id,
+                                 order_id,
+                                 &db_claim_token,
+                                 &god->contract_terms);
       if (0 > qs)
       {
         /* single, read-only SQL statements should never cause
@@ -1252,7 +1275,6 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
                                            TALER_EC_GET_ORDERS_DB_LOOKUP_ERROR,
                                            "database error looking up order");
       }
-#endif
       if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1569,8 +1591,9 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
         tmpl = load_template ("offer_refund");
         if (NULL == tmpl)
         {
-          GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
-                               "mustach");
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "Failed to load template `%s'\n",
+                      "offer_refund");
           return MHD_NO; // FIXME: add nicer error reply...
         }
         if (0 !=
@@ -1595,8 +1618,9 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
         tmpl = load_template ("show_order_details");
         if (NULL == tmpl)
         {
-          GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
-                               "mustach");
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "Failed to load template `%s'\n",
+                      "show_order_details");
           return MHD_NO; // FIXME: add nicer error reply...
         }
         if (0 !=

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