merchant

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

merchant_api_common.h (2747B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2020-2023 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/lib/merchant_api_common.h
     19  * @brief Implementation of common logic for libtalermerchant
     20  * @author Christian Grothoff
     21  * @author Priscilla Huang
     22  */
     23 #ifndef MERCHANT_API_COMMON_H
     24 #define MERCHANT_API_COMMON_H
     25 #include "taler/taler_merchant_service.h"
     26 
     27 
     28 /**
     29  * Function called when we're done processing a
     30  * HTTP POST request to create an order.
     31  *
     32  * @param cb callback
     33  * @param cb_cls closure for @a cb
     34  * @param response_code HTTP response code, 0 on error
     35  * @param json response body, NULL if not JSON
     36  */
     37 void
     38 TALER_MERCHANT_handle_order_creation_response_ (
     39   TALER_MERCHANT_PostPrivateOrdersCallback cb,
     40   void *cb_cls,
     41   long response_code,
     42   const json_t *json);
     43 
     44 
     45 /**
     46  * Take a @a response from the merchant API that (presumably) contains
     47  * error details and setup the corresponding @a hr structure.  Internally
     48  * used to convert merchant's responses in to @a hr.
     49  *
     50  * @param response if NULL we will report #TALER_EC_GENERIC_INVALID_RESPONSE in `ec`
     51  * @param http_status http status to use
     52  * @param[out] hr response object to initialize, fields will
     53  *        only be valid as long as @a response is valid as well
     54  */
     55 void
     56 TALER_MERCHANT_parse_error_details_ (const json_t *response,
     57                                      unsigned int http_status,
     58                                      struct TALER_MERCHANT_HttpResponse *hr);
     59 
     60 
     61 /**
     62  * Parse a 202 Accepted MFA challenge response from JSON.
     63  *
     64  * @param json the JSON response body
     65  * @param[out] cr challenge response to fill in
     66  * @return #GNUNET_OK on success, #GNUNET_SYSERR on parse error
     67  */
     68 enum GNUNET_GenericReturnValue
     69 TALER_MERCHANT_parse_mfa_challenge_response_ (
     70   const json_t *json,
     71   struct TALER_MERCHANT_MfaChallengeResponse *cr);
     72 
     73 
     74 enum GNUNET_GenericReturnValue
     75 TALER_MERCHANT_parse_fractional_string (bool allow_negative,
     76                                         const char *value,
     77                                         int64_t *integer_part,
     78                                         uint32_t *fractional_part);
     79 
     80 
     81 #endif