gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] branch master updated: Method to retrieve


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: Method to retrieve the KYC status of a merchant.
Date: Mon, 09 Jul 2018 10:37:29 +0200

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

marcello pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new cd2538e  Method to retrieve the KYC status of a merchant.
cd2538e is described below

commit cd2538efb57d34d592efc551695a1b1174433ccb
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Jul 9 10:37:12 2018 +0200

    Method to retrieve the KYC status of a merchant.
---
 src/exchangedb/plugin_exchangedb_postgres.c | 47 +++++++++++++++++++++++++++--
 src/exchangedb/test_exchangedb.c            | 12 ++++++++
 src/include/taler_exchangedb_plugin.h       | 13 ++++++++
 3 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index d43132b..6d0889c 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1294,13 +1294,20 @@ postgres_prepare (PGconn *db_conn)
      *
      * 1 Sum money flow for a (unchecked) merchant.
      * 2 Change KYC status for a merchant.
-     * 3 Get KYC status for a merchant.
+     * 3 Get KYC status for a merchant. --
      * 4 Put money flow event for a merchant.
      * 5 Delete money flow records for a fresh-checked merchant.
-     * 6 Put a merchant.
-     * 7 Change KYC status flag for a merchant.
+     * 6 Put a merchant. V
+     * 7 Change KYC status flag for a merchant. V
      */
 
+    GNUNET_PQ_make_prepare ("get_kyc_status",
+                            "SELECT"
+                            " (kyc_checked)"
+                            " FROM kyc_merchants"
+                            " WHERE payto_url=$1",
+                            1),
+
     GNUNET_PQ_make_prepare ("insert_kyc_merchant",
                             "INSERT INTO kyc_merchants "
                             "(payto_url, kyc_checked) VALUES "
@@ -6548,6 +6555,39 @@ postgres_mark_kyc_merchant (void *cls,
                                              params);
 }
 
+/**
+ * Retrieve KYC-check status related to a particular merchant.
+ *
+ * @param payto_url URL identifying a merchant bank account,
+ *        whose KYC is going to be retrieved.
+ * @param[out] status store the result.
+ * @return transaction status.
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_get_kyc_status (void *cls,
+                         struct TALER_EXCHANGEDB_Session *session,
+                         const char *payto_url,
+                         uint8_t *status)
+{ 
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_string (payto_url),
+    GNUNET_PQ_query_param_end
+  }; 
+
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    GNUNET_PQ_result_spec_auto_from_type ("kyc_checked",
+                                          status),
+    GNUNET_PQ_result_spec_end
+  };
+
+  return GNUNET_PQ_eval_prepared_singleton_select
+    (session->conn,
+     "get_kyc_status",
+     params,
+     rs);
+}
+
+
 
 /**
  * Insert a merchant into the KYC monitor table.
@@ -6707,6 +6747,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
 
   plugin->insert_kyc_merchant = postgres_insert_kyc_merchant;
   plugin->mark_kyc_merchant = postgres_mark_kyc_merchant;
+  plugin->get_kyc_status = postgres_get_kyc_status;
 
   return plugin;
 }
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 6adb2da..06b0372 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -2190,6 +2190,18 @@ run (void *cls)
           plugin->mark_kyc_merchant (NULL,
                                      session,
                                      "payto://mock"));
+
+  {
+    uint8_t kyc_checked;
+
+    FAILIF (GNUNET_OK !=
+            plugin->get_kyc_status (NULL,
+                                    session,
+                                    "payto://mock",
+                                    &kyc_checked));
+    FAILIF (GNUNET_YES != kyc_checked);
+
+  }
   plugin->preflight (plugin->cls,
                      session);
 
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 6724be4..8c67d97 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -2248,6 +2248,19 @@ struct TALER_EXCHANGEDB_Plugin
                         struct TALER_EXCHANGEDB_Session *session,
                         const char *payto_url);
 
+  /**
+   * Retrieve KYC-check status related to a particular merchant.
+   *
+   * @param payto_url URL identifying a merchant bank account,
+   *        whose KYC is going to be retrieved.
+   * @param[out] status store the result.
+   * @return transaction status.
+   */
+  enum GNUNET_DB_QueryStatus
+  (*get_kyc_status) (void *cls,
+                     struct TALER_EXCHANGEDB_Session *session,
+                     const char *payto_url,
+                     uint8_t *status);
 };
 
 #endif /* _TALER_EXCHANGE_DB_H */

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



reply via email to

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