account_kyc_set_failed.c (3694B)
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_error_codes.h> 23 #include <taler/taler_dbevents.h> 24 #include <taler/taler_pq_lib.h> 25 #include "merchant-database/account_kyc_set_failed.h" 26 #include "helper.h" 27 28 29 enum GNUNET_DB_QueryStatus 30 TALER_MERCHANTDB_account_kyc_set_failed (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_string (merchant_id), 54 GNUNET_PQ_query_param_auto_from_type (h_wire), 55 GNUNET_PQ_query_param_string (exchange_url), 56 GNUNET_PQ_query_param_timestamp (×tamp), 57 GNUNET_PQ_query_param_uint32 (&http_status32), 58 GNUNET_PQ_query_param_bool (kyc_ok), 59 GNUNET_PQ_query_param_string (notify_s), 60 GNUNET_PQ_query_param_string (notify2_s), 61 GNUNET_PQ_query_param_end 62 }; 63 bool no_instance; 64 bool no_account; 65 struct GNUNET_PQ_ResultSpec rs[] = { 66 GNUNET_PQ_result_spec_bool ("no_instance", 67 &no_instance), 68 GNUNET_PQ_result_spec_bool ("no_account", 69 &no_account), 70 GNUNET_PQ_result_spec_end 71 }; 72 enum GNUNET_DB_QueryStatus qs; 73 74 check_connection (pg); 75 PREPARE (pg, 76 "account_kyc_set_failed", 77 "SELECT " 78 " out_no_instance AS no_instance" 79 " ,out_no_account AS no_account" 80 " FROM merchant_do_account_kyc_set_failed" 81 "($1, $2, $3, $4, $5, $6, $7, $8);"); 82 qs = GNUNET_PQ_eval_prepared_singleton_select ( 83 pg->conn, 84 "account_kyc_set_failed", 85 params, 86 rs); 87 GNUNET_free (notify_s); 88 GNUNET_free (notify2_s); 89 if (qs <= 0) 90 { 91 GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); 92 GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); 93 GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs); 94 return qs; 95 } 96 GNUNET_break (! no_instance); 97 GNUNET_break (! no_account); 98 return qs; 99 }