syncdb_store_payment_TR.c (2518B)
1 /* 2 This file is part of TALER 3 (C) 2014--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 Lesser 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 syncdb/syncdb_store_payment_TR.c 18 * @brief store payment for sync database 19 * @author Christian Grothoff 20 */ 21 #include "syncdb_pg.h" 22 23 24 enum SYNC_DB_QueryStatus 25 SYNCDB_store_payment_TR ( 26 const struct SYNC_AccountPublicKeyP *account_pub, 27 const char *order_id, 28 const struct TALER_ClaimTokenP *token, 29 const struct TALER_Amount *amount) 30 { 31 enum GNUNET_DB_QueryStatus qs; 32 struct TALER_ClaimTokenP tok; 33 struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get (); 34 struct GNUNET_PQ_QueryParam params[] = { 35 GNUNET_PQ_query_param_auto_from_type (account_pub), 36 GNUNET_PQ_query_param_string (order_id), 37 GNUNET_PQ_query_param_auto_from_type (&tok), 38 GNUNET_PQ_query_param_timestamp (&now), 39 TALER_PQ_query_param_amount (pg->conn, 40 amount), 41 GNUNET_PQ_query_param_end 42 }; 43 44 if (NULL == token) 45 memset (&tok, 0, sizeof (tok)); 46 else 47 tok = *token; 48 SYNCDB_preflight (); 49 PREPARE ("payment_insert", 50 "INSERT INTO payments " 51 "(account_pub" 52 ",order_id" 53 ",token" 54 ",timestamp" 55 ",amount" 56 ") VALUES " 57 "($1,$2,$3,$4,$5);"); 58 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, 59 "payment_insert", 60 params); 61 switch (qs) 62 { 63 case GNUNET_DB_STATUS_SOFT_ERROR: 64 GNUNET_break (0); 65 return SYNC_DB_SOFT_ERROR; 66 case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 67 GNUNET_break (0); 68 return SYNC_DB_NO_RESULTS; 69 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 70 return SYNC_DB_ONE_RESULT; 71 case GNUNET_DB_STATUS_HARD_ERROR: 72 GNUNET_break (0); 73 return SYNC_DB_HARD_ERROR; 74 default: 75 GNUNET_break (0); 76 return SYNC_DB_HARD_ERROR; 77 } 78 } 79 80 81 /* end of syncdb_store_payment_TR.c */