diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-09-29 15:45:11 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-09-29 15:45:11 +0200 |
commit | 587382674490778f398c05e970f95cbc2c58f2c3 (patch) | |
tree | 670ad9b39f169311e5d254d3b8625001cf41a2db /src | |
parent | 4dc7dc50ae84c14befb46b424027705b517f944e (diff) |
re-trigger exchange KYC checks if we failed to create an order due to low limits
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-orders.c | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c index 075c2bbe..cd8644e1 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders.c +++ b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -35,6 +35,7 @@ #include <taler/taler_error_codes.h> #include <taler/taler_signatures.h> #include <taler/taler_json_lib.h> +#include <taler/taler_dbevents.h> #include <time.h> #include "taler-merchant-httpd.h" #include "taler-merchant-httpd_private-post-orders.h" @@ -405,9 +406,9 @@ struct OrderContext struct { /** - * Array of exchanges we find acceptable for this - * order. - */ + * Array of exchanges we find acceptable for this + * order. + */ json_t *exchanges; /** @@ -2063,6 +2064,47 @@ get_exchange_keys (void *cls, /** + * Check our KYC status at all exchanges as our current limit is + * too low and we failed to create an order. + * + * @param oc order context + */ +static void +notify_kyc_required (const struct OrderContext *oc) +{ + struct GNUNET_DB_EventHeaderP es = { + .size = htons (sizeof (es)), + .type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_RULE_TRIGGERED) + }; + char *hws; + char *extra; + json_t *exchange; + size_t i; + + hws = GNUNET_STRINGS_data_to_string_alloc ( + &oc->add_payment_details.wm->h_wire, + sizeof (oc->add_payment_details.wm->h_wire)); + json_array_foreach (oc->set_exchanges.exchanges, i, exchange) + { + const char *exchange_url + = json_string_value (json_object_get (exchange, + "url")); + + GNUNET_asprintf (&extra, + "%s %s", + hws, + exchange_url); + TMH_db->event_notify (TMH_db->cls, + &es, + extra, + strlen (extra) + 1); + GNUNET_free (extra); + } + GNUNET_free (hws); +} + + +/** * Set list of acceptable exchanges in @a oc. Upon success, continue * processing with set_max_fee(). * @@ -2135,6 +2177,7 @@ set_exchanges (struct OrderContext *oc) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Cannot create order: %s is the sum of hard limits from supported exchanges\n", TALER_amount2s (&oc->set_exchanges.total_exchange_limit)); + notify_kyc_required (oc); reply_with_error ( oc, MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS, |