summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-11-07 13:58:01 +0100
committerChristian Grothoff <christian@grothoff.org>2021-11-07 13:58:01 +0100
commite2cc5c269ad12c3407886f5030862ef5a26840ba (patch)
treef9a6f19cc1937250e9b6a255e1ad5ad5e69674bd
parent9a93028fb5ec0205362ce9258ba8f3fe21e1053c (diff)
downloadmerchant-e2cc5c269ad12c3407886f5030862ef5a26840ba.tar.gz
merchant-e2cc5c269ad12c3407886f5030862ef5a26840ba.tar.bz2
merchant-e2cc5c269ad12c3407886f5030862ef5a26840ba.zip
finish merchant client api /kyc implementation
-rw-r--r--src/lib/merchant_api_get_kyc.c65
1 files changed, 62 insertions, 3 deletions
diff --git a/src/lib/merchant_api_get_kyc.c b/src/lib/merchant_api_get_kyc.c
index d793703e..8beee99b 100644
--- a/src/lib/merchant_api_get_kyc.c
+++ b/src/lib/merchant_api_get_kyc.c
@@ -78,9 +78,68 @@ parse_kyc (struct TALER_MERCHANT_KycGetHandle *kyc,
json_t *pends,
json_t *touts)
{
- // FIXME...
- GNUNET_break (0);
- return GNUNET_SYSERR;
+ unsigned int num_pends = json_array_size (pends);
+ unsigned int num_touts = json_array_size (touts);
+ struct TALER_MERCHANT_AccountKycRedirectDetail pending_kycs[GNUNET_NZL (
+ num_pends)];
+ struct TALER_MERCHANT_ExchangeKycFailureDetail timeout_kycs[GNUNET_NZL (
+ num_touts)];
+
+ for (unsigned int i = 0; i<num_pends; i++)
+ {
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("kyc_url",
+ &pending_kycs[i].kyc_url),
+ GNUNET_JSON_spec_string ("exchange_url",
+ &pending_kycs[i].exchange_url),
+ GNUNET_JSON_spec_string ("payto_uri",
+ &pending_kycs[i].payto_uri),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (json_array_get (pends,
+ i),
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ }
+ for (unsigned int i = 0; i<num_touts; i++)
+ {
+ uint32_t hs;
+ uint32_t ec;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("exchange_url",
+ &timeout_kycs[i].exchange_url),
+ GNUNET_JSON_spec_uint32 ("exchange_code",
+ &ec),
+ GNUNET_JSON_spec_uint32 ("exchange_http_status",
+ &hs),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (json_array_get (touts,
+ i),
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ timeout_kycs[i].exchange_http_status = (unsigned int) hs;
+ timeout_kycs[i].exchange_code = (enum TALER_ErrorCode) ec;
+ }
+ kr->details.kyc_status.pending_kycs = pending_kycs;
+ kr->details.kyc_status.timeout_kycs = timeout_kycs;
+ kr->details.kyc_status.pending_kycs_length = num_pends;
+ kr->details.kyc_status.timeout_kycs_length = num_touts;
+ kyc->cb (kyc->cb_cls,
+ kr);
+ return GNUNET_OK;
}