merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit ce431cdcbea88fb35142f231a1a370d606748873
parent 9c5b4f1da02db5ffdbdb7dbd1a0a337584d3209b
Author: Florian Dold <florian@dold.me>
Date:   Tue, 14 Jan 2025 18:57:59 +0100

notify kyc helper before filtering exchanges for zero deposit limits

Diffstat:
Msrc/backend/taler-merchant-httpd_post-orders-ID-pay.c | 2+-
Msrc/backend/taler-merchant-httpd_private-post-orders.c | 86++++++++++++++++++++++++++++++++++++++++---------------------------------------
2 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -102,7 +102,7 @@ enum PayPhase PP_CHECK_CONTRACT, /** - * Validate provided tokens and token evelopes. + * Validate provided tokens and token envelopes. */ PP_VALIDATE_TOKENS, diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -2435,6 +2435,41 @@ update_stefan (struct OrderContext *oc, /** + * 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 + * @param exchange_url exchange to notify about + */ +static void +notify_kyc_required (const struct OrderContext *oc, + const char *exchange_url) +{ + struct GNUNET_DB_EventHeaderP es = { + .size = htons (sizeof (es)), + .type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_RULE_TRIGGERED) + }; + char *hws; + char *extra; + + hws = GNUNET_STRINGS_data_to_string_alloc ( + &oc->add_payment_details.wm->h_wire, + sizeof (oc->add_payment_details.wm->h_wire)); + + 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); +} + + +/** * Compute the set of exchanges that would be acceptable * for this order. * @@ -2468,6 +2503,15 @@ get_acceptable (void *cls, TALER_amount2s (&max_amount)); if (TALER_amount_is_zero (&max_amount)) { + if (! TALER_amount_is_zero (max_needed)) + { + /* Trigger re-checking the current deposit limit when + * paying non-zero amount with zero deposit limit */ + notify_kyc_required (oc, + url); + } + /* If deposit is impossible, we don't list the + * exchange in the contract terms. */ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Exchange %s deposit limit is zero, skipping it\n", url); @@ -2676,47 +2720,6 @@ 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); -} - - -/** * Task run when we are timing out on /keys and will just * proceed with what we got. * @@ -2911,7 +2914,6 @@ set_exchanges (struct OrderContext *oc) if (! ok) { - notify_kyc_required (oc); reply_with_error ( oc, MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS,