gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated (4f237e8 -> 64a7d25)


From: gnunet
Subject: [taler-merchant] branch master updated (4f237e8 -> 64a7d25)
Date: Fri, 10 Apr 2020 21:33:21 +0200

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

grothoff pushed a change to branch master
in repository merchant.

    from 4f237e8  add API to store refund proofs
     new 257ee83  implement caching/persisting of exchange /refund responses
     new 64a7d25  fix log levels

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ChangeLog                                          | 42 +++++++--------
 src/backend/taler-merchant-httpd_refund_increase.c |  2 +-
 src/backend/taler-merchant-httpd_refund_lookup.c   | 60 ++++++++++++++++++----
 src/backenddb/plugin_merchantdb_postgres.c         |  2 +-
 4 files changed, 73 insertions(+), 33 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d34b96f..4a61c55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri 10 Apr 2020 09:01:22 PM CEST
+    Changing refund API to have the merchant backend make the /refund
+    request to the exchange instead of having the wallet do it (#5299). -CG
+
 Tue 31 Mar 2020 04:17:58 PM CEST
        Releasing taler-merchant 0.7.0. -CG
 
@@ -30,16 +34,16 @@ Wed Oct 18 15:33:23 CEST 2017
        Releasing taler-merchant 0.4.0. -CG
 
 Thu Jun 22 15:12:37 CEST 2017
-        Implementing /refund
+    Implementing /refund
 
 Tue Jun  6 14:30:43 CEST 2017
-        Abstracting the response gotten from the exchange's tracking
-        API and relying it to the frontend.
-        A payment generator has been implemented so that the db can
-        easily be populated for testing purposes.
-        /history API now has the way to query from a starting base date
-        ahead into the future.
-        Memory leak fixes. -CG/MS
+    Abstracting the response gotten from the exchange's tracking
+    API and relying it to the frontend.
+    A payment generator has been implemented so that the db can
+    easily be populated for testing purposes.
+    /history API now has the way to query from a starting base date
+    ahead into the future.
+    Memory leak fixes. -CG/MS
        Releasing taler-merchant 0.3.0. -CG
 
 Mon Mar  6 17:57:51 CET 2017
@@ -52,24 +56,22 @@ Mon Mar  6 00:59:25 CET 2017
        IP address (#4752).  Enabling use of dual-stack by default. -CG
 
 Thu Dec 15 10:37:08 CET 2016
-        Implementing:
-        - /map/in, /map/out API, to allow frontends to store
-        plain text contracts in database and retrieving them
-        by looking for their hashcodes.
-
+    Implementing:
+    - /map/in, /map/out API, to allow frontends to store
+    plain text contracts in database and retrieving them
+    by looking for their hashcodes.
 
 Fri Nov 18 18:54:07 CET 2016
        Misc. minor updates to match API changes from exchange 0.2.
        Releasing taler-merchant 0.2.0. -CG
 
 Mon Oct 10 16:27:57 CEST 2016
-        Implementing:
-        - /track API, to map transactions to wire transfers and
-        viceversa.
-        - /history API, to get the list of transactions in DB.
-        - merchant "instances", to run make multiple shops on the
-        same backend.
-        -MS
+    Implementing:
+    - /track API, to map transactions to wire transfers and
+    viceversa.
+    - /history API, to get the list of transactions in DB.
+    - merchant "instances", to run make multiple shops on the
+    same backend. -MS
 
 Tue Jun  7 15:17:45 CEST 2016
        Store signing key used by exchange in DB.  Might be useful
diff --git a/src/backend/taler-merchant-httpd_refund_increase.c 
b/src/backend/taler-merchant-httpd_refund_increase.c
index a6ba992..1832dee 100644
--- a/src/backend/taler-merchant-httpd_refund_increase.c
+++ b/src/backend/taler-merchant-httpd_refund_increase.c
@@ -248,7 +248,7 @@ process_refund (struct MHD_Connection *connection,
   }
   if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Refusing refund amount %s that is larger than original 
payment\n",
                 TALER_amount2s (refund));
     return TALER_MHD_reply_with_error (connection,
diff --git a/src/backend/taler-merchant-httpd_refund_lookup.c 
b/src/backend/taler-merchant-httpd_refund_lookup.c
index e80241b..0fd83ad 100644
--- a/src/backend/taler-merchant-httpd_refund_lookup.c
+++ b/src/backend/taler-merchant-httpd_refund_lookup.c
@@ -63,6 +63,11 @@ struct CoinRefund
    */
   struct ProcessRefundData *prd;
 
+  /**
+   * URL of the exchange for this @e coin_pub.
+   */
+  char *exchange_url;
+
   /**
    * Coin to refund.
    */
@@ -213,6 +218,7 @@ cleanup_prd (struct TM_HandlerContext *cls)
       json_decref (cr->exchange_reply);
       cr->exchange_reply = NULL;
     }
+    GNUNET_free (cr->exchange_url);
     GNUNET_free (cr);
   }
   GNUNET_free (prd);
