diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-05-03 15:46:00 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-05-03 15:46:00 +0200 |
commit | 634fc3090574ca303d0fe30ad3189c889782d2cb (patch) | |
tree | 3ffff8b21f2acc6647ec0e6aa94a0977caa5d59c /src/backend/taler-merchant-httpd_post-orders-ID-pay.c | |
parent | fbba13c83b7e209962558c9207358f607074a6da (diff) | |
download | merchant-634fc3090574ca303d0fe30ad3189c889782d2cb.tar.gz merchant-634fc3090574ca303d0fe30ad3189c889782d2cb.tar.bz2 merchant-634fc3090574ca303d0fe30ad3189c889782d2cb.zip |
expand merchant order logic to return exchanges trusted by the merchant and indicate priority based on exchange /wire respons availability and restrictions
Diffstat (limited to 'src/backend/taler-merchant-httpd_post-orders-ID-pay.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_post-orders-ID-pay.c | 58 |
1 files changed, 27 insertions, 31 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 index afec3b25..81189a6d 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -29,7 +29,6 @@ #include <taler/taler_signatures.h> #include <taler/taler_json_lib.h> #include <taler/taler_exchange_service.h> -#include "taler-merchant-httpd_auditors.h" #include "taler-merchant-httpd_exchanges.h" #include "taler-merchant-httpd_helper.h" #include "taler-merchant-httpd_post-orders-ID-pay.h" @@ -805,18 +804,18 @@ deposit_get_callback ( * @param cls the `struct KycContext` * @param hr HTTP response details * @param exchange_handle NULL if exchange was not found to be acceptable - * @param exchange_trusted true if this exchange is - * trusted by config + * @param ih internal handle to the exchange */ static void process_kyc_with_exchange ( void *cls, const struct TALER_EXCHANGE_HttpResponse *hr, struct TALER_EXCHANGE_Handle *exchange_handle, - bool exchange_trusted) + struct TMH_Exchange *ih) { struct KycContext *kc = cls; + (void) ih; kc->fo = NULL; if (NULL == exchange_handle) { @@ -1175,15 +1174,14 @@ batch_deposit_cb ( * @param cls the `struct ExchangeGroup` * @param hr HTTP response details * @param exchange_handle NULL if exchange was not found to be acceptable - * @param exchange_trusted true if this exchange is - * trusted by config + * @param ih internal handle to the exchange */ static void process_pay_with_exchange ( void *cls, const struct TALER_EXCHANGE_HttpResponse *hr, struct TALER_EXCHANGE_Handle *exchange_handle, - bool exchange_trusted) + struct TMH_Exchange *ih) { struct ExchangeGroup *eg = cls; struct PayContext *pc = eg->pc; @@ -1221,6 +1219,21 @@ process_pay_with_exchange ( TMH_pack_exchange_reply (hr))); return; } + if (GNUNET_OK != + TMH_exchange_check_debit (ih, + pc->wm)) + { + GNUNET_break_op (0); + pc->pending_at_eg--; + resume_pay_with_response ( + pc, + MHD_HTTP_CONFLICT, + TALER_MHD_MAKE_JSON_PACK ( + TALER_JSON_pack_ec ( + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_WIRE_METHOD_UNSUPPORTED))); + return; + } + keys = TALER_EXCHANGE_get_keys (exchange_handle); if (NULL == keys) { @@ -1240,8 +1253,6 @@ process_pay_with_exchange ( { struct DepositConfirmation *dc = &pc->dc[i]; const struct TALER_EXCHANGE_DenomPublicKey *denom_details; - unsigned int http_status; - enum TALER_ErrorCode ec; bool is_age_restricted_denom = false; if (0 != strcmp (eg->exchange_url, @@ -1288,33 +1299,18 @@ process_pay_with_exchange ( dc->deposit_fee = denom_details->fees.deposit; dc->refund_fee = denom_details->fees.refund; - if (GNUNET_OK != - TMH_AUDITORS_check_dk (exchange_handle, - denom_details, - exchange_trusted, - &http_status, - &ec)) + if (GNUNET_TIME_absolute_is_past ( + denom_details->expire_deposit.abs_time)) { - if (! eg->tried_force_keys) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Denomination not audited by trusted auditor, re-fetching /keys\n"); - /* let's try *forcing* a re-download of /keys from the exchange. - Maybe the wallet has seen auditors that we missed. */ - eg->tried_force_keys = true; - eg->fo = TMH_EXCHANGES_find_exchange (eg->exchange_url, - true, - &process_pay_with_exchange, - eg); - if (NULL != eg->fo) - return; - } + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Denomination key offered by client has expired for deposits\n"); pc->pending_at_eg--; resume_pay_with_response ( pc, - http_status, + MHD_HTTP_GONE, TALER_MHD_MAKE_JSON_PACK ( - TALER_JSON_pack_ec (ec), + TALER_JSON_pack_ec ( + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_DEPOSIT_EXPIRED), GNUNET_JSON_pack_data_auto ("h_denom_pub", &denom_details->h_key))); return; |