merchant

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

commit 2fe548c732fbe0cd46c1142b94f9597527a3a28f
parent 7dbf4d319487cc38e65eea1c8dc9c21d4dec47f6
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Fri, 14 Aug 2026 23:31:22 +0200

subtract tip from total to be paid to compute the regular contract total

Diffstat:
Msrc/backend/taler-merchant-httpd_post-templates-TEMPLATE_ID.c | 34++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_post-templates-TEMPLATE_ID.c b/src/backend/taler-merchant-httpd_post-templates-TEMPLATE_ID.c @@ -1730,6 +1730,40 @@ handle_phase_compute_price (struct UseContext *uc) GNUNET_assert (uc->template_contract.no_amount); *uc->compute_price.totals = uc->parse_request.amount; + if (! uc->parse_request.no_tip) + { + /* Per the API specification, the client's 'amount' is "the + amount to be paid, including tip", while the total we compute + in this phase excludes the tip: #handle_phase_check_tip() + adds it back on top. Without removing it here, the total + would end up being 'amount' + 'tip' and could thus never + match the 'amount' that #handle_phase_check_total() compares + it against. */ + if (GNUNET_YES != + TALER_amount_cmp_currency (&uc->parse_request.tip, + uc->compute_price.totals)) + { + GNUNET_break_op (0); + use_reply_with_error (uc, + MHD_HTTP_CONFLICT, + TALER_EC_MERCHANT_GENERIC_CURRENCY_MISMATCH, + uc->parse_request.tip.currency); + return; + } + if (0 > + TALER_amount_subtract (uc->compute_price.totals, + uc->compute_price.totals, + &uc->parse_request.tip)) + { + GNUNET_break_op (0); + use_reply_with_error ( + uc, + MHD_HTTP_CONFLICT, + TALER_EC_MERCHANT_POST_USING_TEMPLATES_AMOUNT_CONFLICT_TEMPLATES_CONTRACT_AMOUNT, + "tip exceeds amount"); + return; + } + } /* Only an amount the client chose is subject to the limits. */ if (GNUNET_OK != check_amount_limits (uc,