merchant

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

get-private-templates-TEMPLATE_ID.h (4182B)


      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 include/taler/taler-merchant/get-private-templates-TEMPLATE_ID.h
     19  * @brief C interface for GET /private/templates/$TEMPLATE_ID of the merchant backend
     20  * @author Christian Grothoff
     21  */
     22 #ifndef _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_TEMPLATE_ID_H
     23 #define _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_TEMPLATE_ID_H
     24 
     25 #include <taler/taler-merchant/common.h>
     26 
     27 
     28 /**
     29  * Handle for a GET /private/templates/$TEMPLATE_ID request.
     30  */
     31 struct TALER_MERCHANT_GetPrivateTemplateHandle;
     32 
     33 
     34 /**
     35  * Response details for a GET /private/templates/$TEMPLATE_ID request.
     36  */
     37 struct TALER_MERCHANT_GetPrivateTemplateResponse
     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_OK.
     53      */
     54     struct
     55     {
     56 
     57       /**
     58        * Human-readable description of the template.
     59        */
     60       const char *template_description;
     61 
     62       /**
     63        * OTP device ID associated with this template, or NULL.
     64        */
     65       const char *otp_id;
     66 
     67       /**
     68        * Template contract (JSON).
     69        */
     70       const json_t *template_contract;
     71 
     72       /**
     73        * Editable defaults (JSON), or NULL if not set.
     74        */
     75       const json_t *editable_defaults;
     76 
     77       /**
     78        * Required currency, or NULL if not set.
     79        */
     80       const char *required_currency;
     81 
     82     } ok;
     83 
     84   } details;
     85 
     86 };
     87 
     88 
     89 /**
     90  * Set up GET /private/templates/$TEMPLATE_ID operation.
     91  * Note that you must explicitly start the operation after
     92  * possibly setting options.
     93  *
     94  * @param ctx the context
     95  * @param url base URL of the merchant backend
     96  * @param template_id identifier of the template to retrieve
     97  * @return handle to operation
     98  */
     99 struct TALER_MERCHANT_GetPrivateTemplateHandle *
    100 TALER_MERCHANT_get_private_template_create (
    101   struct GNUNET_CURL_Context *ctx,
    102   const char *url,
    103   const char *template_id);
    104 
    105 
    106 #ifndef TALER_MERCHANT_GET_PRIVATE_TEMPLATE_RESULT_CLOSURE
    107 /**
    108  * Type of the closure used by
    109  * the #TALER_MERCHANT_GetPrivateTemplateCallback.
    110  */
    111 #define TALER_MERCHANT_GET_PRIVATE_TEMPLATE_RESULT_CLOSURE void
    112 #endif /* TALER_MERCHANT_GET_PRIVATE_TEMPLATE_RESULT_CLOSURE */
    113 
    114 /**
    115  * Callback for a GET /private/templates/$TEMPLATE_ID request.
    116  *
    117  * @param cls closure
    118  * @param tgr response details
    119  */
    120 typedef void
    121 (*TALER_MERCHANT_GetPrivateTemplateCallback)(
    122   TALER_MERCHANT_GET_PRIVATE_TEMPLATE_RESULT_CLOSURE *cls,
    123   const struct TALER_MERCHANT_GetPrivateTemplateResponse *tgr);
    124 
    125 
    126 /**
    127  * Start GET /private/templates/$TEMPLATE_ID operation.
    128  *
    129  * @param[in,out] gpt operation to start
    130  * @param cb function to call with the merchant's result
    131  * @param cb_cls closure for @a cb
    132  * @return status code, #TALER_EC_NONE on success
    133  */
    134 enum TALER_ErrorCode
    135 TALER_MERCHANT_get_private_template_start (
    136   struct TALER_MERCHANT_GetPrivateTemplateHandle *gpt,
    137   TALER_MERCHANT_GetPrivateTemplateCallback cb,
    138   TALER_MERCHANT_GET_PRIVATE_TEMPLATE_RESULT_CLOSURE *cb_cls);
    139 
    140 
    141 /**
    142  * Cancel GET /private/templates/$TEMPLATE_ID operation.  This function
    143  * must not be called by clients after the
    144  * TALER_MERCHANT_GetPrivateTemplateCallback has been invoked
    145  * (as in those cases it'll be called internally by the
    146  * implementation already).
    147  *
    148  * @param[in] gpt operation to cancel
    149  */
    150 void
    151 TALER_MERCHANT_get_private_template_cancel (
    152   struct TALER_MERCHANT_GetPrivateTemplateHandle *gpt);
    153 
    154 
    155 #endif /* _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_TEMPLATE_ID_H */