summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-02-20 17:44:06 +0100
committerChristian Grothoff <christian@grothoff.org>2023-02-20 17:44:06 +0100
commit2a52426a7cdc55f49f726f24ddc735d6c01decaa (patch)
tree877fdbd77d028f6650f8cdc1e80b6482d0d30d54 /src
parent8ffaa360d505a40c74071a6cd3f534dfb4776c9f (diff)
downloadmerchant-2a52426a7cdc55f49f726f24ddc735d6c01decaa.tar.gz
merchant-2a52426a7cdc55f49f726f24ddc735d6c01decaa.tar.bz2
merchant-2a52426a7cdc55f49f726f24ddc735d6c01decaa.zip
preparations to store AML decision if any is returned by the exchange, incomplete, not really used
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_post-orders-ID-pay.c15
-rw-r--r--src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c33
-rw-r--r--src/backend/taler-merchant-httpd_private-get-orders-ID.c3
-rw-r--r--src/backenddb/merchant-0004.sql7
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c30
-rw-r--r--src/backenddb/test_merchantdb.c39
-rw-r--r--src/include/taler_merchantdb_plugin.h12
7 files changed, 90 insertions, 49 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 61f232aa..41b526c9 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -760,7 +760,8 @@ deposit_get_callback (
NULL, /* no signature */
NULL, /* no signature */
now,
- true);
+ true,
+ TALER_AML_NORMAL);
GNUNET_break (qs > 0);
break;
case MHD_HTTP_ACCEPTED:
@@ -773,7 +774,8 @@ deposit_get_callback (
NULL, /* no signature */
NULL, /* no signature */
now,
- dr->details.accepted.kyc_ok);
+ dr->details.accepted.kyc_ok,
+ dr->details.accepted.aml_decision);
GNUNET_break (qs > 0);
break;
default:
@@ -841,6 +843,7 @@ process_kyc_with_exchange (
* @param exchange_url base URL of the exchange for which this is a status
* @param last_check when did we last get an update on our KYC status from the exchange
* @param kyc_ok true if we satisfied the KYC requirements
+ * @param aml_decision latest AML decision by the exchange
*/
static void
kyc_cb (
@@ -850,12 +853,18 @@ kyc_cb (
const char *payto_uri,
const char *exchange_url,
struct GNUNET_TIME_Timestamp last_check,
- bool kyc_ok)
+ bool kyc_ok,
+ enum TALER_AmlDecisionState aml_decision)
{
struct KycContext *kc = cls;
+ (void) h_wire;
+ (void) exchange_kyc_serial;
+ (void) payto_uri;
+ (void) exchange_url;
kc->kyc_timestamp = last_check;
kc->kyc_ok = kyc_ok;
+ /* FIXME: act on aml_decision? */
}
diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
index 10c76013..c879fbe0 100644
--- a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
+++ b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
@@ -110,11 +110,6 @@ struct ExchangeKycRequest
*/
struct GNUNET_TIME_Timestamp last_check;
- /**
- * Last KYC status returned by the exchange.
- */
- bool kyc_ok;
-
};
@@ -310,9 +305,9 @@ kyc_context_cleanup (void *cls)
/**
- * Resume the given KYC context and send the given response.
- * Stores the response in the @a kc and signals MHD to resume
- * the connection. Also ensures MHD runs immediately.
+ * Resume the given KYC context and send the given response. Stores the
+ * response in the @a kc and signals MHD to resume the connection. Also
+ * ensures MHD runs immediately.
*
* @param kc KYC context
* @param response_code response code to use
@@ -433,9 +428,8 @@ handle_kyc_timeout (void *cls)
/**
- * We are done with the KYC request @a ekr.
- * Remove it from the work list and check if
- * we are done overall.
+ * We are done with the KYC request @a ekr. Remove it from the work list and
+ * check if we are done overall.
*
* @param[in] ekr key request that is done (and will be freed)
*/
@@ -494,6 +488,7 @@ exchange_check_cb (void *cls,
struct KycContext *kc = ekr->kc;
ekr->kyc = NULL;
+ // FIXME: handle case where exchange returns that account is AML pending/frozen!
switch (ks->http_status)
{
case MHD_HTTP_OK:
@@ -508,7 +503,8 @@ exchange_check_cb (void *cls,
&ks->details.success.exchange_sig,
&ks->details.success.exchange_pub,
ks->details.success.timestamp,
- true);
+ true,
+ TALER_AML_NORMAL);
if (qs < 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -543,7 +539,8 @@ exchange_check_cb (void *cls,
NULL,
NULL,
now,
- true);
+ true,
+ TALER_AML_NORMAL);
if (qs < 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -636,8 +633,8 @@ kyc_with_exchange (void *cls,
/**
- * Function called from ``account_kyc_get_status``
- * with KYC status information for this merchant.
+ * Function called from account_kyc_get_status() with KYC status information
+ * for this merchant.
*
* @param cls our `struct KycContext *`
* @param h_wire hash of the wire account
@@ -646,6 +643,7 @@ kyc_with_exchange (void *cls,
* @param exchange_url base URL of the exchange for which this is a status
* @param last_check when did we last get an update on our KYC status from the exchange
* @param kyc_ok true if we satisfied the KYC requirements
+ * @param aml_decision latest AML decision known to us
*/
static void
kyc_status_cb (void *cls,
@@ -654,12 +652,14 @@ kyc_status_cb (void *cls,
const char *payto_uri,
const char *exchange_url,
struct GNUNET_TIME_Timestamp last_check,
- bool kyc_ok)
+ bool kyc_ok,
+ enum TALER_AmlDecisionState aml_decision)
{
struct KycContext *kc = cls;
struct ExchangeKycRequest *ekr;
if (kyc_ok &&
+ (TALER_AML_PENDING != aml_decision) &&
(GNUNET_TIME_relative_cmp (
GNUNET_TIME_absolute_get_duration (last_check.abs_time),
<,
@@ -680,7 +680,6 @@ kyc_status_cb (void *cls,
ekr->exchange_url = GNUNET_strdup (exchange_url);
ekr->payto_uri = GNUNET_strdup (payto_uri);
ekr->last_check = last_check;
- ekr->kyc_ok = kyc_ok;
ekr->kc = kc;
ekr->fo = TMH_EXCHANGES_find_exchange (exchange_url,
NULL,
diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
index f4e67da9..87ebc44e 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -537,7 +537,8 @@ deposit_get_cb (void *cls,
NULL,
NULL,
now,
- false);
+ dr->details.accepted.kyc_ok,
+ dr->details.accepted.aml_decision);
if (qs < 0)
{
gorc_report (gorc,
diff --git a/src/backenddb/merchant-0004.sql b/src/backenddb/merchant-0004.sql
index 55cfa2fc..b63594ee 100644
--- a/src/backenddb/merchant-0004.sql
+++ b/src/backenddb/merchant-0004.sql
@@ -106,6 +106,13 @@ COMMENT ON COLUMN merchant_pending_webhooks.body
IS 'Body of the webhook';
+ALTER TABLE merchant_kyc
+ ADD COLUMN aml_decision INT4 NOT NULL DEFAULT (0);
+
+COMMENT ON COLUMN merchant_kyc.aml_decision
+ IS 'current AML decision for our account at the exchange';
+
+
COMMIT;
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 5afe7f0a..9f07d3aa 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -907,7 +907,8 @@ kyc_status_cb (void *cls,
char *exchange_url;
char *payto_uri;
struct GNUNET_TIME_Timestamp last_check;
- uint8_t kyc_ok;
+ bool kyc_ok;
+ uint32_t aml_decision;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("h_wire",
&h_wire),
@@ -919,8 +920,10 @@ kyc_status_cb (void *cls,
&exchange_url),
GNUNET_PQ_result_spec_timestamp ("kyc_timestamp",
&last_check),
- GNUNET_PQ_result_spec_auto_from_type ("kyc_ok",
- &kyc_ok),
+ GNUNET_PQ_result_spec_bool ("kyc_ok",
+ &kyc_ok),
+ GNUNET_PQ_result_spec_uint32 ("aml_decision",
+ &aml_decision),
GNUNET_PQ_result_spec_end
};
@@ -954,7 +957,8 @@ kyc_status_cb (void *cls,
payto_uri,
exchange_url,
last_check,
- 0 != kyc_ok);
+ kyc_ok,
+ (enum TALER_AmlDecisionState) aml_decision);
GNUNET_PQ_cleanup_result (rs);
}
}
@@ -1023,6 +1027,7 @@ postgres_account_kyc_get_status (void *cls,
* @param exchange_pub public key of the exchange, or NULL for none
* @param timestamp timestamp to store
* @param kyc_ok current KYC status (true for satisfied)
+ * @param aml_decision current AML decision state at the exchange
* @return database result code
*/
static enum GNUNET_DB_QueryStatus
@@ -1035,23 +1040,25 @@ postgres_account_kyc_set_status (
const struct TALER_ExchangeSignatureP *exchange_sig,
const struct TALER_ExchangePublicKeyP *exchange_pub,
struct GNUNET_TIME_Timestamp timestamp,
- bool kyc_ok)
+ bool kyc_ok,
+ enum TALER_AmlDecisionState aml_decision)
{
struct PostgresClosure *pg = cls;
- uint8_t ok = kyc_ok;
+ uint32_t aml32 = (uint32_t) aml_decision;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (merchant_id),
GNUNET_PQ_query_param_auto_from_type (h_wire),
GNUNET_PQ_query_param_string (exchange_url),
GNUNET_PQ_query_param_uint64 (&exchange_kyc_serial),
GNUNET_PQ_query_param_timestamp (&timestamp),
- GNUNET_PQ_query_param_auto_from_type (&ok),
+ GNUNET_PQ_query_param_bool (kyc_ok),
exchange_pub
? GNUNET_PQ_query_param_auto_from_type (exchange_pub)
: GNUNET_PQ_query_param_null (),
exchange_sig
? GNUNET_PQ_query_param_auto_from_type (exchange_sig)
: GNUNET_PQ_query_param_null (),
+ GNUNET_PQ_query_param_uint32 (&aml32),
GNUNET_PQ_query_param_end
};
@@ -7923,8 +7930,9 @@ postgres_connect (void *cls)
",account_serial"
",exchange_url"
",exchange_pub"
- ",exchange_sig)"
- " SELECT $5, $6, $4, account_serial, $3, $7, $8"
+ ",exchange_sig"
+ ",aml_decision)"
+ " SELECT $5, $6, $4, account_serial, $3, $7, $8, $9"
" FROM merchant_instances"
" JOIN merchant_accounts USING (merchant_serial)"
" WHERE merchant_id=$1"
@@ -7935,7 +7943,8 @@ postgres_connect (void *cls)
" ,kyc_timestamp=$5"
" ,kyc_ok=$6"
" ,exchange_pub=$7"
- " ,exchange_sig=$8"),
+ " ,exchange_sig=$8"
+ " ,aml_decision=$9"),
/* for postgres_account_kyc_get_status */
GNUNET_PQ_make_prepare ("lookup_kyc_status",
"SELECT"
@@ -7945,6 +7954,7 @@ postgres_connect (void *cls)
",exchange_url"
",kyc_timestamp"
",kyc_ok"
+ ",aml_decision"
" FROM merchant_instances"
" JOIN merchant_accounts"
" USING (merchant_serial)"
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 3dbf9cbb..346a5427 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -6722,7 +6722,8 @@ kyc_status_ok (void *cls,
const char *payto_uri,
const char *exchange_url,
struct GNUNET_TIME_Timestamp last_check,
- bool kyc_ok)
+ bool kyc_ok,
+ enum TALER_AmlDecisionState ades)
{
bool *fail = cls;
@@ -6738,7 +6739,8 @@ kyc_status_fail (void *cls,
const char *payto_uri,
const char *exchange_url,
struct GNUNET_TIME_Timestamp last_check,
- bool kyc_ok)
+ bool kyc_ok,
+ enum TALER_AmlDecisionState ades)
{
bool *fail = cls;
@@ -6778,7 +6780,8 @@ test_kyc (void)
NULL,
NULL,
now,
- false));
+ false,
+ TALER_AML_NORMAL));
TEST_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->account_kyc_set_status (plugin->cls,
instance.instance.id,
@@ -6788,7 +6791,8 @@ test_kyc (void)
NULL,
NULL,
now,
- false));
+ false,
+ TALER_AML_NORMAL));
TEST_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->account_kyc_set_status (plugin->cls,
instance.instance.id,
@@ -6798,7 +6802,8 @@ test_kyc (void)
NULL,
NULL,
now,
- true));
+ true,
+ TALER_AML_NORMAL));
fail = true;
TEST_RET_ON_FAIL (1 !=
plugin->account_kyc_get_status (plugin->cls,
@@ -7855,7 +7860,8 @@ test_insert_pending_webhook (const struct InstanceData *instance,
TEST_COND_RET_ON_FAIL (expected_result ==
plugin->insert_pending_webhook (plugin->cls,
instance->instance.id,
- pwebhook->webhook_serial,
+ pwebhook->
+ webhook_serial,
pwebhook->pwebhook.url,
pwebhook->pwebhook.
http_method,
@@ -7885,8 +7891,10 @@ test_update_pending_webhook (const struct InstanceData *instance,
pwebhook->pwebhook.retries++;
TEST_COND_RET_ON_FAIL (expected_result ==
plugin->update_pending_webhook (plugin->cls,
- pwebhook->webhook_serial,
- pwebhook->pwebhook.next_attempt),
+ pwebhook->
+ webhook_serial,
+ pwebhook->pwebhook.
+ next_attempt),
"Update pending webhook failed\n");
return 0;
}
@@ -7936,9 +7944,9 @@ get_pending_serial_cb (void *cls,
header)) &&
(0 == strcmp (lpw->pwebhook->pwebhook.body,
body)) )
- {
- lpw->webhook_pending_serial = webhook_pending_serial;
- }
+ {
+ lpw->webhook_pending_serial = webhook_pending_serial;
+ }
/* else
{
fprintf(stdout, "next_attempt: %lu vs %lu\n", lpw->pwebhook->pwebhook.next_attempt.abs_value_us, next_attempt.abs_value_us);
@@ -8037,9 +8045,9 @@ lookup_pending_webhooks_cb (void *cls,
header)) &&
(0 == strcmp (cmp->webhooks_to_cmp[i].pwebhook.body,
body)) )
- {
- cmp->results_matching[i]++;
- }
+ {
+ cmp->results_matching[i]++;
+ }
}
}
@@ -8194,6 +8202,7 @@ test_lookup_all_webhooks (const struct InstanceData *instance,
return 0;
}
+
/**
* Tests deleting a pending webhook.
*
@@ -8307,7 +8316,7 @@ run_test_pending_webhooks (struct TestPendingWebhooks_Closure *cls)
&cls->pwebhooks[1]));
TEST_RET_ON_FAIL (test_update_pending_webhook (&cls->instance,
&cls->pwebhooks[1],
- GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); //???
+ GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); // ???
TEST_RET_ON_FAIL (test_lookup_all_webhooks (&cls->instance,
2,
cls->pwebhooks));
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index a1208859..4168fffc 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -151,6 +151,7 @@ struct TALER_MERCHANTDB_InstanceSettings
* merchant's logo data uri
*/
char *logo;
+
/**
* Address of the business
*/
@@ -420,7 +421,8 @@ typedef void
typedef void
(*TALER_MERCHANTDB_PendingWebhooksCallback)(void *cls,
uint64_t webhook_pending_serial,
- struct GNUNET_TIME_Absolute next_attempt,
+ struct GNUNET_TIME_Absolute
+ next_attempt,
uint32_t retries,
const char *url,
const char *http_method,
@@ -623,6 +625,7 @@ typedef void
* @param exchange_url base URL of the exchange for which this is a status
* @param last_check when did we last get an update on our KYC status from the exchange
* @param kyc_ok true if we satisfied the KYC requirements
+ * @param aml_decision current AML decision state at the exchange
*/
typedef void
(*TALER_MERCHANTDB_KycCallback)(
@@ -632,7 +635,8 @@ typedef void
const char *payto_uri,
const char *exchange_url,
struct GNUNET_TIME_Timestamp last_check,
- bool kyc_ok);
+ bool kyc_ok,
+ enum TALER_AmlDecisionState aml_decision);
/**
@@ -1248,6 +1252,7 @@ struct TALER_MERCHANTDB_Plugin
* @param exchange_pub public key of the exchange, or NULL for none
* @param timestamp timestamp to store
* @param kyc_ok current KYC status (true for satisfied)
+ * @param aml_decision current AML decision state at the exchange
* @return database result code
*/
enum GNUNET_DB_QueryStatus
@@ -1259,7 +1264,8 @@ struct TALER_MERCHANTDB_Plugin
const struct TALER_ExchangeSignatureP *exchange_sig,
const struct TALER_ExchangePublicKeyP *exchange_pub,
struct GNUNET_TIME_Timestamp timestamp,
- bool kyc_ok);
+ bool kyc_ok,
+ enum TALER_AmlDecisionState aml_decision);
/**