summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-07-09 10:37:12 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-07-09 10:37:12 +0200
commitcd2538efb57d34d592efc551695a1b1174433ccb (patch)
treeddd05c1865e37a47f6dcd251accd8ac96eea2cd0 /src
parent7c94a71def217618056a547ac9e8cfa4b2ea1331 (diff)
downloadexchange-cd2538efb57d34d592efc551695a1b1174433ccb.tar.gz
exchange-cd2538efb57d34d592efc551695a1b1174433ccb.tar.bz2
exchange-cd2538efb57d34d592efc551695a1b1174433ccb.zip
Method to retrieve the KYC status of a merchant.
Diffstat (limited to 'src')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c47
-rw-r--r--src/exchangedb/test_exchangedb.c12
-rw-r--r--src/include/taler_exchangedb_plugin.h13
3 files changed, 69 insertions, 3 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index d43132bdd..6d0889c80 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 6adb2da12..06b0372f4 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 6724be4d2..8c67d9705 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 */