merchant

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

pg_update_donau_instance.c (2667B)


      1 /*
      2    This file is part of TALER
      3    Copyright (C) 2024 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 backenddb/pg_update_donau_instance.c
     18  * @brief Implementation of the update_donau_instance function for Postgres
     19  * @author Bohdan Potuzhnyi
     20  * @author Vlada Svirsh
     21  */
     22 #include "platform.h"
     23 #include <taler/taler_error_codes.h>
     24 #include <taler/taler_dbevents.h>
     25 #include <taler/taler_pq_lib.h>
     26 #include "donau/donau_service.h"
     27 #include "pg_update_donau_instance.h"
     28 #include "pg_helper.h"
     29 
     30 
     31 enum GNUNET_DB_QueryStatus
     32 TMH_PG_update_donau_instance (
     33   void *cls,
     34   const char *donau_url,
     35   const struct DONAU_Charity *charity,
     36   uint64_t charity_id)
     37 {
     38   struct PostgresClosure *pg = cls;
     39   struct GNUNET_PQ_QueryParam params[] = {
     40     GNUNET_PQ_query_param_string (donau_url),
     41     GNUNET_PQ_query_param_string (charity->name),
     42     GNUNET_PQ_query_param_auto_from_type (&charity->charity_pub),
     43     GNUNET_PQ_query_param_uint64 (&charity_id),
     44     TALER_PQ_query_param_amount_with_currency (pg->conn,
     45                                                &charity->max_per_year),
     46     TALER_PQ_query_param_amount_with_currency (pg->conn,
     47                                                &charity->receipts_to_date),
     48     GNUNET_PQ_query_param_uint64 (&charity->current_year),
     49     GNUNET_PQ_query_param_end
     50   };
     51 
     52   check_connection (pg);
     53 
     54   PREPARE (pg,
     55            "update_existing_donau_instance",
     56            "UPDATE merchant_donau_instances SET"
     57            "  charity_name             = $2,"
     58            "  charity_max_per_year     = $5,"
     59            "  charity_receipts_to_date = $6,"
     60            "  current_year             = $7"
     61            " WHERE charity_id = $4"
     62            " AND merchant_instance_serial "
     63            "  = (SELECT merchant_serial"
     64            "      FROM merchant_instances mi"
     65            "     WHERE mi.merchant_pub = $3),"
     66            "  AND donau_url = $1;");
     67 
     68   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     69                                              "update_existing_donau_instance",
     70                                              params);
     71 }