diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2018-07-09 10:37:12 +0200 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2018-07-09 10:37:12 +0200 |
commit | cd2538efb57d34d592efc551695a1b1174433ccb (patch) | |
tree | ddd05c1865e37a47f6dcd251accd8ac96eea2cd0 /src/exchangedb/plugin_exchangedb_postgres.c | |
parent | 7c94a71def217618056a547ac9e8cfa4b2ea1331 (diff) | |
download | exchange-cd2538efb57d34d592efc551695a1b1174433ccb.tar.xz |
Method to retrieve the KYC status of a merchant.
Diffstat (limited to 'src/exchangedb/plugin_exchangedb_postgres.c')
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 47 |
1 files changed, 44 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; } |