merchant

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

merchant_api_common.h (3043B)


      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  * Resource limit for fountain response grants and total withdrawal signatures.
     30  * Exceeds the backend's limits (192 grants and 64 envelopes), while bounding
     31  * allocations even for malformed responses from an untrusted merchant.
     32  */
     33 #define TALER_MERCHANT_MAX_FOUNTAIN_RESPONSE_ITEMS 1024
     34 
     35 
     36 /**
     37  * Function called when we're done processing a
     38  * HTTP POST request to create an order.
     39  *
     40  * @param cb callback
     41  * @param cb_cls closure for @a cb
     42  * @param response_code HTTP response code, 0 on error
     43  * @param json response body, NULL if not JSON
     44  */
     45 void
     46 TALER_MERCHANT_handle_order_creation_response_ (
     47   TALER_MERCHANT_PostPrivateOrdersCallback cb,
     48   void *cb_cls,
     49   long response_code,
     50   const json_t *json);
     51 
     52 
     53 /**
     54  * Take a @a response from the merchant API that (presumably) contains
     55  * error details and setup the corresponding @a hr structure.  Internally
     56  * used to convert merchant's responses in to @a hr.
     57  *
     58  * @param response if NULL we will report #TALER_EC_GENERIC_INVALID_RESPONSE in `ec`
     59  * @param http_status http status to use
     60  * @param[out] hr response object to initialize, fields will
     61  *        only be valid as long as @a response is valid as well
     62  */
     63 void
     64 TALER_MERCHANT_parse_error_details_ (const json_t *response,
     65                                      unsigned int http_status,
     66                                      struct TALER_MERCHANT_HttpResponse *hr);
     67 
     68 
     69 /**
     70  * Parse a 202 Accepted MFA challenge response from JSON.
     71  *
     72  * @param json the JSON response body
     73  * @param[out] cr challenge response to fill in
     74  * @return #GNUNET_OK on success, #GNUNET_SYSERR on parse error
     75  */
     76 enum GNUNET_GenericReturnValue
     77 TALER_MERCHANT_parse_mfa_challenge_response_ (
     78   const json_t *json,
     79   struct TALER_MERCHANT_MfaChallengeResponse *cr);
     80 
     81 
     82 enum GNUNET_GenericReturnValue
     83 TALER_MERCHANT_parse_fractional_string (bool allow_negative,
     84                                         const char *value,
     85                                         int64_t *integer_part,
     86                                         uint32_t *fractional_part);
     87 
     88 
     89 #endif