Method to retrieve the KYC status of a merchant.

This commit is contained in:
Marcello Stanisci 2018-07-09 10:37:12 +02:00
parent 7c94a71def
commit cd2538efb5
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
3 changed files with 69 additions and 3 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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 */