diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c | 78 |
1 files changed, 78 insertions, 0 deletions
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 0ccee818..f667c886 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 @@ -513,6 +513,73 @@ get_exchange_limits ( /** + * Maps @a ekr to a status code for clients to interpret the + * overall result. + * + * @param ekr request summary + * @return status of the KYC state as a string + */ +static const char * +map_to_status (const struct ExchangeKycRequest *ekr) +{ + if (ekr->no_keys) + { + return "no-exchange-keys"; + } + if (ekr->kyc_ok) + { + return "ready"; + } + if (! ekr->auth_ok) + { + if (ekr->kyc_auth_conflict) + return "kyc-wire-impossible"; + return "kyc-wire-required"; + } + if (ekr->in_aml_review) + return "awaiting-aml-review"; + switch (ekr->last_http_status) + { + case 0: + return "exchange-unreachable"; + case MHD_HTTP_OK: + /* then whe should have kyc_ok */ + GNUNET_break (0); + return NULL; + case MHD_HTTP_ACCEPTED: + /* Then KYC is really what is needed */ + return "kyc-required"; + case MHD_HTTP_NO_CONTENT: + /* then whe should have had kyc_ok! */ + GNUNET_break (0); + return NULL; + case MHD_HTTP_FORBIDDEN: + /* then whe should have had ! auth_ok */ + GNUNET_break (0); + return NULL; + case MHD_HTTP_NOT_FOUND: + /* then whe should have had ! auth_ok */ + GNUNET_break (0); + return NULL; + case MHD_HTTP_CONFLICT: + /* then whe should have had ! auth_ok */ + GNUNET_break (0); + return NULL; + case MHD_HTTP_INTERNAL_SERVER_ERROR: + return "exchange-internal-error"; + case MHD_HTTP_GATEWAY_TIMEOUT: + return "exchange-gateway-timeout"; + default: + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Exchange responded with unexpected HTTP status %u to /kyc-check request!\n", + ekr->last_http_status); + break; + } + return "exchange-status-invalid"; +} + + +/** * Take data from @a ekr to expand our response. * * @param ekr exchange we are done inspecting @@ -520,6 +587,14 @@ get_exchange_limits ( static void ekr_expand_response (struct ExchangeKycRequest *ekr) { + const char *status; + + status = map_to_status (ekr); + if (NULL == status) + { + GNUNET_break (0); + status = "logic-bug"; + } GNUNET_assert ( 0 == json_array_append_new ( @@ -532,6 +607,9 @@ ekr_expand_response (struct ExchangeKycRequest *ekr) "h_wire", &ekr->h_wire), GNUNET_JSON_pack_string ( + "status", + status), + GNUNET_JSON_pack_string ( "exchange_url", ekr->exchange_url), GNUNET_JSON_pack_bool ("no_keys", |