merchant

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

commit fd0cb25e44692a491f24e83be161874183415ef7
parent 7cae96494c6fd3ba50b9f86a014c6ec178c16db6
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Thu, 16 Jul 2026 18:11:18 +0200

-bugfixes

Diffstat:
Msrc/backend/taler-merchant-httpd_get-private-orders-ORDER_ID.c | 182++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/testing/testing_api_cmd_pay_order.c | 10+++++++---
2 files changed, 98 insertions(+), 94 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_get-private-orders-ORDER_ID.c b/src/backend/taler-merchant-httpd_get-private-orders-ORDER_ID.c @@ -143,14 +143,14 @@ enum GetOrderPhase GOP_UNPAID_FINISH = 5, /** - * Check if the (paid) order was refunded. + * Load all deposits associated with the order. */ - GOP_CHECK_REFUNDS = 6, + GOP_CHECK_DEPOSITS = 6, /** - * Load all deposits associated with the order. + * Check if the (paid) order was refunded. */ - GOP_CHECK_DEPOSITS = 7, + GOP_CHECK_REFUNDS = 7, /** * Check local records for transfers of funds to @@ -1284,6 +1284,90 @@ phase_unpaid_finish (struct GetOrderRequestContext *gorc) /** + * Function called with each @a coin_pub that was deposited into the + * @a h_wire account of the merchant for the @a deposit_serial as part + * of the payment for the order identified by @a cls. + * + * Queries the exchange for the payment status associated with the + * given coin. + * + * @param cls a `struct GetOrderRequestContext` + * @param deposit_serial identifies the deposit operation + * @param exchange_url URL of the exchange that issued @a coin_pub + * @param h_wire hash of the merchant's wire account into which the deposit was made + * @param deposit_timestamp when was the deposit made + * @param amount_with_fee amount the exchange will deposit for this coin + * @param deposit_fee fee the exchange will charge for this coin + * @param coin_pub public key of the deposited coin + */ +static void +deposit_cb ( + void *cls, + uint64_t deposit_serial, + const char *exchange_url, + const struct TALER_MerchantWireHashP *h_wire, + struct GNUNET_TIME_Timestamp deposit_timestamp, + const struct TALER_Amount *amount_with_fee, + const struct TALER_Amount *deposit_fee, + const struct TALER_CoinSpendPublicKeyP *coin_pub) +{ + struct GetOrderRequestContext *gorc = cls; + struct TransferQuery *tq; + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Checking deposit status for coin %s (over %s)\n", + TALER_B2S (coin_pub), + TALER_amount2s (amount_with_fee)); + gorc->last_payment + = GNUNET_TIME_timestamp_max (gorc->last_payment, + deposit_timestamp); + tq = GNUNET_new (struct TransferQuery); + tq->gorc = gorc; + tq->exchange_url = GNUNET_strdup (exchange_url); + tq->deposit_serial = deposit_serial; + GNUNET_CONTAINER_DLL_insert (gorc->tq_head, + gorc->tq_tail, + tq); + tq->coin_pub = *coin_pub; + tq->h_wire = *h_wire; + tq->amount_with_fee = *amount_with_fee; + tq->deposit_fee = *deposit_fee; +} + + +/** + * Check wire transfer status for the order at the exchange. + * + * @param[in,out] gorc order context to update + */ +static void +phase_check_deposits (struct GetOrderRequestContext *gorc) +{ + GNUNET_assert (! gorc->order_only); + GNUNET_assert (gorc->paid); + + /* amount must be always valid for paid orders */ + GNUNET_assert (GNUNET_OK == + TALER_amount_is_valid (&gorc->contract_amount)); + + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (gorc->contract_amount.currency, + &gorc->deposits_total)); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (gorc->contract_amount.currency, + &gorc->deposit_fees_total)); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (gorc->contract_amount.currency, + &gorc->deposit_fees_refunded_total)); + TALER_MERCHANTDB_lookup_deposits_by_order (TMH_db, + gorc->order_serial, + &deposit_cb, + gorc); + gorc->phase++; +} + + +/** * Function called with information about a refund. * It is responsible for summing up the refund amount. * @@ -1429,90 +1513,6 @@ phase_check_refunds (struct GetOrderRequestContext *gorc) /** - * Function called with each @a coin_pub that was deposited into the - * @a h_wire account of the merchant for the @a deposit_serial as part - * of the payment for the order identified by @a cls. - * - * Queries the exchange for the payment status associated with the - * given coin. - * - * @param cls a `struct GetOrderRequestContext` - * @param deposit_serial identifies the deposit operation - * @param exchange_url URL of the exchange that issued @a coin_pub - * @param h_wire hash of the merchant's wire account into which the deposit was made - * @param deposit_timestamp when was the deposit made - * @param amount_with_fee amount the exchange will deposit for this coin - * @param deposit_fee fee the exchange will charge for this coin - * @param coin_pub public key of the deposited coin - */ -static void -deposit_cb ( - void *cls, - uint64_t deposit_serial, - const char *exchange_url, - const struct TALER_MerchantWireHashP *h_wire, - struct GNUNET_TIME_Timestamp deposit_timestamp, - const struct TALER_Amount *amount_with_fee, - const struct TALER_Amount *deposit_fee, - const struct TALER_CoinSpendPublicKeyP *coin_pub) -{ - struct GetOrderRequestContext *gorc = cls; - struct TransferQuery *tq; - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Checking deposit status for coin %s (over %s)\n", - TALER_B2S (coin_pub), - TALER_amount2s (amount_with_fee)); - gorc->last_payment - = GNUNET_TIME_timestamp_max (gorc->last_payment, - deposit_timestamp); - tq = GNUNET_new (struct TransferQuery); - tq->gorc = gorc; - tq->exchange_url = GNUNET_strdup (exchange_url); - tq->deposit_serial = deposit_serial; - GNUNET_CONTAINER_DLL_insert (gorc->tq_head, - gorc->tq_tail, - tq); - tq->coin_pub = *coin_pub; - tq->h_wire = *h_wire; - tq->amount_with_fee = *amount_with_fee; - tq->deposit_fee = *deposit_fee; -} - - -/** - * Check wire transfer status for the order at the exchange. - * - * @param[in,out] gorc order context to update - */ -static void -phase_check_deposits (struct GetOrderRequestContext *gorc) -{ - GNUNET_assert (! gorc->order_only); - GNUNET_assert (gorc->paid); - - /* amount must be always valid for paid orders */ - GNUNET_assert (GNUNET_OK == - TALER_amount_is_valid (&gorc->contract_amount)); - - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (gorc->contract_amount.currency, - &gorc->deposits_total)); - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (gorc->contract_amount.currency, - &gorc->deposit_fees_total)); - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (gorc->contract_amount.currency, - &gorc->deposit_fees_refunded_total)); - TALER_MERCHANTDB_lookup_deposits_by_order (TMH_db, - gorc->order_serial, - &deposit_cb, - gorc); - gorc->phase++; -} - - -/** * Function called with available wire details, to be added to * the response. * @@ -1876,12 +1876,12 @@ TMH_private_get_orders_ID ( case GOP_UNPAID_FINISH: phase_unpaid_finish (gorc); break; - case GOP_CHECK_REFUNDS: - phase_check_refunds (gorc); - break; case GOP_CHECK_DEPOSITS: phase_check_deposits (gorc); break; + case GOP_CHECK_REFUNDS: + phase_check_refunds (gorc); + break; case GOP_CHECK_LOCAL_TRANSFERS: phase_check_local_transfers (gorc); break; diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c @@ -156,6 +156,9 @@ struct MerchantDonauPayData * * @param is interpreter state * @param ss donau data to prepare + * @return #GNUNET_OK on success, + * #GNUNET_NO to skip + * #GNUNET_SYSERR on failure */ static enum GNUNET_GenericReturnValue prepare_donau_data (struct TALER_TESTING_Interpreter *is, @@ -215,12 +218,13 @@ prepare_donau_data (struct TALER_TESTING_Interpreter *is, TALER_TESTING_interpreter_fail (is); return GNUNET_SYSERR; } - if ((GNUNET_NO == sret) || (0 == ss->num_bkps)) + if ( (GNUNET_NO == sret) || + (0 == ss->num_bkps) ) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not compose exact amount from donation units\n"); TALER_TESTING_interpreter_fail (is); - return GNUNET_NO; + return GNUNET_SYSERR; } } @@ -315,7 +319,7 @@ prepare_donau_data (struct TALER_TESTING_Interpreter *is, } } return GNUNET_OK; -}; +} /**