merchant

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

taler_merchant_service.h (167864B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2014-2025 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU Affero 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 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.LIB.  If not, see <http://www.gnu.org/licenses/>
     15 */
     16 /**
     17  * @file taler_merchant_service.h
     18  * @brief C interface of libtalermerchant, a C library to use merchant's HTTP API
     19  *        This library is not thread-safe, all APIs must only be used from a single thread.
     20  *        This library calls abort() if it runs out of memory. Be aware of these limitations.
     21  * @author Christian Grothoff
     22  * @author Marcello Stanisci
     23  * @author Priscilla HUANG
     24  */
     25 #ifndef _TALER_MERCHANT_SERVICE_H
     26 #define _TALER_MERCHANT_SERVICE_H
     27 
     28 #include <taler/taler_util.h>
     29 #include <taler/taler_error_codes.h>
     30 #include <taler/taler_exchange_service.h>
     31 #include <gnunet/gnunet_curl_lib.h>
     32 #include <jansson.h>
     33 
     34 /**
     35  * Library version (in hex) for compatibility tests.
     36  */
     37 #define TALER_MERCHANT_SERVICE_VERSION 0x00100001
     38 
     39 
     40 /**
     41  * General information about the HTTP response we obtained
     42  * from the merchant for a request.
     43  */
     44 struct TALER_MERCHANT_HttpResponse
     45 {
     46 
     47   /**
     48    * The complete JSON reply. NULL if we failed to parse the
     49    * reply (too big, invalid JSON).
     50    */
     51   const json_t *reply;
     52 
     53   /**
     54    * The complete JSON reply from the exchange, if we generated an error in
     55    * response to an exchange error.  Usually set if @e http_status is
     56    * #MHD_HTTP_FAILED_DEPENDENCY or #MHD_HTTP_SERVICE_UNAVAILABLE. NULL if we
     57    * failed to obtain a JSON reply from the exchange or if we did not receive
     58    * an error from the exchange.
     59    */
     60   const json_t *exchange_reply;
     61 
     62   /**
     63    * Set to the human-readable 'hint' that is optionally
     64    * provided by the exchange together with errors. NULL
     65    * if no hint was provided or if there was no error.
     66    */
     67   const char *hint;
     68 
     69   /**
     70    * The error hint from the exchange, if we generated an error in
     71    * response to an exchange error.  Usually set if @e http_status is
     72    * #MHD_HTTP_FAILED_DEPENDENCY or #MHD_HTTP_SERVICE_UNAVAILABLE. NULL if we
     73    * failed to obtain a hint from the exchange or if we did not receive
     74    * an error from the exchange.
     75    */
     76   const char *exchange_hint;
     77 
     78   /**
     79    * HTTP status code for the response.  0 if the
     80    * HTTP request failed and we did not get any answer, or
     81    * if the answer was invalid and we set @a ec to a
     82    * client-side error code.
     83    */
     84   unsigned int http_status;
     85 
     86   /**
     87    * The HTTP status code from the exchange, if we generated an error in
     88    * response to an exchange error.  Usually set if @e http_status is
     89    * #MHD_HTTP_FAILED_DEPENDENCY or #MHD_HTTP_SERVICE_UNAVAILABLE. 0 if we
     90    * failed to obtain a JSON reply from the exchange or if we did not receive
     91    * an error from the exchange.
     92    */
     93   unsigned int exchange_http_status;
     94 
     95   /**
     96    * Taler error code.  #TALER_EC_NONE if everything was
     97    * OK.  Usually set to the "code" field of an error
     98    * response, but may be set to values created at the
     99    * client side, for example when the response was
    100    * not in JSON format or was otherwise ill-formed.
    101    */
    102   enum TALER_ErrorCode ec;
    103 
    104   /**
    105    * The error code from the reply from the exchange, if we generated an error in
    106    * response to an exchange error.  Usually set if @e http_status is
    107    * #MHD_HTTP_FAILED_DEPENDENCY or #MHD_HTTP_SERVICE_UNAVAILABLE. NULL if we
    108    * failed to obtain a error code from the exchange or if we did not receive
    109    * an error from the exchange.
    110    */
    111   enum TALER_ErrorCode exchange_code;
    112 
    113 };
    114 
    115 
    116 /**
    117  * Contains information gathered from parsing a taler://pay URI.
    118  */
    119 struct TALER_MERCHANT_PayUriData
    120 {
    121   /**
    122    * Hostname (and possibly port) of the merchant.
    123    */
    124   char *merchant_host;
    125 
    126   /**
    127    * Prefix to the base url of the merchant backend. May be NULL.
    128    */
    129   char *merchant_prefix_path;
    130 
    131   /**
    132    * The id of the order to pay.
    133    */
    134   char *order_id;
    135 
    136   /**
    137    * Session id to use when paying the order. May be NULL.
    138    */
    139   char *session_id;
    140 
    141   /**
    142    * Claim token to use when claiming the order. May be NULL.
    143    */
    144   struct TALER_ClaimTokenP *claim_token;
    145 
    146   /**
    147    * A WLAN SSID that the wallet can use to connect to the internet in order to
    148    * to pay. May be NULL.
    149    */
    150   char *ssid;
    151 
    152   /**
    153    * true if the URI used taler+http.
    154    */
    155   bool use_http;
    156 };
    157 
    158 
    159 /**
    160  * Extracts information from a taler://pay URI.
    161  *
    162  * @param pay_uri the URI to parse.
    163  * @param[out] parse_data data extracted from the URI. Must be free'd.
    164  * @return #GNUNET_SYSERR if @e pay_uri is malformed, #GNUNET_OK otherwise.
    165  */
    166 enum GNUNET_GenericReturnValue
    167 TALER_MERCHANT_parse_pay_uri (const char *pay_uri,
    168                               struct TALER_MERCHANT_PayUriData *parse_data);
    169 
    170 
    171 /**
    172  * Frees data contained in the result of parsing a taler://pay URI.
    173  *
    174  * @param[in] parse_data the data to free.
    175  */
    176 void
    177 TALER_MERCHANT_parse_pay_uri_free (
    178   struct TALER_MERCHANT_PayUriData *parse_data);
    179 
    180 
    181 /**
    182  * Contains information gathered from parsing a taler://refund URI.
    183  */
    184 struct TALER_MERCHANT_RefundUriData
    185 {
    186   /**
    187    * Hostname (and possibly port) of the merchant.
    188    */
    189   char *merchant_host;
    190 
    191   /**
    192    * Prefix to the base url of the merchant backend. May be NULL.
    193    */
    194   char *merchant_prefix_path;
    195 
    196   /**
    197    * The id of the order to pay.
    198    */
    199   char *order_id;
    200 
    201   /**
    202    * A WLAN SSID that the wallet can use to connect to the internet in order to
    203    * to pay. May be NULL.
    204    */
    205   char *ssid;
    206 
    207   /**
    208    * true if the URI used taler+http.
    209    */
    210   bool use_http;
    211 };
    212 
    213 
    214 /**
    215  * Extracts information from a taler://refund URI.
    216  *
    217  * @param refund_uri the URI to parse.
    218  * @param[out] parse_data data extracted from the URI. Must be free'd.
    219  * @return #GNUNET_SYSERR if @e refund_uri is malformed, #GNUNET_OK otherwise.
    220  */
    221 enum GNUNET_GenericReturnValue
    222 TALER_MERCHANT_parse_refund_uri (
    223   const char *refund_uri,
    224   struct TALER_MERCHANT_RefundUriData *parse_data);
    225 
    226 
    227 /**
    228  * Frees data contained in the result of parsing a taler://refund URI.
    229  *
    230  * @param parse_data the data to free.
    231  */
    232 void
    233 TALER_MERCHANT_parse_refund_uri_free (
    234   struct TALER_MERCHANT_RefundUriData *parse_data);
    235 
    236 
    237 /* ********************* /public/config ****************** */
    238 
    239 
    240 /**
    241  * How compatible are the protocol version of the auditor and this
    242  * client?  The bits (1,2,4) can be used to test if the auditor's
    243  * version is incompatible, older or newer respectively.
    244  */
    245 enum TALER_MERCHANT_VersionCompatibility
    246 {
    247 
    248   /**
    249    * The auditor runs exactly the same protocol version.
    250    */
    251   TALER_MERCHANT_VC_MATCH = 0,
    252 
    253   /**
    254    * The auditor is too old or too new to be compatible with this
    255    * implementation (bit)
    256    */
    257   TALER_MERCHANT_VC_INCOMPATIBLE = 1,
    258 
    259   /**
    260    * The auditor is older than this implementation (bit)
    261    */
    262   TALER_MERCHANT_VC_OLDER = 2,
    263 
    264   /**
    265    * The auditor is too old to be compatible with
    266    * this implementation.
    267    */
    268   TALER_MERCHANT_VC_INCOMPATIBLE_OUTDATED
    269     = TALER_MERCHANT_VC_INCOMPATIBLE
    270       | TALER_MERCHANT_VC_OLDER,
    271 
    272   /**
    273    * The auditor is more recent than this implementation (bit).
    274    */
    275   TALER_MERCHANT_VC_NEWER = 4,
    276 
    277   /**
    278    * The auditor is too recent for this implementation.
    279    */
    280   TALER_MERCHANT_VC_INCOMPATIBLE_NEWER
    281     = TALER_MERCHANT_VC_INCOMPATIBLE
    282       | TALER_MERCHANT_VC_NEWER,
    283 
    284   /**
    285    * We could not even parse the version data.
    286    */
    287   TALER_MERCHANT_VC_PROTOCOL_ERROR = 8
    288 
    289 };
    290 
    291 
    292 /**
    293  * @brief Config information we get from the backend.
    294  */
    295 struct TALER_MERCHANT_ConfigInformation
    296 {
    297   /**
    298    * Default currency of the merchant.  See cspecs
    299    * for all currencies supported by the merchant.
    300    */
    301   const char *currency;
    302 
    303   /**
    304    * Supported Taler protocol version by the merchant.
    305    * String in the format current:revision:age using the
    306    * semantics of GNU libtool.  See
    307    * https://www.gnu.org/software/libtool/manual/html_node/Versioning.html#Versioning
    308    */
    309   const char *version;
    310 
    311 };
    312 
    313 
    314 /**
    315  * Information about an exchange the merchant backend trusts.
    316  */
    317 struct TALER_MERCHANT_ExchangeConfigInfo
    318 {
    319   /**
    320    * Base URL of the exchange REST API.
    321    */
    322   const char *base_url;
    323 
    324   /**
    325    * Currency for which the merchant is configured to
    326    * trust the exchange.
    327    */
    328   const char *currency;
    329 
    330   /**
    331    * Master public key of the exchange.
    332    */
    333   struct TALER_MasterPublicKeyP master_pub;
    334 
    335 };
    336 
    337 /**
    338  * Response to /config request.
    339  */
    340 struct TALER_MERCHANT_ConfigResponse
    341 {
    342   /**
    343    * HTTP response.
    344    */
    345   struct TALER_MERCHANT_HttpResponse hr;
    346 
    347   /**
    348    * Status-dependent details.
    349    */
    350   union
    351   {
    352     /**
    353      * Information returned on #MHD_HTTP_OK.
    354      */
    355     struct
    356     {
    357 
    358       /**
    359        * basic information about the merchant
    360        */
    361       struct TALER_MERCHANT_ConfigInformation ci;
    362 
    363       /**
    364        * protocol compatibility information
    365        */
    366       enum TALER_MERCHANT_VersionCompatibility compat;
    367 
    368       /**
    369        * Length of the @e cspecs array.
    370        */
    371       unsigned int num_cspecs;
    372 
    373       /**
    374        * Array with rendering specifications for the currencies
    375        * supported by this merchant backend.
    376        */
    377       const struct TALER_CurrencySpecification *cspecs;
    378 
    379       /**
    380        * Length of the @e exchanges array.
    381        */
    382       unsigned int num_exchanges;
    383 
    384       /**
    385        * Array details about exchanges trusted
    386        * by this merchant backend.
    387        */
    388       const struct TALER_MERCHANT_ExchangeConfigInfo *exchanges;
    389 
    390     } ok;
    391   } details;
    392 };
    393 
    394 
    395 /**
    396  * Function called with information about the merchant.
    397  *
    398  * @param cls closure
    399  * @param cr response data
    400  */
    401 typedef void
    402 (*TALER_MERCHANT_ConfigCallback) (
    403   void *cls,
    404   const struct TALER_MERCHANT_ConfigResponse *cr);
    405 
    406 
    407 /**
    408  * Handle for a #TALER_MERCHANT_config_get() operation.
    409  */
    410 struct TALER_MERCHANT_ConfigGetHandle;
    411 
    412 
    413 /**
    414  * Get the config data of a merchant. Will connect to the merchant backend
    415  * and obtain information about the backend.  The respective information will
    416  * be passed to the @a config_cb once available.
    417  *
    418  * @param ctx the context
    419  * @param backend_url HTTP base URL for the backend
    420  * @param config_cb function to call with the
    421  *        backend's config information
    422  * @param config_cb_cls closure for @a config_cb
    423  * @return the config check handle; NULL upon error
    424  */
    425 struct TALER_MERCHANT_ConfigGetHandle *
    426 TALER_MERCHANT_config_get (
    427   struct GNUNET_CURL_Context *ctx,
    428   const char *backend_url,
    429   TALER_MERCHANT_ConfigCallback config_cb,
    430   void *config_cb_cls);
    431 
    432 
    433 /**
    434  * Cancel /config request.  Must not be called by clients after
    435  * the callback was invoked.
    436  *
    437  * @param[in] vgh request to cancel.
    438  */
    439 void
    440 TALER_MERCHANT_config_get_cancel (struct TALER_MERCHANT_ConfigGetHandle *vgh);
    441 
    442 
    443 /* ********************* /instances *********************** */
    444 
    445 
    446 /**
    447  * @brief Information about a merchant instance.
    448  */
    449 struct TALER_MERCHANT_InstanceInformation
    450 {
    451   /**
    452    * Id of this instance.  This $ID can be used to construct the URL of the
    453    * instance, by combining it using "$MERCHANT_BASEURL/instances/$ID/".
    454    */
    455   const char *id;
    456 
    457   /**
    458    * Legal name of the merchant/instance.
    459    */
    460   const char *name;
    461 
    462   /**
    463    * Public key of the instance.
    464    */
    465   struct TALER_MerchantPublicKeyP merchant_pub;
    466 
    467   /**
    468    * JSON array of payment targets (strings) supported by this backend
    469    * instance.
    470    */
    471   const json_t *payment_targets;
    472 
    473 };
    474 
    475 
    476 /**
    477  * Handle for a GET /instances operation.
    478  */
    479 struct TALER_MERCHANT_InstancesGetHandle;
    480 
    481 
    482 /**
    483  * Response to a GET /instances request.
    484  */
    485 struct TALER_MERCHANT_InstancesGetResponse
    486 {
    487   /**
    488    * HTTP response data
    489    */
    490   struct TALER_MERCHANT_HttpResponse hr;
    491 
    492   union
    493   {
    494     /**
    495      * Data returned on #MHD_HTTP_OK status.
    496      */
    497     struct
    498     {
    499       /**
    500        * length of the @e iis array
    501        */
    502       unsigned int iis_length;
    503 
    504       /**
    505        * array with instance information of length @e iis_length
    506        */
    507       const struct TALER_MERCHANT_InstanceInformation *iis;
    508     } ok;
    509   } details;
    510 
    511 };
    512 
    513 
    514 /**
    515  * Function called with the result of the GET /instances operation.
    516  *
    517  * @param cls closure
    518  * @param igr response data
    519  */
    520 typedef void
    521 (*TALER_MERCHANT_InstancesGetCallback)(
    522   void *cls,
    523   const struct TALER_MERCHANT_InstancesGetResponse *igr);
    524 
    525 
    526 /**
    527  * Get the instance data of a backend. Will connect to the merchant backend
    528  * and obtain information about the instances.  The respective information will
    529  * be passed to the @a instances_cb once available.
    530  *
    531  * @param ctx the context
    532  * @param backend_url HTTP base URL for the backend
    533  * @param instances_cb function to call with the
    534  *        backend's instances information
    535  * @param instances_cb_cls closure for @a config_cb
    536  * @return the instances handle; NULL upon error
    537  */
    538 struct TALER_MERCHANT_InstancesGetHandle *
    539 TALER_MERCHANT_instances_get (
    540   struct GNUNET_CURL_Context *ctx,
    541   const char *backend_url,
    542   TALER_MERCHANT_InstancesGetCallback instances_cb,
    543   void *instances_cb_cls);
    544 
    545 
    546 /**
    547  * Cancel /instances request.  Must not be called by clients after
    548  * the callback was invoked.
    549  *
    550  * @param igh request to cancel.
    551  */
    552 void
    553 TALER_MERCHANT_instances_get_cancel (
    554   struct TALER_MERCHANT_InstancesGetHandle *igh);
    555 
    556 
    557 /**
    558  * Handle for a POST /instances/$ID operation.
    559  */
    560 struct TALER_MERCHANT_InstancesPostHandle;
    561 
    562 
    563 /**
    564  * Function called with the result of the POST /instances/$ID operation.
    565  *
    566  * @param cls closure
    567  * @param hr HTTP response data
    568  */
    569 typedef void
    570 (*TALER_MERCHANT_InstancesPostCallback)(
    571   void *cls,
    572   const struct TALER_MERCHANT_HttpResponse *hr);
    573 
    574 
    575 /**
    576  * Setup an new instance in the backend.
    577  *
    578  * @param ctx the context
    579  * @param backend_url HTTP base URL for the backend
    580  * @param instance_id identity of the instance to get information about
    581  * @param name name of the merchant instance
    582  * @param address physical address of the merchant instance
    583  * @param jurisdiction jurisdiction of the merchant instance
    584  * @param use_stefan use STEFAN curve for acceptable fees
    585  * @param default_wire_transfer_delay default wire transfer delay merchant will ask for
    586  * @param default_pay_delay default validity period for offers merchant makes
    587  * @param default_refund_delay default refund period
    588  * @param auth_token authentication token to use for access control, NULL for external auth; MUST follow RFC 8959
    589  * @param cb function to call with the
    590  *        backend's instances information
    591  * @param cb_cls closure for @a config_cb
    592  * @return the instances handle; NULL upon error
    593  */
    594 struct TALER_MERCHANT_InstancesPostHandle *
    595 TALER_MERCHANT_instances_post (
    596   struct GNUNET_CURL_Context *ctx,
    597   const char *backend_url,
    598   const char *instance_id,
    599   const char *name,
    600   const json_t *address,
    601   const json_t *jurisdiction,
    602   bool use_stefan,
    603   struct GNUNET_TIME_Relative default_wire_transfer_delay,
    604   struct GNUNET_TIME_Relative default_pay_delay,
    605   struct GNUNET_TIME_Relative default_refund_delay,
    606   const char *auth_token,
    607   TALER_MERCHANT_InstancesPostCallback cb,
    608   void *cb_cls);
    609 
    610 
    611 /**
    612  * Cancel /instances request.  Must not be called by clients after
    613  * the callback was invoked.
    614  *
    615  * @param iph request to cancel.
    616  */
    617 void
    618 TALER_MERCHANT_instances_post_cancel (
    619   struct TALER_MERCHANT_InstancesPostHandle *iph);
    620 
    621 
    622 /**
    623  * Handle for a PATCH /instances/$ID operation.
    624  */
    625 struct TALER_MERCHANT_InstancePatchHandle;
    626 
    627 
    628 /**
    629  * Function called with the result of the GET /instances/$ID operation.
    630  *
    631  * @param cls closure
    632  * @param hr HTTP response data
    633  */
    634 typedef void
    635 (*TALER_MERCHANT_InstancePatchCallback)(
    636   void *cls,
    637   const struct TALER_MERCHANT_HttpResponse *hr);
    638 
    639 
    640 /**
    641  * Modify an existing instance in the backend.
    642  *
    643  * @param ctx the context
    644  * @param backend_url HTTP base URL for the backend (top-level "default" instance
    645  *                    or base URL of an instance if @a instance_id is NULL)
    646  * @param instance_id identity of the instance to modify information about; NULL
    647  *                    if the instance is identified as part of the @a backend_url
    648  * @param name name of the merchant instance
    649  * @param address physical address of the merchant instance
    650  * @param jurisdiction jurisdiction of the merchant instance
    651  * @param use_stefan use STEFAN curve for acceptable fees
    652  * @param default_wire_transfer_delay default wire transfer delay merchant will ask for
    653  * @param default_pay_delay default validity period for offers merchant makes
    654  * @param default_refund_delay default refund period
    655  * @param cb function to call with the
    656  *        backend's instances information
    657  * @param cb_cls closure for @a config_cb
    658  * @return the instances handle; NULL upon error
    659  */
    660 struct TALER_MERCHANT_InstancePatchHandle *
    661 TALER_MERCHANT_instance_patch (
    662   struct GNUNET_CURL_Context *ctx,
    663   const char *backend_url,
    664   const char *instance_id,
    665   const char *name,
    666   const json_t *address,
    667   const json_t *jurisdiction,
    668   bool use_stefan,
    669   struct GNUNET_TIME_Relative default_wire_transfer_delay,
    670   struct GNUNET_TIME_Relative default_pay_delay,
    671   struct GNUNET_TIME_Relative default_refund_delay,
    672   TALER_MERCHANT_InstancePatchCallback cb,
    673   void *cb_cls);
    674 
    675 
    676 /**
    677  * Cancel /instances request.  Must not be called by clients after
    678  * the callback was invoked.
    679  *
    680  * @param iph request to cancel.
    681  */
    682 void
    683 TALER_MERCHANT_instance_patch_cancel (
    684   struct TALER_MERCHANT_InstancePatchHandle *iph);
    685 
    686 
    687 /**
    688  * Handle for an operation to modify authentication settings.
    689  */
    690 struct TALER_MERCHANT_InstanceAuthPostHande;
    691 
    692 
    693 /**
    694  * Function called with the result of the GET /instances/$ID operation.
    695  *
    696  * @param cls closure
    697  * @param hr HTTP response data
    698  */
    699 typedef void
    700 (*TALER_MERCHANT_InstanceAuthPostCallback)(
    701   void *cls,
    702   const struct TALER_MERCHANT_HttpResponse *hr);
    703 
    704 
    705 /**
    706  * Modify authentication for an existing instance in the backend.
    707  *
    708  * @param ctx the context
    709  * @param backend_url HTTP base URL for the backend (top-level "default" instance
    710  *                    or base URL of an instance if @a instance_id is NULL)
    711  * @param instance_id identity of the instance to patch the authentication for; NULL
    712  *                    if the instance is identified as part of the @a backend_url
    713  * @param auth_token authorization token needed to access the instance, can be NULL
    714  *                   to switch to no (or external) authentication; MUST follow RFC 8959
    715  * @param cb function to call with the backend's response
    716  * @param cb_cls closure for @a config_cb
    717  * @return the instances handle; NULL upon error
    718  */
    719 struct TALER_MERCHANT_InstanceAuthPostHandle *
    720 TALER_MERCHANT_instance_auth_post (
    721   struct GNUNET_CURL_Context *ctx,
    722   const char *backend_url,
    723   const char *instance_id,
    724   const char *auth_token,
    725   TALER_MERCHANT_InstanceAuthPostCallback cb,
    726   void *cb_cls);
    727 
    728 
    729 /**
    730  * Cancel /private/auth request.  Must not be called by clients after
    731  * the callback was invoked.  Afterwards, the authentication may or
    732  * may not have been updated.
    733  *
    734  * @param iaph request to cancel.
    735  */
    736 void
    737 TALER_MERCHANT_instance_auth_post_cancel (
    738   struct TALER_MERCHANT_InstanceAuthPostHandle *iaph);
    739 
    740 /**
    741  * Handle for an operation to get access token.
    742  */
    743 struct TALER_MERCHANT_InstanceTokenPostHande;
    744 
    745 
    746 /**
    747  * Function called with the result of the GET /instances/$ID/private/token
    748  * operation.
    749  *
    750  * @param cls closure
    751  * @param hr HTTP response data
    752  */
    753 typedef void
    754 (*TALER_MERCHANT_InstanceTokenPostCallback)(
    755   void *cls,
    756   const struct TALER_MERCHANT_HttpResponse *hr);
    757 
    758 /**
    759  * Get access token for an existing instance in the backend.
    760  *
    761  * @param ctx the context
    762  * @param backend_url HTTP base URL for the backend (top-level "default" instance
    763  *                    or base URL of an instance if @a instance_id is NULL)
    764  * @param instance_id identity of the instance to patch the authentication for; NULL
    765  *                    if the instance is identified as part of the @a backend_url
    766  * @param scope       authorization scope for token needed to access the instance, can be NULL
    767  * @param duration    requested authorization duration
    768  * @param refreshable requesting a refreshable token or not
    769  * @param cb function to call with the backend's response
    770  * @param cb_cls closure for @a config_cb
    771  * @return the instances handle; NULL upon error
    772  */
    773 struct TALER_MERCHANT_InstanceTokenPostHandle *
    774 TALER_MERCHANT_instance_token_post (
    775   struct GNUNET_CURL_Context *ctx,
    776   const char *backend_url,
    777   const char *instance_id,
    778   const char *scope,
    779   struct GNUNET_TIME_Relative duration,
    780   bool refreshable,
    781   TALER_MERCHANT_InstanceTokenPostCallback cb,
    782   void *cb_cls);
    783 
    784 
    785 /**
    786  * Cancel /private/token request.  Must not be called by clients after
    787  * the callback was invoked.  Afterwards, the authentication may or
    788  * may not have been updated.
    789  *
    790  * @param itph request to cancel.
    791  */
    792 void
    793 TALER_MERCHANT_instance_token_post_cancel (
    794   struct TALER_MERCHANT_InstanceTokenPostHandle *itph);
    795 
    796 /**
    797  * Handle for a DELETE /instances/$ID/private/token operation.
    798  */
    799 struct TALER_MERCHANT_InstanceTokenDeleteHandle;
    800 
    801 
    802 /**
    803  * Function called with the result of the DELETE /instances/$ID/private/token operation.
    804  *
    805  * @param cls closure
    806  * @param hr response data
    807  */
    808 typedef void
    809 (*TALER_MERCHANT_InstanceTokenDeleteCallback)(
    810   void *cls,
    811   const struct TALER_MERCHANT_HttpResponse *hr);
    812 
    813 
    814 /**
    815  * Remove token instance in the backend.
    816  *
    817  * @param ctx the context
    818  * @param backend_url HTTP base URL for the backend
    819  * @param instance_id identity of the instance to patch the authentication for; NULL
    820  *                    if the instance is identified as part of the @a backend_url
    821  * @param cb function to call with the response
    822  * @param cb_cls closure for @a config_cb
    823  * @return the instances handle; NULL upon error
    824  */
    825 struct TALER_MERCHANT_InstanceTokenDeleteHandle *
    826 TALER_MERCHANT_instance_token_delete (
    827   struct GNUNET_CURL_Context *ctx,
    828   const char *backend_url,
    829   const char *instance_id,
    830   TALER_MERCHANT_InstanceTokenDeleteCallback cb,
    831   void *cb_cls);
    832 
    833 
    834 /**
    835  * Cancel DELETE token request.  Must not be called by clients after
    836  * the callback was invoked.
    837  *
    838  * @param tdh request to cancel.
    839  */
    840 void
    841 TALER_MERCHANT_instance_token_delete_cancel (
    842   struct TALER_MERCHANT_InstanceTokenDeleteHandle *tdh);
    843 
    844 
    845 /**
    846  * Handle for a GET /instances/$ID operation.
    847  */
    848 struct TALER_MERCHANT_InstanceGetHandle;
    849 
    850 
    851 /**
    852  * Details about an instance.
    853  */
    854 struct TALER_MERCHANT_InstanceDetails
    855 {
    856   /**
    857    * Name of the merchant instance
    858    */
    859   const char *name;
    860 
    861   /**
    862    * public key of the merchant instance
    863    */
    864   struct TALER_MerchantPublicKeyP merchant_pub;
    865 
    866   /**
    867    * physical address of the merchant instance
    868    */
    869   const json_t *address;
    870 
    871   /**
    872    * jurisdiction of the merchant instance
    873    */
    874   const json_t *jurisdiction;
    875 
    876   /**
    877    * Are we using STEFAN curves to determine acceptable
    878    * fees?
    879    */
    880   bool use_stefan;
    881 
    882   /**
    883    * default wire transfer delay merchant will ask for
    884    */
    885   struct GNUNET_TIME_Relative default_wire_transfer_delay;
    886 
    887   /**
    888    * default validity period for offers merchant makes
    889    */
    890   struct GNUNET_TIME_Relative default_pay_delay;
    891 
    892   /**
    893    * default refund period for offers merchant makes
    894    */
    895   struct GNUNET_TIME_Relative default_refund_delay;
    896 
    897   /**
    898    * Default interval by which we round up wire transfer deadlines
    899    * computed using the @e default_wire_transfer_delay.
    900    */
    901   enum GNUNET_TIME_RounderInterval default_wire_transfer_rounding_interval;
    902 
    903 };
    904 
    905 
    906 struct TALER_MERCHANT_InstanceGetResponse
    907 {
    908   /**
    909    * HTTP response data
    910    */
    911   struct TALER_MERCHANT_HttpResponse hr;
    912 
    913   union
    914   {
    915 
    916     /**
    917      * Data returned on #MHD_HTTP_OK.
    918      */
    919     struct
    920     {
    921       /**
    922        * Details about the instance.
    923        */
    924       struct TALER_MERCHANT_InstanceDetails details;
    925 
    926     } ok;
    927   }
    928   details;
    929 };
    930 
    931 
    932 /**
    933  * Function called with the result of the GET /instances/$ID operation.
    934  *
    935  * @param cls closure
    936  * @param igr response details
    937  */
    938 typedef void
    939 (*TALER_MERCHANT_InstanceGetCallback)(
    940   void *cls,
    941   const struct TALER_MERCHANT_InstanceGetResponse *igr);
    942 
    943 
    944 /**
    945  * Get the details on one of the instances of a backend. Will connect to the
    946  * merchant backend and obtain information about the instance.  The respective
    947  * information will be passed to the @a cb once available.
    948  *
    949  * @param ctx the context
    950  * @param backend_url HTTP base URL for the backend
    951  * @param instance_id identity of the instance to get information about
    952  * @param cb function to call with the
    953  *        backend's instances information
    954  * @param cb_cls closure for @a config_cb
    955  * @return the instances handle; NULL upon error
    956  */
    957 struct TALER_MERCHANT_InstanceGetHandle *
    958 TALER_MERCHANT_instance_get (
    959   struct GNUNET_CURL_Context *ctx,
    960   const char *backend_url,
    961   const char *instance_id,
    962   TALER_MERCHANT_InstanceGetCallback cb,
    963   void *cb_cls);
    964 
    965 
    966 /**
    967  * Cancel /instances request.  Must not be called by clients after
    968  * the callback was invoked.
    969  *
    970  * @param igh request to cancel.
    971  */
    972 void
    973 TALER_MERCHANT_instance_get_cancel (
    974   struct TALER_MERCHANT_InstanceGetHandle *igh);
    975 
    976 
    977 /**
    978  * Handle for a DELETE /instances operation.
    979  */
    980 struct TALER_MERCHANT_InstanceDeleteHandle;
    981 
    982 
    983 /**
    984  * Function called with the result of the DELETE /instances operation.
    985  *
    986  * @param cls closure
    987  * @param hr HTTP response data
    988  */
    989 typedef void
    990 (*TALER_MERCHANT_InstanceDeleteCallback)(
    991   void *cls,
    992   const struct TALER_MERCHANT_HttpResponse *hr);
    993 
    994 
    995 /**
    996  * Delete the private key of an instance of a backend, thereby disabling the
    997  * instance for future requests.  Will preserve the other instance data
    998  * (i.e. for taxation).
    999  *
   1000  * @param ctx the context
   1001  * @param backend_url HTTP base URL for the backend (top-level "default" instance
   1002  *                    or base URL of an instance if @a instance_id is NULL)
   1003  * @param instance_id identity of the instance to modify information about; NULL
   1004  *                    if the instance is identified as part of the @a backend_url
   1005  * @param instances_cb function to call with the
   1006  *        backend's return
   1007  * @param instances_cb_cls closure for @a config_cb
   1008  * @return the instances handle; NULL upon error
   1009  */
   1010 struct TALER_MERCHANT_InstanceDeleteHandle *
   1011 TALER_MERCHANT_instance_delete (
   1012   struct GNUNET_CURL_Context *ctx,
   1013   const char *backend_url,
   1014   const char *instance_id,
   1015   TALER_MERCHANT_InstanceDeleteCallback instances_cb,
   1016   void *instances_cb_cls);
   1017 
   1018 
   1019 /**
   1020  * Purge all data associated with an instance. Use with
   1021  * extreme caution.
   1022  *
   1023  * @param ctx the context
   1024  * @param backend_url HTTP base URL for the backend
   1025  * @param instance_id which instance should be deleted
   1026  * @param instances_cb function to call with the
   1027  *        backend's return
   1028  * @param instances_cb_cls closure for @a config_cb
   1029  * @return the instances handle; NULL upon error
   1030  */
   1031 struct TALER_MERCHANT_InstanceDeleteHandle *
   1032 TALER_MERCHANT_instance_purge (
   1033   struct GNUNET_CURL_Context *ctx,
   1034   const char *backend_url,
   1035   const char *instance_id,
   1036   TALER_MERCHANT_InstanceDeleteCallback instances_cb,
   1037   void *instances_cb_cls);
   1038 
   1039 
   1040 /**
   1041  * Cancel /instances DELETE request.  Must not be called by clients after
   1042  * the callback was invoked.
   1043  *
   1044  * @param idh request to cancel.
   1045  */
   1046 void
   1047 TALER_MERCHANT_instance_delete_cancel (
   1048   struct TALER_MERCHANT_InstanceDeleteHandle *idh);
   1049 
   1050 
   1051 /**
   1052  * Cancel /instances DELETE request.  Must not be called by clients after
   1053  * the callback was invoked.
   1054  *
   1055  * @param arg request to cancel.
   1056  */
   1057 #define TALER_MERCHANT_instance_purge_cancel(arg) \
   1058         TALER_MERCHANT_instance_delete_cancel (arg)
   1059 
   1060 
   1061 /* *************** Accounts **************** */
   1062 
   1063 /**
   1064  * Handle for a POST /instances/$ID/accounts operation.
   1065  */
   1066 struct TALER_MERCHANT_AccountsPostHandle;
   1067 
   1068 
   1069 /**
   1070  * Response for a POST /instances/$ID/account operation.
   1071  */
   1072 struct TALER_MERCHANT_AccountsPostResponse
   1073 {
   1074   /**
   1075    * HTTP response data
   1076    */
   1077   struct TALER_MERCHANT_HttpResponse hr;
   1078 
   1079   /**
   1080    * Details depending on HTTP status.
   1081    */
   1082   union
   1083   {
   1084 
   1085     /**
   1086      * Details returned on #MHD_HTTP_OK.
   1087      */
   1088     struct
   1089     {
   1090 
   1091       /**
   1092        * Hash of @e payto_uri and @e salt.
   1093        */
   1094       struct TALER_MerchantWireHashP h_wire;
   1095 
   1096       /**
   1097        * salt used to compute h_wire
   1098        */
   1099       struct TALER_WireSaltP salt;
   1100     } ok;
   1101 
   1102   } details;
   1103 };
   1104 
   1105 
   1106 /**
   1107  * Function called with the result of the POST /instances/$ID/accounts operation.
   1108  *
   1109  * @param cls closure
   1110  * @param par response data
   1111  */
   1112 typedef void
   1113 (*TALER_MERCHANT_AccountsPostCallback)(
   1114   void *cls,
   1115   const struct TALER_MERCHANT_AccountsPostResponse *par);
   1116 
   1117 
   1118 /**
   1119  * Setup an new account for an instance in the backend.
   1120  *
   1121  * @param ctx the context
   1122  * @param backend_url HTTP base URL for the backend
   1123  * @param payto_uri URI of the bank account as per RFC 8905
   1124  * @param credit_facade_url credit facade for the account, can be NULL
   1125  * @param credit_facade_credentials credentials for credit facade, can be NULL
   1126  * @param cb function to call with the response
   1127  * @param cb_cls closure for @a config_cb
   1128  * @return the instances handle; NULL upon error
   1129  */
   1130 struct TALER_MERCHANT_AccountsPostHandle *
   1131 TALER_MERCHANT_accounts_post (
   1132   struct GNUNET_CURL_Context *ctx,
   1133   const char *backend_url,
   1134   struct TALER_FullPayto payto_uri,
   1135   const char *credit_facade_url,
   1136   const json_t *credit_facade_credentials,
   1137   TALER_MERCHANT_AccountsPostCallback cb,
   1138   void *cb_cls);
   1139 
   1140 
   1141 /**
   1142  * Cancel POST /accounts request.  Must not be called by clients after
   1143  * the callback was invoked.
   1144  *
   1145  * @param pah request to cancel.
   1146  */
   1147 void
   1148 TALER_MERCHANT_accounts_post_cancel (
   1149   struct TALER_MERCHANT_AccountsPostHandle *pah);
   1150 
   1151 
   1152 /**
   1153  * Handle for a GET /accounts/$ID operation.
   1154  */
   1155 struct TALER_MERCHANT_AccountGetHandle;
   1156 
   1157 
   1158 /**
   1159  * Details about a merchant's bank account.
   1160  */
   1161 struct TALER_MERCHANT_AccountDetails
   1162 {
   1163   /**
   1164    * salt used to compute h_wire
   1165    */
   1166   struct TALER_WireSaltP salt;
   1167 
   1168   /**
   1169    * payto:// URI of the account.
   1170    */
   1171   struct TALER_FullPayto payto_uri;
   1172 
   1173   /**
   1174    * Credit facade URL of the account.
   1175    */
   1176   const char *credit_facade_url;
   1177 
   1178   /**
   1179    * Hash of @e payto_uri and @e salt.
   1180    */
   1181   struct TALER_MerchantWireHashP h_wire;
   1182 
   1183   /**
   1184    * true if the account is active,
   1185    * false if it is historic.
   1186    */
   1187   bool active;
   1188 };
   1189 
   1190 
   1191 /**
   1192  * Response returned with details about an account.
   1193  */
   1194 struct TALER_MERCHANT_AccountGetResponse
   1195 {
   1196   /**
   1197    * HTTP response data
   1198    */
   1199   struct TALER_MERCHANT_HttpResponse hr;
   1200 
   1201   union
   1202   {
   1203 
   1204     /**
   1205      * Data returned on #MHD_HTTP_OK.
   1206      */
   1207     struct
   1208     {
   1209 
   1210       /**
   1211        * bank accounts of the merchant instance
   1212        */
   1213       struct TALER_MERCHANT_AccountDetails ad;
   1214 
   1215     } ok;
   1216   }
   1217   details;
   1218 };
   1219 
   1220 
   1221 /**
   1222  * Function called with the result of the GET /instances/$ID/accounts/$H_WIRE operation.
   1223  *
   1224  * @param cls closure
   1225  * @param igr response details
   1226  */
   1227 typedef void
   1228 (*TALER_MERCHANT_AccountGetCallback)(
   1229   void *cls,
   1230   const struct TALER_MERCHANT_AccountGetResponse *igr);
   1231 
   1232 
   1233 /**
   1234  * Get the details on one of the accounts of an instance. Will connect to the
   1235  * merchant backend and obtain information about the account.  The respective
   1236  * information will be passed to the @a cb once available.
   1237  *
   1238  * @param ctx the context
   1239  * @param backend_url HTTP base URL for the backend
   1240  * @param instance_id identity of the instance to get information about
   1241  * @param h_wire hash of the wire details
   1242  * @param cb function to call with the
   1243  *        backend's instances information
   1244  * @param cb_cls closure for @a config_cb
   1245  * @return the instances handle; NULL upon error
   1246  */
   1247 struct TALER_MERCHANT_AccountGetHandle *
   1248 TALER_MERCHANT_account_get (
   1249   struct GNUNET_CURL_Context *ctx,
   1250   const char *backend_url,
   1251   const char *instance_id,
   1252   const struct TALER_MerchantWireHashP *h_wire,
   1253   TALER_MERCHANT_AccountGetCallback cb,
   1254   void *cb_cls);
   1255 
   1256 
   1257 /**
   1258  * Cancel GET /accounts/$H_WIRE request.  Must not be called by clients after
   1259  * the callback was invoked.
   1260  *
   1261  * @param igh request to cancel.
   1262  */
   1263 void
   1264 TALER_MERCHANT_account_get_cancel (
   1265   struct TALER_MERCHANT_AccountGetHandle *igh);
   1266 
   1267 
   1268 /**
   1269  * Handle for a GET /accounts operation.
   1270  */
   1271 struct TALER_MERCHANT_AccountsGetHandle;
   1272 
   1273 /**
   1274  * Individual account (minimal information
   1275  * returned via GET /accounts).
   1276  */
   1277 struct TALER_MERCHANT_AccountEntry
   1278 {
   1279   /**
   1280    * account payto URI.
   1281    */
   1282   struct TALER_FullPayto payto_uri;
   1283 
   1284   /**
   1285    * Hash of @e payto_uri and salt.
   1286    */
   1287   struct TALER_MerchantWireHashP h_wire;
   1288 
   1289 };
   1290 
   1291 
   1292 /**
   1293  * Response to a GET /accounts operation.
   1294  */
   1295 struct TALER_MERCHANT_AccountsGetResponse
   1296 {
   1297   /**
   1298    * HTTP response details
   1299    */
   1300   struct TALER_MERCHANT_HttpResponse hr;
   1301 
   1302   /**
   1303    * Details depending on status.
   1304    */
   1305   union
   1306   {
   1307     /**
   1308      * Details if status is #MHD_HTTP_OK.
   1309      */
   1310     struct
   1311     {
   1312       /**
   1313        * length of the @e accounts array
   1314        */
   1315       unsigned int accounts_length;
   1316 
   1317       /**
   1318        * array of accounts the requested instance offers
   1319        */
   1320       const struct TALER_MERCHANT_AccountEntry *accounts;
   1321     } ok;
   1322   } details;
   1323 };
   1324 
   1325 
   1326 /**
   1327  * Function called with the result of the GET /accounts operation.
   1328  *
   1329  * @param cls closure
   1330  * @param tgr response details
   1331  */
   1332 typedef void
   1333 (*TALER_MERCHANT_AccountsGetCallback)(
   1334   void *cls,
   1335   const struct TALER_MERCHANT_AccountsGetResponse *tgr);
   1336 
   1337 
   1338 /**
   1339  * Make a GET /accounts request.
   1340  *
   1341  * @param ctx the context
   1342  * @param backend_url HTTP base URL for the backend
   1343  * @param cb function to call with the backend information
   1344  * @param cb_cls closure for @a cb
   1345  * @return the request handle; NULL upon error
   1346  */
   1347 struct TALER_MERCHANT_AccountsGetHandle *
   1348 TALER_MERCHANT_accounts_get (
   1349   struct GNUNET_CURL_Context *ctx,
   1350   const char *backend_url,
   1351   TALER_MERCHANT_AccountsGetCallback cb,
   1352   void *cb_cls);
   1353 
   1354 
   1355 /**
   1356  * Cancel GET /accounts operation.
   1357  *
   1358  * @param tgh operation to cancel
   1359  */
   1360 void
   1361 TALER_MERCHANT_accounts_get_cancel (
   1362   struct TALER_MERCHANT_AccountsGetHandle *tgh);
   1363 
   1364 
   1365 /**
   1366  * Handle for a PATCH /account operation.
   1367  */
   1368 struct TALER_MERCHANT_AccountPatchHandle;
   1369 
   1370 
   1371 /**
   1372  * Function called with the result of the PATCH /account operation.
   1373  *
   1374  * @param cls closure
   1375  * @param hr HTTP response details
   1376  */
   1377 typedef void
   1378 (*TALER_MERCHANT_AccountPatchCallback)(
   1379   void *cls,
   1380   const struct TALER_MERCHANT_HttpResponse *hr);
   1381 
   1382 
   1383 /**
   1384  * Make a PATCH /accounts/$H_WIRE request to update account details. Cannot be used to change the payto URI or the salt.
   1385  *
   1386  * @param ctx the context
   1387  * @param backend_url HTTP base URL for the backend
   1388  * @param h_wire identifies the account to patch
   1389  * @param credit_facade_url credit facade for the account, can be NULL
   1390  * @param credit_facade_credentials credentials for credit facade, can be NULL
   1391  * @param cb function to call with the backend's result
   1392  * @param cb_cls closure for @a cb
   1393  * @return the request handle; NULL upon error
   1394  */
   1395 struct TALER_MERCHANT_AccountPatchHandle *
   1396 TALER_MERCHANT_account_patch (
   1397   struct GNUNET_CURL_Context *ctx,
   1398   const char *backend_url,
   1399   const struct TALER_MerchantWireHashP *h_wire,
   1400   const char *credit_facade_url,
   1401   const json_t *credit_facade_credentials,
   1402   TALER_MERCHANT_AccountPatchCallback cb,
   1403   void *cb_cls);
   1404 
   1405 
   1406 /**
   1407  * Cancel PATCH /accounts/$H_WIRE operation.
   1408  *
   1409  * @param[in] tph operation to cancel
   1410  */
   1411 void
   1412 TALER_MERCHANT_account_patch_cancel (
   1413   struct TALER_MERCHANT_AccountPatchHandle *tph);
   1414 
   1415 
   1416 /**
   1417  * Handle for a DELETE /instances/$ID/account/$H_WIRE operation.
   1418  */
   1419 struct TALER_MERCHANT_AccountDeleteHandle;
   1420 
   1421 
   1422 /**
   1423  * Response for a DELETE /instances/$ID/account operation.
   1424  */
   1425 struct TALER_MERCHANT_AccountDeleteResponse
   1426 {
   1427   /**
   1428    * HTTP response data
   1429    */
   1430   struct TALER_MERCHANT_HttpResponse hr;
   1431 };
   1432 
   1433 
   1434 /**
   1435  * Function called with the result of the DELETE /instances/$ID/account/$H_WIRE operation.
   1436  *
   1437  * @param cls closure
   1438  * @param par response data
   1439  */
   1440 typedef void
   1441 (*TALER_MERCHANT_AccountDeleteCallback)(
   1442   void *cls,
   1443   const struct TALER_MERCHANT_AccountDeleteResponse *par);
   1444 
   1445 
   1446 /**
   1447  * Remove bank account from an instance in the backend.
   1448  *
   1449  * @param ctx the context
   1450  * @param backend_url HTTP base URL for the backend
   1451  * @param h_wire wire hash of the bank accounts to delete
   1452  * @param cb function to call with the response
   1453  * @param cb_cls closure for @a config_cb
   1454  * @return the instances handle; NULL upon error
   1455  */
   1456 struct TALER_MERCHANT_AccountDeleteHandle *
   1457 TALER_MERCHANT_account_delete (
   1458   struct GNUNET_CURL_Context *ctx,
   1459   const char *backend_url,
   1460   const struct TALER_MerchantWireHashP *h_wire,
   1461   TALER_MERCHANT_AccountDeleteCallback cb,
   1462   void *cb_cls);
   1463 
   1464 
   1465 /**
   1466  * Cancel /account request.  Must not be called by clients after
   1467  * the callback was invoked.
   1468  *
   1469  * @param pah request to cancel.
   1470  */
   1471 void
   1472 TALER_MERCHANT_account_delete_cancel (
   1473   struct TALER_MERCHANT_AccountDeleteHandle *pah);
   1474 
   1475 
   1476 /* ********************* /products *********************** */
   1477 
   1478 
   1479 /**
   1480  * Handle for a GET /products operation.
   1481  */
   1482 struct TALER_MERCHANT_ProductsGetHandle;
   1483 
   1484 /**
   1485  * Individual product from the inventory (minimal information
   1486  * returned via GET /products).
   1487  */
   1488 struct TALER_MERCHANT_InventoryEntry
   1489 {
   1490   /**
   1491    * Product identifier.
   1492    */
   1493   const char *product_id;
   1494 
   1495   /**
   1496    * Serial ID of the product.
   1497    */
   1498   uint64_t product_serial;
   1499 };
   1500 
   1501 
   1502 /**
   1503  * Response to a GET /products request.
   1504  */
   1505 struct TALER_MERCHANT_GetProductsResponse
   1506 {
   1507   /**
   1508    * HTTP response details
   1509    */
   1510   struct TALER_MERCHANT_HttpResponse hr;
   1511 
   1512   union
   1513   {
   1514     struct
   1515     {
   1516 
   1517       /**
   1518        * length of the @a products array
   1519        */
   1520       unsigned int products_length;
   1521 
   1522       /**
   1523        * array of products the requested instance offers
   1524        */
   1525       const struct TALER_MERCHANT_InventoryEntry *products;
   1526     } ok;
   1527 
   1528   } details;
   1529 };
   1530 
   1531 
   1532 /**
   1533  * Function called with the result of the GET /products operation.
   1534  *
   1535  * @param cls closure
   1536  * @param gpr response details
   1537  */
   1538 typedef void
   1539 (*TALER_MERCHANT_ProductsGetCallback)(
   1540   void *cls,
   1541   const struct TALER_MERCHANT_GetProductsResponse *gpr);
   1542 
   1543 
   1544 /**
   1545  * Make a GET /products request.
   1546  *
   1547  * @param ctx the context
   1548  * @param backend_url HTTP base URL for the backend
   1549  * @param cb function to call with the backend's inventory information
   1550  * @param cb_cls closure for @a cb
   1551  * @return the request handle; NULL upon error
   1552  */
   1553 struct TALER_MERCHANT_ProductsGetHandle *
   1554 TALER_MERCHANT_products_get (
   1555   struct GNUNET_CURL_Context *ctx,
   1556   const char *backend_url,
   1557   TALER_MERCHANT_ProductsGetCallback cb,
   1558   void *cb_cls);
   1559 
   1560 
   1561 /**
   1562  * Cancel GET /products operation.
   1563  *
   1564  * @param pgh operation to cancel
   1565  */
   1566 void
   1567 TALER_MERCHANT_products_get_cancel (
   1568   struct TALER_MERCHANT_ProductsGetHandle *pgh);
   1569 
   1570 
   1571 /**
   1572  * Handle for a GET /product/$ID operation. Gets details
   1573  * about a single product. Do not confused with a
   1574  * `struct TALER_MERCHANT_ProductsGetHandle`, which
   1575  * obtains a list of all products.
   1576  */
   1577 struct TALER_MERCHANT_ProductGetHandle;
   1578 
   1579 
   1580 /**
   1581  * Response to GET /product/$ID operation.
   1582  */
   1583 struct TALER_MERCHANT_ProductGetResponse
   1584 {
   1585   /**
   1586    * HTTP response details
   1587    */
   1588   struct TALER_MERCHANT_HttpResponse hr;
   1589 
   1590   /**
   1591    * Details depending on HTTP status.
   1592    */
   1593   union
   1594   {
   1595     /**
   1596      * Details for #MHD_HTTP_OK.
   1597      */
   1598     struct
   1599     {
   1600 
   1601       /**
   1602        * description of the product
   1603        */
   1604       const char *description;
   1605 
   1606       /**
   1607        * Map from IETF BCP 47 language tags to localized descriptions
   1608        */
   1609       const json_t *description_i18n;
   1610 
   1611       /**
   1612        * unit in which the product is measured (liters, kilograms, packages, etc.)
   1613        */
   1614       const char *unit;
   1615 
   1616       /**
   1617        * the price for one @a unit of the product, zero is used to imply that
   1618        * this product is not sold separately or that the price is
   1619        * not fixed and must be supplied by the front-end.  If
   1620        * non-zero, price must include applicable taxes.
   1621        */
   1622       struct TALER_Amount price;
   1623 
   1624       /**
   1625        * Optional list of price tiers as provided by the backend.
   1626        */
   1627       const struct TALER_Amount *unit_price;
   1628 
   1629       /**
   1630        * Size of unit_price array
   1631        */
   1632       size_t unit_price_len;
   1633 
   1634       /**
   1635        * base64-encoded product image, can be NULL if none is set.
   1636        */
   1637       const char *image;
   1638 
   1639       /**
   1640        * list of taxes paid by the merchant, can be NULL if no taxes were specified.
   1641        */
   1642       const json_t *taxes;
   1643 
   1644       /**
   1645        * total_stock in @e units, -1 to indicate "infinite" (i.e. electronic
   1646        * books), does NOT indicate remaining stocks, to get remaining stocks,
   1647        * subtract @e total_sold and @e total_lost. Note that this still does
   1648        * not then say how many of the remaining inventory are locked.
   1649        */
   1650       int64_t total_stock;
   1651 
   1652       /**
   1653        * Set to true if fractional quantities are allowed for this product.
   1654        */
   1655       bool unit_allow_fraction;
   1656 
   1657       /**
   1658        * Suggested fractional precision for fractional quantities.
   1659        */
   1660       uint32_t unit_precision_level;
   1661 
   1662       /**
   1663        * Stock level encoded as a decimal string. Preferred source of truth for fractional stock.
   1664        */
   1665       const char *unit_total_stock;
   1666 
   1667       /**
   1668        * in @e units, total number of @e unit of product sold
   1669        */
   1670       uint64_t total_sold;
   1671 
   1672       /**
   1673        * in @e units, total number of @e unit of product lost from inventory
   1674        */
   1675       uint64_t total_lost;
   1676 
   1677       /**
   1678        * where the product is in stock, can be NULL if no location was given.
   1679        */
   1680       const json_t *location;
   1681 
   1682       /**
   1683        * when the next restocking is expected to happen, 0 for unknown,
   1684        * #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
   1685        */
   1686       struct GNUNET_TIME_Timestamp next_restock;
   1687 
   1688       /**
   1689        * name of the product
   1690        */
   1691       const char *product_name;
   1692     } ok;
   1693 
   1694   } details;
   1695 
   1696 };
   1697 
   1698 
   1699 /**
   1700  * Function called with the result of the GET /products operation.
   1701  *
   1702  * @param cls closure
   1703  * @param pgr response details
   1704  */
   1705 typedef void
   1706 (*TALER_MERCHANT_ProductGetCallback)(
   1707   void *cls,
   1708   const struct TALER_MERCHANT_ProductGetResponse *pgr);
   1709 
   1710 
   1711 /**
   1712  * Make a GET /product/$ID request to get details about an
   1713  * individual product.
   1714  *
   1715  * @param ctx the context
   1716  * @param backend_url HTTP base URL for the backend
   1717  * @param product_id identifier of the product to inquire about
   1718  * @param cb function to call with the backend's product information
   1719  * @param cb_cls closure for @a cb
   1720  * @return the request handle; NULL upon error
   1721  */
   1722 struct TALER_MERCHANT_ProductGetHandle *
   1723 TALER_MERCHANT_product_get (
   1724   struct GNUNET_CURL_Context *ctx,
   1725   const char *backend_url,
   1726   const char *product_id,
   1727   TALER_MERCHANT_ProductGetCallback cb,
   1728   void *cb_cls);
   1729 
   1730 
   1731 /**
   1732  * Cancel GET /products/$ID operation.
   1733  *
   1734  * @param pgh operation to cancel
   1735  */
   1736 void
   1737 TALER_MERCHANT_product_get_cancel (
   1738   struct TALER_MERCHANT_ProductGetHandle *pgh);
   1739 
   1740 
   1741 /* ********************* /products/$HASH/image *********************** */
   1742 
   1743 
   1744 /**
   1745  * Handle for a GET /products/$HASH/image operation.
   1746  */
   1747 struct TALER_MERCHANT_ProductImageGetHandle;
   1748 
   1749 
   1750 /**
   1751  * Response to GET /products/$HASH/image operation.
   1752  */
   1753 struct TALER_MERCHANT_ProductImageGetResponse
   1754 {
   1755   /**
   1756    * HTTP response details
   1757    */
   1758   struct TALER_MERCHANT_HttpResponse hr;
   1759 
   1760   union
   1761   {
   1762     /**
   1763      * Details for #MHD_HTTP_OK.
   1764      */
   1765     struct
   1766     {
   1767       /**
   1768        * Base64-encoded data URL containing the product image.
   1769        */
   1770       const char *image;
   1771     } ok;
   1772   } details;
   1773 };
   1774 
   1775 
   1776 /**
   1777  * Function called with the result of the GET /products/$HASH/image operation.
   1778  *
   1779  * @param cls closure
   1780  * @param pir response details
   1781  */
   1782 typedef void
   1783 (*TALER_MERCHANT_ProductImageGetCallback)(
   1784   void *cls,
   1785   const struct TALER_MERCHANT_ProductImageGetResponse *pir);
   1786 
   1787 
   1788 /**
   1789  * Make a GET /products/$HASH/image request.
   1790  *
   1791  * @param ctx the context
   1792  * @param backend_url HTTP base URL for the backend
   1793  * @param image_hash the image hash to fetch
   1794  * @param cb function to call with the backend's response
   1795  * @param cb_cls closure for @a cb
   1796  * @return the request handle; NULL upon error
   1797  */
   1798 struct TALER_MERCHANT_ProductImageGetHandle *
   1799 TALER_MERCHANT_product_image_get (
   1800   struct GNUNET_CURL_Context *ctx,
   1801   const char *backend_url,
   1802   const char *image_hash,
   1803   TALER_MERCHANT_ProductImageGetCallback cb,
   1804   void *cb_cls);
   1805 
   1806 
   1807 /**
   1808  * Cancel GET /products/$HASH/image operation.
   1809  *
   1810  * @param pigh operation to cancel
   1811  */
   1812 void
   1813 TALER_MERCHANT_product_image_get_cancel (
   1814   struct TALER_MERCHANT_ProductImageGetHandle *pigh);
   1815 
   1816 
   1817 /**
   1818  * Handle for a POST /products operation.
   1819  */
   1820 struct TALER_MERCHANT_ProductsPostHandle;
   1821 
   1822 
   1823 /**
   1824  * Function called with the result of the POST /products operation.
   1825  *
   1826  * @param cls closure
   1827  * @param hr HTTP response details
   1828  */
   1829 typedef void
   1830 (*TALER_MERCHANT_ProductsPostCallback)(
   1831   void *cls,
   1832   const struct TALER_MERCHANT_HttpResponse *hr);
   1833 
   1834 
   1835 /**
   1836  * Make a POST /products request to add a product to the
   1837  * inventory.
   1838  *
   1839  * @param ctx the context
   1840  * @param backend_url HTTP base URL for the backend
   1841  * @param product_id identifier to use for the product
   1842  * @param description description of the product
   1843  * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
   1844  * @param unit unit in which the product is measured (liters, kilograms, packages, etc.)
   1845  * @param price the price for one @a unit of the product, zero is used to imply that
   1846  *              this product is not sold separately or that the price is not fixed and
   1847  *              must be supplied by the front-end.  If non-zero, price must include
   1848  *              applicable taxes.
   1849  * @param image base64-encoded product image
   1850  * @param taxes list of taxes paid by the merchant
   1851  * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books)
   1852  * @param address where the product is in stock
   1853  * @param next_restock when the next restocking is expected to happen, 0 for unknown,
   1854  *                     #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
   1855  * @param cb function to call with the backend's result
   1856  * @param cb_cls closure for @a cb
   1857  * @return the request handle; NULL upon error
   1858  */
   1859 struct TALER_MERCHANT_ProductsPostHandle *
   1860 TALER_MERCHANT_products_post (
   1861   struct GNUNET_CURL_Context *ctx,
   1862   const char *backend_url,
   1863   const char *product_id,
   1864   const char *description,
   1865   const json_t *description_i18n,
   1866   const char *unit,
   1867   const struct TALER_Amount *price,
   1868   const char *image,
   1869   const json_t *taxes,
   1870   int64_t total_stock,
   1871   const json_t *address,
   1872   struct GNUNET_TIME_Timestamp next_restock,
   1873   TALER_MERCHANT_ProductsPostCallback cb,
   1874   void *cb_cls);
   1875 
   1876 
   1877 /**
   1878  * Make a POST /products request to add a product to the
   1879  * inventory.
   1880  *
   1881  * @param ctx the context
   1882  * @param backend_url HTTP base URL for the backend
   1883  * @param product_id identifier to use for the product
   1884  * @param description description of the product
   1885  * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
   1886  * @param unit unit in which the product is measured (liters, kilograms, packages, etc.)
   1887  * @param price the price for one @a unit of the product, zero is used to imply that
   1888  *              this product is not sold separately or that the price is not fixed and
   1889  *              must be supplied by the front-end.  If non-zero, price must include
   1890  *              applicable taxes.
   1891  * @param image base64-encoded product image
   1892  * @param taxes list of taxes paid by the merchant
   1893  * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books)
   1894  * @param address where the product is in stock
   1895  * @param next_restock when the next restocking is expected to happen, 0 for unknown,
   1896  *                     #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
   1897  * @param minimum_age minimum age the buyer must have
   1898  * @param cb function to call with the backend's result
   1899  * @param cb_cls closure for @a cb
   1900  * @return the request handle; NULL upon error
   1901  */
   1902 struct TALER_MERCHANT_ProductsPostHandle *
   1903 TALER_MERCHANT_products_post2 (
   1904   struct GNUNET_CURL_Context *ctx,
   1905   const char *backend_url,
   1906   const char *product_id,
   1907   const char *description,
   1908   const json_t *description_i18n,
   1909   const char *unit,
   1910   const struct TALER_Amount *price,
   1911   const char *image,
   1912   const json_t *taxes,
   1913   int64_t total_stock,
   1914   const json_t *address,
   1915   struct GNUNET_TIME_Timestamp next_restock,
   1916   uint32_t minimum_age,
   1917   TALER_MERCHANT_ProductsPostCallback cb,
   1918   void *cb_cls);
   1919 
   1920 
   1921 /**
   1922  * Make a POST /products request to add a product to the
   1923  * inventory.
   1924  *
   1925  * @param ctx the context
   1926  * @param backend_url HTTP base URL for the backend
   1927  * @param product_id identifier to use for the product
   1928  * @param description description of the product
   1929  * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
   1930  * @param unit unit in which the product is measured (liters, kilograms, packages, etc.)
   1931  * @param price the price for one @a unit of the product, zero is used to imply that
   1932  *              this product is not sold separately or that the price is not fixed and
   1933  *              must be supplied by the front-end.  If non-zero, price must include
   1934  *              applicable taxes.
   1935  * @param image base64-encoded product image
   1936  * @param taxes list of taxes paid by the merchant
   1937  * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books)
   1938  * @param address where the product is in stock
   1939  * @param next_restock when the next restocking is expected to happen, 0 for unknown,
   1940  *                     #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
   1941  * @param minimum_age minimum age the buyer must have
   1942  * @param num_cats length of the @a cats array
   1943  * @param cats array of categories the product is in
   1944  * @param cb function to call with the backend's result
   1945  * @param cb_cls closure for @a cb
   1946  * @return the request handle; NULL upon error
   1947  */
   1948 struct TALER_MERCHANT_ProductsPostHandle *
   1949 TALER_MERCHANT_products_post3 (
   1950   struct GNUNET_CURL_Context *ctx,
   1951   const char *backend_url,
   1952   const char *product_id,
   1953   const char *description,
   1954   const json_t *description_i18n,
   1955   const char *unit,
   1956   const struct TALER_Amount *price,
   1957   const char *image,
   1958   const json_t *taxes,
   1959   int64_t total_stock,
   1960   const json_t *address,
   1961   struct GNUNET_TIME_Timestamp next_restock,
   1962   uint32_t minimum_age,
   1963   unsigned int num_cats,
   1964   const uint64_t *cats,
   1965   TALER_MERCHANT_ProductsPostCallback cb,
   1966   void *cb_cls);
   1967 
   1968 
   1969 /**
   1970  * Make a POST /products request to add a product to the
   1971  * inventory.
   1972  *
   1973  * @param ctx the context
   1974  * @param backend_url HTTP base URL for the backend
   1975  * @param product_id identifier to use for the product
   1976  * @param description description of the product
   1977  * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
   1978  * @param unit unit in which the product is measured (liters, kilograms, packages, etc.)
   1979  * @param unit_prices array of price tiers (at least one entry)
   1980  * @param unit_price_len length of @a unit_prices
   1981  * @param image base64-encoded product image
   1982  * @param taxes list of taxes paid by the merchant
   1983  * @param total_stock integer quantity to use when @a unit_allow_fraction is false;
   1984  *        set to -1 for unlimited stock
   1985  * @param total_stock_frac fractional component (0-#MERCHANT_UNIT_FRAC_BASE) to use when
   1986  *        @a unit_allow_fraction is true; ignored otherwise. Clients should use 0
   1987  *        when there is no fractional part or when @a total_stock is -1 (unlimited).
   1988  * @param unit_allow_fraction whether fractional quantity purchases are allowed
   1989  * @param unit_precision_level optional override for the fractional precision; pass NULL to use the default derived from @a unit
   1990  * @param address where the product is in stock
   1991  * @param next_restock when the next restocking is expected to happen, 0 for unknown
   1992  * @param minimum_age minimum age the buyer must have
   1993  * @param num_cats length of the @a cats array
   1994  * @param cats array of categories the product is in
   1995  * @param cb function to call with the backend's result
   1996  * @param cb_cls closure for @a cb
   1997  * @return the request handle; NULL upon error
   1998  */
   1999 struct TALER_MERCHANT_ProductsPostHandle *
   2000 TALER_MERCHANT_products_post4 (
   2001   struct GNUNET_CURL_Context *ctx,
   2002   const char *backend_url,
   2003   const char *product_id,
   2004   const char *description,
   2005   const json_t *description_i18n,
   2006   const char *unit,
   2007   const struct TALER_Amount *unit_prices,
   2008   size_t unit_price_len,
   2009   const char *image,
   2010   const json_t *taxes,
   2011   int64_t total_stock,
   2012   uint32_t total_stock_frac,
   2013   bool unit_allow_fraction,
   2014   const uint32_t *unit_precision_level,
   2015   const json_t *address,
   2016   struct GNUNET_TIME_Timestamp next_restock,
   2017   uint32_t minimum_age,
   2018   unsigned int num_cats,
   2019   const uint64_t *cats,
   2020   TALER_MERCHANT_ProductsPostCallback cb,
   2021   void *cb_cls);
   2022 
   2023 
   2024 /**
   2025  * Cancel POST /products operation.
   2026  *
   2027  * @param pph operation to cancel
   2028  */
   2029 void
   2030 TALER_MERCHANT_products_post_cancel (
   2031   struct TALER_MERCHANT_ProductsPostHandle *pph);
   2032 
   2033 
   2034 /**
   2035  * Handle for a PATCH /products operation.
   2036  */
   2037 struct TALER_MERCHANT_ProductPatchHandle;
   2038 
   2039 
   2040 /**
   2041  * Function called with the result of the PATCH /products operation.
   2042  *
   2043  * @param cls closure
   2044  * @param hr HTTP response details
   2045  */
   2046 typedef void
   2047 (*TALER_MERCHANT_ProductPatchCallback)(
   2048   void *cls,
   2049   const struct TALER_MERCHANT_HttpResponse *hr);
   2050 
   2051 
   2052 /**
   2053  * Make a PATCH /products request to update product details in the
   2054  * inventory.
   2055  *
   2056  * @param ctx the context
   2057  * @param backend_url HTTP base URL for the backend
   2058  * @param product_id identifier to use for the product; the product must exist,
   2059  *                    or the transaction will fail with a #MHD_HTTP_NOT_FOUND
   2060  *                    HTTP status code
   2061  * @param description description of the product
   2062  * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
   2063  * @param unit unit in which the product is measured (liters, kilograms, packages, etc.)
   2064  * @param price the price for one @a unit of the product, zero is used to imply that
   2065  *              this product is not sold separately or that the price is not fixed and
   2066  *              must be supplied by the front-end.  If non-zero, price must include
   2067  *              applicable taxes.
   2068  * @param image base64-encoded product image
   2069  * @param taxes list of taxes paid by the merchant
   2070  * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books),
   2071  *               must be larger than previous values
   2072  * @param total_lost in @a units, must be larger than previous values, and may
   2073  *               not exceed total_stock minus total_sold; if it does, the transaction
   2074  *               will fail with a #MHD_HTTP_CONFLICT HTTP status code
   2075  * @param address where the product is in stock
   2076  * @param next_restock when the next restocking is expected to happen
   2077  * @param cb function to call with the backend's result
   2078  * @param cb_cls closure for @a cb
   2079  * @return the request handle; NULL upon error
   2080  */
   2081 struct TALER_MERCHANT_ProductPatchHandle *
   2082 TALER_MERCHANT_product_patch (
   2083   struct GNUNET_CURL_Context *ctx,
   2084   const char *backend_url,
   2085   const char *product_id,
   2086   const char *description,
   2087   const json_t *description_i18n,
   2088   const char *unit,
   2089   const struct TALER_Amount *price,
   2090   const char *image,
   2091   const json_t *taxes,
   2092   int64_t total_stock,
   2093   uint64_t total_lost,
   2094   const json_t *address,
   2095   struct GNUNET_TIME_Timestamp next_restock,
   2096   TALER_MERCHANT_ProductPatchCallback cb,
   2097   void *cb_cls);
   2098 
   2099 
   2100 /**
   2101  * Make a PATCH /products request to update a product using the
   2102  * extended inventory fields.
   2103  *
   2104  * @param ctx the context
   2105  * @param backend_url HTTP base URL for the backend
   2106  * @param product_id identifier of the product to modify
   2107  * @param description description of the product
   2108  * @param description_i18n localized descriptions
   2109  * @param unit sales unit
   2110  * @param unit_prices array of price tiers (at least one entry)
   2111  * @param unit_price_len number of entries in @a unit_prices
   2112  * @param image base64-encoded image
   2113  * @param taxes list of taxes
   2114  * @param total_stock integer quantity when @a unit_allow_fraction is false
   2115  * @param total_stock_frac fractional quantity component (0-#MERCHANT_UNIT_FRAC_BASE) when
   2116  *        @a unit_allow_fraction is true; ignored otherwise
   2117  * @param unit_allow_fraction whether fractional quantity purchases are allowed
   2118  * @param unit_precision_level optional override for the fractional precision; pass NULL to use the default derived from @a unit
   2119  * @param total_lost stock lost so far
   2120  * @param address inventory address
   2121  * @param next_restock expected restock date
   2122  * @param cb function to call with the backend's result
   2123  * @param cb_cls closure for @a cb
   2124  * @return the request handle; NULL upon error
   2125  */
   2126 struct TALER_MERCHANT_ProductPatchHandle *
   2127 TALER_MERCHANT_product_patch2 (
   2128   struct GNUNET_CURL_Context *ctx,
   2129   const char *backend_url,
   2130   const char *product_id,
   2131   const char *description,
   2132   const json_t *description_i18n,
   2133   const char *unit,
   2134   const struct TALER_Amount *unit_prices,
   2135   size_t unit_price_len,
   2136   const char *image,
   2137   const json_t *taxes,
   2138   int64_t total_stock,
   2139   uint32_t total_stock_frac,
   2140   bool unit_allow_fraction,
   2141   const uint32_t *unit_precision_level,
   2142   uint64_t total_lost,
   2143   const json_t *address,
   2144   struct GNUNET_TIME_Timestamp next_restock,
   2145   TALER_MERCHANT_ProductPatchCallback cb,
   2146   void *cb_cls);
   2147 
   2148 
   2149 /**
   2150  * Cancel PATCH /products operation.
   2151  *
   2152  * @param pph operation to cancel
   2153  */
   2154 void
   2155 TALER_MERCHANT_product_patch_cancel (
   2156   struct TALER_MERCHANT_ProductPatchHandle *pph);
   2157 
   2158 
   2159 /**
   2160  * Handle for a POST /products/$ID/lock operation.
   2161  */
   2162 struct TALER_MERCHANT_ProductLockHandle;
   2163 
   2164 
   2165 /**
   2166  * Function called with the result of the POST /product/$ID/lock operation.
   2167  *
   2168  * @param cls closure
   2169  * @param hr HTTP response details
   2170  */
   2171 typedef void
   2172 (*TALER_MERCHANT_ProductLockCallback)(
   2173   void *cls,
   2174   const struct TALER_MERCHANT_HttpResponse *hr);
   2175 
   2176 
   2177 /**
   2178  * Make a POST /products/$ID/lock request to reserve a certain
   2179  * amount of product in inventory to a reservation UUID.
   2180  *
   2181  * @param ctx the context
   2182  * @param backend_url HTTP base URL for the backend
   2183  * @param product_id identifier of the product
   2184  * @param uuid UUID that identifies the client holding the lock
   2185  * @param duration how long should the lock be held
   2186  * @param quantity how much product should be locked (integer part)
   2187  * @param quantity_frac fractional component to lock when
   2188  *        @a use_fractional_quantity is true; value is expressed in units of
   2189  *        1/1000000 of the base unit
   2190  * @param use_fractional_quantity set to true when @a quantity_frac is used
   2191  * @param cb function to call with the backend's lock status
   2192  * @param cb_cls closure for @a cb
   2193  * @return the request handle; NULL upon error
   2194  */
   2195 struct TALER_MERCHANT_ProductLockHandle *
   2196 TALER_MERCHANT_product_lock2 (
   2197   struct GNUNET_CURL_Context *ctx,
   2198   const char *backend_url,
   2199   const char *product_id,
   2200   const char *uuid,
   2201   struct GNUNET_TIME_Relative duration,
   2202   uint64_t quantity,
   2203   uint32_t quantity_frac,
   2204   bool use_fractional_quantity,
   2205   TALER_MERCHANT_ProductLockCallback cb,
   2206   void *cb_cls);
   2207 
   2208 
   2209 /**
   2210  * Legacy helper that locks products using integer quantities only.
   2211  * Prefer using #TALER_MERCHANT_product_lock2 for fractional quantities.
   2212  */
   2213 struct TALER_MERCHANT_ProductLockHandle *
   2214 TALER_MERCHANT_product_lock (
   2215   struct GNUNET_CURL_Context *ctx,
   2216   const char *backend_url,
   2217   const char *product_id,
   2218   const char *uuid,
   2219   struct GNUNET_TIME_Relative duration,
   2220   uint32_t quantity,
   2221   TALER_MERCHANT_ProductLockCallback cb,
   2222   void *cb_cls);
   2223 
   2224 
   2225 /**
   2226  * Cancel POST /products/$ID/lock operation. Note that the
   2227  * lock may or may not be acquired despite the cancellation.
   2228  *
   2229  * @param plh operation to cancel
   2230  */
   2231 void
   2232 TALER_MERCHANT_product_lock_cancel (
   2233   struct TALER_MERCHANT_ProductLockHandle *plh);
   2234 
   2235 
   2236 /**
   2237  * Handle for a DELETE /products/$ID operation.
   2238  */
   2239 struct TALER_MERCHANT_ProductDeleteHandle;
   2240 
   2241 
   2242 /**
   2243  * Function called with the result of the DELETE /product/$ID operation.
   2244  *
   2245  * @param cls closure
   2246  * @param hr HTTP response details
   2247  */
   2248 typedef void
   2249 (*TALER_MERCHANT_ProductDeleteCallback)(
   2250   void *cls,
   2251   const struct TALER_MERCHANT_HttpResponse *hr);
   2252 
   2253 
   2254 /**
   2255  * Make a DELETE /products/$ID request to delete a product from our
   2256  * inventory.
   2257  *
   2258  * @param ctx the context
   2259  * @param backend_url HTTP base URL for the backend
   2260  * @param product_id identifier of the product
   2261  * @param cb function to call with the backend's deletion status
   2262  * @param cb_cls closure for @a cb
   2263  * @return the request handle; NULL upon error
   2264  */
   2265 struct TALER_MERCHANT_ProductDeleteHandle *
   2266 TALER_MERCHANT_product_delete (
   2267   struct GNUNET_CURL_Context *ctx,
   2268   const char *backend_url,
   2269   const char *product_id,
   2270   TALER_MERCHANT_ProductDeleteCallback cb,
   2271   void *cb_cls);
   2272 
   2273 
   2274 /**
   2275  * Cancel DELETE /products/$ID operation.
   2276  *
   2277  * @param pdh operation to cancel
   2278  */
   2279 void
   2280 TALER_MERCHANT_product_delete_cancel (
   2281   struct TALER_MERCHANT_ProductDeleteHandle *pdh);
   2282 
   2283 
   2284 /* ********************* /tokenfamilies ************************** */
   2285 
   2286 /**
   2287  * Handle for a GET /tokenfamilies/$SLUG operation.
   2288  */
   2289 struct TALER_MERCHANT_TokenFamilyGetHandle;
   2290 
   2291 
   2292 /**
   2293  * Response to GET /tokenfamilies/$SLUG operation.
   2294  */
   2295 struct TALER_MERCHANT_TokenFamilyGetResponse
   2296 {
   2297   /**
   2298    * HTTP response details
   2299    */
   2300   struct TALER_MERCHANT_HttpResponse hr;
   2301 
   2302   /**
   2303    * Details depending on HTTP status.
   2304    */
   2305   union
   2306   {
   2307     /**
   2308      * Details for #MHD_HTTP_OK.
   2309      */
   2310     struct
   2311     {
   2312 
   2313       /**
   2314        * Identifier for the token family consisting of unreserved characters
   2315        * according to RFC 3986.
   2316        */
   2317       const char *slug;
   2318 
   2319       /**
   2320        * Human-readable name for the token family.
   2321        */
   2322       const char *name;
   2323 
   2324       /**
   2325        * description of the token family
   2326        */
   2327       const char *description;
   2328 
   2329       /**
   2330        * Optional map from IETF BCP 47 language tags to localized descriptions.
   2331        */
   2332       const json_t *description_i18n;
   2333 
   2334       /**
   2335        * Additional data about the token family (such as expected_domains).
   2336        */
   2337       const json_t *extra_data;
   2338 
   2339       /**
   2340        * Start time of the token family's validity period.
   2341        */
   2342       struct GNUNET_TIME_Timestamp valid_after;
   2343 
   2344       /**
   2345        * End time of the token family's validity period.
   2346        */
   2347       struct GNUNET_TIME_Timestamp valid_before;
   2348 
   2349       /**
   2350        * Validity duration of an issued token.
   2351        */
   2352       struct GNUNET_TIME_Relative duration;
   2353 
   2354       /**
   2355        * Granularity of the validity periods of the token.
   2356        */
   2357       struct GNUNET_TIME_Relative validity_granularity;
   2358 
   2359       /**
   2360        * Offset subtracted from the rounded start time to determine
   2361        * the actual start time.
   2362        */
   2363       struct GNUNET_TIME_Relative start_offset;
   2364 
   2365       /**
   2366        * Kind of token family, "subscription" or "discount".
   2367        */
   2368       const char *kind;
   2369 
   2370       /**
   2371        * How many tokens have been issued for this family.
   2372        */
   2373       uint64_t issued;
   2374 
   2375       /**
   2376        * How many tokens have been used for this family.
   2377        */
   2378       uint64_t used;
   2379     } ok;
   2380 
   2381   } details;
   2382 
   2383 };
   2384 
   2385 /**
   2386  * Cancel GET /tokenfamilies/$SLUG operation.
   2387  *
   2388  * @param handle operation to cancel
   2389  */
   2390 void
   2391 TALER_MERCHANT_token_family_get_cancel (
   2392   struct TALER_MERCHANT_TokenFamilyGetHandle *handle);
   2393 
   2394 
   2395 /**
   2396  * Function called with the result of the GET /tokenfamilies/$SLUG operation.
   2397  *
   2398  * @param cls closure
   2399  * @param pgr response details
   2400  */
   2401 typedef void
   2402 (*TALER_MERCHANT_TokenFamilyGetCallback)(
   2403   void *cls,
   2404   const struct TALER_MERCHANT_TokenFamilyGetResponse *pgr);
   2405 
   2406 /**
   2407  * Handle for a POST /tokenfamilies operation.
   2408  */
   2409 struct TALER_MERCHANT_TokenFamiliesPostHandle;
   2410 
   2411 
   2412 /**
   2413  * Function called with the result of the POST /tokenfamilies operation.
   2414  *
   2415  * @param cls closure
   2416  * @param hr HTTP response details
   2417  */
   2418 typedef void
   2419 (*TALER_MERCHANT_TokenFamiliesPostCallback)(
   2420   void *cls,
   2421   const struct TALER_MERCHANT_HttpResponse *hr);
   2422 
   2423 
   2424 /**
   2425  * Make a POST /tokenfamilies request to add a token family to the
   2426  * merchant instance.
   2427  *
   2428  * @param ctx the context
   2429  * @param backend_url HTTP base URL for the backend
   2430  * @param slug short, url-safe identifier for the token family
   2431  * @param name human-readable name for the token family
   2432  * @param description description of the token family
   2433  * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
   2434  * @param extra_data additional meta-data about the token family
   2435  * @param valid_after when the token family becomes valid
   2436  * @param valid_before when the token family expires
   2437  * @param duration how long tokens issued by this token family are valid for
   2438  * @param validity_granularity rounding duration of token family
   2439  * @param start_offset time to subtract after rounding down to get
   2440  *        the actual start time for each round
   2441  * @param kind kind of token family, "subscription" or "discount"
   2442  * @param cb function to call with the backend's result
   2443  * @param cb_cls closure for @a cb
   2444  * @return the request handle; NULL upon error
   2445  */
   2446 struct TALER_MERCHANT_TokenFamiliesPostHandle *
   2447 TALER_MERCHANT_token_families_post (
   2448   struct GNUNET_CURL_Context *ctx,
   2449   const char *backend_url,
   2450   const char *slug,
   2451   const char *name,
   2452   const char *description,
   2453   const json_t *description_i18n,
   2454   const json_t *extra_data,
   2455   struct GNUNET_TIME_Timestamp valid_after,
   2456   struct GNUNET_TIME_Timestamp valid_before,
   2457   struct GNUNET_TIME_Relative duration,
   2458   struct GNUNET_TIME_Relative validity_granularity,
   2459   struct GNUNET_TIME_Relative start_offset,
   2460   const char *kind,
   2461   TALER_MERCHANT_TokenFamiliesPostCallback cb,
   2462   void *cb_cls);
   2463 
   2464 
   2465 /**
   2466  * Cancel POST /tokenfamilies operation.
   2467  *
   2468  * @param handle operation to cancel
   2469  */
   2470 void
   2471 TALER_MERCHANT_token_families_post_cancel (
   2472   struct TALER_MERCHANT_TokenFamiliesPostHandle *handle);
   2473 
   2474 
   2475 /* FIXME: token_families_patch API is missing... */
   2476 
   2477 
   2478 /* ********************* /orders ************************** */
   2479 
   2480 
   2481 /**
   2482  * Handle to a POST /private/orders operation
   2483  */
   2484 struct TALER_MERCHANT_PostOrdersHandle;
   2485 
   2486 
   2487 /**
   2488  * Possible details from a reply to POST /private/orders.
   2489  */
   2490 struct TALER_MERCHANT_PostOrdersReply
   2491 {
   2492 
   2493   /**
   2494    * HTTP response details. HTTP status code
   2495    * determines what parts of @e details are valid.
   2496    */
   2497   struct TALER_MERCHANT_HttpResponse hr;
   2498 
   2499   /**
   2500    * Details of the reply, depending on the HTTP
   2501    * status code.
   2502    */
   2503   union
   2504   {
   2505 
   2506     /**
   2507      * Details provided if the @e hr.http_status is
   2508      * #MHD_HTTP_OK and the order was created.
   2509      */
   2510     struct
   2511     {
   2512 
   2513       /**
   2514        * order id of the newly created order
   2515        */
   2516       const char *order_id;
   2517 
   2518       /**
   2519        * the claim token generated by the merchant,
   2520        * (NULL if it was NOT generated).
   2521        */
   2522       const struct TALER_ClaimTokenP *token;
   2523 
   2524       /**
   2525        * When will the order have to be paid?
   2526        * Note: only available since protocol v21,
   2527        * will be zero if server is older.
   2528        */
   2529       struct GNUNET_TIME_Timestamp pay_deadline;
   2530 
   2531     } ok;
   2532 
   2533     /**
   2534      * Details provided if the @e hr.http_status is
   2535      * #MHD_HTTP_GONE because a product was out of stock.
   2536      */
   2537     struct
   2538     {
   2539       /**
   2540        * ID of the product of the order that is out of
   2541        * stock.
   2542        */
   2543       const char *product_id;
   2544 
   2545       /**
   2546        * How many units were requested by the order.
   2547        */
   2548       uint64_t requested_quantity;
   2549 
   2550       /**
   2551        * Fractional component of the requested quantity in units of
   2552        * 1/#TALER_AMOUNT_FRAC_BASE. Absent or zero when the request did not
   2553        * include a fractional part.
   2554        */
   2555       uint32_t requested_quantity_frac;
   2556 
   2557       /**
   2558        * How many units are actually still in stock.
   2559        */
   2560       uint64_t available_quantity;
   2561 
   2562       /**
   2563        * Fractional component of the available quantity in units of
   2564        * 1/#TALER_AMOUNT_FRAC_BASE.
   2565        */
   2566       uint32_t available_quantity_frac;
   2567 
   2568       /**
   2569        * When does the backend expect the stock to be
   2570        * restocked? 0 for unknown.
   2571        */
   2572       struct GNUNET_TIME_Timestamp restock_expected;
   2573 
   2574     } gone;
   2575 
   2576   } details;
   2577 
   2578 };
   2579 
   2580 
   2581 /**
   2582  * Callbacks of this type are used to serve the result of submitting a
   2583  * POST /using-templates and POST /orders request to a merchant.
   2584  *
   2585  * @param cls closure
   2586  * @param por response details
   2587  */
   2588 typedef void
   2589 (*TALER_MERCHANT_PostOrdersCallback) (
   2590   void *cls,
   2591   const struct TALER_MERCHANT_PostOrdersReply *por);
   2592 
   2593 
   2594 /**
   2595  * POST to /orders at the backend to setup an order and obtain
   2596  * the order ID (which may have been set by the front-end).
   2597  *
   2598  * @param ctx execution context
   2599  * @param backend_url URL of the backend
   2600  * @param order basic information about this purchase, to be extended by the backend
   2601  * @param refund_delay how long can refunds happen for this order; 0 to use
   2602  *             absolute value from contract (or not allow refunds).
   2603  * @param cb the callback to call when a reply for this request is available
   2604  * @param cb_cls closure for @a cb
   2605  * @return a handle for this request, NULL on error
   2606  */
   2607 struct TALER_MERCHANT_PostOrdersHandle *
   2608 TALER_MERCHANT_orders_post (
   2609   struct GNUNET_CURL_Context *ctx,
   2610   const char *backend_url,
   2611   const json_t *order,
   2612   struct GNUNET_TIME_Relative refund_delay,
   2613   TALER_MERCHANT_PostOrdersCallback cb,
   2614   void *cb_cls);
   2615 
   2616 /**
   2617  * Information needed per product for constructing orders from
   2618  * the inventory.
   2619  */
   2620 struct TALER_MERCHANT_InventoryProduct
   2621 {
   2622 
   2623   /**
   2624    * Identifier of the product.
   2625    */
   2626   char *product_id;
   2627 
   2628   /**
   2629    * How many units of this product should be ordered.
   2630    */
   2631   uint64_t quantity;
   2632 
   2633   /**
   2634    * Fractional component of the quantity in units of 1/1000000 of the
   2635    * base value.
   2636    */
   2637   uint32_t quantity_frac;
   2638 
   2639   /**
   2640    * Set to true if this product uses fractional quantity fields.
   2641    */
   2642   bool use_fractional_quantity;
   2643 };
   2644 
   2645 
   2646 /**
   2647  * POST to /orders at the backend to setup an order and obtain
   2648  * the order ID (which may have been set by the front-end).
   2649  *
   2650  * @param ctx execution context
   2651  * @param backend_url URL of the backend
   2652  * @param order basic information about this purchase, to be extended by the backend
   2653  * @param refund_delay how long can refunds happen for this order; 0 to use
   2654  *             absolute value from contract (or not allow refunds).
   2655  * @param payment_target desired payment target identifier (to select merchant bank details)
   2656  * @param inventory_products_length length of the @a inventory_products array
   2657  * @param inventory_products products to add to the order from the inventory
   2658  * @param uuids_length length of the @a uuids array
   2659  * @param uuids array of UUIDs with locks on @a inventory_products
   2660  * @param create_token whether to create a claim token
   2661  * @param cb the callback to call when a reply for this request is available
   2662  * @param cb_cls closure for @a cb
   2663  * @return a handle for this request, NULL on error
   2664  */
   2665 struct TALER_MERCHANT_PostOrdersHandle *
   2666 TALER_MERCHANT_orders_post2 (
   2667   struct GNUNET_CURL_Context *ctx,
   2668   const char *backend_url,
   2669   const json_t *order,
   2670   struct GNUNET_TIME_Relative refund_delay,
   2671   const char *payment_target,
   2672   unsigned int inventory_products_length,
   2673   const struct TALER_MERCHANT_InventoryProduct inventory_products[],
   2674   unsigned int uuids_length,
   2675   const char *uuids[static uuids_length],
   2676   bool create_token,
   2677   TALER_MERCHANT_PostOrdersCallback cb,
   2678   void *cb_cls);
   2679 
   2680 
   2681 /**
   2682  * POST to /orders at the backend to setup an order and obtain
   2683  * the order ID (which may have been set by the front-end).
   2684  *
   2685  * @param ctx execution context
   2686  * @param backend_url URL of the backend
   2687  * @param order basic information about this purchase, to be extended by the backend
   2688  * @param session_id session ID to set for the order
   2689  * @param refund_delay how long can refunds happen for this order; 0 to use
   2690  *             absolute value from contract (or not allow refunds).
   2691  * @param payment_target desired payment target identifier (to select merchant bank details)
   2692  * @param inventory_products_length length of the @a inventory_products array
   2693  * @param inventory_products products to add to the order from the inventory
   2694  * @param uuids_length length of the @a uuids array
   2695  * @param uuids array of UUIDs with locks on @a inventory_products
   2696  * @param create_token whether to create a claim token
   2697  * @param cb the callback to call when a reply for this request is available
   2698  * @param cb_cls closure for @a cb
   2699  * @return a handle for this request, NULL on error
   2700  */
   2701 struct TALER_MERCHANT_PostOrdersHandle *
   2702 TALER_MERCHANT_orders_post3 (
   2703   struct GNUNET_CURL_Context *ctx,
   2704   const char *backend_url,
   2705   const json_t *order,
   2706   const char *session_id,
   2707   struct GNUNET_TIME_Relative refund_delay,
   2708   const char *payment_target,
   2709   unsigned int inventory_products_length,
   2710   const struct TALER_MERCHANT_InventoryProduct inventory_products[],
   2711   unsigned int uuids_length,
   2712   const char *uuids[static uuids_length],
   2713   bool create_token,
   2714   TALER_MERCHANT_PostOrdersCallback cb,
   2715   void *cb_cls);
   2716 
   2717 
   2718 /**
   2719  * Cancel a POST /orders request.  This function cannot be used
   2720  * on a request handle if a response is already served for it.
   2721  *
   2722  * @param[in] po the proposal operation request handle
   2723  */
   2724 void
   2725 TALER_MERCHANT_orders_post_cancel (
   2726   struct TALER_MERCHANT_PostOrdersHandle *po);
   2727 
   2728 
   2729 /**
   2730  * Handle for a GET /orders operation.
   2731  */
   2732 struct TALER_MERCHANT_OrdersGetHandle;
   2733 
   2734 /**
   2735  * Individual order (minimal information returned via GET /orders).
   2736  */
   2737 struct TALER_MERCHANT_OrderEntry
   2738 {
   2739   /**
   2740    * Order identifier.
   2741    */
   2742   const char *order_id;
   2743 
   2744   /**
   2745    * Time when the order was created. Useful for filtering by
   2746    * 'date' (in #TALER_MERCHANT_orders_get2()).
   2747    */
   2748   struct GNUNET_TIME_Timestamp timestamp;
   2749 
   2750   /**
   2751    * Serial ID of the order. Useful for filtering by 'start_row'
   2752    * (in #TALER_MERCHANT_orders_get2()).
   2753    */
   2754   uint64_t order_serial;
   2755 
   2756   /**
   2757    * The amount of the order.
   2758    */
   2759   struct TALER_Amount amount;
   2760 
   2761   /**
   2762    * The summary of the order.
   2763    */
   2764   const char *summary;
   2765 
   2766   /**
   2767    * Whether it is possible to refund a part of the order still.
   2768    */
   2769   bool refundable;
   2770 
   2771   /**
   2772    * Whether the order has been paid.
   2773    */
   2774   bool paid;
   2775 
   2776   /**
   2777    * Total amount of refunds granted (but not necessarily
   2778    * accepted by the wallet).  Only set if @e paid, otherwise
   2779    * set to an invalid amount!
   2780    */
   2781   struct TALER_Amount refund_amount;
   2782 
   2783   /**
   2784    * Total amount of refunds pending (wallet did not pick them up).
   2785    * Only set if @e paid, otherwise set to an invalid amount!
   2786    */
   2787   struct TALER_Amount pending_refund_amount;
   2788 
   2789 };
   2790 
   2791 
   2792 /**
   2793  * Response for a GET /private/orders request.
   2794  */
   2795 struct TALER_MERCHANT_OrdersGetResponse
   2796 {
   2797   /**
   2798    * HTTP response details.
   2799    */
   2800   struct TALER_MERCHANT_HttpResponse hr;
   2801 
   2802   /**
   2803    * Details depending on HTTP status.
   2804    */
   2805   union
   2806   {
   2807     /**
   2808      * Details for #MHD_HTTP_OK.
   2809      */
   2810     struct
   2811     {
   2812 
   2813       /**
   2814        * length of the @e orders array
   2815        */
   2816       unsigned int orders_length;
   2817 
   2818       /**
   2819        * array of orders the requested instance has made
   2820        */
   2821       const struct TALER_MERCHANT_OrderEntry *orders;
   2822     } ok;
   2823   } details;
   2824 
   2825 };
   2826 
   2827 
   2828 /**
   2829  * Function called with the result of the GET /orders operation.
   2830  *
   2831  * @param cls closure
   2832  * @param ogr response details
   2833  */
   2834 typedef void
   2835 (*TALER_MERCHANT_OrdersGetCallback)(
   2836   void *cls,
   2837   const struct TALER_MERCHANT_OrdersGetResponse *ogr);
   2838 
   2839 
   2840 /**
   2841  * Make a GET /orders request.
   2842  *
   2843  * @param ctx the context
   2844  * @param backend_url HTTP base URL for the backend
   2845  * @param cb function to call with the backend's inventory information
   2846  * @param cb_cls closure for @a cb
   2847  * @return the request handle; NULL upon error
   2848  */
   2849 struct TALER_MERCHANT_OrdersGetHandle *
   2850 TALER_MERCHANT_orders_get (
   2851   struct GNUNET_CURL_Context *ctx,
   2852   const char *backend_url,
   2853   TALER_MERCHANT_OrdersGetCallback cb,
   2854   void *cb_cls);
   2855 
   2856 
   2857 /**
   2858  * Make a GET /orders request with filters.
   2859  *
   2860  * @param ctx the context
   2861  * @param backend_url HTTP base URL for the backend
   2862  * @param paid filter on payment status
   2863  * @param refunded filter on refund status
   2864  * @param wired filter on wire transfer status
   2865  * @param date range limit by date
   2866  * @param start_row range limit by order table row
   2867  * @param delta range from which @a date and @a start_row apply, positive
   2868  *              to return delta items after the given limit(s), negative to
   2869  *              return delta items before the given limit(s)
   2870  * @param timeout how long to wait (long polling) of zero results match the query
   2871  * @param cb function to call with the backend's inventory information
   2872  * @param cb_cls closure for @a cb
   2873  * @return the request handle; NULL upon error
   2874  */
   2875 struct TALER_MERCHANT_OrdersGetHandle *
   2876 TALER_MERCHANT_orders_get2 (
   2877   struct GNUNET_CURL_Context *ctx,
   2878   const char *backend_url,
   2879   enum TALER_EXCHANGE_YesNoAll paid,
   2880   enum TALER_EXCHANGE_YesNoAll refunded,
   2881   enum TALER_EXCHANGE_YesNoAll wired,
   2882   struct GNUNET_TIME_Timestamp date,
   2883   uint64_t start_row,
   2884   int64_t delta,
   2885   struct GNUNET_TIME_Relative timeout,
   2886   TALER_MERCHANT_OrdersGetCallback cb,
   2887   void *cb_cls);
   2888 
   2889 
   2890 /**
   2891  * Make a GET /orders request with more filters.
   2892  *
   2893  * @param ctx the context
   2894  * @param backend_url HTTP base URL for the backend
   2895  * @param paid filter on payment status
   2896  * @param refunded filter on refund status
   2897  * @param wired filter on wire transfer status
   2898  * @param session_id filter by session ID
   2899  * @param fulfillment_url filter by fulfillment URL
   2900  * @param date range limit by date
   2901  * @param start_row range limit by order table row
   2902  * @param delta range from which @a date and @a start_row apply, positive
   2903  *              to return delta items after the given limit(s), negative to
   2904  *              return delta items before the given limit(s)
   2905  * @param timeout how long to wait (long polling) of zero results match the query
   2906  * @param cb function to call with the backend's inventory information
   2907  * @param cb_cls closure for @a cb
   2908  * @return the request handle; NULL upon error
   2909  */
   2910 struct TALER_MERCHANT_OrdersGetHandle *
   2911 TALER_MERCHANT_orders_get3 (
   2912   struct GNUNET_CURL_Context *ctx,
   2913   const char *backend_url,
   2914   enum TALER_EXCHANGE_YesNoAll paid,
   2915   enum TALER_EXCHANGE_YesNoAll refunded,
   2916   enum TALER_EXCHANGE_YesNoAll wired,
   2917   const char *session_id,
   2918   const char *fulfillment_url,
   2919   struct GNUNET_TIME_Timestamp date,
   2920   uint64_t start_row,
   2921   int64_t delta,
   2922   struct GNUNET_TIME_Relative timeout,
   2923   TALER_MERCHANT_OrdersGetCallback cb,
   2924   void *cb_cls);
   2925 
   2926 
   2927 /**
   2928  * Cancel GET /orders operation.
   2929  *
   2930  * @param[in] pgh operation to cancel
   2931  */
   2932 void
   2933 TALER_MERCHANT_orders_get_cancel (
   2934   struct TALER_MERCHANT_OrdersGetHandle *pgh);
   2935 
   2936 
   2937 /**
   2938  * Handle for a GET /orders/$ID operation. (Wallet's public endpoint,
   2939  * not to be confused with the private endpoint for the merchant.)
   2940  */
   2941 struct TALER_MERCHANT_OrderWalletGetHandle;
   2942 
   2943 
   2944 /**
   2945  * Response to a GET /orders/$ID request.
   2946  */
   2947 struct TALER_MERCHANT_OrderWalletGetResponse
   2948 {
   2949   /**
   2950    * Full HTTP response details.
   2951    */
   2952   struct TALER_MERCHANT_HttpResponse hr;
   2953 
   2954   /**
   2955    * Response details depending on the HTTP status.
   2956    */
   2957   union
   2958   {
   2959     /**
   2960      * Response details if the response code is #MHD_HTTP_OK.
   2961      */
   2962     struct
   2963     {
   2964 
   2965       /**
   2966        * True if there is at least on refund on this payment.
   2967        */
   2968       bool refunded;
   2969 
   2970       /**
   2971        * True if there are refunds waiting to be
   2972        * obtained.
   2973        */
   2974       bool refund_pending;
   2975 
   2976       /**
   2977        * Amount that was refunded, only set if
   2978        * @e refunded is #GNUNET_YES.
   2979        */
   2980       struct TALER_Amount refund_amount;
   2981 
   2982     } ok;
   2983 
   2984     /**
   2985      * Response if a payment is required from the client.
   2986      */
   2987     struct
   2988     {
   2989 
   2990       /**
   2991        * The URI that instructs the wallet to process
   2992        * the payment.
   2993        */
   2994       const char *taler_pay_uri;
   2995 
   2996       /**
   2997        * Equivalent order that this customer paid already, or NULL for none.
   2998        */
   2999       const char *already_paid_order_id;
   3000 
   3001     } payment_required;
   3002 
   3003   } details;
   3004 };
   3005 
   3006 
   3007 /**
   3008  * Callback to process a GET /orders/$ID response
   3009  *
   3010  * @param cls closure
   3011  * @param owgs HTTP response details
   3012  */
   3013 typedef void
   3014 (*TALER_MERCHANT_OrderWalletGetCallback) (
   3015   void *cls,
   3016   const struct TALER_MERCHANT_OrderWalletGetResponse *owgs);
   3017 
   3018 
   3019 /**
   3020  * Checks the status of a payment.  Issue a GET /orders/$ID request to the
   3021  * backend.  The @a h_contract serves as identification of the wallet and is
   3022  * used to authorize the request.
   3023  *
   3024  * @param ctx execution context
   3025  * @param backend_url base URL of the merchant backend
   3026  * @param order_id order id to identify the payment
   3027  * @param h_contract hash of the contract to authenticate the wallet
   3028  * @param timeout timeout to use in long polling (how long may the server wait to reply
   3029  *        before generating an unpaid response). Note that this is just provided to
   3030  *        the server, we as client will block until the response comes back or until
   3031  *        #TALER_MERCHANT_wallet_order_get_cancel() is called.
   3032  * @param session_id for which session should the payment status be checked. Use
   3033  *        NULL to disregard sessions.
   3034  * @param min_refund long poll for the service to approve a refund exceeding this value;
   3035  *        use NULL to not wait for any refund (only for payment). Only makes sense
   3036  *        with a non-zero @a timeout. Can be NULL.
   3037  * @param await_refund_obtained long poll for the order's refunds to be
   3038  *        picked up by the wallet.
   3039  * @param cb callback which will work the response gotten from the backend
   3040  * @param cb_cls closure to pass to @a cb
   3041  * @return handle for this operation, NULL upon errors
   3042  */
   3043 struct TALER_MERCHANT_OrderWalletGetHandle *
   3044 TALER_MERCHANT_wallet_order_get (
   3045   struct GNUNET_CURL_Context *ctx,
   3046   const char *backend_url,
   3047   const char *order_id,
   3048   const struct TALER_PrivateContractHashP *h_contract,
   3049   struct GNUNET_TIME_Relative timeout,
   3050   const char *session_id,
   3051   const struct TALER_Amount *min_refund,
   3052   bool await_refund_obtained,
   3053   TALER_MERCHANT_OrderWalletGetCallback cb,
   3054   void *cb_cls);
   3055 
   3056 /**
   3057  * Cancel a GET /orders/$ID request.
   3058  *
   3059  * @param[in] owgh handle to the request to be canceled
   3060  */
   3061 void
   3062 TALER_MERCHANT_wallet_order_get_cancel (
   3063   struct TALER_MERCHANT_OrderWalletGetHandle *owgh);
   3064 
   3065 
   3066 /**
   3067  * Handle for a GET /private/orders/$ID operation (merchant's internal
   3068  * API, not to be confused with the endpoint for wallets).
   3069  */
   3070 struct TALER_MERCHANT_OrderMerchantGetHandle;
   3071 
   3072 
   3073 /**
   3074  * Details about a wire transfer to the merchant related to the order.
   3075  */
   3076 struct TALER_MERCHANT_WireTransfer
   3077 {
   3078   /**
   3079    * Base URL of the exchange that made the transfer.
   3080    */
   3081   const char *exchange_url;
   3082 
   3083   /**
   3084    * When the transfer took place (note: may not be exact,
   3085    * as the time at which the exchange initiated the transfer
   3086    * may differ from the time the bank or the merchant observed).
   3087    */
   3088   struct GNUNET_TIME_Timestamp execution_time;
   3089 
   3090   /**
   3091    * Wire transfer subject.
   3092    */
   3093   struct TALER_WireTransferIdentifierRawP wtid;
   3094 
   3095   /**
   3096    * Total amount that was transferred.
   3097    */
   3098   struct TALER_Amount total_amount;
   3099 
   3100   /**
   3101    * Whether this transfer was confirmed by the merchant using
   3102    * the POST /transfers API, or whether it was merely claimed
   3103    * by the exchange.
   3104    */
   3105   bool confirmed;
   3106 };
   3107 
   3108 
   3109 /**
   3110  * Details about a failures returned by the exchange when
   3111  * tracking wire transfers.
   3112  */
   3113 struct TALER_MERCHANT_WireReport
   3114 {
   3115 
   3116   /**
   3117    * Error code explaining the nature of the problem.
   3118    */
   3119   enum TALER_ErrorCode code;
   3120 
   3121   /**
   3122    * Human-readable error description.
   3123    */
   3124   const char *hint;
   3125 
   3126   /**
   3127    * Public key of the coin involved.
   3128    */
   3129   struct TALER_CoinSpendPublicKeyP coin_pub;
   3130 
   3131   /**
   3132    * HTTP response data from the exchange (fields are MAY BE NULL or 0 if not
   3133    * available).
   3134    */
   3135   struct TALER_EXCHANGE_HttpResponse hr;
   3136 
   3137 };
   3138 
   3139 
   3140 /**
   3141  * Detail returned by the merchant backend about refunds.
   3142  */
   3143 struct TALER_MERCHANT_RefundOrderDetail
   3144 {
   3145 
   3146   /**
   3147    * Human-readable reason given for the refund.
   3148    */
   3149   const char *reason;
   3150 
   3151   /**
   3152    * Time when the refund was granted.
   3153    */
   3154   struct GNUNET_TIME_Timestamp refund_time;
   3155 
   3156   /**
   3157    * Total amount that was refunded.
   3158    */
   3159   struct TALER_Amount refund_amount;
   3160 
   3161 };
   3162 
   3163 
   3164 /**
   3165  * Status of an order.
   3166  */
   3167 enum TALER_MERCHANT_OrderStatusCode
   3168 {
   3169   /**
   3170    * The order was paid.
   3171    */
   3172   TALER_MERCHANT_OSC_PAID = 1,
   3173 
   3174   /**
   3175   * The order was claimed but not yet paid.
   3176   */
   3177   TALER_MERCHANT_OSC_CLAIMED = 2,
   3178 
   3179   /**
   3180    * The order was never paid or claimed.
   3181    */
   3182   TALER_MERCHANT_OSC_UNPAID = 3
   3183 };
   3184 
   3185 
   3186 /**
   3187  * Details about the status of an order.
   3188  */
   3189 struct TALER_MERCHANT_OrderStatusResponse
   3190 {
   3191   /**
   3192    * HTTP response details.
   3193    */
   3194   struct TALER_MERCHANT_HttpResponse hr;
   3195 
   3196   /**
   3197    * Details provided depending on the HTTP status code.
   3198    */
   3199   union
   3200   {
   3201     /**
   3202      * Details provided if the HTTP status is #MHD_HTTP_OK.
   3203      */
   3204     struct
   3205     {
   3206 
   3207       /**
   3208        * Status of the order.
   3209        */
   3210       enum TALER_MERCHANT_OrderStatusCode status;
   3211 
   3212       /**
   3213        * Details depending on the payment status given in @e status.
   3214        */
   3215       union
   3216       {
   3217 
   3218         /**
   3219          * Details provided if @e status is #TALER_MERCHANT_OSC_PAID.
   3220          */
   3221         struct
   3222         {
   3223           /**
   3224            * Amount that was refunded.
   3225            */
   3226           struct TALER_Amount refund_amount;
   3227 
   3228           /**
   3229            * Amount that was deposited into our bank account,
   3230            * excluding fees.
   3231            */
   3232           struct TALER_Amount deposit_total;
   3233 
   3234           /**
   3235            * The full contract terms of the order.
   3236            */
   3237           const json_t *contract_terms;
   3238 
   3239           /**
   3240            * Array of wire transfers made for this payment to the
   3241            * merchant by the exchange. Of length @e wts_len.
   3242            */
   3243           struct TALER_MERCHANT_WireTransfer *wts;
   3244 
   3245           /**
   3246            * Length of the @e wts array.
   3247            */
   3248           unsigned int wts_len;
   3249 
   3250           /**
   3251            * Details returned by the merchant backend about refunds.
   3252            * Of length @e refunds_len.
   3253            */
   3254           struct TALER_MERCHANT_RefundOrderDetail *refunds;
   3255 
   3256           /**
   3257            * Length of the @e refunds array.
   3258            */
   3259           unsigned int refunds_len;
   3260 
   3261           /**
   3262            * Error code encountered trying to contact the exchange
   3263            * about the wire tracking, 0 for none.
   3264            */
   3265           enum TALER_ErrorCode exchange_ec;
   3266 
   3267           /**
   3268            * HTTP status code encountered trying to contact the exchange
   3269            * about the wire tracking, 0 for no error.
   3270            */
   3271           unsigned int exchange_hc;
   3272 
   3273           /**
   3274            * true if there is at least on refund on this payment,
   3275            * false if there are no refunds.
   3276            */
   3277           bool refunded;
   3278 
   3279           /**
   3280            * true if refunds were approved that have not yet been obtained
   3281            * by the wallet.
   3282            */
   3283           bool refund_pending;
   3284 
   3285           /**
   3286            * true if the exchange paid the merchant for this order,
   3287            * false if not.
   3288            */
   3289           bool wired;
   3290 
   3291           /**
   3292            * Time of the last payment made on this order.
   3293            * Only available if the server supports protocol
   3294            * **v14** or higher, otherwise zero.
   3295            */
   3296           struct GNUNET_TIME_Timestamp last_payment;
   3297         } paid;
   3298 
   3299         /**
   3300          * Details provided if @e status is #TALER_MERCHANT_OSC_CLAIMED.
   3301          */
   3302         struct
   3303         {
   3304 
   3305           /**
   3306            * The full contract terms of the claimed order (including client nonce from claiming).
   3307            */
   3308           const json_t *contract_terms;
   3309 
   3310         } claimed;
   3311 
   3312         /**
   3313          * Details provided if @e status is #TALER_MERCHANT_OSC_UNPAID.
   3314          */
   3315         struct
   3316         {
   3317 
   3318           /**
   3319            * URI that should be shown to the wallet to trigger a payment.
   3320            */
   3321           const char *taler_pay_uri;
   3322 
   3323           /**
   3324            * Alternative order ID which was paid for already in the same session.
   3325            * Only given if the same product was purchased before in the same session.
   3326            * Otherwise NULL.
   3327            */
   3328           const char *already_paid_order_id;
   3329 
   3330           /**
   3331            * Order summary.
   3332            */
   3333           const char *summary;
   3334 
   3335           /**
   3336            * Time when the order was created.
   3337            */
   3338           struct GNUNET_TIME_Timestamp creation_time;
   3339 
   3340           /**
   3341            * Total amount the order is about (amount to be paid by customer).
   3342            */
   3343           struct TALER_Amount contract_amount;
   3344 
   3345         } unpaid;
   3346 
   3347       } details;
   3348 
   3349     } ok;
   3350 
   3351   } details;
   3352 };
   3353 
   3354 
   3355 /**
   3356  * Callback to process a GET /orders/$ID request
   3357  *
   3358  * @param cls closure
   3359  * @param osr order status response details
   3360  */
   3361 typedef void
   3362 (*TALER_MERCHANT_OrderMerchantGetCallback) (
   3363   void *cls,
   3364   const struct TALER_MERCHANT_OrderStatusResponse *osr);
   3365 
   3366 
   3367 /**
   3368  * Checks the status of a payment.  Issue a GET /private/orders/$ID request to
   3369  * the backend.
   3370  *
   3371  * @param ctx execution context
   3372  * @param backend_url base URL of the merchant backend
   3373  * @param order_id order id to identify the payment
   3374  * @param session_id session id for the payment (or NULL if the check is not
   3375  *                   bound to a session)
   3376  * @param timeout timeout to use in long polling (how long may the server wait to reply
   3377  *        before generating an unpaid response). Note that this is just provided to
   3378  *        the server, we as client will block until the response comes back or until
   3379  *        #TALER_MERCHANT_merchant_order_get_cancel() is called.
   3380  * @param cb callback which will work the response gotten from the backend
   3381  * @param cb_cls closure to pass to @a cb
   3382  * @return handle for this operation, NULL upon errors
   3383  */
   3384 struct TALER_MERCHANT_OrderMerchantGetHandle *
   3385 TALER_MERCHANT_merchant_order_get (struct GNUNET_CURL_Context *ctx,
   3386                                    const char *backend_url,
   3387                                    const char *order_id,
   3388                                    const char *session_id,
   3389                                    struct GNUNET_TIME_Relative timeout,
   3390                                    TALER_MERCHANT_OrderMerchantGetCallback cb,
   3391                                    void *cb_cls);
   3392 
   3393 
   3394 /**
   3395  * Cancel a GET /private/orders/$ID request.
   3396  *
   3397  * @param[in] omgh handle to the request to be canceled
   3398  */
   3399 void
   3400 TALER_MERCHANT_merchant_order_get_cancel (
   3401   struct TALER_MERCHANT_OrderMerchantGetHandle *omgh);
   3402 
   3403 
   3404 /**
   3405  * Handle for a DELETE /orders/$ID operation.
   3406  */
   3407 struct TALER_MERCHANT_OrderDeleteHandle;
   3408 
   3409 
   3410 /**
   3411  * Function called with the result of the DELETE /orders/$ID operation.
   3412  *
   3413  * @param cls closure
   3414  * @param hr HTTP response details
   3415  */
   3416 typedef void
   3417 (*TALER_MERCHANT_OrderDeleteCallback)(
   3418   void *cls,
   3419   const struct TALER_MERCHANT_HttpResponse *hr);
   3420 
   3421 
   3422 /**
   3423  * Make a DELETE /orders/$ID request to delete a order from our
   3424  * inventory.
   3425  *
   3426  * @param ctx the context
   3427  * @param backend_url HTTP base URL for the backend
   3428  * @param order_id identifier of the order
   3429  * @param force force deletion of claimed (but unpaid) orders
   3430  * @param cb function to call with the backend's deletion status
   3431  * @param cb_cls closure for @a cb
   3432  * @return the request handle; NULL upon error
   3433  */
   3434 struct TALER_MERCHANT_OrderDeleteHandle *
   3435 TALER_MERCHANT_order_delete (
   3436   struct GNUNET_CURL_Context *ctx,
   3437   const char *backend_url,
   3438   const char *order_id,
   3439   bool force,
   3440   TALER_MERCHANT_OrderDeleteCallback cb,
   3441   void *cb_cls);
   3442 
   3443 
   3444 /**
   3445  * Cancel DELETE /orders/$ID operation.
   3446  *
   3447  * @param[in] odh operation to cancel
   3448  */
   3449 void
   3450 TALER_MERCHANT_order_delete_cancel (
   3451   struct TALER_MERCHANT_OrderDeleteHandle *odh);
   3452 
   3453 
   3454 /**
   3455  * Handle to a POST /orders/$ID/claim handle
   3456  */
   3457 struct TALER_MERCHANT_OrderClaimHandle;
   3458 
   3459 
   3460 /**
   3461  * Response to a POST /orders/$ID/claim request.
   3462  */
   3463 struct TALER_MERCHANT_OrderClaimResponse
   3464 {
   3465   /**
   3466    * HTTP response details
   3467    */
   3468   struct TALER_MERCHANT_HttpResponse hr;
   3469 
   3470   /**
   3471    * Details depending on HTTP status.
   3472    */
   3473   union
   3474   {
   3475     /**
   3476      * Details for #MHD_HTTP_OK.
   3477      */
   3478     struct
   3479     {
   3480       /**
   3481        * the details of the contract
   3482        */
   3483       const json_t *contract_terms;
   3484 
   3485       /**
   3486        * merchant's signature over @e contract_terms (already verified)
   3487        */
   3488       struct TALER_MerchantSignatureP sig;
   3489 
   3490       /**
   3491        * hash over @e contract_terms (computed client-side to verify @e sig)
   3492        */
   3493       struct TALER_PrivateContractHashP h_contract_terms;
   3494     } ok;
   3495 
   3496   } details;
   3497 };
   3498 
   3499 /**
   3500  * Callback called to process a POST /orders/$ID/claim response.
   3501  *
   3502  * @param cls closure
   3503  * @param ocr response details
   3504  */
   3505 typedef void
   3506 (*TALER_MERCHANT_OrderClaimCallback) (
   3507   void *cls,
   3508   const struct TALER_MERCHANT_OrderClaimResponse *ocr);
   3509 
   3510 
   3511 /**
   3512  * Calls the POST /orders/$ID/claim API at the backend.  That is,
   3513  * retrieve the final contract terms including the client nonce.
   3514  *
   3515  * This is a PUBLIC API for wallets.
   3516  *
   3517  * @param ctx execution context
   3518  * @param backend_url base URL of the merchant backend
   3519  * @param order_id order id used to perform the lookup
   3520  * @param nonce nonce to use to claim the proposal
   3521  * @param claim_token the token used to verify the claim (NULL for none)
   3522  * @param cb callback which will work the response gotten from the backend
   3523  * @param cb_cls closure to pass to @a cb
   3524  * @return handle for this handle, NULL upon errors
   3525  */
   3526 struct TALER_MERCHANT_OrderClaimHandle *
   3527 TALER_MERCHANT_order_claim (
   3528   struct GNUNET_CURL_Context *ctx,
   3529   const char *backend_url,
   3530   const char *order_id,
   3531   const struct GNUNET_CRYPTO_EddsaPublicKey *nonce,
   3532   const struct TALER_ClaimTokenP *claim_token,
   3533   TALER_MERCHANT_OrderClaimCallback cb,
   3534   void *cb_cls);
   3535 
   3536 
   3537 /**
   3538  * Cancel a POST /order/$ID/claim request.
   3539  *
   3540  * @param[in] och handle to the request to be canceled
   3541  */
   3542 void
   3543 TALER_MERCHANT_order_claim_cancel (struct TALER_MERCHANT_OrderClaimHandle *och);
   3544 
   3545 
   3546 /**
   3547  * All the details about a token that are generated during issuance and
   3548  * that may be needed for future operations on the coin.
   3549  */
   3550 struct TALER_MERCHANT_PrivateTokenDetails
   3551 {
   3552 
   3553   /**
   3554    * Master secret used to derive the private key from.
   3555    */
   3556   struct TALER_TokenUseMasterSecretP master;
   3557 
   3558   /**
   3559    * Private key of the token.
   3560    */
   3561   struct TALER_TokenUsePrivateKeyP token_priv;
   3562 
   3563   /**
   3564    * Public key of the token.
   3565    */
   3566   struct TALER_TokenUsePublicKeyP token_pub;
   3567 
   3568   /**
   3569    * Public key of the token.
   3570    */
   3571   struct TALER_TokenUsePublicKeyHashP h_token_pub;
   3572 
   3573   /**
   3574    * Blinded public key of the token.
   3575    */
   3576   struct TALER_TokenEnvelope envelope;
   3577 
   3578   /**
   3579    * Value used to blind the key for the signature.
   3580    */
   3581   union GNUNET_CRYPTO_BlindingSecretP blinding_secret;
   3582 
   3583   /**
   3584    * Inputs needed from the merchant for blind signing.
   3585    */
   3586   struct TALER_TokenUseMerchantValues blinding_inputs;
   3587 
   3588   /**
   3589    * Token issue public key.
   3590    */
   3591   struct TALER_TokenIssuePublicKey issue_pub;
   3592 
   3593   /**
   3594    * Unblinded token issue signature made by the merchant.
   3595    */
   3596   struct TALER_TokenIssueSignature issue_sig;
   3597 
   3598   /**
   3599    * Blinded token issue signature made by the merchant.
   3600    */
   3601   struct TALER_BlindedTokenIssueSignature blinded_sig;
   3602 
   3603 };
   3604 
   3605 /**
   3606  * @brief Handle to a POST /orders/$ID/pay operation at a merchant.  Note that
   3607  * we use the same handle for interactions with frontends (API for wallets) or
   3608  * backends (API for frontends).  The difference is that for the frontend API,
   3609  * we need the private keys of the coins, while for the backend API we need
   3610  * the public keys and signatures received from the wallet.
   3611  */
   3612 struct TALER_MERCHANT_OrderPayHandle;
   3613 
   3614 
   3615 /**
   3616  * Information returned in response to a payment.
   3617  */
   3618 struct TALER_MERCHANT_PayResponse
   3619 {
   3620 
   3621   /**
   3622    * General HTTP response details.
   3623    */
   3624   struct TALER_MERCHANT_HttpResponse hr;
   3625 
   3626   /**
   3627    * Details returned depending on @e hr.
   3628    */
   3629   union
   3630   {
   3631 
   3632     /**
   3633      * Details returned on success.
   3634      */
   3635     struct
   3636     {
   3637 
   3638       /**
   3639        * Signature affirming that the order was paid.
   3640        */
   3641       struct TALER_MerchantSignatureP merchant_sig;
   3642 
   3643       /**
   3644        * Optional payment confirmation code returned by the service.
   3645        */
   3646       const char *pos_confirmation;
   3647 
   3648       /**
   3649        * Array of tokens that were issued for the payment.
   3650        */
   3651       struct TALER_MERCHANT_OutputToken *tokens;
   3652 
   3653       /**
   3654        * Length of the @e tokens array.
   3655        */
   3656       unsigned int num_tokens;
   3657 
   3658     } ok;
   3659 
   3660     // TODO: might want to return further details on errors,
   3661     // especially refund signatures on double-pay conflict.
   3662 
   3663     struct
   3664     {
   3665 
   3666       /**
   3667        * Array of exchange URLs which had legal problems.
   3668        */
   3669       const char **exchanges;
   3670 
   3671       /**
   3672        * Length of the @e exchanges array.
   3673        */
   3674       unsigned int num_exchanges;
   3675 
   3676     } unavailable_for_legal_reasons;
   3677 
   3678   } details;
   3679 
   3680 };
   3681 
   3682 
   3683 /**
   3684  * Callbacks of this type are used to serve the result of submitting a
   3685  * POST /orders/$ID/pay request to a merchant.
   3686  *
   3687  * @param cls closure
   3688  * @param pr HTTP response details
   3689  */
   3690 typedef void
   3691 (*TALER_MERCHANT_OrderPayCallback) (
   3692   void *cls,
   3693   const struct TALER_MERCHANT_PayResponse *pr);
   3694 
   3695 
   3696 /**
   3697  * Information we need from the frontend (ok, the frontend sends just JSON)
   3698  * when forwarding a payment to the backend.
   3699  */
   3700 struct TALER_MERCHANT_PaidCoin
   3701 {
   3702   /**
   3703    * Denomination key with which the coin is signed
   3704    */
   3705   struct TALER_DenominationPublicKey denom_pub;
   3706 
   3707   /**
   3708    * Exchange’s unblinded signature of the coin
   3709    */
   3710   struct TALER_DenominationSignature denom_sig;
   3711 
   3712   /**
   3713    * Overall value that coins of this @e denom_pub have.
   3714    */
   3715   struct TALER_Amount denom_value;
   3716 
   3717   /**
   3718    * Coin's public key.
   3719    */
   3720   struct TALER_CoinSpendPublicKeyP coin_pub;
   3721 
   3722   /**
   3723    * Coin's signature key.
   3724    */
   3725   struct TALER_CoinSpendSignatureP coin_sig;
   3726 
   3727   /**
   3728    * Amount this coin contributes to (including fee).
   3729    */
   3730   struct TALER_Amount amount_with_fee;
   3731 
   3732   /**
   3733    * Amount this coin contributes to (without fee).
   3734    */
   3735   struct TALER_Amount amount_without_fee;
   3736 
   3737   /**
   3738    * What is the URL of the exchange that issued @a coin_pub?
   3739    */
   3740   const char *exchange_url;
   3741 
   3742 };
   3743 
   3744 
   3745 /**
   3746  * Information the frontend forwards to the backend to use a token for
   3747  * an order. Note that this does not include the token use private key,
   3748  * but only public keys and signatures.
   3749  */
   3750 struct TALER_MERCHANT_UsedToken
   3751 {
   3752 
   3753   /**
   3754    * Signature on TALER_TokenUseRequestPS made with the token use private key.
   3755    */
   3756   struct TALER_TokenUseSignatureP token_sig;
   3757 
   3758   /**
   3759    * Public key of the token. This was blindly signed by the merchant
   3760    * during the issuance and is now being revealed to the merchant.
   3761    */
   3762   struct TALER_TokenUsePublicKeyP token_pub;
   3763 
   3764   /**
   3765    * Unblinded signature made by the token issue public key of the merchant.
   3766    */
   3767   struct TALER_TokenIssueSignature ub_sig;
   3768 
   3769   /**
   3770    * Token issue public key associated with this token.
   3771    */
   3772   struct TALER_TokenIssuePublicKey issue_pub;
   3773 
   3774 };
   3775 
   3776 
   3777 /**
   3778  * Information the frontend forwards to the backend for an output token. The
   3779  * blinded issue signature is set once the request return with an HTTP_OK.
   3780  * This does not include the blinding secret or any other private information.
   3781  */
   3782 struct TALER_MERCHANT_OutputToken
   3783 {
   3784 
   3785   /**
   3786    * Token envelope.
   3787    */
   3788   struct TALER_TokenEnvelope envelope;
   3789 
   3790   /**
   3791    * Blinded issue signature made by the merchant.
   3792    */
   3793   struct TALER_BlindedTokenIssueSignature blinded_sig;
   3794 
   3795 };
   3796 
   3797 
   3798 /**
   3799  * Pay a merchant.  API for frontends talking to backends. Here,
   3800  * the frontend does not have the coin's private keys, but just
   3801  * the public keys and signatures.
   3802  *
   3803  * This is a PUBLIC API, albeit in this form useful for the frontend,
   3804  * in case the frontend is proxying the request.
   3805  *
   3806  * @param ctx execution context
   3807  * @param merchant_url base URL of the merchant
   3808  * @param order_id which order should be paid
   3809  * @param session_id session to pay for, or NULL for none
   3810  * @param wallet_data inputs from the wallet for the contract, NULL for none
   3811  * @param num_coins length of the @a coins array
   3812  * @param coins array of coins to pay with
   3813  * @param num_tokens length of the @a tokens array
   3814  * @param tokens array of tokens used
   3815  * @param j_output_tokens json array of token envelopes, NULL for none
   3816  * @param pay_cb the callback to call when a reply for this request is available
   3817  * @param pay_cb_cls closure for @a pay_cb
   3818  * @return a handle for this request
   3819  */
   3820 struct TALER_MERCHANT_OrderPayHandle *
   3821 TALER_MERCHANT_order_pay_frontend (
   3822   struct GNUNET_CURL_Context *ctx,
   3823   const char *merchant_url,
   3824   const char *order_id,
   3825   const char *session_id,
   3826   const json_t *wallet_data,
   3827   unsigned int num_coins,
   3828   const struct TALER_MERCHANT_PaidCoin coins[static num_coins],
   3829   unsigned int num_tokens,
   3830   const struct TALER_MERCHANT_UsedToken tokens[static num_tokens],
   3831   json_t *j_output_tokens,
   3832   TALER_MERCHANT_OrderPayCallback pay_cb,
   3833   void *pay_cb_cls);
   3834 
   3835 
   3836 /**
   3837  * Information we need from the wallet for each coin when doing the
   3838  * payment.
   3839  */
   3840 struct TALER_MERCHANT_PayCoin
   3841 {
   3842   /**
   3843    * Denomination key with which the coin is signed
   3844    */
   3845   struct TALER_DenominationPublicKey denom_pub;
   3846 
   3847   /**
   3848    * Exchange’s unblinded signature of the coin
   3849    */
   3850   struct TALER_DenominationSignature denom_sig;
   3851 
   3852   /**
   3853    * Overall value that coins of this @e denom_pub have.
   3854    */
   3855   struct TALER_Amount denom_value;
   3856 
   3857   /**
   3858    * Coin's private key.
   3859    */
   3860   struct TALER_CoinSpendPrivateKeyP coin_priv;
   3861 
   3862   /**
   3863    * Coin's age commitment. Might be NULL, if not applicable.
   3864    */
   3865   const struct TALER_AgeCommitmentHashP *h_age_commitment;
   3866 
   3867   /**
   3868    * Amount this coin contributes to (including fee).
   3869    */
   3870   struct TALER_Amount amount_with_fee;
   3871 
   3872   /**
   3873    * Amount this coin contributes to (without fee).
   3874    */
   3875   struct TALER_Amount amount_without_fee;
   3876 
   3877   /**
   3878    * URL of the exchange that issued @e coin_priv.
   3879    */
   3880   const char *exchange_url;
   3881 
   3882 };
   3883 
   3884 
   3885 /**
   3886  * Information we need from the wallet to use a token for an order.
   3887  */
   3888 struct TALER_MERCHANT_UseToken
   3889 {
   3890 
   3891   /**
   3892    * Token use private key. We will derive the public key from this.
   3893    */
   3894   struct TALER_TokenUsePrivateKeyP token_priv;
   3895 
   3896   /**
   3897    * Unblinded signature made by the token issue public key of the merchant.
   3898    */
   3899   struct TALER_TokenIssueSignature ub_sig;
   3900 
   3901   /**
   3902    * Token issue public key associated with this token.
   3903    */
   3904   struct TALER_TokenIssuePublicKey issue_pub;
   3905 
   3906 };
   3907 
   3908 
   3909 /**
   3910  * Pay a merchant.  API for wallets that have the coin's private keys.
   3911  *
   3912  * This is a PUBLIC API for wallets.
   3913  *
   3914  * @param ctx execution context
   3915  * @param merchant_url base URL of the merchant
   3916  * @param session_id session to pay for, or NULL for none
   3917  * @param h_contract hash of the contact of the merchant with the customer
   3918  * @param choice_index index of the selected contract choice, -1 for none
   3919  * @param amount total value of the contract to be paid to the merchant
   3920  * @param max_fee maximum fee covered by the merchant (according to the contract)
   3921  * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
   3922  * @param merchant_sig signature from the merchant over the original contract
   3923  * @param timestamp timestamp when the contract was finalized, must match approximately the current time of the merchant
   3924  * @param refund_deadline date until which the merchant can issue a refund to the customer via the merchant (can be zero if refunds are not allowed)
   3925  * @param pay_deadline maximum time limit to pay for this contract
   3926  * @param h_wire hash of the merchant’s account details
   3927  * @param order_id order id
   3928  * @param num_coins number of coins used to pay
   3929  * @param coins array of coins we use to pay
   3930  * @param num_tokens number of tokens to used in this payment request
   3931  * @param tokens array of tokens we use in this payment request
   3932  * @param num_output_tokens length of the @a output_tokens array
   3933  * @param output_tokens array of output tokens to be issued by the merchant
   3934  * @param pay_cb the callback to call when a reply for this request is available
   3935  * @param pay_cb_cls closure for @a pay_cb
   3936  * @return a handle for this request
   3937  */
   3938 struct TALER_MERCHANT_OrderPayHandle *
   3939 TALER_MERCHANT_order_pay (
   3940   struct GNUNET_CURL_Context *ctx,
   3941   const char *merchant_url,
   3942   const char *session_id,
   3943   const struct TALER_PrivateContractHashP *h_contract,
   3944   int choice_index,
   3945   const struct TALER_Amount *amount,
   3946   const struct TALER_Amount *max_fee,
   3947   const struct TALER_MerchantPublicKeyP *merchant_pub,
   3948   const struct TALER_MerchantSignatureP *merchant_sig,
   3949   struct GNUNET_TIME_Timestamp timestamp,
   3950   struct GNUNET_TIME_Timestamp refund_deadline,
   3951   struct GNUNET_TIME_Timestamp pay_deadline,
   3952   const struct TALER_MerchantWireHashP *h_wire,
   3953   const char *order_id,
   3954   unsigned int num_coins,
   3955   const struct TALER_MERCHANT_PayCoin coins[static num_coins],
   3956   unsigned int num_tokens,
   3957   const struct TALER_MERCHANT_UseToken tokens[static num_tokens],
   3958   unsigned int num_output_tokens,
   3959   const struct TALER_MERCHANT_OutputToken output_tokens[static num_output_tokens
   3960   ],
   3961   TALER_MERCHANT_OrderPayCallback pay_cb,
   3962   void *pay_cb_cls);
   3963 
   3964 /**
   3965  * Cancel a POST /orders/$ID/pay request.  Note that if you cancel a request
   3966  * like this, you have no assurance that the request has not yet been
   3967  * forwarded to the merchant. Thus, the payment may still succeed or fail.
   3968  * Re-issue the original /pay request to resume/retry and obtain a definitive
   3969  * result, or refresh the coins involved to ensure that the merchant can no
   3970  * longer complete the payment.
   3971  *
   3972  * @param oph the payment request handle
   3973  */
   3974 void
   3975 TALER_MERCHANT_order_pay_cancel (struct TALER_MERCHANT_OrderPayHandle *oph);
   3976 
   3977 
   3978 /**
   3979  * @brief Handle to a POST /orders/$ID/paid operation at a merchant.
   3980  */
   3981 struct TALER_MERCHANT_OrderPaidHandle;
   3982 
   3983 /**
   3984  * Response to an /orders/$ID/paid request.
   3985  */
   3986 struct TALER_MERCHANT_OrderPaidResponse
   3987 {
   3988   /**
   3989    * HTTP response details.
   3990    */
   3991   struct TALER_MERCHANT_HttpResponse hr;
   3992   /**
   3993    * HTTP-status code dependent details.
   3994    */
   3995   union
   3996   {
   3997     /**
   3998      * Details on success.
   3999      */
   4000     struct
   4001     {
   4002       /**
   4003        * Set to true if the order was paid but also
   4004        * refunded.
   4005        */
   4006       bool refunded;
   4007     } ok;
   4008   } details;
   4009 };
   4010 
   4011 
   4012 /**
   4013  * Callbacks of this type are used to serve the result of submitting a
   4014  * POST /orders/$ID/paid request to a merchant.
   4015  *
   4016  * @param cls closure
   4017  * @param opr response details
   4018  */
   4019 typedef void
   4020 (*TALER_MERCHANT_OrderPaidCallback) (
   4021   void *cls,
   4022   const struct TALER_MERCHANT_OrderPaidResponse *opr);
   4023 
   4024 
   4025 /**
   4026  * Send proof of payment to a merchant.
   4027  *
   4028  * This is a PUBLIC API, albeit in this form useful for the frontend,
   4029  * in case the frontend is proxying the request.
   4030  *
   4031  * @param ctx execution context
   4032  * @param merchant_url base URL of the merchant
   4033  * @param order_id which order should be paid
   4034  * @param session_id session to pay for, or NULL for none
   4035  * @param h_contract_terms hash of the contract terms
   4036  * @param wallet_data_hash inputs from the wallet for the contract, NULL for none; FIXME: this argument is not needed and should be removed!
   4037  * @param merchant_sig signature from the merchant
   4038  *        affirming payment, or NULL on errors
   4039  * @param paid_cb the callback to call when a reply for this request is available
   4040  * @param paid_cb_cls closure for @a paid_cb
   4041  * @return a handle for this request
   4042  */
   4043 struct TALER_MERCHANT_OrderPaidHandle *
   4044 TALER_MERCHANT_order_paid (
   4045   struct GNUNET_CURL_Context *ctx,
   4046   const char *merchant_url,
   4047   const char *order_id,
   4048   const char *session_id,
   4049   const struct TALER_PrivateContractHashP *h_contract_terms,
   4050   const struct GNUNET_HashCode *wallet_data_hash,
   4051   const struct TALER_MerchantSignatureP *merchant_sig,
   4052   TALER_MERCHANT_OrderPaidCallback paid_cb,
   4053   void *paid_cb_cls);
   4054 
   4055 
   4056 /**
   4057  * Cancel POST /orders/$ID/paid operation.
   4058  *
   4059  * @param oph operation to cancel
   4060  */
   4061 void
   4062 TALER_MERCHANT_order_paid_cancel (
   4063   struct TALER_MERCHANT_OrderPaidHandle *oph);
   4064 
   4065 
   4066 /**
   4067  * Handle for an POST /orders/$ID/abort operation.
   4068  */
   4069 struct TALER_MERCHANT_OrderAbortHandle;
   4070 
   4071 
   4072 /**
   4073  * Entry in the array of refunded coins.
   4074  */
   4075 struct TALER_MERCHANT_AbortedCoin
   4076 {
   4077   /**
   4078    * Exchange signature affirming the refund.
   4079    */
   4080   struct TALER_ExchangeSignatureP exchange_sig;
   4081 
   4082   /**
   4083    * Exchange public key affirming the refund.
   4084    */
   4085   struct TALER_ExchangePublicKeyP exchange_pub;
   4086 };
   4087 
   4088 
   4089 /**
   4090  * Response to an /orders/$ID/abort request.
   4091  */
   4092 struct TALER_MERCHANT_AbortResponse
   4093 {
   4094   /**
   4095    * HTTP response details
   4096    */
   4097   struct TALER_MERCHANT_HttpResponse hr;
   4098 
   4099   /**
   4100    * Details depending on HTTP status code.
   4101    */
   4102   union
   4103   {
   4104     /**
   4105      * Details for #MHD_HTTP_OK.
   4106      */
   4107     struct
   4108     {
   4109 
   4110       /**
   4111        * public key of the merchant
   4112        */
   4113       const struct TALER_MerchantPublicKeyP *merchant_pub;
   4114 
   4115       /**
   4116        * size of the @e aborts array
   4117        */
   4118       unsigned int num_aborts;
   4119 
   4120       /**
   4121        * merchant signatures refunding coins
   4122        */
   4123       const struct TALER_MERCHANT_AbortedCoin *aborts;
   4124     } ok;
   4125 
   4126   } details;
   4127 };
   4128 
   4129 
   4130 /**
   4131  * Callbacks of this type are used to serve the result of submitting a
   4132  * /orders/$ID/abort request to a merchant.
   4133  *
   4134  * @param cls closure
   4135  * @param ar response details
   4136  */
   4137 typedef void
   4138 (*TALER_MERCHANT_AbortCallback) (
   4139   void *cls,
   4140   const struct TALER_MERCHANT_AbortResponse *ar);
   4141 
   4142 
   4143 /**
   4144  * Information we need from the wallet for each coin when aborting.
   4145  */
   4146 struct TALER_MERCHANT_AbortCoin
   4147 {
   4148 
   4149   /**
   4150    * Coin's public key.
   4151    */
   4152   struct TALER_CoinSpendPublicKeyP coin_pub;
   4153 
   4154   /**
   4155    * Amount this coin contributes to (including fee).
   4156    * FIXME: no longer needed since **v18**. Remove eventually!
   4157    */
   4158   struct TALER_Amount amount_with_fee;
   4159 
   4160   /**
   4161    * URL of the exchange that issued @e coin_priv.
   4162    */
   4163   const char *exchange_url;
   4164 
   4165 };
   4166 
   4167 /**
   4168  * Run a payment abort operation, asking for the payment to be aborted,
   4169  * yieldingrefunds for coins that were previously spend on a payment that
   4170  * failed to go through.
   4171  *
   4172  * This is a PUBLIC API for wallets.
   4173  *
   4174  * @param ctx execution context
   4175  * @param merchant_url base URL of the merchant
   4176  * @param order_id order to abort
   4177  * @param h_contract hash of the contact of the merchant with the customer
   4178  * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
   4179  * @param num_coins number of coins used to pay
   4180  * @param coins array of coins we use to pay
   4181  * @param cb the callback to call when a reply for this request is available
   4182  * @param cb_cls closure for @a cb
   4183  * @return a handle for this request
   4184  */
   4185 struct TALER_MERCHANT_OrderAbortHandle *
   4186 TALER_MERCHANT_order_abort (
   4187   struct GNUNET_CURL_Context *ctx,
   4188   const char *merchant_url,
   4189   const char *order_id,
   4190   const struct TALER_MerchantPublicKeyP *merchant_pub,
   4191   const struct TALER_PrivateContractHashP *h_contract,
   4192   unsigned int num_coins,
   4193   const struct TALER_MERCHANT_AbortCoin coins[static num_coins],
   4194   TALER_MERCHANT_AbortCallback cb,
   4195   void *cb_cls);
   4196 
   4197 
   4198 /**
   4199  * Cancel a POST /orders/$ID/abort request.  Note that if you cancel a request
   4200  * like this, you have no assurance that the request has not yet been
   4201  * forwarded to the merchant.
   4202  *
   4203  * @param oah the abort request handle
   4204  */
   4205 void
   4206 TALER_MERCHANT_order_abort_cancel (struct TALER_MERCHANT_OrderAbortHandle *oah);
   4207 
   4208 
   4209 /**
   4210  * Handle for an PATCH /orders/$ID/forget operation.
   4211  */
   4212 struct TALER_MERCHANT_OrderForgetHandle;
   4213 
   4214 
   4215 /**
   4216  * Callbacks of this type are used to serve the result of submitting a
   4217  * /orders/$ID/forget request to a merchant.
   4218  *
   4219  * @param cls closure
   4220  * @param hr HTTP response details
   4221  */
   4222 typedef void
   4223 (*TALER_MERCHANT_ForgetCallback) (
   4224   void *cls,
   4225   const struct TALER_MERCHANT_HttpResponse *hr);
   4226 
   4227 
   4228 /**
   4229  * Run an order forget operation, which forgets certain fields in an order's
   4230  * contract terms without changing the hash of the contract terms.
   4231  *
   4232  * @param ctx execution context.
   4233  * @param merchant_url base URL of the merchant.
   4234  * @param order_id order to forget.
   4235  * @param fields_length length of @e fields.
   4236  * @param fields the fields in the contract terms to forget.
   4237  * @param cb the callback to call when a reply for this request is available.
   4238  * @param cb_cls closure for @a cb.
   4239  * @return a handle for this request.
   4240  */
   4241 struct TALER_MERCHANT_OrderForgetHandle *
   4242 TALER_MERCHANT_order_forget (
   4243   struct GNUNET_CURL_Context *ctx,
   4244   const char *merchant_url,
   4245   const char *order_id,
   4246   unsigned int fields_length,
   4247   const char *fields[static fields_length],
   4248   TALER_MERCHANT_ForgetCallback cb,
   4249   void *cb_cls);
   4250 
   4251 
   4252 /**
   4253  * Cancel a PATCH /orders/$ID/forget request.  Note that if you cancel a request
   4254  * like this, you have no assurance that the request has not yet been
   4255  * forwarded to the merchant.
   4256  *
   4257  * @param[in] ofh the forget request handle
   4258  */
   4259 void
   4260 TALER_MERCHANT_order_forget_cancel (
   4261   struct TALER_MERCHANT_OrderForgetHandle *ofh);
   4262 
   4263 
   4264 /**
   4265  * Handle for a POST /orders/ID/refund operation.
   4266  */
   4267 struct TALER_MERCHANT_OrderRefundHandle;
   4268 
   4269 
   4270 /**
   4271  * Response to a POST /orders/$ID/refund request
   4272  */
   4273 struct TALER_MERCHANT_RefundResponse
   4274 {
   4275   /**
   4276    * HTTP response details this request
   4277    */
   4278   struct TALER_MERCHANT_HttpResponse hr;
   4279 
   4280   /**
   4281    * Details depending on HTTP status.
   4282    */
   4283   union
   4284   {
   4285     /**
   4286      * Details if status is #MHD_HTTP_OK.
   4287      */
   4288     struct
   4289     {
   4290 
   4291       /**
   4292        * the refund uri offered to the wallet
   4293        */
   4294       const char *taler_refund_uri;
   4295 
   4296       /**
   4297        * Hash of the contract a wallet may need to authorize obtaining the HTTP
   4298        * response.
   4299        */
   4300       struct TALER_PrivateContractHashP h_contract;
   4301     } ok;
   4302   } details;
   4303 };
   4304 
   4305 
   4306 /**
   4307  * Callback to process a POST /orders/$ID/refund request
   4308  *
   4309  * @param cls closure
   4310  * @param rr response details this request
   4311  */
   4312 typedef void
   4313 (*TALER_MERCHANT_RefundCallback) (
   4314   void *cls,
   4315   const struct TALER_MERCHANT_RefundResponse *rr);
   4316 
   4317 
   4318 /**
   4319  * Increase the refund granted for an order
   4320  *
   4321  * @param ctx the CURL context used to connect to the backend
   4322  * @param backend_url backend's base URL, including final "/"
   4323  * @param order_id id of the order whose refund is to be increased
   4324  * @param refund amount to which increase the refund
   4325  * @param reason human-readable reason justifying the refund
   4326  * @param cb callback processing the response from /refund
   4327  * @param cb_cls closure for cb
   4328  */
   4329 struct TALER_MERCHANT_OrderRefundHandle *
   4330 TALER_MERCHANT_post_order_refund (
   4331   struct GNUNET_CURL_Context *ctx,
   4332   const char *backend_url,
   4333   const char *order_id,
   4334   const struct TALER_Amount *refund,
   4335   const char *reason,
   4336   TALER_MERCHANT_RefundCallback cb,
   4337   void *cb_cls);
   4338 
   4339 /**
   4340  * Cancel a POST /refund request.
   4341  *
   4342  * @param orh the refund increasing operation to cancel
   4343  */
   4344 void
   4345 TALER_MERCHANT_post_order_refund_cancel (
   4346   struct TALER_MERCHANT_OrderRefundHandle *orh);
   4347 
   4348 
   4349 /**
   4350  * Handle for a (public) POST /orders/ID/refund operation.
   4351  */
   4352 struct TALER_MERCHANT_WalletOrderRefundHandle;
   4353 
   4354 
   4355 /**
   4356  * Detail about a refund lookup result.
   4357  */
   4358 struct TALER_MERCHANT_RefundDetail
   4359 {
   4360 
   4361   /**
   4362    * Exchange response details.  Full details are only included
   4363    * upon failure (HTTP status is not #MHD_HTTP_OK).
   4364    */
   4365   struct TALER_EXCHANGE_HttpResponse hr;
   4366 
   4367   /**
   4368    * Coin this detail is about.
   4369    */
   4370   struct TALER_CoinSpendPublicKeyP coin_pub;
   4371 
   4372   /**
   4373    * Refund transaction ID used.
   4374    */
   4375   uint64_t rtransaction_id;
   4376 
   4377   /**
   4378    * Amount to be refunded for this coin.
   4379    */
   4380   struct TALER_Amount refund_amount;
   4381 
   4382   /**
   4383    * Details depending on exchange HTTP status.
   4384    */
   4385   union
   4386   {
   4387     /**
   4388      * Details if exchange status is #MHD_HTTP_OK.
   4389      */
   4390     struct
   4391     {
   4392       /**
   4393        * Public key of the exchange affirming the refund,
   4394        * only valid if the @e hr http_status is #MHD_HTTP_OK.
   4395        */
   4396       struct TALER_ExchangePublicKeyP exchange_pub;
   4397 
   4398       /**
   4399        * Signature of the exchange affirming the refund,
   4400        * only valid if the @e hr http_status is #MHD_HTTP_OK.
   4401        */
   4402       struct TALER_ExchangeSignatureP exchange_sig;
   4403     } ok;
   4404   } details;
   4405 };
   4406 
   4407 
   4408 /**
   4409  * Response to a POST /orders/$ID/refund request
   4410  * for wallet API.
   4411  */
   4412 struct TALER_MERCHANT_WalletRefundResponse
   4413 {
   4414   /**
   4415    * HTTP response details this request
   4416    */
   4417   struct TALER_MERCHANT_HttpResponse hr;
   4418 
   4419   /**
   4420    * Details depending on HTTP status.
   4421    */
   4422   union
   4423   {
   4424     /**
   4425      * Details if status is #MHD_HTTP_OK.
   4426      */
   4427     struct
   4428     {
   4429 
   4430       /**
   4431        * Total amount of the refund that was granted
   4432        */
   4433       struct TALER_Amount refund_amount;
   4434 
   4435       /**
   4436        * public key of the merchant signing the @e refunds
   4437        */
   4438       struct TALER_MerchantPublicKeyP merchant_pub;
   4439 
   4440       /**
   4441        * array with details about the refunds obtained
   4442        */
   4443       const struct TALER_MERCHANT_RefundDetail *refunds;
   4444 
   4445       /**
   4446        * length of the @e refunds array
   4447        */
   4448       unsigned int refunds_length;
   4449     } ok;
   4450   } details;
   4451 };
   4452 
   4453 
   4454 /**
   4455  * Callback to process a (public) POST /orders/ID/refund request
   4456  *
   4457  * @param cls closure
   4458  * @param wrr HTTP response details
   4459  */
   4460 typedef void
   4461 (*TALER_MERCHANT_WalletRefundCallback) (
   4462   void *cls,
   4463   const struct TALER_MERCHANT_WalletRefundResponse *wrr);
   4464 
   4465 
   4466 /**
   4467  * Obtain the refunds that have been granted for an order.
   4468  *
   4469  * @param ctx the CURL context used to connect to the backend
   4470  * @param backend_url backend's base URL, including final "/"
   4471  * @param order_id id of the order whose refund is to be increased
   4472  * @param h_contract_terms hash of the contract terms of the order
   4473  * @param cb callback processing the response from /refund
   4474  * @param cb_cls closure for cb
   4475  */
   4476 struct TALER_MERCHANT_WalletOrderRefundHandle *
   4477 TALER_MERCHANT_wallet_post_order_refund (
   4478   struct GNUNET_CURL_Context *ctx,
   4479   const char *backend_url,
   4480   const char *order_id,
   4481   const struct TALER_PrivateContractHashP *h_contract_terms,
   4482   TALER_MERCHANT_WalletRefundCallback cb,
   4483   void *cb_cls);
   4484 
   4485 /**
   4486  * Cancel a (public) POST /refund request.
   4487  *
   4488  * @param orh the refund operation to cancel
   4489  */
   4490 void
   4491 TALER_MERCHANT_wallet_post_order_refund_cancel (
   4492   struct TALER_MERCHANT_WalletOrderRefundHandle *orh);
   4493 
   4494 
   4495 /* ********************* /transfers *********************** */
   4496 
   4497 /**
   4498  * @brief Handle to a POST /transfers operation at a merchant's backend.
   4499  */
   4500 struct TALER_MERCHANT_PostTransfersHandle;
   4501 
   4502 
   4503 /**
   4504  * @brief Response to a POST /transfers operation from a merchant's backend.
   4505  */
   4506 struct TALER_MERCHANT_PostTransfersResponse
   4507 {
   4508   /**
   4509    * HTTP response details
   4510    */
   4511   struct TALER_MERCHANT_HttpResponse hr;
   4512 
   4513   /**
   4514    * Details depending on HTTP status.
   4515    */
   4516   union
   4517   {
   4518 
   4519     /**
   4520      * Details if we got an #MHD_HTTP_BAD_GATEWAY.
   4521      */
   4522     struct
   4523     {
   4524       /**
   4525        * HTTP status of the exchange (or 0 if not available).
   4526        */
   4527       unsigned int exchange_http_status;
   4528 
   4529       /**
   4530        * Error code of the exchange (or TALER_EC_NONE if not available).
   4531        */
   4532       enum TALER_ErrorCode exchange_ec;
   4533 
   4534     } bad_gateway;
   4535 
   4536   } details;
   4537 
   4538 };
   4539 
   4540 
   4541 /**
   4542  * Callbacks of this type are used to work the result of submitting a
   4543  * POST /transfers request to a merchant
   4544  *
   4545  * @param cls closure
   4546  * @param ptr response details
   4547  */
   4548 typedef void
   4549 (*TALER_MERCHANT_PostTransfersCallback) (
   4550   void *cls,
   4551   const struct TALER_MERCHANT_PostTransfersResponse *ptr);
   4552 
   4553 
   4554 /**
   4555  * Request backend to remember that we received the given
   4556  * wire transfer and to request details about the aggregated
   4557  * transactions from the exchange.
   4558  *
   4559  * @param ctx execution context
   4560  * @param backend_url base URL of the backend
   4561  * @param credit_amount how much money did we receive (without wire fee)
   4562  * @param wtid base32 string indicating a wtid
   4563  * @param payto_uri which account was credited by the wire transfer
   4564  * @param exchange_url what is the URL of the exchange that made the transfer
   4565  * @param cb the callback to call when a reply for this request is available
   4566  * @param cls closure for @a cb
   4567  * @return a handle for this request
   4568  */
   4569 struct TALER_MERCHANT_PostTransfersHandle *
   4570 TALER_MERCHANT_transfers_post (
   4571   struct GNUNET_CURL_Context *ctx,
   4572   const char *backend_url,
   4573   const struct TALER_Amount *credit_amount,
   4574   const struct TALER_WireTransferIdentifierRawP *wtid,
   4575   struct TALER_FullPayto payto_uri,
   4576   const char *exchange_url,
   4577   TALER_MERCHANT_PostTransfersCallback cb,
   4578   void *cls);
   4579 
   4580 
   4581 /**
   4582  * Cancel a POST /transfers request.  This function cannot be used
   4583  * on a request handle if a response is already served for it.
   4584  *
   4585  * @param pth the operation to cancel
   4586  */
   4587 void
   4588 TALER_MERCHANT_transfers_post_cancel (
   4589   struct TALER_MERCHANT_PostTransfersHandle *pth);
   4590 
   4591 
   4592 /**
   4593  * Handle for a DELETE /transfers/ID operation.
   4594  */
   4595 struct TALER_MERCHANT_TransferDeleteHandle;
   4596 
   4597 
   4598 /**
   4599  * Function called with the result of the DELETE /transfers/$ID operation.
   4600  *
   4601  * @param cls closure
   4602  * @param hr HTTP response details
   4603  */
   4604 typedef void
   4605 (*TALER_MERCHANT_TransferDeleteCallback)(
   4606   void *cls,
   4607   const struct TALER_MERCHANT_HttpResponse *hr);
   4608 
   4609 
   4610 /**
   4611  * Delete an incoming wire transfer at an instance of a backend. This
   4612  * will only succeed if the exchange did not respond to the inquiry
   4613  * about the transfer.
   4614  *
   4615  * @param ctx the context
   4616  * @param backend_url HTTP base URL for the backend (top-level "default" instance
   4617  *                    or base URL of an instance if @a instance_id is NULL)
   4618  * @param wire_transfer_serial unique number that identifies the transfer
   4619  * @param td_cb function to call with the backend's result
   4620  * @param td_cb_cls closure for @a td_cb
   4621  * @return the request handle; NULL upon error
   4622  */
   4623 struct TALER_MERCHANT_TransferDeleteHandle *
   4624 TALER_MERCHANT_transfer_delete (
   4625   struct GNUNET_CURL_Context *ctx,
   4626   const char *backend_url,
   4627   uint64_t wire_transfer_serial,
   4628   TALER_MERCHANT_TransferDeleteCallback td_cb,
   4629   void *td_cb_cls);
   4630 
   4631 
   4632 /**
   4633  * Cancel deletion operation. Note that the operation may still
   4634  * succeed.
   4635  *
   4636  * @param tdh operation to cancel
   4637  */
   4638 void
   4639 TALER_MERCHANT_transfer_delete_cancel (
   4640   struct TALER_MERCHANT_TransferDeleteHandle *tdh);
   4641 
   4642 
   4643 /**
   4644  * @brief Handle to a GET /transfers operation at a merchant's backend.
   4645  */
   4646 struct TALER_MERCHANT_GetTransfersHandle;
   4647 
   4648 /**
   4649  * Information about the _total_ amount that was paid back
   4650  * by the exchange for a given h_contract_terms, by _one_ wire
   4651  * transfer.
   4652  */
   4653 struct TALER_MERCHANT_TransferData
   4654 {
   4655 
   4656   /**
   4657    * Total amount wired by the exchange (without wire fee)
   4658    */
   4659   struct TALER_Amount credit_amount;
   4660 
   4661   /**
   4662    * Wire transfer identifier used.
   4663    */
   4664   struct TALER_WireTransferIdentifierRawP wtid;
   4665 
   4666   /**
   4667    * URI of the target account.
   4668    */
   4669   struct TALER_FullPayto payto_uri;
   4670 
   4671   /**
   4672    * URL of the exchange that made the transfer.
   4673    */
   4674   const char *exchange_url;
   4675 
   4676   /**
   4677    * Serial number of the credit operation in the merchant backend.
   4678    * Needed, for example, to delete the transfer using
   4679    * #TALER_MERCHANT_transfer_delete().
   4680    */
   4681   uint64_t credit_serial;
   4682 
   4683   /**
   4684    * Time of the wire transfer, based on when we received
   4685    * a confirmation for the wire transfer.
   4686    */
   4687   struct GNUNET_TIME_Timestamp execution_time;
   4688 
   4689   /**
   4690    * True if this wire transfer was expected.
   4691    */
   4692   bool expected;
   4693 
   4694 };
   4695 
   4696 
   4697 /**
   4698  * Response from a GET /transfers request.
   4699  */
   4700 struct TALER_MERCHANT_GetTransfersResponse
   4701 {
   4702   /**
   4703    * HTTP response details
   4704    */
   4705   struct TALER_MERCHANT_HttpResponse hr;
   4706 
   4707   /**
   4708    * Details depending on HTTP status.
   4709    */
   4710   union
   4711   {
   4712 
   4713     /**
   4714      * Details for status #MHD_HTTP_OK.
   4715      */
   4716     struct
   4717     {
   4718 
   4719       /**
   4720        * length of the @e transfers array
   4721        */
   4722       unsigned int transfers_length;
   4723 
   4724       /**
   4725        * array with details about the transfers we received
   4726        */
   4727       const struct TALER_MERCHANT_TransferData *transfers;
   4728     } ok;
   4729   } details;
   4730 };
   4731 
   4732 
   4733 /**
   4734  * Callbacks of this type are used to work the result of submitting a
   4735  * GET /transfers request to a merchant
   4736  *
   4737  * @param cls closure
   4738  * @param gtr HTTP response details
   4739  */
   4740 typedef void
   4741 (*TALER_MERCHANT_GetTransfersCallback) (
   4742   void *cls,
   4743   const struct TALER_MERCHANT_GetTransfersResponse *gtr);
   4744 
   4745 
   4746 /**
   4747  * Request backend to return list of all wire transfers that
   4748  * we received.
   4749  *
   4750  * @param ctx execution context
   4751  * @param backend_url base URL of the backend
   4752  * @param payto_uri filter by this credit account of the merchant
   4753  * @param before limit to transactions before this timestamp, use
   4754  *                 #GNUNET_TIME_UNIT_FOREVER_ABS to not filter by @a before
   4755  * @param after limit to transactions after this timestamp, use
   4756  *                 #GNUNET_TIME_UNIT_ZERO_ABS to not filter by @a after
   4757  * @param limit return at most this number of results; negative to descend in execution time
   4758  * @param offset start at this "credit serial" number (exclusive)
   4759  * @param expected filter results by expectation status
   4760  * @param cb the callback to call when a reply for this request is available
   4761  * @param cb_cls closure for @a cb
   4762  * @return a handle for this request
   4763  */
   4764 struct TALER_MERCHANT_GetTransfersHandle *
   4765 TALER_MERCHANT_transfers_get (
   4766   struct GNUNET_CURL_Context *ctx,
   4767   const char *backend_url,
   4768   struct TALER_FullPayto payto_uri,
   4769   const struct GNUNET_TIME_Timestamp before,
   4770   const struct GNUNET_TIME_Timestamp after,
   4771   int64_t limit,
   4772   uint64_t offset,
   4773   enum TALER_EXCHANGE_YesNoAll expected,
   4774   TALER_MERCHANT_GetTransfersCallback cb,
   4775   void *cb_cls);
   4776 
   4777 
   4778 /**
   4779  * Cancel a POST /transfers request.  This function cannot be used
   4780  * on a request handle if a response is already served for it.
   4781  *
   4782  * @param gth the operation to cancel
   4783  */
   4784 void
   4785 TALER_MERCHANT_transfers_get_cancel (
   4786   struct TALER_MERCHANT_GetTransfersHandle *gth);
   4787 
   4788 
   4789 /* ********************* /kyc ************************** */
   4790 
   4791 /**
   4792  * Handle for getting the KYC status of instance(s).
   4793  */
   4794 struct TALER_MERCHANT_KycGetHandle;
   4795 
   4796 
   4797 /**
   4798  * Information about KYC actions the merchant still must perform.
   4799  */
   4800 struct TALER_MERCHANT_AccountKycRedirectDetail
   4801 {
   4802 
   4803   /**
   4804    * Access token the user needs to start a KYC process,
   4805    * all zero if a KYC auth transfer must be made first.
   4806    */
   4807   struct TALER_AccountAccessTokenP access_token;
   4808 
   4809   /**
   4810    * Base URL of the exchange this is about.
   4811    */
   4812   const char *exchange_url;
   4813 
   4814   /**
   4815    * Our bank wire account this is about.
   4816    */
   4817   struct TALER_FullPayto payto_uri;
   4818 
   4819   /**
   4820    * Array of length @e limits_array with (exposed) limits that apply to the
   4821    * account.
   4822    */
   4823   const struct TALER_EXCHANGE_AccountLimit *limits;
   4824 
   4825   /**
   4826    * Array of payto://-URIs with instructions for wire
   4827    * transfers to perform a KYC auth wire transfer for
   4828    * the given account. Needed if @e kyc_url is NULL
   4829    * and @e limits are to be passed.
   4830    */
   4831   struct TALER_FullPayto *payto_kycauths;
   4832 
   4833   /**
   4834    * Length of the @e limits array.
   4835    */
   4836   unsigned int limits_length;
   4837 
   4838   /**
   4839    * Length of the @e payto_kycauths array.
   4840    */
   4841   unsigned int pkycauth_length;
   4842 
   4843   /**
   4844    * HTTP status code returned by the exchange when we asked for
   4845    * information about the KYC status.
   4846    * 0 if there was no response at all.
   4847    */
   4848   unsigned int exchange_http_status;
   4849 
   4850   /**
   4851    * Error code indicating errors the exchange
   4852    * returned, or #TALER_EC_NONE for none.
   4853    */
   4854   enum TALER_ErrorCode exchange_code;
   4855 
   4856   /**
   4857    * Set to true if @e access_token was not given.
   4858    */
   4859   bool no_access_token;
   4860 
   4861   /**
   4862    * Set to true if the merchant backend could not
   4863    * get the exchanges ``/keys`` and thus could not
   4864    * determine default limits or determine an
   4865    * @e auth_conflict.
   4866    */
   4867   bool no_keys;
   4868 
   4869   /**
   4870    * Set to true if the given account cannot to KYC at the given exchange
   4871    * because no wire method exists that could be used to do the KYC auth wire
   4872    * transfer.
   4873    */
   4874   bool auth_conflict;
   4875 };
   4876 
   4877 
   4878 /**
   4879  * Details in a response to a GET /kyc request.
   4880  */
   4881 struct TALER_MERCHANT_KycResponse
   4882 {
   4883   /**
   4884    * HTTP response details.
   4885    */
   4886   struct TALER_MERCHANT_HttpResponse hr;
   4887 
   4888   /**
   4889    * Response details depending on the HTTP status.
   4890    */
   4891   union
   4892   {
   4893     /**
   4894      * Information returned if the status was #MHD_HTTP_OK.
   4895      */
   4896     struct
   4897     {
   4898 
   4899       /**
   4900        * Array with information about KYC actions the merchant may perform.
   4901        */
   4902       struct TALER_MERCHANT_AccountKycRedirectDetail *kycs;
   4903 
   4904       /**
   4905        * Length of the @e pending_kycs array.
   4906        */
   4907       unsigned int kycs_length;
   4908 
   4909     } ok;
   4910 
   4911   } details;
   4912 
   4913 };
   4914 
   4915 
   4916 /**
   4917  * Callback to with a response from a GET [/private]/kyc request
   4918  *
   4919  * @param cls closure
   4920  * @param kr response details
   4921  */
   4922 typedef void
   4923 (*TALER_MERCHANT_KycGetCallback) (
   4924   void *cls,
   4925   const struct TALER_MERCHANT_KycResponse *kr);
   4926 
   4927 
   4928 /**
   4929  * Issue a GET /private/kycs/$KYC_ID (private variant) request to the backend.
   4930  * Returns KYC status of bank accounts.
   4931  *
   4932  * @param ctx execution context
   4933  * @param backend_url base URL of the merchant backend
   4934  * @param h_wire which bank account to query, NULL for all
   4935  * @param exchange_url which exchange to query, NULL for all
   4936  * @param lpt target for long polling
   4937  * @param timeout how long to wait for an answer, including possibly long polling for the desired @a lpt status;
   4938  *    note that when pulling for multiple accounts, any
   4939  *    account reaching this status will cause the
   4940  *    response to be returned
   4941  * @param cb function to call with the result
   4942  * @param cb_cls closure for @a cb
   4943  * @return handle for this operation, NULL upon errors
   4944  */
   4945 struct TALER_MERCHANT_KycGetHandle *
   4946 TALER_MERCHANT_kyc_get (
   4947   struct GNUNET_CURL_Context *ctx,
   4948   const char *backend_url,
   4949   const struct TALER_MerchantWireHashP *h_wire,
   4950   const char *exchange_url,
   4951   enum TALER_EXCHANGE_KycLongPollTarget lpt,
   4952   struct GNUNET_TIME_Relative timeout,
   4953   TALER_MERCHANT_KycGetCallback cb,
   4954   void *cb_cls);
   4955 
   4956 
   4957 /**
   4958  * Issue a GET /management/instances/$INSTANCE/kyc request to the backend.
   4959  * Returns KYC status of bank accounts.
   4960  *
   4961  * @param ctx execution context
   4962  * @param backend_url base URL of the merchant backend
   4963  * @param instance_id specific instance to query
   4964  * @param h_wire which bank account to query, NULL for all
   4965  * @param exchange_url which exchange to query, NULL for all
   4966  * @param lpt target for long polling
   4967  * @param timeout how long to wait for a reply
   4968  * @param cb function to call with the result
   4969  * @param cb_cls closure for @a cb
   4970  * @return handle for this operation, NULL upon errors
   4971  */
   4972 struct TALER_MERCHANT_KycGetHandle *
   4973 TALER_MERCHANT_management_kyc_get (
   4974   struct GNUNET_CURL_Context *ctx,
   4975   const char *backend_url,
   4976   const char *instance_id,
   4977   const struct TALER_MerchantWireHashP *h_wire,
   4978   const char *exchange_url,
   4979   enum TALER_EXCHANGE_KycLongPollTarget lpt,
   4980   struct GNUNET_TIME_Relative timeout,
   4981   TALER_MERCHANT_KycGetCallback cb,
   4982   void *cb_cls);
   4983 
   4984 
   4985 /**
   4986  * Cancel a GET [/private]/kyc/$KYC_ID request.
   4987  *
   4988  * @param kyc handle to the request to be canceled
   4989  */
   4990 void
   4991 TALER_MERCHANT_kyc_get_cancel (
   4992   struct TALER_MERCHANT_KycGetHandle *kyc);
   4993 
   4994 
   4995 /* ********************* /otp-devices *********************** */
   4996 
   4997 
   4998 /**
   4999  * Handle for a GET /otp-devices operation.
   5000  */
   5001 struct TALER_MERCHANT_OtpDevicesGetHandle;
   5002 
   5003 /**
   5004  * Individual OTP device (minimal information
   5005  * returned via GET /otp-devices).
   5006  */
   5007 struct TALER_MERCHANT_OtpDeviceEntry
   5008 {
   5009   /**
   5010    * OTP device identifier.
   5011    */
   5012   const char *otp_device_id;
   5013 
   5014   /**
   5015    * OTP device description.
   5016    */
   5017   const char *device_description;
   5018 
   5019 };
   5020 
   5021 
   5022 /**
   5023  * Response to a GET /otp-devices operation.
   5024  */
   5025 struct TALER_MERCHANT_OtpDevicesGetResponse
   5026 {
   5027   /**
   5028    * HTTP response details
   5029    */
   5030   struct TALER_MERCHANT_HttpResponse hr;
   5031 
   5032   /**
   5033    * Details depending on status.
   5034    */
   5035   union
   5036   {
   5037     /**
   5038      * Details if status is #MHD_HTTP_OK.
   5039      */
   5040     struct
   5041     {
   5042       /**
   5043        * length of the @e otp_devices array
   5044        */
   5045       unsigned int otp_devices_length;
   5046 
   5047       /**
   5048        * array of otp_devices the requested instance offers
   5049        */
   5050       const struct TALER_MERCHANT_OtpDeviceEntry *otp_devices;
   5051     } ok;
   5052   } details;
   5053 };
   5054 
   5055 
   5056 /**
   5057  * Function called with the result of the GET /otp-devices operation.
   5058  *
   5059  * @param cls closure
   5060  * @param tgr response details
   5061  */
   5062 typedef void
   5063 (*TALER_MERCHANT_OtpDevicesGetCallback)(
   5064   void *cls,
   5065   const struct TALER_MERCHANT_OtpDevicesGetResponse *tgr);
   5066 
   5067 
   5068 /**
   5069  * Make a GET /otp-devices request.
   5070  *
   5071  * @param ctx the context
   5072  * @param backend_url HTTP base URL for the backend
   5073  * @param cb function to call with the backend information
   5074  * @param cb_cls closure for @a cb
   5075  * @return the request handle; NULL upon error
   5076  */
   5077 struct TALER_MERCHANT_OtpDevicesGetHandle *
   5078 TALER_MERCHANT_otp_devices_get (
   5079   struct GNUNET_CURL_Context *ctx,
   5080   const char *backend_url,
   5081   TALER_MERCHANT_OtpDevicesGetCallback cb,
   5082   void *cb_cls);
   5083 
   5084 
   5085 /**
   5086  * Cancel GET /otp-devices operation.
   5087  *
   5088  * @param tgh operation to cancel
   5089  */
   5090 void
   5091 TALER_MERCHANT_otp_devices_get_cancel (
   5092   struct TALER_MERCHANT_OtpDevicesGetHandle *tgh);
   5093 
   5094 
   5095 /**
   5096  * Handle for a GET /otp-device/$ID operation. Gets details
   5097  * about a single otp_device. Do not confused with a
   5098  * `struct TALER_MERCHANT_OtpDevicesGetHandle`, which
   5099  * obtains a list of all otp_devices.
   5100  */
   5101 struct TALER_MERCHANT_OtpDeviceGetHandle;
   5102 
   5103 
   5104 /**
   5105  * Details in a response to a GET /otp-devices request.
   5106  */
   5107 struct TALER_MERCHANT_OtpDeviceGetResponse
   5108 {
   5109   /**
   5110    * HTTP response details.
   5111    */
   5112   struct TALER_MERCHANT_HttpResponse hr;
   5113 
   5114   /**
   5115    * Response details depending on the HTTP status.
   5116    */
   5117   union
   5118   {
   5119     /**
   5120      * Information returned if the status was #MHD_HTTP_OK.
   5121      */
   5122     struct
   5123     {
   5124 
   5125       /**
   5126        * description of the otp_device
   5127        */
   5128       const char *otp_device_description;
   5129 
   5130       /**
   5131        * POS confirmation text with OTP codes that
   5132        * would be returned for a purchase over the
   5133        * amount given in the query for the respective
   5134        * time and algorithm. NULL if the confirmation
   5135        * could not be computed based on the query and
   5136        * OTP algorithm.
   5137        */
   5138       const char *otp_code;
   5139 
   5140       /**
   5141        * current counter.
   5142        */
   5143       uint64_t otp_ctr;
   5144 
   5145       /**
   5146        * OTP algorithm used.
   5147        */
   5148       enum TALER_MerchantConfirmationAlgorithm otp_alg;
   5149 
   5150       /**
   5151        * Timestamp in second used to compute
   5152        * @e otp_code.
   5153        */
   5154       uint64_t otp_timestamp_s;
   5155 
   5156     } ok;
   5157 
   5158   } details;
   5159 
   5160 };
   5161 
   5162 
   5163 /**
   5164  * Function called with the result of the GET /otp-device/$ID operation.
   5165  *
   5166  * @param cls closure
   5167  * @param tgr HTTP response details
   5168  */
   5169 typedef void
   5170 (*TALER_MERCHANT_OtpDeviceGetCallback)(
   5171   void *cls,
   5172   const struct TALER_MERCHANT_OtpDeviceGetResponse *tgr);
   5173 
   5174 
   5175 /**
   5176  * Make a GET /otp-device/$ID request to get details about an
   5177  * individual OTP device.
   5178  *
   5179  * @param ctx the context
   5180  * @param backend_url HTTP base URL for the backend
   5181  * @param otp_device_id identifier of the otp_device to inquire about
   5182  * @param cb function to call with the backend's otp_device information
   5183  * @param cb_cls closure for @a cb
   5184  * @return the request handle; NULL upon error
   5185  */
   5186 struct TALER_MERCHANT_OtpDeviceGetHandle *
   5187 TALER_MERCHANT_otp_device_get (
   5188   struct GNUNET_CURL_Context *ctx,
   5189   const char *backend_url,
   5190   const char *otp_device_id,
   5191   TALER_MERCHANT_OtpDeviceGetCallback cb,
   5192   void *cb_cls);
   5193 
   5194 
   5195 /**
   5196  * Cancel GET /otp-devices/$ID operation.
   5197  *
   5198  * @param tgh operation to cancel
   5199  */
   5200 void
   5201 TALER_MERCHANT_otp_device_get_cancel (
   5202   struct TALER_MERCHANT_OtpDeviceGetHandle *tgh);
   5203 
   5204 
   5205 /**
   5206  * Handle for a POST /otp-devices operation.
   5207  */
   5208 struct TALER_MERCHANT_OtpDevicesPostHandle;
   5209 
   5210 
   5211 /**
   5212  * Function called with the result of the POST /otp-devices operation.
   5213  *
   5214  * @param cls closure
   5215  * @param hr HTTP response details
   5216  */
   5217 typedef void
   5218 (*TALER_MERCHANT_OtpDevicesPostCallback)(
   5219   void *cls,
   5220   const struct TALER_MERCHANT_HttpResponse *hr);
   5221 
   5222 
   5223 /**
   5224  * Make a POST /otp-devices request to add an OTP device
   5225  *
   5226  * @param ctx the context
   5227  * @param backend_url HTTP base URL for the backend
   5228  * @param otp_id identifier to use for the OTP device
   5229  * @param otp_device_description description of the OTP device
   5230  * @param otp_key key of the OTP device
   5231  * @param otp_alg OTP algorithm used
   5232  * @param otp_ctr counter for counter-based OTP
   5233  * @param cb function to call with the backend's result
   5234  * @param cb_cls closure for @a cb
   5235  * @return the request handle; NULL upon error
   5236  */
   5237 struct TALER_MERCHANT_OtpDevicesPostHandle *
   5238 TALER_MERCHANT_otp_devices_post (
   5239   struct GNUNET_CURL_Context *ctx,
   5240   const char *backend_url,
   5241   const char *otp_id,
   5242   const char *otp_device_description,
   5243   const char *otp_key,
   5244   enum TALER_MerchantConfirmationAlgorithm otp_alg,
   5245   uint64_t otp_ctr,
   5246   TALER_MERCHANT_OtpDevicesPostCallback cb,
   5247   void *cb_cls);
   5248 
   5249 
   5250 /**
   5251  * Cancel POST /otp-devices operation.
   5252  *
   5253  * @param[in] tph operation to cancel
   5254  */
   5255 void
   5256 TALER_MERCHANT_otp_devices_post_cancel (
   5257   struct TALER_MERCHANT_OtpDevicesPostHandle *tph);
   5258 
   5259 
   5260 /**
   5261  * Handle for a PATCH /otp-device operation.
   5262  */
   5263 struct TALER_MERCHANT_OtpDevicePatchHandle;
   5264 
   5265 
   5266 /**
   5267  * Function called with the result of the PATCH /otp-device operation.
   5268  *
   5269  * @param cls closure
   5270  * @param hr HTTP response details
   5271  */
   5272 typedef void
   5273 (*TALER_MERCHANT_OtpDevicePatchCallback)(
   5274   void *cls,
   5275   const struct TALER_MERCHANT_HttpResponse *hr);
   5276 
   5277 
   5278 /**
   5279  * Make a PATCH /otp-device request to update OTP device details
   5280  *
   5281  * @param ctx the context
   5282  * @param backend_url HTTP base URL for the backend
   5283  * @param otp_id identifier to use for the OTP device; the OTP device must exist,
   5284  *                    or the transaction will fail with a #MHD_HTTP_NOT_FOUND
   5285  *                    HTTP status code
   5286  * @param otp_device_description description of the otp_device
   5287  * @param otp_key key of the OTP device
   5288  * @param otp_alg OTP algorithm used
   5289  * @param otp_ctr counter for counter-based OTP
   5290  * @param cb function to call with the backend's result
   5291  * @param cb_cls closure for @a cb
   5292  * @return the request handle; NULL upon error
   5293  */
   5294 struct TALER_MERCHANT_OtpDevicePatchHandle *
   5295 TALER_MERCHANT_otp_device_patch (
   5296   struct GNUNET_CURL_Context *ctx,
   5297   const char *backend_url,
   5298   const char *otp_id,
   5299   const char *otp_device_description,
   5300   const char *otp_key,
   5301   enum TALER_MerchantConfirmationAlgorithm otp_alg,
   5302   uint64_t otp_ctr,
   5303   TALER_MERCHANT_OtpDevicePatchCallback cb,
   5304   void *cb_cls);
   5305 
   5306 
   5307 /**
   5308  * Cancel PATCH /otp-device operation.
   5309  *
   5310  * @param[in] tph operation to cancel
   5311  */
   5312 void
   5313 TALER_MERCHANT_otp_device_patch_cancel (
   5314   struct TALER_MERCHANT_OtpDevicePatchHandle *tph);
   5315 
   5316 
   5317 /**
   5318  * Handle for a DELETE /otp-device/$ID operation.
   5319  */
   5320 struct TALER_MERCHANT_OtpDeviceDeleteHandle;
   5321 
   5322 
   5323 /**
   5324  * Function called with the result of the DELETE /otp-device/$ID operation.
   5325  *
   5326  * @param cls closure
   5327  * @param hr HTTP response details
   5328  */
   5329 typedef void
   5330 (*TALER_MERCHANT_OtpDeviceDeleteCallback)(
   5331   void *cls,
   5332   const struct TALER_MERCHANT_HttpResponse *hr);
   5333 
   5334 
   5335 /**
   5336  * Make a DELETE /otp-device/$ID request to delete an OTP device.
   5337  *
   5338  * @param ctx the context
   5339  * @param backend_url HTTP base URL for the backend
   5340  * @param otp_device_id identifier of the OTP device
   5341  * @param cb function to call with the backend's deletion status
   5342  * @param cb_cls closure for @a cb
   5343  * @return the request handle; NULL upon error
   5344  */
   5345 struct TALER_MERCHANT_OtpDeviceDeleteHandle *
   5346 TALER_MERCHANT_otp_device_delete (
   5347   struct GNUNET_CURL_Context *ctx,
   5348   const char *backend_url,
   5349   const char *otp_device_id,
   5350   TALER_MERCHANT_OtpDeviceDeleteCallback cb,
   5351   void *cb_cls);
   5352 
   5353 
   5354 /**
   5355  * Cancel DELETE /otp-device/$ID operation.
   5356  *
   5357  * @param[in] tdh operation to cancel
   5358  */
   5359 void
   5360 TALER_MERCHANT_otp_device_delete_cancel (
   5361   struct TALER_MERCHANT_OtpDeviceDeleteHandle *tdh);
   5362 
   5363 
   5364 /* ********************* /units *********************** */
   5365 
   5366 struct TALER_MERCHANT_UnitEntry
   5367 {
   5368   const char *unit;
   5369   const char *unit_name_long;
   5370   const char *unit_name_short;
   5371   const json_t *unit_name_long_i18n;
   5372   const json_t *unit_name_short_i18n;
   5373   bool unit_allow_fraction;
   5374   uint32_t unit_precision_level;
   5375   bool unit_active;
   5376   bool unit_builtin;
   5377 };
   5378 
   5379 struct TALER_MERCHANT_UnitsGetResponse
   5380 {
   5381   struct TALER_MERCHANT_HttpResponse hr;
   5382   union
   5383   {
   5384     struct
   5385     {
   5386       struct TALER_MERCHANT_UnitEntry *units;
   5387       unsigned int units_length;
   5388     } ok;
   5389   } details;
   5390 };
   5391 
   5392 struct TALER_MERCHANT_UnitGetResponse
   5393 {
   5394   struct TALER_MERCHANT_HttpResponse hr;
   5395   union
   5396   {
   5397     struct
   5398     {
   5399       struct TALER_MERCHANT_UnitEntry unit;
   5400     } ok;
   5401   } details;
   5402 };
   5403 
   5404 typedef void
   5405 (*TALER_MERCHANT_UnitsGetCallback)(
   5406   void *cls,
   5407   const struct TALER_MERCHANT_UnitsGetResponse *ugr);
   5408 
   5409 typedef void
   5410 (*TALER_MERCHANT_UnitGetCallback)(
   5411   void *cls,
   5412   const struct TALER_MERCHANT_UnitGetResponse *ugr);
   5413 
   5414 typedef void
   5415 (*TALER_MERCHANT_UnitsPostCallback)(
   5416   void *cls,
   5417   const struct TALER_MERCHANT_HttpResponse *hr);
   5418 
   5419 typedef void
   5420 (*TALER_MERCHANT_UnitPatchCallback)(
   5421   void *cls,
   5422   const struct TALER_MERCHANT_HttpResponse *hr);
   5423 
   5424 typedef void
   5425 (*TALER_MERCHANT_UnitDeleteCallback)(
   5426   void *cls,
   5427   const struct TALER_MERCHANT_HttpResponse *hr);
   5428 
   5429 struct TALER_MERCHANT_UnitsGetHandle;
   5430 struct TALER_MERCHANT_UnitGetHandle;
   5431 struct TALER_MERCHANT_UnitsPostHandle;
   5432 struct TALER_MERCHANT_UnitPatchHandle;
   5433 struct TALER_MERCHANT_UnitDeleteHandle;
   5434 
   5435 struct TALER_MERCHANT_UnitsGetHandle *
   5436 TALER_MERCHANT_units_get (struct GNUNET_CURL_Context *ctx,
   5437                           const char *backend_url,
   5438                           TALER_MERCHANT_UnitsGetCallback cb,
   5439                           void *cb_cls);
   5440 
   5441 void
   5442 TALER_MERCHANT_units_get_cancel (
   5443   struct TALER_MERCHANT_UnitsGetHandle *ugh);
   5444 
   5445 struct TALER_MERCHANT_UnitGetHandle *
   5446 TALER_MERCHANT_unit_get (struct GNUNET_CURL_Context *ctx,
   5447                          const char *backend_url,
   5448                          const char *unit_id,
   5449                          TALER_MERCHANT_UnitGetCallback cb,
   5450                          void *cb_cls);
   5451 
   5452 void
   5453 TALER_MERCHANT_unit_get_cancel (
   5454   struct TALER_MERCHANT_UnitGetHandle *ugh);
   5455 
   5456 struct TALER_MERCHANT_UnitsPostHandle *
   5457 TALER_MERCHANT_units_post (struct GNUNET_CURL_Context *ctx,
   5458                            const char *backend_url,
   5459                            const char *unit_id,
   5460                            const char *unit_name_long,
   5461                            const char *unit_name_short,
   5462                            bool unit_allow_fraction,
   5463                            uint32_t unit_precision_level,
   5464                            bool unit_active,
   5465                            const json_t *unit_name_long_i18n,
   5466                            const json_t *unit_name_short_i18n,
   5467                            TALER_MERCHANT_UnitsPostCallback cb,
   5468                            void *cb_cls);
   5469 
   5470 void
   5471 TALER_MERCHANT_units_post_cancel (
   5472   struct TALER_MERCHANT_UnitsPostHandle *uph);
   5473 
   5474 struct TALER_MERCHANT_UnitPatchHandle *
   5475 TALER_MERCHANT_unit_patch (struct GNUNET_CURL_Context *ctx,
   5476                            const char *backend_url,
   5477                            const char *unit_id,
   5478                            const char *unit_name_long,
   5479                            const char *unit_name_short,
   5480                            const json_t *unit_name_long_i18n,
   5481                            const json_t *unit_name_short_i18n,
   5482                            const bool *unit_allow_fraction,
   5483                            const uint32_t *unit_precision_level,
   5484                            const bool *unit_active,
   5485                            TALER_MERCHANT_UnitPatchCallback cb,
   5486                            void *cb_cls);
   5487 
   5488 void
   5489 TALER_MERCHANT_unit_patch_cancel (
   5490   struct TALER_MERCHANT_UnitPatchHandle *uph);
   5491 
   5492 struct TALER_MERCHANT_UnitDeleteHandle *
   5493 TALER_MERCHANT_unit_delete (struct GNUNET_CURL_Context *ctx,
   5494                             const char *backend_url,
   5495                             const char *unit_id,
   5496                             TALER_MERCHANT_UnitDeleteCallback cb,
   5497                             void *cb_cls);
   5498 
   5499 void
   5500 TALER_MERCHANT_unit_delete_cancel (
   5501   struct TALER_MERCHANT_UnitDeleteHandle *udh);
   5502 
   5503 
   5504 /* ********************* /templates *********************** */
   5505 
   5506 
   5507 /**
   5508  * Handle for a GET /templates operation.
   5509  */
   5510 struct TALER_MERCHANT_TemplatesGetHandle;
   5511 
   5512 /**
   5513  * Individual template (minimal information
   5514  * returned via GET /templates).
   5515  */
   5516 struct TALER_MERCHANT_TemplateEntry
   5517 {
   5518   /**
   5519    * template identifier.
   5520    */
   5521   const char *template_id;
   5522 
   5523 };
   5524 
   5525 
   5526 /**
   5527  * Response to a GET /templates operation.
   5528  */
   5529 struct TALER_MERCHANT_TemplatesGetResponse
   5530 {
   5531   /**
   5532    * HTTP response details
   5533    */
   5534   struct TALER_MERCHANT_HttpResponse hr;
   5535 
   5536   /**
   5537    * Details depending on status.
   5538    */
   5539   union
   5540   {
   5541     /**
   5542      * Details if status is #MHD_HTTP_OK.
   5543      */
   5544     struct
   5545     {
   5546       /**
   5547        * length of the @e templates array
   5548        */
   5549       unsigned int templates_length;
   5550 
   5551       /**
   5552        * array of templates the requested instance offers
   5553        */
   5554       const struct TALER_MERCHANT_TemplateEntry *templates;
   5555     } ok;
   5556   } details;
   5557 };
   5558 
   5559 
   5560 /**
   5561  * Function called with the result of the GET /templates operation.
   5562  *
   5563  * @param cls closure
   5564  * @param tgr response details
   5565  */
   5566 typedef void
   5567 (*TALER_MERCHANT_TemplatesGetCallback)(
   5568   void *cls,
   5569   const struct TALER_MERCHANT_TemplatesGetResponse *tgr);
   5570 
   5571 
   5572 /**
   5573  * Make a GET /templates request.
   5574  *
   5575  * @param ctx the context
   5576  * @param backend_url HTTP base URL for the backend
   5577  * @param cb function to call with the backend information
   5578  * @param cb_cls closure for @a cb
   5579  * @return the request handle; NULL upon error
   5580  */
   5581 struct TALER_MERCHANT_TemplatesGetHandle *
   5582 TALER_MERCHANT_templates_get (
   5583   struct GNUNET_CURL_Context *ctx,
   5584   const char *backend_url,
   5585   TALER_MERCHANT_TemplatesGetCallback cb,
   5586   void *cb_cls);
   5587 
   5588 
   5589 /**
   5590  * Cancel GET /templates operation.
   5591  *
   5592  * @param tgh operation to cancel
   5593  */
   5594 void
   5595 TALER_MERCHANT_templates_get_cancel (
   5596   struct TALER_MERCHANT_TemplatesGetHandle *tgh);
   5597 
   5598 
   5599 /**
   5600  * Handle for a GET /private/template/$ID operation. Gets details
   5601  * about a single template. Do not confused with a
   5602  * `struct TALER_MERCHANT_TemplatesGetHandle`, which
   5603  * obtains a list of all templates.
   5604  */
   5605 struct TALER_MERCHANT_TemplateGetHandle;
   5606 
   5607 
   5608 /**
   5609  * Details in a response to a GET /private/templates/$ID request.
   5610  */
   5611 struct TALER_MERCHANT_TemplateGetResponse
   5612 {
   5613   /**
   5614    * HTTP response details.
   5615    */
   5616   struct TALER_MERCHANT_HttpResponse hr;
   5617 
   5618   /**
   5619    * Response details depending on the HTTP status.
   5620    */
   5621   union
   5622   {
   5623     /**
   5624      * Information returned if the status was #MHD_HTTP_OK.
   5625      */
   5626     struct
   5627     {
   5628 
   5629       /**
   5630        * description of the template
   5631        */
   5632       const char *template_description;
   5633 
   5634       /**
   5635        * OTP device ID used by the POS, NULL if none.
   5636        */
   5637       const char *otp_id;
   5638 
   5639       /**
   5640        * Template for the contract.
   5641        */
   5642       const json_t *template_contract;
   5643 
   5644     } ok;
   5645 
   5646   } details;
   5647 
   5648 };
   5649 
   5650 
   5651 /**
   5652  * Function called with the result of the GET /private/template/$ID operation.
   5653  *
   5654  * @param cls closure
   5655  * @param tgr HTTP response details
   5656  */
   5657 typedef void
   5658 (*TALER_MERCHANT_TemplateGetCallback)(
   5659   void *cls,
   5660   const struct TALER_MERCHANT_TemplateGetResponse *tgr);
   5661 
   5662 
   5663 /**
   5664  * Make a GET /private/template/$ID request to get details about an
   5665  * individual template.
   5666  *
   5667  * @param ctx the context
   5668  * @param backend_url HTTP base URL for the backend
   5669  * @param template_id identifier of the template to inquire about
   5670  * @param cb function to call with the backend's template information
   5671  * @param cb_cls closure for @a cb
   5672  * @return the request handle; NULL upon error
   5673  */
   5674 struct TALER_MERCHANT_TemplateGetHandle *
   5675 TALER_MERCHANT_template_get (
   5676   struct GNUNET_CURL_Context *ctx,
   5677   const char *backend_url,
   5678   const char *template_id,
   5679   TALER_MERCHANT_TemplateGetCallback cb,
   5680   void *cb_cls);
   5681 
   5682 
   5683 /**
   5684  * Cancel GET /private/templates/$ID operation.
   5685  *
   5686  * @param tgh operation to cancel
   5687  */
   5688 void
   5689 TALER_MERCHANT_template_get_cancel (
   5690   struct TALER_MERCHANT_TemplateGetHandle *tgh);
   5691 
   5692 
   5693 /**
   5694  * Handle for a (public) GET /template/$ID operation. Gets details about a
   5695  * single template. Do not confused with a `struct
   5696  * TALER_MERCHANT_TemplateGetHandle`, which is for the private API.
   5697  */
   5698 struct TALER_MERCHANT_WalletTemplateGetHandle;
   5699 
   5700 
   5701 /**
   5702  * Details in a response to a GET /templates request.
   5703  */
   5704 struct TALER_MERCHANT_WalletTemplateGetResponse
   5705 {
   5706   /**
   5707    * HTTP response details.
   5708    */
   5709   struct TALER_MERCHANT_HttpResponse hr;
   5710 
   5711   /**
   5712    * Response details depending on the HTTP status.
   5713    */
   5714   union
   5715   {
   5716     /**
   5717      * Information returned if the status was #MHD_HTTP_OK.
   5718      */
   5719     struct
   5720     {
   5721 
   5722       /**
   5723        * Template for the contract.
   5724        */
   5725       const json_t *template_contract;
   5726 
   5727     } ok;
   5728 
   5729   } details;
   5730 
   5731 };
   5732 
   5733 
   5734 /**
   5735  * Function called with the result of the GET /template/$ID operation.
   5736  *
   5737  * @param cls closure
   5738  * @param tgr HTTP response details
   5739  */
   5740 typedef void
   5741 (*TALER_MERCHANT_WalletTemplateGetCallback)(
   5742   void *cls,
   5743   const struct TALER_MERCHANT_WalletTemplateGetResponse *tgr);
   5744 
   5745 
   5746 /**
   5747  * Make a GET /template/$ID request to get details about an
   5748  * individual template.
   5749  *
   5750  * @param ctx the context
   5751  * @param backend_url HTTP base URL for the backend
   5752  * @param template_id identifier of the template to inquire about
   5753  * @param cb function to call with the backend's template information
   5754  * @param cb_cls closure for @a cb
   5755  * @return the request handle; NULL upon error
   5756  */
   5757 struct TALER_MERCHANT_WalletTemplateGetHandle *
   5758 TALER_MERCHANT_wallet_template_get (
   5759   struct GNUNET_CURL_Context *ctx,
   5760   const char *backend_url,
   5761   const char *template_id,
   5762   TALER_MERCHANT_WalletTemplateGetCallback cb,
   5763   void *cb_cls);
   5764 
   5765 
   5766 /**
   5767  * Cancel GET /templates/$ID operation.
   5768  *
   5769  * @param tgh operation to cancel
   5770  */
   5771 void
   5772 TALER_MERCHANT_wallet_template_get_cancel (
   5773   struct TALER_MERCHANT_WalletTemplateGetHandle *tgh);
   5774 
   5775 
   5776 /**
   5777  * Handle for a POST /templates operation.
   5778  */
   5779 struct TALER_MERCHANT_TemplatesPostHandle;
   5780 
   5781 
   5782 /**
   5783  * Function called with the result of the POST /templates operation.
   5784  *
   5785  * @param cls closure
   5786  * @param hr HTTP response details
   5787  */
   5788 typedef void
   5789 (*TALER_MERCHANT_TemplatesPostCallback)(
   5790   void *cls,
   5791   const struct TALER_MERCHANT_HttpResponse *hr);
   5792 
   5793 
   5794 /**
   5795  * Make a POST /templates request to add a template
   5796  *
   5797  * @param ctx the context
   5798  * @param backend_url HTTP base URL for the backend
   5799  * @param template_id identifier to use for the template
   5800  * @param template_description description of the template
   5801  * @param otp_id ID of the OTP device, or NULL if OTP is not used
   5802  * @param template_contract is the contract of the company
   5803  * @param cb function to call with the backend's result
   5804  * @param cb_cls closure for @a cb
   5805  * @return the request handle; NULL upon error
   5806  */
   5807 struct TALER_MERCHANT_TemplatesPostHandle *
   5808 TALER_MERCHANT_templates_post (
   5809   struct GNUNET_CURL_Context *ctx,
   5810   const char *backend_url,
   5811   const char *template_id,
   5812   const char *template_description,
   5813   const char *otp_id,
   5814   const json_t *template_contract,
   5815   TALER_MERCHANT_TemplatesPostCallback cb,
   5816   void *cb_cls);
   5817 
   5818 
   5819 /**
   5820  * Cancel POST /templates operation.
   5821  *
   5822  * @param[in] tph operation to cancel
   5823  */
   5824 void
   5825 TALER_MERCHANT_templates_post_cancel (
   5826   struct TALER_MERCHANT_TemplatesPostHandle *tph);
   5827 
   5828 
   5829 /**
   5830  * Handle for a PATCH /template operation.
   5831  */
   5832 struct TALER_MERCHANT_TemplatePatchHandle;
   5833 
   5834 
   5835 /**
   5836  * Function called with the result of the PATCH /template operation.
   5837  *
   5838  * @param cls closure
   5839  * @param hr HTTP response details
   5840  */
   5841 typedef void
   5842 (*TALER_MERCHANT_TemplatePatchCallback)(
   5843   void *cls,
   5844   const struct TALER_MERCHANT_HttpResponse *hr);
   5845 
   5846 
   5847 /**
   5848  * Make a PATCH /template request to update template details
   5849  *
   5850  * @param ctx the context
   5851  * @param backend_url HTTP base URL for the backend
   5852  * @param template_id identifier to use for the template; the template must exist,
   5853  *                    or the transaction will fail with a #MHD_HTTP_NOT_FOUND
   5854  *                    HTTP status code
   5855  * @param template_description description of the template
   5856  * @param otp_id device ID of the OTP device, or NULL if OTP is not used
   5857  * @param template_contract is the contract of the company
   5858  * @param cb function to call with the backend's result
   5859  * @param cb_cls closure for @a cb
   5860  * @return the request handle; NULL upon error
   5861  */
   5862 struct TALER_MERCHANT_TemplatePatchHandle *
   5863 TALER_MERCHANT_template_patch (
   5864   struct GNUNET_CURL_Context *ctx,
   5865   const char *backend_url,
   5866   const char *template_id,
   5867   const char *template_description,
   5868   const char *otp_id,
   5869   json_t *template_contract,
   5870   TALER_MERCHANT_TemplatePatchCallback cb,
   5871   void *cb_cls);
   5872 
   5873 
   5874 /**
   5875  * Cancel PATCH /template operation.
   5876  *
   5877  * @param[in] tph operation to cancel
   5878  */
   5879 void
   5880 TALER_MERCHANT_template_patch_cancel (
   5881   struct TALER_MERCHANT_TemplatePatchHandle *tph);
   5882 
   5883 
   5884 /**
   5885  * Handle for a DELETE /template/$ID operation.
   5886  */
   5887 struct TALER_MERCHANT_TemplateDeleteHandle;
   5888 
   5889 
   5890 /**
   5891  * Function called with the result of the DELETE /template/$ID operation.
   5892  *
   5893  * @param cls closure
   5894  * @param hr HTTP response details
   5895  */
   5896 typedef void
   5897 (*TALER_MERCHANT_TemplateDeleteCallback)(
   5898   void *cls,
   5899   const struct TALER_MERCHANT_HttpResponse *hr);
   5900 
   5901 
   5902 /**
   5903  * Make a DELETE /template/$ID request to delete a template.
   5904  *
   5905  * @param ctx the context
   5906  * @param backend_url HTTP base URL for the backend
   5907  * @param template_id identifier of the template
   5908  * @param cb function to call with the backend's deletion status
   5909  * @param cb_cls closure for @a cb
   5910  * @return the request handle; NULL upon error
   5911  */
   5912 struct TALER_MERCHANT_TemplateDeleteHandle *
   5913 TALER_MERCHANT_template_delete (
   5914   struct GNUNET_CURL_Context *ctx,
   5915   const char *backend_url,
   5916   const char *template_id,
   5917   TALER_MERCHANT_TemplateDeleteCallback cb,
   5918   void *cb_cls);
   5919 
   5920 
   5921 /**
   5922  * Cancel DELETE /template/$ID operation.
   5923  *
   5924  * @param[in] tdh operation to cancel
   5925  */
   5926 void
   5927 TALER_MERCHANT_template_delete_cancel (
   5928   struct TALER_MERCHANT_TemplateDeleteHandle *tdh);
   5929 
   5930 
   5931 /**
   5932  * Make a POST /using-templates request to add an using template
   5933  *
   5934  * @param ctx the context
   5935  * @param backend_url HTTP base URL for the backend
   5936  * @param template_id which template should be used
   5937  * @param summary summary of the using template
   5938  * @param amount to pay given by the customer
   5939  * @param cb function to call with the backend's result
   5940  * @param cb_cls closure for @a cb
   5941  * @return the request handle; NULL upon error
   5942  */
   5943 struct TALER_MERCHANT_UsingTemplatesPostHandle *
   5944 TALER_MERCHANT_using_templates_post (
   5945   struct GNUNET_CURL_Context *ctx,
   5946   const char *backend_url,
   5947   const char *template_id,
   5948   const char *summary,
   5949   const struct TALER_Amount *amount,
   5950   TALER_MERCHANT_PostOrdersCallback cb,
   5951   void *cb_cls);
   5952 
   5953 
   5954 /**
   5955  * Cancel POST /using-templates operation.
   5956  *
   5957  * @param[in] utph operation to cancel
   5958  */
   5959 void
   5960 TALER_MERCHANT_using_templates_post_cancel (
   5961   struct TALER_MERCHANT_UsingTemplatesPostHandle *utph);
   5962 
   5963 
   5964 /* ********************* /webhooks *********************** */
   5965 
   5966 
   5967 /**
   5968  * Handle for a GET /webhooks operation.
   5969  */
   5970 struct TALER_MERCHANT_WebhooksGetHandle;
   5971 
   5972 /**
   5973  * Individual webhook (minimal information
   5974  * returned via GET /webhooks).
   5975  */
   5976 struct TALER_MERCHANT_WebhookEntry
   5977 {
   5978   /**
   5979    * webhook identifier.
   5980    */
   5981   const char *webhook_id;
   5982 
   5983 };
   5984 
   5985 
   5986 /**
   5987  * Response to a GET /webhooks operation.
   5988  */
   5989 struct TALER_MERCHANT_WebhooksGetResponse
   5990 {
   5991   /**
   5992    * HTTP response details
   5993    */
   5994   struct TALER_MERCHANT_HttpResponse hr;
   5995 
   5996   /**
   5997    * Details depending on status.
   5998    */
   5999   union
   6000   {
   6001     /**
   6002      * Details if status is #MHD_HTTP_OK.
   6003      */
   6004     struct
   6005     {
   6006       /**
   6007        * length of the @e webhooks array
   6008        */
   6009       unsigned int webhooks_length;
   6010 
   6011       /**
   6012        * array of templates the requested instance offers
   6013        */
   6014       const struct TALER_MERCHANT_WebhookEntry *webhooks;
   6015 
   6016     } ok;
   6017 
   6018   } details;
   6019 };
   6020 
   6021 
   6022 /**
   6023  * Function called with the result of the GET /webhooks operation.
   6024  *
   6025  * @param cls closure
   6026  * @param wgr response details
   6027  */
   6028 typedef void
   6029 (*TALER_MERCHANT_WebhooksGetCallback)(
   6030   void *cls,
   6031   const struct TALER_MERCHANT_WebhooksGetResponse *wgr);
   6032 
   6033 
   6034 /**
   6035  * Make a GET /webhooks request.
   6036  *
   6037  * @param ctx the context
   6038  * @param backend_url HTTP base URL for the backend
   6039  * @param cb function to call with the backend information
   6040  * @param cb_cls closure for @a cb
   6041  * @return the request handle; NULL upon error
   6042  */
   6043 struct TALER_MERCHANT_WebhooksGetHandle *
   6044 TALER_MERCHANT_webhooks_get (
   6045   struct GNUNET_CURL_Context *ctx,
   6046   const char *backend_url,
   6047   TALER_MERCHANT_WebhooksGetCallback cb,
   6048   void *cb_cls);
   6049 
   6050 
   6051 /**
   6052  * Cancel GET /webhooks operation.
   6053  *
   6054  * @param[in] tgh operation to cancel
   6055  */
   6056 void
   6057 TALER_MERCHANT_webhooks_get_cancel (
   6058   struct TALER_MERCHANT_WebhooksGetHandle *tgh);
   6059 
   6060 
   6061 /**
   6062  * Handle for a GET /webhook/$ID operation. Gets details
   6063  * about a single webhook. Do not confused with a
   6064  * `struct TALER_MERCHANT_WebhooksGetHandle`, which
   6065  * obtains a list of all webhooks.
   6066  */
   6067 struct TALER_MERCHANT_WebhookGetHandle;
   6068 
   6069 
   6070 /**
   6071  * Function called with the result of the GET /webhooks operation.
   6072  *
   6073  * @param cls closure
   6074  * @param hr HTTP response details
   6075  * @param event_type event of the webhook
   6076  * @param url url to trigger webhook at
   6077  * @param http_method use for the webhook
   6078  * @param header_template header of the webhook
   6079  * @param body_template body of the webhook
   6080  */
   6081 typedef void
   6082 (*TALER_MERCHANT_WebhookGetCallback)(
   6083   void *cls,
   6084   const struct TALER_MERCHANT_HttpResponse *hr,
   6085   const char *event_type,
   6086   const char *url,
   6087   const char *http_method,
   6088   const char *header_template,
   6089   const char *body_template);
   6090 
   6091 
   6092 /**
   6093  * Make a GET /webhook/$ID request to get details about an
   6094  * individual webhook.
   6095  *
   6096  * @param ctx the context
   6097  * @param backend_url HTTP base URL for the backend
   6098  * @param webhook_id identifier of the webhook to inquire about
   6099  * @param cb function to call with the backend's webhook information
   6100  * @param cb_cls closure for @a cb
   6101  * @return the request handle; NULL upon error
   6102  */
   6103 struct TALER_MERCHANT_WebhookGetHandle *
   6104 TALER_MERCHANT_webhook_get (
   6105   struct GNUNET_CURL_Context *ctx,
   6106   const char *backend_url,
   6107   const char *webhook_id,
   6108   TALER_MERCHANT_WebhookGetCallback cb,
   6109   void *cb_cls);
   6110 
   6111 
   6112 /**
   6113  * Cancel GET /webhooks/$ID operation.
   6114  *
   6115  * @param[in] tgh operation to cancel
   6116  */
   6117 void
   6118 TALER_MERCHANT_webhook_get_cancel (
   6119   struct TALER_MERCHANT_WebhookGetHandle *tgh);
   6120 
   6121 
   6122 /**
   6123  * Handle for a POST /webhooks operation.
   6124  */
   6125 struct TALER_MERCHANT_WebhooksPostHandle;
   6126 
   6127 
   6128 /**
   6129  * Function called with the result of the POST /webhooks operation.
   6130  *
   6131  * @param cls closure
   6132  * @param hr HTTP response details
   6133  */
   6134 typedef void
   6135 (*TALER_MERCHANT_WebhooksPostCallback)(
   6136   void *cls,
   6137   const struct TALER_MERCHANT_HttpResponse *hr);
   6138 
   6139 
   6140 /**
   6141  * Make a POST /webhooks request to add a webhook
   6142  *
   6143  * @param ctx the context
   6144  * @param backend_url HTTP base URL for the backend
   6145  * @param webhook_id identifier to use for the webhook
   6146  * @param event_type event of the webhook
   6147  * @param url url use by the customer
   6148  * @param http_method http method use by the merchant
   6149  * @param header_template header of the webhook
   6150  * @param body_template body of the webhook
   6151  * @param cb function to call with the backend's result
   6152  * @param cb_cls closure for @a cb
   6153  * @return the request handle; NULL upon error
   6154  */
   6155 struct TALER_MERCHANT_WebhooksPostHandle *
   6156 TALER_MERCHANT_webhooks_post (
   6157   struct GNUNET_CURL_Context *ctx,
   6158   const char *backend_url,
   6159   const char *webhook_id,
   6160   const char *event_type,
   6161   const char *url,
   6162   const char *http_method,
   6163   const char *header_template,
   6164   const char *body_template,
   6165   TALER_MERCHANT_WebhooksPostCallback cb,
   6166   void *cb_cls);
   6167 
   6168 
   6169 /**
   6170  * Cancel POST /webhooks operation.
   6171  *
   6172  * @param[in] wph operation to cancel
   6173  */
   6174 void
   6175 TALER_MERCHANT_webhooks_post_cancel (
   6176   struct TALER_MERCHANT_WebhooksPostHandle *wph);
   6177 
   6178 
   6179 /**
   6180  * Handle for a PATCH /webhook operation.
   6181  */
   6182 struct TALER_MERCHANT_WebhookPatchHandle;
   6183 
   6184 
   6185 /**
   6186  * Function called with the result of the PATCH /webhook operation.
   6187  *
   6188  * @param cls closure
   6189  * @param hr HTTP response details
   6190  */
   6191 typedef void
   6192 (*TALER_MERCHANT_WebhookPatchCallback)(
   6193   void *cls,
   6194   const struct TALER_MERCHANT_HttpResponse *hr);
   6195 
   6196 
   6197 /**
   6198  * Make a PATCH /webhook request to update webhook details
   6199  *
   6200  * @param ctx the context
   6201  * @param backend_url HTTP base URL for the backend
   6202  * @param webhook_id identifier to use for the webhook; the webhook must exist,
   6203  *                    or the transaction will fail with a #MHD_HTTP_NOT_FOUND
   6204  *                    HTTP status code
   6205  * @param event_type event of the webhook
   6206  * @param url url use by the customer
   6207  * @param http_method http method use by the merchant
   6208  * @param header_template header of the webhook
   6209  * @param body_template body of the webhook
   6210  * @param cb function to call with the backend's result
   6211  * @param cb_cls closure for @a cb
   6212  * @return the request handle; NULL upon error
   6213  */
   6214 struct TALER_MERCHANT_WebhookPatchHandle *
   6215 TALER_MERCHANT_webhook_patch (
   6216   struct GNUNET_CURL_Context *ctx,
   6217   const char *backend_url,
   6218   const char *webhook_id,
   6219   const char *event_type,
   6220   const char *url,
   6221   const char *http_method,
   6222   const char *header_template,
   6223   const char *body_template,
   6224   TALER_MERCHANT_WebhookPatchCallback cb,
   6225   void *cb_cls);
   6226 
   6227 
   6228 /**
   6229  * Cancel PATCH /webhook operation.
   6230  *
   6231  * @param[in] wph operation to cancel
   6232  */
   6233 void
   6234 TALER_MERCHANT_webhook_patch_cancel (
   6235   struct TALER_MERCHANT_WebhookPatchHandle *wph);
   6236 
   6237 
   6238 /**
   6239  * Handle for a DELETE /webhook$ID operation.
   6240  */
   6241 struct TALER_MERCHANT_WebhookDeleteHandle;
   6242 
   6243 
   6244 /**
   6245  * Function called with the result of the DELETE /webhook/$ID operation.
   6246  *
   6247  * @param cls closure
   6248  * @param hr HTTP response details
   6249  */
   6250 typedef void
   6251 (*TALER_MERCHANT_WebhookDeleteCallback)(
   6252   void *cls,
   6253   const struct TALER_MERCHANT_HttpResponse *hr);
   6254 
   6255 
   6256 /**
   6257  * Make a DELETE /webhook/$ID request to delete a webhook.
   6258  *
   6259  * @param ctx the context
   6260  * @param backend_url HTTP base URL for the backend
   6261  * @param webhook_id identifier of the webhook
   6262  * @param cb function to call with the backend's deletion status
   6263  * @param cb_cls closure for @a cb
   6264  * @return the request handle; NULL upon error
   6265  */
   6266 struct TALER_MERCHANT_WebhookDeleteHandle *
   6267 TALER_MERCHANT_webhook_delete (
   6268   struct GNUNET_CURL_Context *ctx,
   6269   const char *backend_url,
   6270   const char *webhook_id,
   6271   TALER_MERCHANT_WebhookDeleteCallback cb,
   6272   void *cb_cls);
   6273 
   6274 
   6275 /**
   6276  * Cancel DELETE /webhook/$ID operation.
   6277  *
   6278  * @param[in] wdh operation to cancel
   6279  */
   6280 void
   6281 TALER_MERCHANT_webhook_delete_cancel (
   6282   struct TALER_MERCHANT_WebhookDeleteHandle *wdh);
   6283 
   6284 /* ********************* /statistics-[counter,amount] ************************** */
   6285 
   6286 /**
   6287  * Statistic type that can be filtered by
   6288  */
   6289 enum TALER_MERCHANT_StatisticsType
   6290 {
   6291 
   6292   /**
   6293    * Get all statistics
   6294    */
   6295   TALER_MERCHANT_STATISTICS_ALL,
   6296 
   6297   /**
   6298    * Get statistics by interval only
   6299    */
   6300   TALER_MERCHANT_STATISTICS_BY_INTERVAL,
   6301 
   6302   /**
   6303    * Get statistics by bucket only
   6304    */
   6305   TALER_MERCHANT_STATISTICS_BY_BUCKET,
   6306 
   6307 };
   6308 
   6309 /**
   6310  * Handle for a GET /statistics-counter/$SLUG operation.
   6311  */
   6312 struct TALER_MERCHANT_StatisticsCounterGetHandle;
   6313 
   6314 /**
   6315  * Counter by interval result object
   6316  */
   6317 struct TALER_MERCHANT_StatisticCounterByInterval
   6318 {
   6319 
   6320   /**
   6321    * Start time of the interval (inclusive).
   6322    * The interval always ends at the response
   6323    * generation time.
   6324    */
   6325   struct GNUNET_TIME_Timestamp start_time;
   6326 
   6327   /**
   6328    * Sum of all counters falling under the given
   6329    * SLUG within this timeframe.
   6330    */
   6331   uint64_t cumulative_counter;
   6332 
   6333 };
   6334 
   6335 /**
   6336  * Counter by bucket result object
   6337  */
   6338 struct TALER_MERCHANT_StatisticCounterByBucket
   6339 {
   6340 
   6341   /**
   6342    * Start time of the bucket (inclusive).
   6343    */
   6344   struct GNUNET_TIME_Timestamp start_time;
   6345 
   6346   /**
   6347    * End time of the bucket (exclusive).
   6348    */
   6349   struct GNUNET_TIME_Timestamp end_time;
   6350 
   6351   /**
   6352    * Range of the bucket
   6353    */
   6354   const char *range;
   6355 
   6356   /**
   6357    * Sum of all counters falling under the given
   6358    * SLUG within this timeframe.
   6359    */
   6360   uint64_t cumulative_counter;
   6361 
   6362 };
   6363 
   6364 /**
   6365  * Response to GET /statistics-counter/$SLUG operation.
   6366  */
   6367 struct TALER_MERCHANT_StatisticsCounterGetResponse
   6368 {
   6369   /**
   6370    * HTTP response details
   6371    */
   6372   struct TALER_MERCHANT_HttpResponse hr;
   6373 
   6374   /**
   6375    * Details depending on HTTP status.
   6376    */
   6377   union
   6378   {
   6379     /**
   6380      * Details for #MHD_HTTP_OK.
   6381      */
   6382     struct
   6383     {
   6384       /**
   6385        * length of the @a buckets array
   6386        */
   6387       unsigned int buckets_length;
   6388 
   6389       /**
   6390        * array of statistics in this bucket
   6391        */
   6392       const struct TALER_MERCHANT_StatisticCounterByBucket *buckets;
   6393 
   6394       /**
   6395        * description of the statistic of the buckets
   6396        */
   6397       const char *buckets_description;
   6398 
   6399       /**
   6400        * length of the @a intervals array
   6401        */
   6402       unsigned int intervals_length;
   6403 
   6404       /**
   6405        * array of statistics in this interval
   6406        */
   6407       const struct TALER_MERCHANT_StatisticCounterByInterval *intervals;
   6408 
   6409       /**
   6410        * description of the statistic of the intervals
   6411        */
   6412       const char *intervals_description;
   6413 
   6414     } ok;
   6415 
   6416   } details;
   6417 
   6418 };
   6419 
   6420 /**
   6421  * Cancel GET /statistics-counter/$SLUG operation.
   6422  *
   6423  * @param handle operation to cancel
   6424  */
   6425 void
   6426 TALER_MERCHANT_statistic_counter_get_cancel (
   6427   struct TALER_MERCHANT_StatisticsCounterGetHandle *handle);
   6428 
   6429 
   6430 /**
   6431  * Function called with the result of the GET /statistics-counter/$SLUG operation.
   6432  *
   6433  * @param cls closure
   6434  * @param scgr response details
   6435  */
   6436 typedef void
   6437 (*TALER_MERCHANT_StatisticsCounterGetCallback)(
   6438   void *cls,
   6439   const struct TALER_MERCHANT_StatisticsCounterGetResponse *scgr);
   6440 
   6441 /**
   6442  * Make a GET /statistics-counter/$SLUG request.
   6443  *
   6444  * @param ctx the context
   6445  * @param backend_url HTTP base URL for the backend
   6446  * @param slug short, url-safe identifier for the statistic
   6447  * @param stype the type of statistic to get, see #TALER_MERCHANT_StatisticsType
   6448  * @param cb function to call with the statistic information
   6449  * @param cb_cls closure for @a cb
   6450  * @return the request handle; NULL upon error
   6451  */
   6452 struct TALER_MERCHANT_StatisticsCounterGetHandle *
   6453 TALER_MERCHANT_statistic_counter_get (
   6454   struct GNUNET_CURL_Context *ctx,
   6455   const char *backend_url,
   6456   const char *slug,
   6457   enum TALER_MERCHANT_StatisticsType stype,
   6458   TALER_MERCHANT_StatisticsCounterGetCallback cb,
   6459   void *cb_cls);
   6460 
   6461 /**
   6462  * Handle for a GET /statistics-amount/$SLUG operation.
   6463  */
   6464 struct TALER_MERCHANT_StatisticsAmountGetHandle;
   6465 
   6466 /**
   6467  * Amount by interval result object
   6468  */
   6469 struct TALER_MERCHANT_StatisticAmountByInterval
   6470 {
   6471   /**
   6472    * Start time of the interval (inclusive).
   6473    * The interval always ends at the response
   6474    * generation time.
   6475    */
   6476   struct GNUNET_TIME_Timestamp start_time;
   6477 
   6478   /**
   6479    * Sum of all amounts falling under the given
   6480    * SLUG within this timeframe.
   6481    */
   6482   struct TALER_Amount *cumulative_amounts;
   6483 
   6484   /**
   6485    * Length of array @a cumulative_amounts
   6486    */
   6487   unsigned int cumulative_amount_len;
   6488 
   6489 };
   6490 
   6491 /**
   6492  * Amount by bucket result object
   6493  */
   6494 struct TALER_MERCHANT_StatisticAmountByBucket
   6495 {
   6496   /**
   6497    * Start time of the bucket (inclusive).
   6498    */
   6499   struct GNUNET_TIME_Timestamp start_time;
   6500 
   6501   /**
   6502    * End time of the bucket (exclusive).
   6503    */
   6504   struct GNUNET_TIME_Timestamp end_time;
   6505 
   6506   /**
   6507    * Range of the bucket
   6508    */
   6509   const char *range;
   6510 
   6511   /**
   6512    * Sum of all amounts falling under the given
   6513    * SLUG within this timeframe.
   6514    */
   6515   struct TALER_Amount *cumulative_amounts;
   6516 
   6517   /**
   6518    * Length of array @a cumulative_amounts
   6519    */
   6520   unsigned int cumulative_amount_len;
   6521 };
   6522 
   6523 /**
   6524  * Response to GET /statistics-amount/$SLUG operation.
   6525  */
   6526 struct TALER_MERCHANT_StatisticsAmountGetResponse
   6527 {
   6528   /**
   6529    * HTTP response details
   6530    */
   6531   struct TALER_MERCHANT_HttpResponse hr;
   6532 
   6533   /**
   6534    * Details depending on HTTP status.
   6535    */
   6536   union
   6537   {
   6538     /**
   6539      * Details for #MHD_HTTP_OK.
   6540      */
   6541     struct
   6542     {
   6543       /**
   6544        * length of the @a buckets array
   6545        */
   6546       unsigned int buckets_length;
   6547 
   6548       /**
   6549        * array of statistics in this bucket
   6550        */
   6551       const struct TALER_MERCHANT_StatisticAmountByBucket *buckets;
   6552 
   6553       /**
   6554        * description of the statistic of the buckets
   6555        */
   6556       const char *buckets_description;
   6557 
   6558       /**
   6559        * length of the @a intervals array
   6560        */
   6561       unsigned int intervals_length;
   6562 
   6563       /**
   6564        * array of statistics in this Interval
   6565        */
   6566       const struct TALER_MERCHANT_StatisticAmountByInterval *intervals;
   6567 
   6568       /**
   6569        * description of the statistic of the intervals
   6570        */
   6571       const char *intervals_description;
   6572 
   6573     } ok;
   6574 
   6575   } details;
   6576 
   6577 };
   6578 
   6579 /**
   6580  * Cancel GET /statistics-amount/$SLUG operation.
   6581  *
   6582  * @param handle operation to cancel
   6583  */
   6584 void
   6585 TALER_MERCHANT_statistic_amount_get_cancel (
   6586   struct TALER_MERCHANT_StatisticsAmountGetHandle *handle);
   6587 
   6588 
   6589 /**
   6590  * Function called with the result of the GET /statistics-amount/$SLUG operation.
   6591  *
   6592  * @param cls closure
   6593  * @param sagr response details
   6594  */
   6595 typedef void
   6596 (*TALER_MERCHANT_StatisticsAmountGetCallback)(
   6597   void *cls,
   6598   const struct TALER_MERCHANT_StatisticsAmountGetResponse *sagr);
   6599 
   6600 /**
   6601  * Make a GET /statistics-amount request.
   6602  *
   6603  * @param ctx the context
   6604  * @param backend_url HTTP base URL for the backend
   6605  * @param slug short, url-safe identifier for the statistic
   6606  * @param stype the type of statistic to get, see #TALER_MERCHANT_StatisticsType
   6607  * @param cb function to call with the statistic information
   6608  * @param cb_cls closure for @a cb
   6609  * @return the request handle; NULL upon error
   6610  */
   6611 struct TALER_MERCHANT_StatisticsAmountGetHandle *
   6612 TALER_MERCHANT_statistic_amount_get (
   6613   struct GNUNET_CURL_Context *ctx,
   6614   const char *backend_url,
   6615   const char *slug,
   6616   enum TALER_MERCHANT_StatisticsType stype,
   6617   TALER_MERCHANT_StatisticsAmountGetCallback cb,
   6618   void *cb_cls);
   6619 
   6620 
   6621 #endif  /* _TALER_MERCHANT_SERVICE_H */