merchant

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

update_instance.c (3315B)


      1 /*
      2    This file is part of TALER
      3    Copyright (C) 2022, 2025 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/update_instance.c
     18  * @brief Implementation of the update_instance function for Postgres
     19  * @author Christian Grothoff
     20  * @author Iván Ávalos
     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 "merchant-database/update_instance.h"
     27 #include "helper.h"
     28 
     29 
     30 enum GNUNET_DB_QueryStatus
     31 TALER_MERCHANTDB_update_instance (struct TALER_MERCHANTDB_PostgresContext *pg,
     32                                   const struct TALER_MERCHANTDB_InstanceSettings *is)
     33 {
     34   struct GNUNET_PQ_QueryParam params[] = {
     35     GNUNET_PQ_query_param_string (is->id),
     36     GNUNET_PQ_query_param_string (is->name),
     37     TALER_PQ_query_param_json (is->address),
     38     TALER_PQ_query_param_json (is->jurisdiction),
     39     GNUNET_PQ_query_param_bool (is->use_stefan),
     40     GNUNET_PQ_query_param_relative_time (
     41       &is->default_wire_transfer_delay),
     42     GNUNET_PQ_query_param_relative_time (
     43       &is->default_pay_delay),
     44     GNUNET_PQ_query_param_relative_time (
     45       &is->default_refund_delay),
     46     (NULL == is->website)
     47     ? GNUNET_PQ_query_param_null ()
     48     : GNUNET_PQ_query_param_string (is->website),
     49     (NULL == is->email)
     50     ? GNUNET_PQ_query_param_null ()
     51     : GNUNET_PQ_query_param_string (is->email),
     52     (NULL == is->logo)
     53     ? GNUNET_PQ_query_param_null ()
     54     : GNUNET_PQ_query_param_string (is->logo),
     55     (NULL == is->phone)
     56     ? GNUNET_PQ_query_param_null ()
     57     : GNUNET_PQ_query_param_string (is->phone),
     58     GNUNET_PQ_query_param_bool (is->phone_validated),
     59     GNUNET_PQ_query_param_bool (is->email_validated),
     60     GNUNET_PQ_query_param_string (
     61       GNUNET_TIME_round_interval2s (
     62         is->default_wire_transfer_rounding_interval)),
     63     GNUNET_PQ_query_param_end
     64   };
     65 
     66   check_connection (pg);
     67   PREPARE (pg,
     68            "update_instance",
     69            "UPDATE merchant_instances SET"
     70            " merchant_name=$2"
     71            ",address=$3::TEXT::JSONB"
     72            ",jurisdiction=$4::TEXT::JSONB"
     73            ",use_stefan=$5"
     74            ",default_wire_transfer_delay=$6"
     75            ",default_pay_delay=$7"
     76            ",default_refund_delay=$8"
     77            ",website=$9"
     78            ",email=$10"
     79            ",logo=$11"
     80            ",phone_number=$12"
     81            ",phone_validated=$13"
     82            ",email_validated=$14"
     83            ",default_wire_transfer_rounding_interval=($15::time_rounder_interval)"
     84            " WHERE merchant_id=$1");
     85   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     86                                              "update_instance",
     87                                              params);
     88 }