integrate /kyc-* handlers with dispatching logic
This commit is contained in:
parent
b38b51d5e8
commit
adb9335528
@ -835,6 +835,25 @@ handle_mhd_request (void *cls,
|
||||
.handler.get = &TEH_handler_deposits_get,
|
||||
.nargs = 4
|
||||
},
|
||||
/* KYC endpoints */
|
||||
{
|
||||
.url = "kyc-check",
|
||||
.method = MHD_HTTP_METHOD_GET,
|
||||
.handler.get = &TEH_handler_kyc_check,
|
||||
.nargs = 1
|
||||
},
|
||||
{
|
||||
.url = "kyc-proof",
|
||||
.method = MHD_HTTP_METHOD_GET,
|
||||
.handler.get = &TEH_handler_kyc_proof,
|
||||
.nargs = 1
|
||||
},
|
||||
{
|
||||
.url = "kyc-wallet",
|
||||
.method = MHD_HTTP_METHOD_POST,
|
||||
.handler.post = &TEH_handler_kyc_wallet,
|
||||
.nargs = 0
|
||||
},
|
||||
/* POST management endpoints */
|
||||
{
|
||||
.url = "management",
|
||||
|
@ -98,25 +98,43 @@ kyc_check (void *cls,
|
||||
|
||||
MHD_RESULT
|
||||
TEH_handler_kyc_check (
|
||||
struct MHD_Connection *connection,
|
||||
uint64_t payment_target_uuid)
|
||||
struct TEH_RequestContext *rc,
|
||||
const char *const args[])
|
||||
{
|
||||
struct KycCheckContext kcc = {
|
||||
.payment_target_uuid = payment_target_uuid
|
||||
};
|
||||
unsigned long long payment_target_uuid;
|
||||
MHD_RESULT res;
|
||||
enum GNUNET_GenericReturnValue ret;
|
||||
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
|
||||
char dummy;
|
||||
|
||||
if (1 !=
|
||||
sscanf (args[0],
|
||||
"%llu%c",
|
||||
&payment_target_uuid,
|
||||
&dummy))
|
||||
{
|
||||
GNUNET_break_op (0);
|
||||
return TALER_MHD_reply_with_error (rc->connection,
|
||||
MHD_HTTP_BAD_REQUEST,
|
||||
TALER_EC_GENERIC_PARAMETER_MALFORMED,
|
||||
"payment_target_uuid");
|
||||
}
|
||||
|
||||
(void) GNUNET_TIME_round_abs (&now);
|
||||
if (TEH_KYC_NONE == TEH_kyc_config.mode)
|
||||
return TALER_MHD_reply_static (
|
||||
connection,
|
||||
rc->connection,
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
ret = TEH_DB_run_transaction (connection,
|
||||
{
|
||||
struct GNUNET_TIME_Absolute now;
|
||||
struct KycCheckContext kcc = {
|
||||
.payment_target_uuid = payment_target_uuid
|
||||
};
|
||||
|
||||
now = GNUNET_TIME_absolute_get ();
|
||||
(void) GNUNET_TIME_round_abs (&now);
|
||||
ret = TEH_DB_run_transaction (rc->connection,
|
||||
"kyc check",
|
||||
&res,
|
||||
&kyc_check,
|
||||
@ -127,7 +145,7 @@ TEH_handler_kyc_check (
|
||||
{
|
||||
GNUNET_assert (TEH_KYC_OAUTH2 == TEH_kyc_config.mode);
|
||||
return TALER_MHD_REPLY_JSON_PACK (
|
||||
connection,
|
||||
rc->connection,
|
||||
MHD_HTTP_ACCEPTED,
|
||||
GNUNET_JSON_pack_string ("kyc_url",
|
||||
TEH_kyc_config.details.oauth2.url));
|
||||
@ -136,7 +154,8 @@ TEH_handler_kyc_check (
|
||||
struct TALER_ExchangePublicKeyP pub;
|
||||
struct TALER_ExchangeSignatureP sig;
|
||||
struct TALER_ExchangeAccountSetupSuccessPS as = {
|
||||
.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_ACCOUNT_SETUP_SUCCESS),
|
||||
.purpose.purpose = htonl (
|
||||
TALER_SIGNATURE_EXCHANGE_ACCOUNT_SETUP_SUCCESS),
|
||||
.purpose.size = htonl (sizeof (as)),
|
||||
.h_payto = kcc.h_payto,
|
||||
.timestamp = GNUNET_TIME_absolute_hton (now)
|
||||
@ -148,12 +167,12 @@ TEH_handler_kyc_check (
|
||||
&pub,
|
||||
&sig)))
|
||||
{
|
||||
return TALER_MHD_reply_with_ec (connection,
|
||||
return TALER_MHD_reply_with_ec (rc->connection,
|
||||
ec,
|
||||
NULL);
|
||||
}
|
||||
return TALER_MHD_REPLY_JSON_PACK (
|
||||
connection,
|
||||
rc->connection,
|
||||
MHD_HTTP_OK,
|
||||
GNUNET_JSON_pack_data_auto ("exchange_sig",
|
||||
&sig),
|
||||
@ -163,6 +182,7 @@ TEH_handler_kyc_check (
|
||||
now));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* end of taler-exchange-httpd_kyc-check.c */
|
||||
|
@ -30,13 +30,13 @@
|
||||
* status of the given account and returns it.
|
||||
*
|
||||
* @param connection request to handle
|
||||
* @param payment_target_uuid which account are we to check
|
||||
* @param args one argument with the payment_target_uuid
|
||||
* @return MHD result code
|
||||
*/
|
||||
MHD_RESULT
|
||||
TEH_handler_kyc_check (
|
||||
struct MHD_Connection *connection,
|
||||
uint64_t payment_target_uuid);
|
||||
struct TEH_RequestContext *rc,
|
||||
const char *const args[]);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -67,21 +67,36 @@ proof_kyc_check (void *cls,
|
||||
|
||||
MHD_RESULT
|
||||
TEH_handler_kyc_proof (
|
||||
struct MHD_Connection *connection,
|
||||
...)
|
||||
struct TEH_RequestContext *rc,
|
||||
const char *const args[])
|
||||
{
|
||||
struct KycProofContext kpc;
|
||||
MHD_RESULT res;
|
||||
enum GNUNET_GenericReturnValue ret;
|
||||
unsigned long long payment_target_uuid;
|
||||
char dummy;
|
||||
|
||||
if (1 !=
|
||||
sscanf (args[0],
|
||||
"%llu%c",
|
||||
&payment_target_uuid,
|
||||
&dummy))
|
||||
{
|
||||
GNUNET_break_op (0);
|
||||
return TALER_MHD_reply_with_error (rc->connection,
|
||||
MHD_HTTP_BAD_REQUEST,
|
||||
TALER_EC_GENERIC_PARAMETER_MALFORMED,
|
||||
"payment_target_uuid");
|
||||
}
|
||||
|
||||
if (1 || (TEH_KYC_NONE == TEH_kyc_config.mode))
|
||||
return TALER_MHD_reply_static (
|
||||
connection,
|
||||
rc->connection,
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
ret = TEH_DB_run_transaction (connection,
|
||||
ret = TEH_DB_run_transaction (rc->connection,
|
||||
"check proof kyc",
|
||||
&res,
|
||||
&proof_kyc_check,
|
||||
@ -89,7 +104,7 @@ TEH_handler_kyc_proof (
|
||||
if (GNUNET_SYSERR == ret)
|
||||
return res;
|
||||
return TALER_MHD_REPLY_JSON_PACK (
|
||||
connection,
|
||||
rc->connection,
|
||||
MHD_HTTP_OK,
|
||||
GNUNET_JSON_pack_uint64 ("42",
|
||||
42));
|
||||
|
@ -28,13 +28,14 @@
|
||||
/**
|
||||
* Handle a "/kyc-proof" request.
|
||||
*
|
||||
* @param connection request to handle
|
||||
* @param rc request to handle
|
||||
* @param args one argument with the payment_target_uuid
|
||||
* @return MHD result code
|
||||
*/
|
||||
MHD_RESULT
|
||||
TEH_handler_kyc_proof (
|
||||
struct MHD_Connection *connection,
|
||||
...);
|
||||
struct TEH_RequestContext *rc,
|
||||
const char *const args[]);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -89,8 +89,9 @@ wallet_kyc_check (void *cls,
|
||||
|
||||
MHD_RESULT
|
||||
TEH_handler_kyc_wallet (
|
||||
struct MHD_Connection *connection,
|
||||
const json_t *root)
|
||||
struct TEH_RequestContext *rc,
|
||||
const json_t *root,
|
||||
const char *const args[])
|
||||
{
|
||||
struct TALER_ReserveSignatureP reserve_sig;
|
||||
struct KycRequestContext krc;
|
||||
@ -108,7 +109,7 @@ TEH_handler_kyc_wallet (
|
||||
.purpose = htonl (TALER_SIGNATURE_WALLET_ACCOUNT_SETUP)
|
||||
};
|
||||
|
||||
ret = TALER_MHD_parse_json_data (connection,
|
||||
ret = TALER_MHD_parse_json_data (rc->connection,
|
||||
root,
|
||||
spec);
|
||||
if (GNUNET_SYSERR == ret)
|
||||
@ -124,19 +125,19 @@ TEH_handler_kyc_wallet (
|
||||
{
|
||||
GNUNET_break_op (0);
|
||||
return TALER_MHD_reply_with_error (
|
||||
connection,
|
||||
rc->connection,
|
||||
MHD_HTTP_FORBIDDEN,
|
||||
TALER_EC_EXCHANGE_KYC_WALLET_SIGNATURE_INVALID,
|
||||
NULL);
|
||||
}
|
||||
if (TEH_KYC_NONE == TEH_kyc_config.mode)
|
||||
return TALER_MHD_reply_static (
|
||||
connection,
|
||||
rc->connection,
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
ret = TEH_DB_run_transaction (connection,
|
||||
ret = TEH_DB_run_transaction (rc->connection,
|
||||
"check wallet kyc",
|
||||
&res,
|
||||
&wallet_kyc_check,
|
||||
@ -144,7 +145,7 @@ TEH_handler_kyc_wallet (
|
||||
if (GNUNET_SYSERR == ret)
|
||||
return res;
|
||||
return TALER_MHD_REPLY_JSON_PACK (
|
||||
connection,
|
||||
rc->connection,
|
||||
MHD_HTTP_OK,
|
||||
GNUNET_JSON_pack_uint64 ("payment_target_uuid",
|
||||
krc.kyc.payment_target_uuid));
|
||||
|
@ -30,14 +30,16 @@
|
||||
* reserve and the signature "reserve_sig" which affirms the operation. If OK,
|
||||
* a KYC record is created (if missing) and the KYC status returned.
|
||||
*
|
||||
* @param connection request to handle
|
||||
* @param rc request to handle
|
||||
* @param root uploaded JSON data
|
||||
* @param args empty array
|
||||
* @return MHD result code
|
||||
*/
|
||||
MHD_RESULT
|
||||
TEH_handler_kyc_wallet (
|
||||
struct MHD_Connection *connection,
|
||||
const json_t *root);
|
||||
struct TEH_RequestContext *rc,
|
||||
const json_t *root,
|
||||
const char *const args[]);
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user