merchant

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

commit b76c77637a0782bccafddbbccac707b2abc962c6
parent 8c90b0d096cd5c2dc5bdee899766fa6b0a9ba85c
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu,  2 Jan 2025 12:54:21 +0100

-address more minor FIXMEs

Diffstat:
Mconfigure.ac | 4++--
Msrc/backend/taler-merchant-httpd_exchanges.c | 29+++++------------------------
Msrc/backend/taler-merchant-kyccheck.c | 26+++++---------------------
Msrc/backenddb/merchantdb_helper.c | 13-------------
Msrc/backenddb/pg_select_category.c | 13+++++++------
Msrc/backenddb/pg_select_category_by_name.c | 15+++++++--------
Msrc/include/taler_merchantdb_plugin.h | 32--------------------------------
7 files changed, 26 insertions(+), 106 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -277,12 +277,12 @@ AS_CASE([$with_exchange], CPPFLAGS="-I$with_exchange/include $CPPFLAGS $POSTGRESQL_CPPFLAGS"]) AC_CHECK_HEADERS([taler/taler_exchange_service.h], - [AC_CHECK_LIB([talerexchange], [TALER_EXCHANGE_test_account_allowed], libtalerexchange=1)]) + [AC_CHECK_LIB([talerexchange], [TALER_EXCHANGE_keys_test_account_allowed], libtalerexchange=1)]) AM_CONDITIONAL(HAVE_TALEREXCHANGE, test x$libtalerexchange = x1) AS_IF([test $libtalerexchange != 1], [AC_MSG_ERROR([[ *** -*** You need libtalerexchange >= 0.14.0 to build this program. +*** You need libtalerexchange >= 15:0:0 to build this program. *** This library is part of the GNU Taler exchange, available at *** https://taler.net *** ]])]) diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c @@ -675,7 +675,7 @@ TMH_exchange_check_debit ( { const struct TALER_EXCHANGE_Keys *keys = exchange->keys; struct TALER_NormalizedPayto np; - bool account_ok = false; + bool account_ok; bool have_kyc = false; struct TALER_Amount kyc_limit; bool unlimited = true; @@ -693,30 +693,11 @@ TMH_exchange_check_debit ( max_amount->currency); return GNUNET_SYSERR; } - np = TALER_payto_normalize (wm->payto_uri); - - /* For all accounts of the exchange */ - for (unsigned int i = 0; i<keys->accounts_len; i++) - { - const struct TALER_EXCHANGE_WireAccount *account - = &keys->accounts[i]; - if (NULL != account->conversion_url) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Exchange %s account requires currency conversion (not supported)\n", - exchange->url); - continue; /* never use accounts with conversion */ - } - if (GNUNET_YES != - TALER_EXCHANGE_test_account_allowed (account, - false, /* debit */ - np)) - continue; - account_ok = true; - /* Check legitimization limits we have with this - account at this exchange, if we have any, apply them */ - } + np = TALER_payto_normalize (wm->payto_uri); + account_ok = TALER_EXCHANGE_keys_test_account_allowed (keys, + false, + np); GNUNET_free (np.normalized_payto); if (keys->kyc_enabled) { diff --git a/src/backend/taler-merchant-kyccheck.c b/src/backend/taler-merchant-kyccheck.c @@ -715,30 +715,14 @@ is_eligible (const struct TALER_EXCHANGE_Keys *keys, const struct Account *a) { struct TALER_NormalizedPayto np; + bool ret; np = TALER_payto_normalize (a->merchant_account_uri); - /* For all accounts of the exchange */ - for (unsigned int i = 0; i<keys->accounts_len; i++) - { - /* FIXME: move into convenience function in libtalerexchange? See also taler-merchant-httpd_private-get-instances-ID-kyc.c, taler-merchant-httpd_exchanges (!)*/ - const struct TALER_EXCHANGE_WireAccount *account - = &keys->accounts[i]; - - /* KYC auth transfers are never supported with conversion */ - if (NULL != account->conversion_url) - continue; - /* filter by source account by credit_restrictions */ - if (GNUNET_YES != - TALER_EXCHANGE_test_account_allowed (account, - true, /* credit */ - np)) - continue; - /* exchange account is allowed, add it */ - GNUNET_free (np.normalized_payto); - return true; - } + ret = TALER_EXCHANGE_keys_test_account_allowed (keys, + true, + np); GNUNET_free (np.normalized_payto); - return false; + return ret; } diff --git a/src/backenddb/merchantdb_helper.c b/src/backenddb/merchantdb_helper.c @@ -88,19 +88,6 @@ TALER_MERCHANTDB_category_details_free ( { GNUNET_free (cd->category_name); json_decref (cd->category_name_i18n); - // FIXME: also return product details - // for (unsigned int i = 0; i<cd->num_products; i++) - // { - // const char* *ps - // = &cd->products[i]; - - // GNUNET_free (ps); - // // GNUNET_free (ps->description); - // // json_decref (ps->description_i18n); - // } - // GNUNET_array_grow (cd->products, - // cd->num_products, - // 0); } diff --git a/src/backenddb/pg_select_category.c b/src/backenddb/pg_select_category.c @@ -27,12 +27,13 @@ enum GNUNET_DB_QueryStatus -TMH_PG_select_category (void *cls, - const char *instance_id, - uint64_t category_id, - struct TALER_MERCHANTDB_CategoryDetails *cd, - size_t *num_products, - char **products) +TMH_PG_select_category ( + void *cls, + const char *instance_id, + uint64_t category_id, + struct TALER_MERCHANTDB_CategoryDetails *cd, + size_t *num_products, + char **products) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { diff --git a/src/backenddb/pg_select_category_by_name.c b/src/backenddb/pg_select_category_by_name.c @@ -27,11 +27,12 @@ enum GNUNET_DB_QueryStatus -TMH_PG_select_category_by_name (void *cls, - const char *instance_id, - const char *category_name, - json_t **name_i18n, - uint64_t *category_id) +TMH_PG_select_category_by_name ( + void *cls, + const char *instance_id, + const char *category_name, + json_t **name_i18n, + uint64_t *category_id) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -47,6 +48,7 @@ TMH_PG_select_category_by_name (void *cls, GNUNET_PQ_result_spec_end }; + check_connection (pg); PREPARE (pg, "select_category_by_name", "SELECT" @@ -57,9 +59,6 @@ TMH_PG_select_category_by_name (void *cls, " USING (merchant_serial)" " WHERE mi.merchant_id=$1" " AND mc.category_name=$2"); - - - check_connection (pg); return GNUNET_PQ_eval_prepared_singleton_select ( pg->conn, "select_category_by_name", diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h @@ -525,28 +525,6 @@ typedef void /** * Details about a product category. */ -struct TALER_MERCHANTDB_ProductSummary -{ - /** - * ID of the product. - */ - char *product_id; - - /** - * Description for the product. - */ - char *description; - - /** - * Translation of the @e description. - */ - json_t *description_i18n; - -}; - -/** - * Details about a product category. - */ struct TALER_MERCHANTDB_CategoryDetails { @@ -560,16 +538,6 @@ struct TALER_MERCHANTDB_CategoryDetails */ json_t *category_name_i18n; - /** - * Products in the category. - */ - struct TALER_MERCHANTDB_ProductSummary *products; - - /** - * Length of the @e products array. - */ - unsigned int num_products; - };