Line data Source code
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 exchangedb/do_reserve_legitimization_process.c
18 : * @brief atomically reserve or reuse an external KYC process
19 : */
20 : #include "taler/taler_pq_lib.h"
21 : #include "exchange-database/do_reserve_legitimization_process.h"
22 : #include "helper.h"
23 :
24 :
25 : enum GNUNET_DB_QueryStatus
26 14 : TALER_EXCHANGEDB_do_reserve_legitimization_process (
27 : struct TALER_EXCHANGEDB_PostgresContext *pg,
28 : const struct TALER_NormalizedPaytoHashP *h_payto,
29 : uint32_t measure_index,
30 : uint64_t legitimization_measure_serial_id,
31 : const char *provider_name,
32 : struct GNUNET_TIME_Absolute now,
33 : struct GNUNET_TIME_Absolute lease_expiration,
34 : uint64_t *process_row,
35 : struct GNUNET_TIME_Absolute *start_time,
36 : char **redirect_url,
37 : enum TALER_EXCHANGEDB_KycProcessReservationState *state)
38 : {
39 : uint32_t state32;
40 14 : struct GNUNET_PQ_QueryParam params[] = {
41 14 : GNUNET_PQ_query_param_auto_from_type (h_payto),
42 14 : GNUNET_PQ_query_param_uint32 (&measure_index),
43 14 : GNUNET_PQ_query_param_uint64 (&legitimization_measure_serial_id),
44 14 : GNUNET_PQ_query_param_string (provider_name),
45 14 : GNUNET_PQ_query_param_absolute_time (&now),
46 14 : GNUNET_PQ_query_param_absolute_time (&lease_expiration),
47 : GNUNET_PQ_query_param_end
48 : };
49 14 : struct GNUNET_PQ_ResultSpec rs[] = {
50 14 : GNUNET_PQ_result_spec_uint64 ("process_row",
51 : process_row),
52 14 : GNUNET_PQ_result_spec_absolute_time ("start_time",
53 : start_time),
54 14 : GNUNET_PQ_result_spec_allow_null (
55 : GNUNET_PQ_result_spec_string ("redirect_url",
56 : redirect_url),
57 : NULL),
58 14 : GNUNET_PQ_result_spec_uint32 ("state",
59 : &state32),
60 : GNUNET_PQ_result_spec_end
61 : };
62 : enum GNUNET_DB_QueryStatus qs;
63 :
64 14 : *redirect_url = NULL;
65 14 : PREPARE (pg,
66 : "do_reserve_legitimization_process",
67 : "SELECT"
68 : " out_process_row AS process_row"
69 : ",out_start_time AS start_time"
70 : ",out_redirect_url AS redirect_url"
71 : ",out_state AS state"
72 : " FROM exchange_do_reserve_legitimization_process"
73 : " ($1,$2,$3,$4,$5,$6);");
74 14 : qs = GNUNET_PQ_eval_prepared_singleton_select (
75 : pg->conn,
76 : "do_reserve_legitimization_process",
77 : params,
78 : rs);
79 14 : if (qs > 0)
80 14 : *state = (enum TALER_EXCHANGEDB_KycProcessReservationState) state32;
81 14 : return qs;
82 : }
|