merchant

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

account_kyc_set_failed.c (3334B)


      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 src/backenddb/account_kyc_set_failed.c
     18  * @brief Implementation of the account_kyc_set_failed function for Postgres
     19  * @author Christian Grothoff
     20  */
     21 #include "platform.h"
     22 #include <taler/taler_dbevents.h>
     23 #include <taler/taler_pq_lib.h>
     24 #include "merchant-database/account_kyc_set_failed.h"
     25 #include "helper.h"
     26 
     27 
     28 enum GNUNET_DB_QueryStatus
     29 TALER_MERCHANTDB_account_kyc_set_failed (
     30   struct TALER_MERCHANTDB_PostgresContext *pg,
     31   const char *merchant_id,
     32   const struct TALER_MerchantWireHashP *h_wire,
     33   const char *exchange_url,
     34   struct GNUNET_TIME_Timestamp timestamp,
     35   unsigned int exchange_http_status,
     36   bool kyc_ok)
     37 {
     38   struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP ev = {
     39     .header.size = htons (sizeof (ev)),
     40     .header.type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED),
     41     .h_wire = *h_wire
     42   };
     43   struct GNUNET_DB_EventHeaderP hdr = {
     44     .size = htons (sizeof (hdr)),
     45     .type = htons (TALER_DBEVENT_MERCHANT_KYC_STATUS_CHANGED)
     46   };
     47   char *notify_s
     48     = GNUNET_PQ_get_event_notify_channel (&ev.header);
     49   char *notify2_s
     50     = GNUNET_PQ_get_event_notify_channel (&hdr);
     51   uint32_t http_status32 = (uint32_t) exchange_http_status;
     52   struct GNUNET_PQ_QueryParam params[] = {
     53     GNUNET_PQ_query_param_auto_from_type (h_wire),
     54     GNUNET_PQ_query_param_string (exchange_url),
     55     GNUNET_PQ_query_param_timestamp (&timestamp),
     56     GNUNET_PQ_query_param_uint32 (&http_status32),
     57     GNUNET_PQ_query_param_bool (kyc_ok),
     58     GNUNET_PQ_query_param_string (notify_s),
     59     GNUNET_PQ_query_param_string (notify2_s),
     60     GNUNET_PQ_query_param_end
     61   };
     62   bool no_account;
     63   struct GNUNET_PQ_ResultSpec rs[] = {
     64     GNUNET_PQ_result_spec_bool ("no_account",
     65                                 &no_account),
     66     GNUNET_PQ_result_spec_end
     67   };
     68   enum GNUNET_DB_QueryStatus qs;
     69 
     70   GNUNET_assert (NULL != pg->current_merchant_id);
     71   GNUNET_assert (0 == strcmp (merchant_id,
     72                               pg->current_merchant_id));
     73   check_connection (pg);
     74   TMH_PQ_prepare_anon (pg,
     75                        "SELECT "
     76                        "  out_no_account AS no_account"
     77                        " FROM merchant_do_account_kyc_set_failed"
     78                        "($1, $2, $3, $4, $5, $6, $7);");
     79   qs = GNUNET_PQ_eval_prepared_singleton_select (
     80     pg->conn,
     81     "",
     82     params,
     83     rs);
     84   GNUNET_free (notify_s);
     85   GNUNET_free (notify2_s);
     86   if (qs <= 0)
     87   {
     88     GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
     89     GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
     90     GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs);
     91     return qs;
     92   }
     93   GNUNET_break (! no_account);
     94   return qs;
     95 }