merchant

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

update_instance.c (3233B)


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