diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-04-11 19:44:51 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-04-11 19:44:51 +0200 |
commit | 5ed3b2cfe1aa0cb31c589b308cc70684a20dd368 (patch) | |
tree | 858e253a3393febe8207e5870e59e04946fa6958 /src/lib/merchant_api_get_instance.c | |
parent | feaf7bae8baf8ec701d02374e18a6b978dcfb9f8 (diff) | |
download | merchant-5ed3b2cfe1aa0cb31c589b308cc70684a20dd368.tar.gz merchant-5ed3b2cfe1aa0cb31c589b308cc70684a20dd368.tar.bz2 merchant-5ed3b2cfe1aa0cb31c589b308cc70684a20dd368.zip |
store user-type with merchant settings
Diffstat (limited to 'src/lib/merchant_api_get_instance.c')
-rw-r--r-- | src/lib/merchant_api_get_instance.c | 109 |
1 files changed, 56 insertions, 53 deletions
diff --git a/src/lib/merchant_api_get_instance.c b/src/lib/merchant_api_get_instance.c index bb71a1ed..c8fbfc00 100644 --- a/src/lib/merchant_api_get_instance.c +++ b/src/lib/merchant_api_get_instance.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2018, 2020 Taler Systems SA + Copyright (C) 2014-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software @@ -28,6 +28,7 @@ #include "taler_merchant_service.h" #include "merchant_api_curl_defaults.h" #include <taler/taler_json_lib.h> +#include <taler/taler_kyclogic_lib.h> #include <taler/taler_signatures.h> @@ -79,9 +80,9 @@ handle_get_instance_finished (void *cls, { struct TALER_MERCHANT_InstanceGetHandle *igh = cls; const json_t *json = response; - struct TALER_MERCHANT_HttpResponse hr = { - .http_status = (unsigned int) response_code, - .reply = json + struct TALER_MERCHANT_InstanceGetResponse igr = { + .hr.http_status = (unsigned int) response_code, + .hr.reply = json }; igh->job = NULL; @@ -93,36 +94,38 @@ handle_get_instance_finished (void *cls, case MHD_HTTP_OK: { json_t *accounts; - const char *name; - struct TALER_MerchantPublicKeyP merchant_pub; + const char *uts; json_t *address; json_t *jurisdiction; - struct TALER_Amount default_max_wire_fee; - uint32_t default_wire_fee_amortization; - struct TALER_Amount default_max_deposit_fee; - struct GNUNET_TIME_Relative default_wire_transfer_delay; - struct GNUNET_TIME_Relative default_pay_delay; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_json ("accounts", &accounts), GNUNET_JSON_spec_string ("name", - &name), - GNUNET_JSON_spec_fixed_auto ("merchant_pub", - &merchant_pub), + &igr.details.success.details.name), + GNUNET_JSON_spec_string ("user_type", + &uts), + GNUNET_JSON_spec_fixed_auto ( + "merchant_pub", + &igr.details.success.details.merchant_pub), GNUNET_JSON_spec_json ("address", &address), GNUNET_JSON_spec_json ("jurisdiction", &jurisdiction), - TALER_JSON_spec_amount_any ("default_max_wire_fee", - &default_max_wire_fee), - GNUNET_JSON_spec_uint32 ("default_wire_fee_amortization", - &default_wire_fee_amortization), - TALER_JSON_spec_amount_any ("default_max_deposit_fee", - &default_max_deposit_fee), - GNUNET_JSON_spec_relative_time ("default_wire_transfer_delay", - &default_wire_transfer_delay), - GNUNET_JSON_spec_relative_time ("default_pay_delay", - &default_pay_delay), + TALER_JSON_spec_amount_any ( + "default_max_wire_fee", + &igr.details.success.details.default_max_wire_fee), + GNUNET_JSON_spec_uint32 ( + "default_wire_fee_amortization", + &igr.details.success.details.default_wire_fee_amortization), + TALER_JSON_spec_amount_any ( + "default_max_deposit_fee", + &igr.details.success.details.default_max_deposit_fee), + GNUNET_JSON_spec_relative_time ( + "default_wire_transfer_delay", + &igr.details.success.details.default_wire_transfer_delay), + GNUNET_JSON_spec_relative_time ( + "default_pay_delay", + &igr.details.success.details.default_pay_delay), GNUNET_JSON_spec_end () }; @@ -161,6 +164,8 @@ handle_get_instance_finished (void *cls, { GNUNET_break_op (0); ret = GNUNET_SYSERR; + igr.hr.http_status = 0; + igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } aa[index].payto_uri = payto_uris[index]; @@ -168,59 +173,57 @@ handle_get_instance_finished (void *cls, if (GNUNET_OK == ret) { - struct TALER_MERCHANT_InstanceDetails details = { - .name = name, - .merchant_pub = &merchant_pub, - .address = address, - .jurisdiction = jurisdiction, - .default_max_wire_fee = &default_max_wire_fee, - .default_wire_fee_amortization = default_wire_fee_amortization, - .default_max_deposit_fee = &default_max_deposit_fee, - .default_wire_transfer_delay = default_wire_transfer_delay, - .default_pay_delay = default_pay_delay - }; - + igr.details.success.details.address = address; + igr.details.success.details.jurisdiction = jurisdiction; + if (GNUNET_OK != + TALER_KYCLOGIC_kyc_user_type_from_string ( + uts, + &igr.details.success.details.ut)) + { + GNUNET_break_op (0); + ret = GNUNET_SYSERR; + igr.hr.http_status = 0; + igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + GNUNET_JSON_parse_free (spec); + break; + } + igr.details.success.accounts_length = accounts_length; + igr.details.success.accounts = aa; igh->cb (igh->cb_cls, - &hr, - accounts_length, - aa, - &details); + &igr); GNUNET_JSON_parse_free (spec); TALER_MERCHANT_instance_get_cancel (igh); return; } } GNUNET_break_op (0); - hr.http_status = 0; - hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + igr.hr.http_status = 0; + igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; GNUNET_JSON_parse_free (spec); break; } case MHD_HTTP_UNAUTHORIZED: - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + igr.hr.ec = TALER_JSON_get_error_code (json); + igr.hr.hint = TALER_JSON_get_error_hint (json); /* Nothing really to verify, merchant says we need to authenticate. */ break; case MHD_HTTP_NOT_FOUND: /* instance does not exist */ - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + igr.hr.ec = TALER_JSON_get_error_code (json); + igr.hr.hint = TALER_JSON_get_error_hint (json); break; default: /* unexpected response code */ - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + igr.hr.ec = TALER_JSON_get_error_code (json); + igr.hr.hint = TALER_JSON_get_error_hint (json); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u/%d\n", (unsigned int) response_code, - (int) hr.ec); + (int) igr.hr.ec); break; } igh->cb (igh->cb_cls, - &hr, - 0, - NULL, - NULL); + &igr); TALER_MERCHANT_instance_get_cancel (igh); } |