LCOV - code coverage report
Current view: top level - backenddb - insert_refund_by_coin.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 10 10
Test Date: 2026-09-04 23:42:01 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 2022 Taler Systems SA
       4              : 
       5              :    TALER is free software; you can redistribute it and/or modify it under the
       6              :    terms of the GNU General Public License as published by the Free Software
       7              :    Foundation; either version 3, or (at your option) any later version.
       8              : 
       9              :    TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10              :    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11              :    A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
      12              : 
      13              :    You should have received a copy of the GNU General Public License along with
      14              :    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15              :  */
      16              : /**
      17              :  * @file src/backenddb/insert_refund_by_coin.c
      18              :  * @brief Implementation of the insert_refund_by_coin function for Postgres
      19              :  * @author Iván Ávalos
      20              :  */
      21              : #include "platform.h"
      22              : #include <taler/taler_pq_lib.h>
      23              : #include "merchant-database/insert_refund_by_coin.h"
      24              : #include "helper.h"
      25              : 
      26              : 
      27              : enum GNUNET_DB_QueryStatus
      28           22 : TALER_MERCHANTDB_insert_refund_by_coin (
      29              :   struct TALER_MERCHANTDB_PostgresContext *pg,
      30              :   const char *instance_id,
      31              :   const struct TALER_PrivateContractHashP *h_contract_terms,
      32              :   struct GNUNET_TIME_Timestamp refund_timestamp,
      33              :   const struct TALER_CoinSpendPublicKeyP *coin_pub,
      34              :   const char *reason)
      35              : {
      36           22 :   struct GNUNET_PQ_QueryParam params[] = {
      37           22 :     GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
      38           22 :     GNUNET_PQ_query_param_timestamp (&refund_timestamp),
      39           22 :     GNUNET_PQ_query_param_auto_from_type (coin_pub),
      40           22 :     GNUNET_PQ_query_param_string (reason),
      41              :     GNUNET_PQ_query_param_end
      42              :   };
      43              : 
      44           22 :   GNUNET_assert (NULL != pg->current_merchant_id);
      45           22 :   GNUNET_assert (0 == strcmp (instance_id,
      46              :                               pg->current_merchant_id));
      47           22 :   TMH_PQ_prepare_anon (pg,
      48              :                        "INSERT INTO merchant_refunds"
      49              :                        "(order_serial"
      50              :                        ",rtransaction_id"
      51              :                        ",refund_timestamp"
      52              :                        ",coin_pub"
      53              :                        ",reason"
      54              :                        ",refund_amount"
      55              :                        ") "
      56              :                        "SELECT "
      57              :                        " dcon.order_serial"
      58              :                        ",0" /* rtransaction_id always 0 for /abort */
      59              :                        ",$2"
      60              :                        ",dep.coin_pub"
      61              :                        ",$4"
      62              :                        ",dep.amount_with_fee"
      63              :                        " FROM merchant_deposits dep"
      64              :                        " JOIN merchant_deposit_confirmations dcon"
      65              :                        "   USING (deposit_confirmation_serial)"
      66              :                        " WHERE dep.coin_pub=$3"
      67              :                        "   AND dcon.order_serial="
      68              :                        "  (SELECT order_serial"
      69              :                        "     FROM merchant_contract_terms"
      70              :                        "    WHERE h_contract_terms=$1)"
      71              :                        " ON CONFLICT (order_serial"
      72              :                        ",coin_pub"
      73              :                        ",rtransaction_id)"
      74              :                        " DO NOTHING");
      75           22 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
      76              :                                              "",
      77              :                                              params);
      78              : }
        

Generated by: LCOV version 2.0-1