gnunet-svn
[Top][All Lists]
Advanced

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

[merchant] branch master updated: notify kyc helper before filtering exc


From: gnunet
Subject: [merchant] branch master updated: notify kyc helper before filtering exchanges for zero deposit limits
Date: Tue, 14 Jan 2025 18:58:08 +0100

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 ce431cdc notify kyc helper before filtering exchanges for zero deposit 
limits
ce431cdc is described below

commit ce431cdcbea88fb35142f231a1a370d606748873
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Jan 14 18:57:59 2025 +0100

    notify kyc helper before filtering exchanges for zero deposit limits
---
 .../taler-merchant-httpd_post-orders-ID-pay.c      |  2 +-
 .../taler-merchant-httpd_private-post-orders.c     | 86 +++++++++++-----------
 2 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c 
b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
index 71d5e1af..335884f3 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -102,7 +102,7 @@ enum PayPhase
   PP_CHECK_CONTRACT,
 
   /**
-   * Validate provided tokens and token evelopes.
+   * Validate provided tokens and token envelopes.
    */
   PP_VALIDATE_TOKENS,
 
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c 
b/src/backend/taler-merchant-httpd_private-post-orders.c
index 4c467cb0..67e42f0d 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -2434,6 +2434,41 @@ update_stefan (struct OrderContext *oc,
 }
 
 
+/**
+ * Check our KYC status at all exchanges as our current limit is
+ * too low and we failed to create an order.
+ *
+ * @param oc order context
+ * @param exchange_url exchange to notify about
+ */
+static void
+notify_kyc_required (const struct OrderContext *oc,
+                     const char *exchange_url)
+{
+  struct GNUNET_DB_EventHeaderP es = {
+    .size = htons (sizeof (es)),
+    .type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_RULE_TRIGGERED)
+  };
+  char *hws;
+  char *extra;
+
+  hws = GNUNET_STRINGS_data_to_string_alloc (
+    &oc->add_payment_details.wm->h_wire,
+    sizeof (oc->add_payment_details.wm->h_wire));
+
+  GNUNET_asprintf (&extra,
+                   "%s %s",
+                   hws,
+                   exchange_url);
+  TMH_db->event_notify (TMH_db->cls,
+                        &es,
+                        extra,
+                        strlen (extra) + 1);
+  GNUNET_free (extra);
+  GNUNET_free (hws);
+}
+
+
 /**
  * Compute the set of exchanges that would be acceptable
  * for this order.
@@ -2468,6 +2503,15 @@ get_acceptable (void *cls,
               TALER_amount2s (&max_amount));
   if (TALER_amount_is_zero (&max_amount))
   {
+    if (! TALER_amount_is_zero (max_needed))
+    {
+      /* Trigger re-checking the current deposit limit when
+       * paying non-zero amount with zero deposit limit */
+      notify_kyc_required (oc,
+                           url);
+    }
+    /* If deposit is impossible, we don't list the
+     * exchange in the contract terms. */
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Exchange %s deposit limit is zero, skipping it\n",
                 url);
@@ -2675,47 +2719,6 @@ get_exchange_keys (void *cls,
 }
 
 
-/**
- * Check our KYC status at all exchanges as our current limit is
- * too low and we failed to create an order.
- *
- * @param oc order context
- */
-static void
-notify_kyc_required (const struct OrderContext *oc)
-{
-  struct GNUNET_DB_EventHeaderP es = {
-    .size = htons (sizeof (es)),
-    .type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_RULE_TRIGGERED)
-  };
-  char *hws;
-  char *extra;
-  json_t *exchange;
-  size_t i;
-
-  hws = GNUNET_STRINGS_data_to_string_alloc (
-    &oc->add_payment_details.wm->h_wire,
-    sizeof (oc->add_payment_details.wm->h_wire));
-  json_array_foreach (oc->set_exchanges.exchanges, i, exchange)
-  {
-    const char *exchange_url
-      = json_string_value (json_object_get (exchange,
-                                            "url"));
-
-    GNUNET_asprintf (&extra,
-                     "%s %s",
-                     hws,
-                     exchange_url);
-    TMH_db->event_notify (TMH_db->cls,
-                          &es,
-                          extra,
-                          strlen (extra) + 1);
-    GNUNET_free (extra);
-  }
-  GNUNET_free (hws);
-}
-
-
 /**
  * Task run when we are timing out on /keys and will just
  * proceed with what we got.
@@ -2911,7 +2914,6 @@ set_exchanges (struct OrderContext *oc)
 
     if (! ok)
     {
-      notify_kyc_required (oc);
       reply_with_error (
         oc,
         MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS,

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