@@ -295,12 +301,25 @@ refund_cb (void *cls,
   }
   else
   {
+    enum GNUNET_DB_QueryStatus qs;
+
     cr->exchange_pub = *exchange_pub;
     cr->exchange_sig = *exchange_sig;
-    /* FIXME: store in our database,
-       1) as evidence for us that the refund happened, and
-       2) to possibly avoid doing another exchange iteration
-       the next time around. */
+    qs = db->put_refund_proof (db->cls,
+                               &cr->prd->merchant->pubkey,
+                               &cr->prd->h_contract_terms,
+                               &cr->coin_pub,
+                               cr->rtransaction_id,
+                               exchange_pub,
+                               exchange_sig);
+    if (0 >= qs)
+    {
+      /* generally, this is relatively harmless for the merchant, but let's at
+         least log this. */
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "Failed to persist exchange response to /refund in database: 
%d\n",
+                  qs);
+    }
   }
   check_resume_prd (cr->prd);
 }
@@ -381,6 +400,7 @@ process_refunds_cb (void *cls,
               TALER_amount2s (refund_amount),
               reason);
   cr = GNUNET_new (struct CoinRefund);
+  cr->exchange_url = GNUNET_strdup (exchange_url);
   cr->prd = prd;
   cr->coin_pub = *coin_pub;
   cr->rtransaction_id = rtransaction_id;
@@ -389,13 +409,6 @@ process_refunds_cb (void *cls,
   GNUNET_CONTAINER_DLL_insert (prd->cr_head,
                                prd->cr_tail,
                                cr);
-  /* FIXME: check in database if we already got the
-     results from #refund_cb() from an earlier request,
-     if so, avoid this step: */
-  cr->fo = TMH_EXCHANGES_find_exchange (exchange_url,
-                                        NULL,
-                                        &exchange_found_cb,
-                                        cr);
 }
 
 
@@ -529,6 +542,31 @@ MH_handler_refund_lookup (struct TMH_RequestHandler *rh,
                                          TALER_EC_REFUND_LOOKUP_DB_ERROR,
                                          "Failed to lookup refunds for 
contract");
     }
+
+    /* Now launch exchange interactions, unless we already have the
+       response in the database! */
+    for (struct CoinRefund *cr = prd->cr_head;
+         NULL != cr;
+         cr = cr->next)
+    {
+      enum GNUNET_DB_QueryStatus qs;
+
+      qs = db->get_refund_proof (db->cls,
+                                 &cr->prd->merchant->pubkey,
+                                 &cr->prd->h_contract_terms,
+                                 &cr->coin_pub,
+                                 cr->rtransaction_id,
+                                 &cr->exchange_pub,
+                                 &cr->exchange_sig);
+      if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
+      {
+        /* We need to talk to the exchange */
+        cr->fo = TMH_EXCHANGES_find_exchange (cr->exchange_url,
+                                              NULL,
+                                              &exchange_found_cb,
+                                              cr);
+      }
+    }
   }
 
   /* Check if there are still exchange operations pending */
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 77c9607..697732d 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -2388,7 +2388,7 @@ process_deposits_for_refund_cb (void *cls,
    * issue a refund bigger than the contract's actual price, we cannot
    * rely upon the frontend being correct.
    *///
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
               "The refund of %s is bigger than the order's value\n",
               TALER_amount2s (ctx->refund));
   ctx->qs = GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;

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



reply via email to

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