summaryrefslogtreecommitdiff
path: root/src/lib/merchant_api_get_instance.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/merchant_api_get_instance.c')
-rw-r--r--src/lib/merchant_api_get_instance.c176
1 files changed, 64 insertions, 112 deletions
diff --git a/src/lib/merchant_api_get_instance.c b/src/lib/merchant_api_get_instance.c
index bb71a1ed..eef95b84 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;
@@ -92,135 +93,86 @@ handle_get_instance_finished (void *cls,
{
case MHD_HTTP_OK:
{
- json_t *accounts;
- const char *name;
- struct TALER_MerchantPublicKeyP merchant_pub;
- 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;
+ const char *uts;
+ const json_t *address;
+ const json_t *jurisdiction;
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),
- 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),
+ GNUNET_JSON_spec_string (
+ "name",
+ &igr.details.ok.details.name),
+ GNUNET_JSON_spec_string (
+ "user_type",
+ &uts),
+ GNUNET_JSON_spec_fixed_auto (
+ "merchant_pub",
+ &igr.details.ok.details.merchant_pub),
+ GNUNET_JSON_spec_object_const (
+ "address",
+ &address),
+ GNUNET_JSON_spec_object_const (
+ "jurisdiction",
+ &jurisdiction),
+ GNUNET_JSON_spec_bool (
+ "use_stefan",
+ &igr.details.ok.details.use_stefan),
+ GNUNET_JSON_spec_relative_time (
+ "default_wire_transfer_delay",
+ &igr.details.ok.details.default_wire_transfer_delay),
+ GNUNET_JSON_spec_relative_time (
+ "default_pay_delay",
+ &igr.details.ok.details.default_pay_delay),
GNUNET_JSON_spec_end ()
};
- if ( (GNUNET_OK ==
- GNUNET_JSON_parse (json,
- spec,
- NULL, NULL)) &&
- (json_is_array (accounts)) )
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (json,
+ spec,
+ NULL, NULL))
{
- unsigned int accounts_length = json_array_size (accounts);
- struct TALER_MERCHANT_Account aa[accounts_length];
- const char *payto_uris[accounts_length];
- size_t index;
- json_t *value;
- int ret = GNUNET_OK;
-
- memset (payto_uris, 0, sizeof (payto_uris));
- json_array_foreach (accounts, index, value)
- {
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("salt",
- &aa[index].salt),
- GNUNET_JSON_spec_string ("payto_uri",
- &payto_uris[index]),
- GNUNET_JSON_spec_fixed_auto ("h_wire",
- &aa[index].h_wire),
- GNUNET_JSON_spec_bool ("active",
- &aa[index].active),
- GNUNET_JSON_spec_end ()
- };
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (value,
- spec,
- NULL, NULL))
- {
- GNUNET_break_op (0);
- ret = GNUNET_SYSERR;
- break;
- }
- aa[index].payto_uri = payto_uris[index];
- }
-
- 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
- };
-
- igh->cb (igh->cb_cls,
- &hr,
- accounts_length,
- aa,
- &details);
- GNUNET_JSON_parse_free (spec);
- TALER_MERCHANT_instance_get_cancel (igh);
- return;
- }
+ GNUNET_break_op (0);
+ igr.hr.http_status = 0;
+ igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ break;
+ }
+ igr.details.ok.details.address = address;
+ igr.details.ok.details.jurisdiction = jurisdiction;
+ if (GNUNET_OK !=
+ TALER_KYCLOGIC_kyc_user_type_from_string (
+ uts,
+ &igr.details.ok.details.ut))
+ {
+ GNUNET_break_op (0);
+ igr.hr.http_status = 0;
+ igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ break;
}
- GNUNET_break_op (0);
- hr.http_status = 0;
- hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
- GNUNET_JSON_parse_free (spec);
- break;
+ igh->cb (igh->cb_cls,
+ &igr);
+ TALER_MERCHANT_instance_get_cancel (igh);
+ return;
}
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);
}