merchant

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

post-private-transfers.h (4121B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2014-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 Lesser General Public License as published by the Free Software
      7   Foundation; either version 2.1, 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 Lesser General Public License for more details.
     12 
     13   You should have received a copy of the GNU Lesser General Public License along with
     14   TALER; see the file COPYING.LGPL.  If not, see
     15   <http://www.gnu.org/licenses/>
     16 */
     17 /**
     18  * @file src/include/taler/merchant/post-private-transfers.h
     19  * @brief C interface for the POST /private/transfers endpoint
     20  * @author Christian Grothoff
     21  */
     22 #ifndef _TALER_MERCHANT__POST_PRIVATE_TRANSFERS_H
     23 #define _TALER_MERCHANT__POST_PRIVATE_TRANSFERS_H
     24 
     25 #include <taler/merchant/common.h>
     26 
     27 
     28 /**
     29  * Handle for a POST /private/transfers request.
     30  */
     31 struct TALER_MERCHANT_PostPrivateTransfersHandle;
     32 
     33 
     34 /**
     35  * Response details for a POST /private/transfers request.
     36  */
     37 struct TALER_MERCHANT_PostPrivateTransfersResponse
     38 {
     39 
     40   /**
     41    * HTTP response details.
     42    */
     43   struct TALER_MERCHANT_HttpResponse hr;
     44 
     45   /**
     46    * Details depending on the HTTP status code.
     47    */
     48   union
     49   {
     50 
     51     /**
     52      * Details on #MHD_HTTP_BAD_GATEWAY (exchange returned an error).
     53      */
     54     struct
     55     {
     56 
     57       /**
     58        * Error code returned by the exchange.
     59        */
     60       enum TALER_ErrorCode exchange_ec;
     61 
     62       /**
     63        * HTTP status code returned by the exchange.
     64        */
     65       unsigned int exchange_http_status;
     66 
     67     } bad_gateway;
     68 
     69   } details;
     70 
     71 };
     72 
     73 
     74 /**
     75  * Set up POST /private/transfers operation.
     76  * Note that you must explicitly start the operation after
     77  * possibly setting options.
     78  *
     79  * @param ctx the context
     80  * @param url base URL of the merchant backend
     81  * @param credit_amount amount credited in this transfer
     82  * @param wtid wire transfer identifier
     83  * @param payto_uri payto URI of the merchant account that received the funds
     84  * @param exchange_url base URL of the exchange that made the transfer
     85  * @return handle to operation
     86  */
     87 struct TALER_MERCHANT_PostPrivateTransfersHandle *
     88 TALER_MERCHANT_post_private_transfers_create (
     89   struct GNUNET_CURL_Context *ctx,
     90   const char *url,
     91   const struct TALER_Amount *credit_amount,
     92   const struct TALER_WireTransferIdentifierRawP *wtid,
     93   struct TALER_FullPayto payto_uri,
     94   const char *exchange_url);
     95 
     96 
     97 #ifndef TALER_MERCHANT_POST_PRIVATE_TRANSFERS_RESULT_CLOSURE
     98 /**
     99  * Type of the closure used by
    100  * the #TALER_MERCHANT_PostPrivateTransfersCallback.
    101  */
    102 #define TALER_MERCHANT_POST_PRIVATE_TRANSFERS_RESULT_CLOSURE void
    103 #endif /* TALER_MERCHANT_POST_PRIVATE_TRANSFERS_RESULT_CLOSURE */
    104 
    105 /**
    106  * Callback for a POST /private/transfers request.
    107  *
    108  * @param cls closure
    109  * @param ptr response details
    110  */
    111 typedef void
    112 (*TALER_MERCHANT_PostPrivateTransfersCallback)(
    113   TALER_MERCHANT_POST_PRIVATE_TRANSFERS_RESULT_CLOSURE *cls,
    114   const struct TALER_MERCHANT_PostPrivateTransfersResponse *ptr);
    115 
    116 
    117 /**
    118  * Start POST /private/transfers operation.
    119  *
    120  * @param[in,out] ppth operation to start
    121  * @param cb function to call with the merchant's result
    122  * @param cb_cls closure for @a cb
    123  * @return status code, #TALER_EC_NONE on success
    124  */
    125 enum TALER_ErrorCode
    126 TALER_MERCHANT_post_private_transfers_start (
    127   struct TALER_MERCHANT_PostPrivateTransfersHandle *ppth,
    128   TALER_MERCHANT_PostPrivateTransfersCallback cb,
    129   TALER_MERCHANT_POST_PRIVATE_TRANSFERS_RESULT_CLOSURE *cb_cls);
    130 
    131 
    132 /**
    133  * Cancel POST /private/transfers operation.  This function must not be
    134  * called by clients after the TALER_MERCHANT_PostPrivateTransfersCallback
    135  * has been invoked (as in those cases it'll be called internally by the
    136  * implementation already).
    137  *
    138  * @param[in] ppth operation to cancel
    139  */
    140 void
    141 TALER_MERCHANT_post_private_transfers_cancel (
    142   struct TALER_MERCHANT_PostPrivateTransfersHandle *ppth);
    143 
    144 
    145 #endif /* _TALER_MERCHANT__POST_PRIVATE_TRANSFERS_H */