summaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd_kyc-check.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange/taler-exchange-httpd_kyc-check.c')
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-check.c79
1 files changed, 59 insertions, 20 deletions
diff --git a/src/exchange/taler-exchange-httpd_kyc-check.c b/src/exchange/taler-exchange-httpd_kyc-check.c
index 0372573bb..362c20a2e 100644
--- a/src/exchange/taler-exchange-httpd_kyc-check.c
+++ b/src/exchange/taler-exchange-httpd_kyc-check.c
@@ -238,7 +238,8 @@ initiate_cb (
kyp->ih = NULL;
kyp->ih_done = true;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "KYC initiation completed with ec=%d (%s)\n",
+ "KYC initiation `%s' completed with ec=%d (%s)\n",
+ provider_legitimization_id,
ec,
(TALER_EC_NONE == ec)
? redirect_url
@@ -259,8 +260,9 @@ initiate_cb (
&kyp->h_payto,
provider_user_id,
provider_legitimization_id,
+ redirect_url,
GNUNET_TIME_UNIT_ZERO_ABS);
- if (qs < 0)
+ if (qs <= 0)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"KYC requirement update failed for %s with status %d at %s:%u\n",
TALER_B2S (&kyp->h_payto),
@@ -302,6 +304,7 @@ kyc_check (void *cls,
enum GNUNET_GenericReturnValue ret;
struct TALER_PaytoHashP h_payto;
char *requirements;
+ char *redirect_url;
bool satisfied;
qs = TEH_plugin->lookup_kyc_requirement_by_row (
@@ -387,14 +390,11 @@ kyc_check (void *cls,
if (kyp->ih_done)
return qs;
-
- qs = TEH_plugin->insert_kyc_requirement_process (
+ qs = TEH_plugin->get_pending_kyc_requirement_process (
TEH_plugin->cls,
&h_payto,
kyp->section_name,
- NULL,
- NULL,
- &kyp->process_row);
+ &redirect_url);
if (qs < 0)
{
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
@@ -406,6 +406,34 @@ kyc_check (void *cls,
"insert_kyc_requirement_process");
return GNUNET_DB_STATUS_HARD_ERROR;
}
+ if ( (qs > 0) &&
+ (NULL != redirect_url) )
+ {
+ kyp->kyc_url = redirect_url;
+ return qs;
+ }
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+ {
+ /* set up new requirement process */
+ qs = TEH_plugin->insert_kyc_requirement_process (
+ TEH_plugin->cls,
+ &h_payto,
+ kyp->section_name,
+ NULL,
+ NULL,
+ &kyp->process_row);
+ if (qs < 0)
+ {
+ if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
+ return qs;
+ GNUNET_break (0);
+ *mhd_ret = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_STORE_FAILED,
+ "insert_kyc_requirement_process");
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Initiating KYC check with logic %s\n",
kyp->ih_logic->name);
@@ -523,6 +551,17 @@ TEH_handler_kyc_check (
TALER_MHD_parse_request_timeout (rc->connection,
&kyp->timeout);
}
+ /* KYC plugin generated reply? */
+ if (NULL != kyp->kyc_url)
+ {
+ return TALER_MHD_REPLY_JSON_PACK (
+ rc->connection,
+ MHD_HTTP_ACCEPTED,
+ GNUNET_JSON_pack_uint64 ("aml_status",
+ kyp->aml_status),
+ GNUNET_JSON_pack_string ("kyc_url",
+ kyp->kyc_url));
+ }
if ( (NULL == kyp->eh) &&
GNUNET_TIME_absolute_is_future (kyp->timeout) )
@@ -556,6 +595,17 @@ TEH_handler_kyc_check (
"Transaction failed.\n");
return res;
}
+ /* KYC plugin generated reply? */
+ if (NULL != kyp->kyc_url)
+ {
+ return TALER_MHD_REPLY_JSON_PACK (
+ rc->connection,
+ MHD_HTTP_ACCEPTED,
+ GNUNET_JSON_pack_uint64 ("aml_status",
+ kyp->aml_status),
+ GNUNET_JSON_pack_string ("kyc_url",
+ kyp->kyc_url));
+ }
if ( (NULL == kyp->ih) &&
(! kyp->kyc_required) )
@@ -601,11 +651,12 @@ TEH_handler_kyc_check (
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Suspending HTTP request on timeout (%s) now...\n",
- GNUNET_TIME_relative2s (GNUNET_TIME_absolute_get_duration (
+ GNUNET_TIME_relative2s (GNUNET_TIME_absolute_get_remaining (
kyp->timeout),
true));
GNUNET_assert (NULL != kyp->eh);
kyp->suspended = true;
+ kyp->section_name = NULL;
GNUNET_CONTAINER_DLL_insert (kyp_head,
kyp_tail,
kyp);
@@ -613,18 +664,6 @@ TEH_handler_kyc_check (
return MHD_YES;
}
- /* KYC plugin generated reply? */
- if (NULL != kyp->kyc_url)
- {
- return TALER_MHD_REPLY_JSON_PACK (
- rc->connection,
- MHD_HTTP_ACCEPTED,
- GNUNET_JSON_pack_uint64 ("aml_status",
- kyp->aml_status),
- GNUNET_JSON_pack_string ("kyc_url",
- kyp->kyc_url));
- }
-
if (TALER_EC_NONE != kyp->ec)
{
return TALER_MHD_reply_with_ec (rc->connection,