gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 01/03: fix order id generation


From: gnunet
Subject: [taler-anastasis] 01/03: fix order id generation
Date: Fri, 20 Nov 2020 14:36:01 +0100

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

dennis-neufeld pushed a commit to branch master
in repository anastasis.

commit fe36c52f9ddfcbc0a2f16a231d3a637e8600d075
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Fri Nov 20 09:52:29 2020 +0100

    fix order id generation
---
 src/backend/anastasis-httpd_policy_upload.c | 46 +++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 13 deletions(-)

diff --git a/src/backend/anastasis-httpd_policy_upload.c 
b/src/backend/anastasis-httpd_policy_upload.c
index 0b64415..7be4a87 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -416,22 +416,29 @@ check_payment_cb (void *cls,
   MHD_resume_connection (puc->con);
   AH_trigger_daemon ();
 
-  if (osr->status)
+  switch (osr->status)
   {
-    enum ANASTASIS_DB_QueryStatus qs;
+  case TALER_MERCHANT_OSC_PAID:
+    {
+
+      enum ANASTASIS_DB_QueryStatus qs;
 
-    qs = db->increment_lifetime (db->cls,
-                                 &puc->account,
-                                 &puc->payment_identifier,
-                                 GNUNET_TIME_UNIT_YEARS); /* FIXME: always 
annual ?*/
-    if (0 <= qs)
+      qs = db->increment_lifetime (db->cls,
+                                   &puc->account,
+                                   &puc->payment_identifier,
+                                   GNUNET_TIME_UNIT_YEARS); /* FIXME: always 
annual ?*/
+      if (0 <= qs)
+        return; /* continue as planned */
+      GNUNET_break (0);
+      puc->resp = TALER_MHD_make_error (
+        TALER_EC_GENERIC_DB_FETCH_FAILED,
+        "increment lifetime");
+      puc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
       return; /* continue as planned */
-    GNUNET_break (0);
-    puc->resp = TALER_MHD_make_error (
-      TALER_EC_GENERIC_DB_FETCH_FAILED,
-      "increment lifetime");
-    puc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
-    return; /* continue as planned */
+    }
+  case TALER_MERCHANT_OSC_UNPAID:
+  case TALER_MERCHANT_OSC_CLAIMED:
+    break;
   }
   if (NULL != puc->existing_order_id)
   {
@@ -862,6 +869,19 @@ AH_handler_policy_post (struct MHD_Connection *connection,
 
         if ((qs >= 0) && (! paid || ! valid_counter))
         {
+          if (qs == 0)
+          {
+            // generate new payment identifier
+            GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+                                        &puc->payment_identifier,
+                                        sizeof (
+                                          struct ANASTASIS_PaymentSecretP));
+            GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                        "At %s:%d Payment-Identifier generated is: %s\n",
+                        __FILE__,
+                        __LINE__,
+                        TALER_B2S (&puc->payment_identifier));
+          }
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "At %s:%d paid is: '%d' and valid_counter is '%d'\n",
                       __FILE__,

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