merchant

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

delete_tos_accepted_early.c (2949B)


      1 /*
      2    This file is part of TALER
      3    Copyright (C) 2026 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/delete_tos_accepted_early.c
     18  * @brief Implementation of the delete_tos_accepted_early function for Postgres
     19  * @author Christian Grothoff
     20  */
     21 #include "platform.h"
     22 #include <taler/taler_pq_lib.h>
     23 #include <taler/taler_dbevents.h>
     24 #include "merchant-database/delete_tos_accepted_early.h"
     25 #include "helper.h"
     26 
     27 
     28 enum GNUNET_DB_QueryStatus
     29 TALER_MERCHANTDB_delete_tos_accepted_early (
     30   struct TALER_MERCHANTDB_PostgresContext *pg,
     31   const char *merchant_id,
     32   const char *exchange_url)
     33 {
     34   struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP ev = {
     35     .header.size = htons (sizeof (ev)),
     36     .header.type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED),
     37     .merchant_pub = pg->current_merchant_pub
     38   };
     39   struct TALER_MERCHANTDB_InstanceKycStatusChangeEventP hdr = {
     40     .header.size = htons (sizeof (hdr)),
     41     .header.type = htons (TALER_DBEVENT_MERCHANT_KYC_STATUS_CHANGED),
     42     .merchant_pub = pg->current_merchant_pub
     43   };
     44   char *notify_s = GNUNET_PQ_get_event_notify_channel (&hdr.header);
     45   struct GNUNET_PQ_QueryParam params[] = {
     46     GNUNET_PQ_query_param_string (exchange_url),
     47     GNUNET_PQ_query_param_null (),
     48     GNUNET_PQ_query_param_fixed_size (
     49       &ev,
     50       offsetof (struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP, h_wire)),
     51     GNUNET_PQ_query_param_string (notify_s),
     52     GNUNET_PQ_query_param_end
     53   };
     54   bool changed;
     55   struct GNUNET_PQ_ResultSpec rs[] = {
     56     GNUNET_PQ_result_spec_bool ("changed", &changed),
     57     GNUNET_PQ_result_spec_end
     58   };
     59   enum GNUNET_DB_QueryStatus qs;
     60 
     61   GNUNET_assert (NULL != pg->current_merchant_id);
     62   GNUNET_assert (0 == strcmp (merchant_id,
     63                               pg->current_merchant_id));
     64   TMH_PQ_prepare_anon (pg,
     65                        "SELECT merchant_do_set_tos_accepted_early"
     66                        " ($1, $2, $3, $4) AS changed");
     67   qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
     68                                                   "",
     69                                                   params,
     70                                                   rs);
     71   GNUNET_free (notify_s);
     72   if (qs <= 0)
     73     return qs;
     74   return changed
     75          ? GNUNET_DB_STATUS_SUCCESS_ONE_RESULT
     76          : GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
     77 }