merchant

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

activate_account.c (3429B)


      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/activate_account.c
     18  * @brief Implementation of the activate_account function for Postgres
     19  * @author Christian Grothoff
     20  */
     21 #include "platform.h"
     22 #include <taler/taler_error_codes.h>
     23 #include <taler/taler_dbevents.h>
     24 #include <taler/taler_pq_lib.h>
     25 #include "merchant-database/activate_account.h"
     26 #include "helper.h"
     27 
     28 
     29 enum GNUNET_DB_QueryStatus
     30 TALER_MERCHANTDB_activate_account (struct TALER_MERCHANTDB_PostgresContext *pg,
     31                                    const struct TALER_MERCHANTDB_AccountDetails *account_details,
     32                                    struct TALER_MerchantWireHashP *h_wire,
     33                                    struct TALER_WireSaltP *salt,
     34                                    bool *not_found,
     35                                    bool *conflict)
     36 {
     37   struct GNUNET_PQ_QueryParam params[] = {
     38     GNUNET_PQ_query_param_string (account_details->instance_id),
     39     GNUNET_PQ_query_param_auto_from_type (&account_details->h_wire),
     40     GNUNET_PQ_query_param_auto_from_type (&account_details->salt),
     41     GNUNET_PQ_query_param_string (account_details->payto_uri.full_payto),
     42     NULL ==account_details->credit_facade_url
     43     ? GNUNET_PQ_query_param_null ()
     44     : GNUNET_PQ_query_param_string (account_details->credit_facade_url),
     45     NULL == account_details->credit_facade_credentials
     46     ? GNUNET_PQ_query_param_null ()
     47     : TALER_PQ_query_param_json (account_details->credit_facade_credentials),
     48     NULL == account_details->extra_wire_subject_metadata
     49     ? GNUNET_PQ_query_param_null ()
     50     : GNUNET_PQ_query_param_string (
     51       account_details->extra_wire_subject_metadata),
     52     GNUNET_PQ_query_param_end
     53   };
     54   struct GNUNET_PQ_ResultSpec rs[] = {
     55     GNUNET_PQ_result_spec_bool ("not_found",
     56                                 not_found),
     57     GNUNET_PQ_result_spec_bool ("conflict",
     58                                 conflict),
     59     GNUNET_PQ_result_spec_auto_from_type ("h_wire",
     60                                           h_wire),
     61     GNUNET_PQ_result_spec_auto_from_type ("salt",
     62                                           salt),
     63     GNUNET_PQ_result_spec_end
     64   };
     65 
     66   GNUNET_assert (account_details->active);
     67   check_connection (pg);
     68   PREPARE (pg,
     69            "activate_account",
     70            "SELECT "
     71            "  out_h_wire AS h_wire"
     72            " ,out_salt AS salt"
     73            " ,out_conflict AS conflict"
     74            " ,out_not_found AS not_found"
     75            " FROM merchant_do_activate_account"
     76            " ($1,$2,$3,$4,$5,$6,$7);");
     77   return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
     78                                                    "activate_account",
     79                                                    params,
     80                                                    rs);
     81 }