merchant

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

lookup_transfers.h (3673B)


      1 /*
      2    This file is part of TALER
      3    Copyright (C) 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 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/include/merchant-database/lookup_transfers.h
     18  * @brief implementation of the lookup_transfers function for Postgres
     19  * @author Christian Grothoff
     20  */
     21 #ifndef MERCHANT_DATABASE_LOOKUP_TRANSFERS_H
     22 #define MERCHANT_DATABASE_LOOKUP_TRANSFERS_H
     23 
     24 #include <taler/taler_util.h>
     25 #include <taler/taler_json_lib.h>
     26 #include "merchantdb_lib.h"
     27 
     28 
     29 /**
     30  * Function called with information about a wire transfer.
     31  *
     32  * @param cls closure with a `json_t *` array to build up the response
     33  * @param expected_credit_amount how we expect to see wired to the merchant (minus fees), NULL if unknown
     34  * @param wtid wire transfer identifier
     35  * @param payto_uri target account that received the wire transfer
     36  * @param exchange_url base URL of the exchange that made the wire transfer
     37  * @param transfer_serial_id serial number identifying the transfer in the backend
     38  * @param expected_transfer_serial_id serial number identifying the expected transfer in the backend, 0 if not @a expected
     39  * @param execution_time when did the exchange make the transfer, #GNUNET_TIME_UNIT_FOREVER_ABS
     40  *           if it did not yet happen
     41  * @param expected true if the merchant acknowledged the wire transfer reception
     42  */
     43 typedef void
     44 (*TALER_MERCHANTDB_TransferCallback)(
     45   void *cls,
     46   const struct TALER_Amount *expected_credit_amount,
     47   const struct TALER_WireTransferIdentifierRawP *wtid,
     48   struct TALER_FullPayto payto_uri,
     49   const char *exchange_url,
     50   uint64_t transfer_serial_id,
     51   uint64_t expected_transfer_serial_id,
     52   struct GNUNET_TIME_Absolute execution_time,
     53   bool expected);
     54 
     55 /**
     56  * Lookup transfers. Note that filtering by @a verified status is done
     57  * outside of SQL, as we already have 8 prepared statements and adding
     58  * a filter on verified would further double the number of statements for
     59  * a likely rather ineffective filter. So we apply that filter in
     60  * #lookup_transfers_cb().
     61  *
     62  * @param pg database context
     63  * @param instance_id instance to lookup payments for
     64  * @param payto_uri account that we are interested in transfers to
     65  * @param before timestamp for the earliest transfer we care about
     66  * @param after timestamp for the last transfer we care about
     67  * @param limit number of entries to return, negative for descending in execution time,
     68  *                positive for ascending in execution time
     69  * @param offset transfer_serial number of the transfer we want to offset from
     70  * @param expected filter for transfers that were expected
     71  * @param cb function to call with detailed transfer data
     72  * @param cb_cls closure for @a cb
     73  * @return transaction status
     74  */
     75 enum GNUNET_DB_QueryStatus
     76 TALER_MERCHANTDB_lookup_transfers (
     77   struct TALER_MERCHANTDB_PostgresContext *pg,
     78   const char *instance_id,
     79   struct TALER_FullPayto payto_uri,
     80   struct GNUNET_TIME_Timestamp before,
     81   struct GNUNET_TIME_Timestamp after,
     82   int64_t limit,
     83   uint64_t offset,
     84   enum TALER_EXCHANGE_YesNoAll expected,
     85   TALER_MERCHANTDB_TransferCallback cb,
     86   void *cb_cls);
     87 
     88 #endif