commit 676410784e5e79e5eab6133c84f1dbd3400bc428
parent ec196ace7cc6a8ebdf970f2561792594e7a12562
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 4 Mar 2026 12:13:28 +0100
split taler_merchant_service header by endpoints, and misc. minor fixes
Diffstat:
86 files changed, 20574 insertions(+), 41 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -502,6 +502,8 @@ src/bank/Makefile
src/backend/Makefile
src/backenddb/Makefile
src/include/Makefile
+src/include/taler/Makefile
+src/include/taler/taler-merchant/Makefile
src/lib/Makefile
src/merchant-tools/Makefile
src/util/Makefile
diff --git a/src/include/taler/Makefile.am b/src/include/taler/Makefile.am
@@ -0,0 +1,20 @@
+# This Makefile.am is in the public domain
+SUBDIRS = taler-merchant .
+EXTRA_DIST = \
+ platform.h
+
+talerincludedir = $(includedir)/taler
+
+talerinclude_HEADERS = \
+ taler_merchant_bank_lib.h \
+ taler_merchantdb_lib.h \
+ taler_merchantdb_plugin.h \
+ taler_merchant_util.h \
+ taler_merchant_service.h \
+ taler_merchant_pay_service.h \
+ taler_merchant_testing_lib.h
+
+if HAVE_DONAU
+talerinclude_HEADERS += \
+ taler_merchant_donau.h
+endif
diff --git a/src/include/taler/platform.h b/src/include/taler/platform.h
@@ -0,0 +1,334 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014, 2015, 2016, 2021 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file src/include/platform.h
+ * @brief This file contains the includes and definitions which are used by the
+ * rest of the modules
+ * @author Sree Harsha Totakura <sreeharsha@totakura.in>
+ */
+
+#ifndef PLATFORM_H_
+#define PLATFORM_H_
+
+/* Include our configuration header */
+#ifndef HAVE_USED_CONFIG_H
+#define HAVE_USED_CONFIG_H
+#ifdef HAVE_CONFIG_H
+#include "taler_merchant_config.h"
+#endif
+#endif
+
+
+#if (GNUNET_EXTRA_LOGGING >= 1)
+#define VERBOSE(cmd) cmd
+#else
+#define VERBOSE(cmd) do { break; } while (0)
+#endif
+
+/* Include the features available for GNU source */
+#define _GNU_SOURCE
+
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef __clang__
+#undef HAVE_STATIC_ASSERT
+#endif
+
+/**
+ * These may be expensive, but good for debugging...
+ */
+#define ALLOW_EXTRA_CHECKS GNUNET_YES
+
+/**
+ * For strptime (glibc2 needs this).
+ */
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 499
+#endif
+
+#ifndef _REENTRANT
+#define _REENTRANT
+#endif
+
+/* configuration options */
+
+#define VERBOSE_STATS 0
+
+#include <netdb.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+#include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IP_H
+#include <netinet/ip.h> /* superset of previous */
+#endif
+#include <arpa/inet.h>
+#include <netinet/tcp.h>
+#include <pwd.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+#include <grp.h>
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <signal.h>
+#include <libgen.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h> /* for mallinfo on GNU */
+#endif
+#include <unistd.h> /* KLB_FIX */
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <dirent.h> /* KLB_FIX */
+#include <fcntl.h>
+#include <math.h>
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <time.h>
+#ifdef BSD
+#include <net/if.h>
+#endif
+#if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__)
+#include <semaphore.h>
+#endif
+#ifdef DARWIN
+#include <dlfcn.h>
+#include <semaphore.h>
+#include <net/if.h>
+#endif
+#if defined(__linux__) || defined(GNU)
+#include <net/if.h>
+#endif
+#ifdef SOLARIS
+#include <sys/sockio.h>
+#include <sys/filio.h>
+#include <sys/loadavg.h>
+#include <semaphore.h>
+#endif
+#if HAVE_UCRED_H
+#include <ucred.h>
+#endif
+#if HAVE_SYS_UCRED_H
+#include <sys/ucred.h>
+#endif
+#if HAVE_IFADDRS_H
+#include <ifaddrs.h>
+#endif
+#include <errno.h>
+#include <limits.h>
+
+#if HAVE_VFORK_H
+#include <vfork.h>
+#endif
+
+#include <ctype.h>
+#if HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+#if HAVE_ENDIAN_H
+#include <endian.h>
+#endif
+#if HAVE_SYS_ENDIAN_H
+#include <sys/endian.h>
+#endif
+
+#define DIR_SEPARATOR '/'
+#define DIR_SEPARATOR_STR "/"
+#define PATH_SEPARATOR ':'
+#define PATH_SEPARATOR_STR ":"
+#define NEWLINE "\n"
+
+#include <locale.h>
+#include "gettext.h"
+/**
+ * GNU gettext support macro.
+ */
+#define _(String) dgettext (PACKAGE, String)
+#define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
+
+#include <sys/mman.h>
+
+/* FreeBSD_kernel is not defined on the now discontinued kFreeBSD */
+#if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__)
+#define __BYTE_ORDER BYTE_ORDER
+#define __BIG_ENDIAN BIG_ENDIAN
+#endif
+
+#ifdef DARWIN
+#define __BYTE_ORDER BYTE_ORDER
+#define __BIG_ENDIAN BIG_ENDIAN
+/* not available on darwin, override configure */
+#undef HAVE_STAT64
+#undef HAVE_MREMAP
+#endif
+
+#if ! HAVE_ATOLL
+long long
+atoll (const char *nptr);
+
+#endif
+
+#if ENABLE_NLS
+#include "langinfo.h"
+#endif
+
+#ifndef SIZE_MAX
+#define SIZE_MAX ((size_t) (-1))
+#endif
+
+#ifndef O_LARGEFILE
+#define O_LARGEFILE 0
+#endif
+
+/**
+ * AI_NUMERICSERV not defined in windows. Then we just do without.
+ */
+#ifndef AI_NUMERICSERV
+#define AI_NUMERICSERV 0
+#endif
+
+
+#if defined(__sparc__)
+#define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove (&__tmp, &(val), \
+ sizeof((val))); \
+ __tmp; })
+#else
+#define MAKE_UNALIGNED(val) val
+#endif
+
+/**
+ * The termination signal
+ */
+#define GNUNET_TERM_SIG SIGTERM
+
+
+#ifndef PATH_MAX
+/**
+ * Assumed maximum path length.
+ */
+#define PATH_MAX 4096
+#endif
+
+#if HAVE_THREAD_LOCAL_GCC
+#define TALER_THREAD_LOCAL __thread
+#else
+#define TALER_THREAD_LOCAL
+#endif
+
+
+/**
+ * clang et al do not have such an attribute
+ */
+#if __has_attribute (__nonstring__)
+# define __nonstring __attribute__((__nonstring__))
+#else
+# define __nonstring
+#endif
+
+/* Do not use shortcuts for gcrypt mpi */
+#define GCRYPT_NO_MPI_MACROS 1
+
+/* Do not use deprecated functions from gcrypt */
+#define GCRYPT_NO_DEPRECATED 1
+
+/* Ignore MHD deprecations for now as we want to be compatible
+ to "ancient" MHD releases. */
+#define MHD_NO_DEPRECATION 1
+
+
+/**
+ * Required prefix for the authorization header as per RFC 8959.
+ * (Follows RFC 6750 albeit technically violates RFC 7235, but
+ * Mark Nottingham thinks this should be fixed by revising HTTP
+ * spec (https://github.com/httpwg/http-core/issues/733))
+ */
+#define RFC_8959_PREFIX "secret-token:"
+
+/* LSB-style exit status codes */
+#ifndef EXIT_INVALIDARGUMENT
+/**
+ * Command-line arguments are invalid.
+ * Restarting useless.
+ */
+#define EXIT_INVALIDARGUMENT 2
+#endif
+
+#ifndef EXIT_NOTIMPLEMENTED
+/**
+ * The requested operation is not implemented.
+ * Restarting useless.
+ */
+#define EXIT_NOTIMPLEMENTED 3
+#endif
+
+#ifndef EXIT_NOPERMISSION
+/**
+ * Permissions needed to run are not available.
+ * Restarting useless.
+ */
+#define EXIT_NOPERMISSION 4
+#endif
+
+#ifndef EXIT_NOTINSTALLED
+/**
+ * Key resources are not installed.
+ * Restarting useless.
+ */
+#define EXIT_NOTINSTALLED 5
+#endif
+
+#ifndef EXIT_NOTCONFIGURED
+/**
+ * Key configuration settings are missing or invalid.
+ * Restarting useless.
+ */
+#define EXIT_NOTCONFIGURED 6
+#endif
+
+#ifndef EXIT_NOTRUNNING
+#define EXIT_NOTRUNNING 7
+#endif
+
+#ifndef EXIT_NO_RESTART
+/**
+ * Exit code from 'main' if we do not want to be restarted,
+ * except by manual intervention (hard failure).
+ */
+#define EXIT_NO_RESTART 9
+#endif
+
+
+#endif /* PLATFORM_H_ */
+
+/* end of platform.h */
diff --git a/src/include/taler/taler-merchant/Makefile.am b/src/include/taler/taler-merchant/Makefile.am
@@ -0,0 +1,73 @@
+# This Makefile.am is in the public domain
+SUBDIRS = .
+talermerchantincludedir = $(includedir)/taler/taler-merchant
+
+talermerchantinclude_HEADERS = \
+ common.h \
+ delete-management-instances-INSTANCE.h \
+ delete-private-accounts-H_WIRE.h \
+ delete-private-donau-DONAU_SERIAL.h \
+ delete-private-orders-ORDER_ID.h \
+ delete-private-otp-devices-DEVICE_ID.h \
+ delete-private-products-PRODUCT_ID.h \
+ delete-private-templates-TEMPLATE_ID.h \
+ delete-private-tokens-SERIAL.h \
+ delete-private-transfers-TID.h \
+ delete-private-units-UNIT.h \
+ delete-private-webhooks-WEBHOOK_ID.h \
+ get-config.h \
+ get-management-instances.h \
+ get-management-instances-INSTANCE.h \
+ get-private-kyc.h \
+ get-private-statistics-amount-SLUG.h \
+ get-private-statistics-counter-SLUG.h \
+ get-orders-ORDER_ID.h \
+ get-private-accounts.h \
+ get-private-accounts-H_WIRE.h \
+ get-private-donau.h \
+ get-private-orders.h \
+ get-private-orders-ORDER_ID.h \
+ get-private-otp-devices.h \
+ get-private-otp-devices-DEVICE_ID.h \
+ get-private-products.h \
+ get-private-products-PRODUCT_ID.h \
+ get-private-templates.h \
+ get-private-templates-TEMPLATE_ID.h \
+ get-private-tokenfamilies-TOKEN_FAMILY_SLUG.h \
+ get-private-transfers.h \
+ get-private-units.h \
+ get-private-units-UNIT.h \
+ get-private-webhooks.h \
+ get-private-webhooks-WEBHOOK_ID.h \
+ get-products-IMAGE_HASH-image.h \
+ get-templates-TEMPLATE_ID.h \
+ patch-management-instances-INSTANCE.h \
+ patch-private-accounts-H_WIRE.h \
+ patch-private-otp-devices-DEVICE_ID.h \
+ patch-private-orders-ORDER_ID-forget.h \
+ patch-private-products-PRODUCT_ID.h \
+ patch-private-templates-TEMPLATE_ID.h \
+ patch-private-units-UNIT.h \
+ patch-private-webhooks-WEBHOOK_ID.h \
+ post-management-instances.h \
+ post-management-instances-INSTANCE-auth.h \
+ post-orders-ORDER_ID-abort.h \
+ post-orders-ORDER_ID-claim.h \
+ post-orders-ORDER_ID-paid.h \
+ post-orders-ORDER_ID-pay.h \
+ post-orders-ORDER_ID-refund.h \
+ post-private-accounts.h \
+ post-private-categories.h \
+ post-private-donau.h \
+ post-private-orders.h \
+ post-private-orders-ORDER_ID-refund.h \
+ post-private-otp-devices.h \
+ post-private-products.h \
+ post-private-products-PRODUCT_ID-lock.h \
+ post-private-templates.h \
+ post-private-tokenfamilies.h \
+ post-private-token.h \
+ post-private-transfers.h \
+ post-private-units.h \
+ post-private-webhooks.h \
+ post-templates-TEMPLATE_ID.h
diff --git a/src/include/taler/taler-merchant/common.h b/src/include/taler/taler-merchant/common.h
@@ -0,0 +1,326 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/common.h
+ * @brief Common functions of libtalermerchant not specific to a particular endpoint
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__COMMON_H
+#define _TALER_MERCHANT__COMMON_H
+
+#include <jansson.h>
+#include <taler/taler_util.h>
+#include <taler/taler_error_codes.h>
+#include <taler/taler_exchange_service.h>
+#include <gnunet/gnunet_curl_lib.h>
+
+
+/**
+ * Maximum number of options that can be set in one set_options
+ * call. Used as a dummy for "infinite" in the varargs case.
+ */
+#define TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE UINT_MAX
+
+
+/**
+ * General information about the HTTP response we obtained
+ * from the merchant for a request.
+ */
+struct TALER_MERCHANT_HttpResponse
+{
+
+ /**
+ * The complete JSON reply. NULL if we failed to parse the
+ * reply (too big, invalid JSON).
+ */
+ const json_t *reply;
+
+ /**
+ * Set to the human-readable 'hint' that is optionally
+ * provided by the merchant together with errors. NULL
+ * if no hint was provided or if there was no error.
+ */
+ const char *hint;
+
+ /**
+ * HTTP status code for the response. 0 if the
+ * HTTP request failed and we did not get any answer, or
+ * if the answer was invalid and we set @a ec to a
+ * client-side error code.
+ */
+ unsigned int http_status;
+
+ /**
+ * Taler error code. #TALER_EC_NONE if everything was
+ * OK. Usually set to the "code" field of an error
+ * response, but may be set to values created at the
+ * client side, for example when the response was
+ * not in JSON format or was otherwise ill-formed.
+ */
+ enum TALER_ErrorCode ec;
+
+ /**
+ * HTTP status code returned by the exchange, if
+ * the merchant forwarded an exchange error to us.
+ * Set to 0 if there was no exchange involved.
+ */
+ unsigned int exchange_http_status;
+
+ /**
+ * JSON reply from the exchange, if the merchant
+ * forwarded an exchange error to us. NULL otherwise.
+ */
+ const json_t *exchange_reply;
+
+ /**
+ * Taler error code from the exchange, if the merchant
+ * forwarded an exchange error to us.
+ */
+ enum TALER_ErrorCode exchange_code;
+
+ /**
+ * Human-readable hint from the exchange, if the merchant
+ * forwarded an exchange error to us. NULL otherwise.
+ */
+ const char *exchange_hint;
+
+};
+
+
+/**
+ * Parse URI data for taler://pay/ URIs.
+ */
+struct TALER_MERCHANT_PayUriData
+{
+
+ /**
+ * Hostname (and possibly port) of the merchant backend.
+ */
+ char *merchant_host;
+
+ /**
+ * Prefix path at the merchant backend (may be NULL).
+ */
+ char *merchant_prefix_path;
+
+ /**
+ * The order ID.
+ */
+ char *order_id;
+
+ /**
+ * The session ID (may be NULL if none given).
+ */
+ char *session_id;
+
+ /**
+ * Claim token (may be NULL if not given in the URI).
+ */
+ struct TALER_ClaimTokenP *claim_token;
+
+ /**
+ * Subscription session ID (SSID), may be NULL.
+ */
+ char *ssid;
+
+ /**
+ * Set to true if taler+http:// was used (test only).
+ */
+ bool use_http;
+
+};
+
+
+/**
+ * Parse URI data for taler://refund/ URIs.
+ */
+struct TALER_MERCHANT_RefundUriData
+{
+
+ /**
+ * Hostname (and possibly port) of the merchant backend.
+ */
+ char *merchant_host;
+
+ /**
+ * Prefix path at the merchant backend (may be NULL).
+ */
+ char *merchant_prefix_path;
+
+ /**
+ * The order ID.
+ */
+ char *order_id;
+
+ /**
+ * Subscription session ID (SSID), may be NULL.
+ */
+ char *ssid;
+
+ /**
+ * Set to true if taler+http:// was used (test only).
+ */
+ bool use_http;
+
+};
+
+/**
+ * Entry for one measurement unit.
+ */
+struct TALER_MERCHANT_UnitEntry
+{
+
+ /**
+ * Identifier of the unit.
+ */
+ const char *unit;
+
+ /**
+ * Long (human-readable) name of the unit.
+ */
+ const char *unit_name_long;
+
+ /**
+ * Short symbol for the unit.
+ */
+ const char *unit_name_short;
+
+ const json_t *unit_name_long_i18n;
+
+ const json_t *unit_name_short_i18n;
+
+ /**
+ * Whether fractional quantities are allowed.
+ */
+ bool unit_allow_fraction;
+
+ /**
+ * Precision level for fractional quantities.
+ */
+ uint32_t unit_precision_level;
+
+ /**
+ * Whether this unit is currently active.
+ */
+ bool unit_active;
+
+ bool unit_builtin;
+};
+
+
+/**
+ * Type of a statistics metric / aggregation mode.
+ */
+enum TALER_MERCHANT_StatisticsType
+{
+ /**
+ * Return statistics aggregated by bucket.
+ */
+ TALER_MERCHANT_STATISTICS_BY_BUCKET = 0,
+
+ /**
+ * Return statistics aggregated by time interval.
+ */
+ TALER_MERCHANT_STATISTICS_BY_INTERVAL = 1,
+
+ /**
+ * Return all available statistics (both buckets and intervals).
+ */
+ TALER_MERCHANT_STATISTICS_ALL = 2
+};
+
+
+/**
+ * Parse a taler://pay/ URI into its components.
+ *
+ * @param pay_uri the URI to parse
+ * @param[out] parse_data parsed URI data, to be freed with
+ * #TALER_MERCHANT_parse_pay_uri_free()
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ */
+enum GNUNET_GenericReturnValue
+TALER_MERCHANT_parse_pay_uri (const char *pay_uri,
+ struct TALER_MERCHANT_PayUriData *parse_data);
+
+
+/**
+ * Free a #TALER_MERCHANT_PayUriData previously obtained from
+ * #TALER_MERCHANT_parse_pay_uri().
+ *
+ * @param[in] parse_data the data to free (fields only, not the struct itself)
+ */
+void
+TALER_MERCHANT_parse_pay_uri_free (
+ struct TALER_MERCHANT_PayUriData *parse_data);
+
+
+/**
+ * Parse a taler://refund/ URI into its components.
+ *
+ * @param refund_uri the URI to parse
+ * @param[out] parse_data parsed URI data, to be freed with
+ * #TALER_MERCHANT_parse_refund_uri_free()
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ */
+enum GNUNET_GenericReturnValue
+TALER_MERCHANT_parse_refund_uri (
+ const char *refund_uri,
+ struct TALER_MERCHANT_RefundUriData *parse_data);
+
+
+/**
+ * Free a #TALER_MERCHANT_RefundUriData previously obtained from
+ * #TALER_MERCHANT_parse_refund_uri().
+ *
+ * @param[in] parse_data the data to free (fields only, not the struct itself)
+ */
+void
+TALER_MERCHANT_parse_refund_uri_free (
+ struct TALER_MERCHANT_RefundUriData *parse_data);
+
+
+/**
+ * Format a quantity into its decimal string representation.
+ *
+ * @param quantity integer part of the quantity
+ * @param quantity_frac fractional part
+ * @param[out] buffer output buffer
+ * @param buffer_length size of @a buffer
+ */
+void
+TALER_MERCHANT_format_quantity_string (uint64_t quantity,
+ uint32_t quantity_frac,
+ char *buffer,
+ size_t buffer_length);
+
+
+/**
+ * Format a stock value into its decimal string representation.
+ *
+ * @param total_stock integer part of the stock value
+ * @param total_stock_frac fractional part
+ * @param[out] buffer output buffer
+ * @param buffer_length size of @a buffer
+ */
+void
+TALER_MERCHANT_format_stock_string (uint64_t total_stock,
+ uint32_t total_stock_frac,
+ char *buffer,
+ size_t buffer_length);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/delete-management-instances-INSTANCE.h b/src/include/taler/taler-merchant/delete-management-instances-INSTANCE.h
@@ -0,0 +1,94 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/delete-management-instances-INSTANCE.h
+ * @brief C interface for DELETE /management/instances/$INSTANCE of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__DELETE_MANAGEMENT_INSTANCES_INSTANCE_H
+#define _TALER_MERCHANT__DELETE_MANAGEMENT_INSTANCES_INSTANCE_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a DELETE /management/instances/$INSTANCE request.
+ */
+struct TALER_MERCHANT_InstanceDeleteHandle;
+
+
+/**
+ * Callback for a DELETE /management/instances/$INSTANCE request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_InstanceDeleteCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a DELETE /management/instances/$INSTANCE request (soft delete,
+ * preserves data).
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param instance_id identifier of the instance to delete
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_InstanceDeleteHandle *
+TALER_MERCHANT_instance_delete (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance_id,
+ TALER_MERCHANT_InstanceDeleteCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Issue a DELETE /management/instances/$INSTANCE request with purge=yes
+ * (hard delete, removes all data).
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param instance_id identifier of the instance to purge
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_InstanceDeleteHandle *
+TALER_MERCHANT_instance_purge (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance_id,
+ TALER_MERCHANT_InstanceDeleteCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a DELETE /management/instances/$INSTANCE request.
+ *
+ * @param[in] idh handle to cancel
+ */
+void
+TALER_MERCHANT_instance_delete_cancel (
+ struct TALER_MERCHANT_InstanceDeleteHandle *idh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/delete-private-accounts-H_WIRE.h b/src/include/taler/taler-merchant/delete-private-accounts-H_WIRE.h
@@ -0,0 +1,89 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/delete-private-accounts-H_WIRE.h
+ * @brief C interface for DELETE /private/accounts/$H_WIRE of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__DELETE_PRIVATE_ACCOUNTS_H_WIRE_H
+#define _TALER_MERCHANT__DELETE_PRIVATE_ACCOUNTS_H_WIRE_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a DELETE /private/accounts/$H_WIRE request.
+ */
+struct TALER_MERCHANT_AccountDeleteHandle;
+
+
+/**
+ * Response details for a DELETE /private/accounts/$H_WIRE request.
+ */
+struct TALER_MERCHANT_AccountDeleteResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+};
+
+
+/**
+ * Callback for a DELETE /private/accounts/$H_WIRE request.
+ *
+ * @param cls closure
+ * @param adr response details
+ */
+typedef void
+(*TALER_MERCHANT_AccountDeleteCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_AccountDeleteResponse *adr);
+
+
+/**
+ * Issue a DELETE /private/accounts/$H_WIRE request to remove a wire account.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param h_wire hash of the wire details identifying the account to delete
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_AccountDeleteHandle *
+TALER_MERCHANT_account_delete (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct TALER_MerchantWireHashP *h_wire,
+ TALER_MERCHANT_AccountDeleteCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a DELETE /private/accounts/$H_WIRE request.
+ *
+ * @param[in] adh handle to cancel
+ */
+void
+TALER_MERCHANT_account_delete_cancel (
+ struct TALER_MERCHANT_AccountDeleteHandle *adh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/delete-private-donau-DONAU_SERIAL.h b/src/include/taler/taler-merchant/delete-private-donau-DONAU_SERIAL.h
@@ -0,0 +1,75 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/delete-private-donau-DONAU_SERIAL.h
+ * @brief C interface for DELETE /private/donau/$DONAU_SERIAL of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__DELETE_PRIVATE_DONAU_DONAU_SERIAL_H
+#define _TALER_MERCHANT__DELETE_PRIVATE_DONAU_DONAU_SERIAL_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a DELETE /private/donau/$DONAU_SERIAL request.
+ */
+struct TALER_MERCHANT_DonauInstanceDeleteHandle;
+
+
+/**
+ * Callback for a DELETE /private/donau/$DONAU_SERIAL request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_DonauInstanceDeleteCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a DELETE /private/donau/$DONAU_SERIAL request to unregister a charity.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param charity_id charity identifier to delete
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_DonauInstanceDeleteHandle *
+TALER_MERCHANT_donau_instance_delete (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ uint64_t charity_id,
+ TALER_MERCHANT_DonauInstanceDeleteCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a DELETE /private/donau/$DONAU_SERIAL request.
+ *
+ * @param[in] ddh handle to cancel
+ */
+void
+TALER_MERCHANT_donau_instance_delete_cancel (
+ struct TALER_MERCHANT_DonauInstanceDeleteHandle *ddh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/delete-private-orders-ORDER_ID.h b/src/include/taler/taler-merchant/delete-private-orders-ORDER_ID.h
@@ -0,0 +1,76 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/delete-private-orders-ORDER_ID.h
+ * @brief C interface for DELETE /private/orders/$ORDER_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__DELETE_PRIVATE_ORDERS_ORDER_ID_H
+#define _TALER_MERCHANT__DELETE_PRIVATE_ORDERS_ORDER_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a DELETE /private/orders/$ORDER_ID request.
+ */
+struct TALER_MERCHANT_OrderDeleteHandle;
+
+
+/**
+ * Callback for a DELETE /private/orders/$ORDER_ID request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_OrderDeleteCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a DELETE /private/orders/$ORDER_ID request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param order_id identifier of the order to delete
+ * @param force if true, force deletion even if order has payments
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrderDeleteHandle *
+TALER_MERCHANT_order_delete (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *order_id,
+ bool force,
+ TALER_MERCHANT_OrderDeleteCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a DELETE /private/orders/$ORDER_ID request.
+ *
+ * @param[in] odh handle to cancel
+ */
+void
+TALER_MERCHANT_order_delete_cancel (
+ struct TALER_MERCHANT_OrderDeleteHandle *odh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/delete-private-otp-devices-DEVICE_ID.h b/src/include/taler/taler-merchant/delete-private-otp-devices-DEVICE_ID.h
@@ -0,0 +1,75 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/delete-private-otp-devices-DEVICE_ID.h
+ * @brief C interface for DELETE /private/otp-devices/$DEVICE_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__DELETE_PRIVATE_OTP_DEVICES_DEVICE_ID_H
+#define _TALER_MERCHANT__DELETE_PRIVATE_OTP_DEVICES_DEVICE_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a DELETE /private/otp-devices/$DEVICE_ID request.
+ */
+struct TALER_MERCHANT_OtpDeviceDeleteHandle;
+
+
+/**
+ * Callback for a DELETE /private/otp-devices/$DEVICE_ID request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_OtpDeviceDeleteCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a DELETE /private/otp-devices/$DEVICE_ID request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param otp_device_id identifier of the OTP device to delete
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OtpDeviceDeleteHandle *
+TALER_MERCHANT_otp_device_delete (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *otp_device_id,
+ TALER_MERCHANT_OtpDeviceDeleteCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a DELETE /private/otp-devices/$DEVICE_ID request.
+ *
+ * @param[in] tdh handle to cancel
+ */
+void
+TALER_MERCHANT_otp_device_delete_cancel (
+ struct TALER_MERCHANT_OtpDeviceDeleteHandle *tdh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/delete-private-products-PRODUCT_ID.h b/src/include/taler/taler-merchant/delete-private-products-PRODUCT_ID.h
@@ -0,0 +1,74 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/delete-private-products-PRODUCT_ID.h
+ * @brief C interface for DELETE /private/products/$PRODUCT_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__DELETE_PRIVATE_PRODUCTS_PRODUCT_ID_H
+#define _TALER_MERCHANT__DELETE_PRIVATE_PRODUCTS_PRODUCT_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a DELETE /private/products/$PRODUCT_ID request.
+ */
+struct TALER_MERCHANT_ProductDeleteHandle;
+
+
+/**
+ * Callback for a DELETE /private/products/$PRODUCT_ID request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_ProductDeleteCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a DELETE /private/products/$PRODUCT_ID request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param product_id identifier of the product to delete
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ProductDeleteHandle *
+TALER_MERCHANT_product_delete (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *product_id,
+ TALER_MERCHANT_ProductDeleteCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a DELETE /private/products/$PRODUCT_ID request.
+ *
+ * @param[in] pdh handle to cancel
+ */
+void
+TALER_MERCHANT_product_delete_cancel (
+ struct TALER_MERCHANT_ProductDeleteHandle *pdh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/delete-private-templates-TEMPLATE_ID.h b/src/include/taler/taler-merchant/delete-private-templates-TEMPLATE_ID.h
@@ -0,0 +1,74 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/delete-private-templates-TEMPLATE_ID.h
+ * @brief C interface for DELETE /private/templates/$TEMPLATE_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__DELETE_PRIVATE_TEMPLATES_TEMPLATE_ID_H
+#define _TALER_MERCHANT__DELETE_PRIVATE_TEMPLATES_TEMPLATE_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a DELETE /private/templates/$TEMPLATE_ID request.
+ */
+struct TALER_MERCHANT_TemplateDeleteHandle;
+
+
+/**
+ * Callback for a DELETE /private/templates/$TEMPLATE_ID request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_TemplateDeleteCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a DELETE /private/templates/$TEMPLATE_ID request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param template_id identifier of the template to delete
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_TemplateDeleteHandle *
+TALER_MERCHANT_template_delete (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *template_id,
+ TALER_MERCHANT_TemplateDeleteCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a DELETE /private/templates/$TEMPLATE_ID request.
+ *
+ * @param[in] tdh handle to cancel
+ */
+void
+TALER_MERCHANT_template_delete_cancel (
+ struct TALER_MERCHANT_TemplateDeleteHandle *tdh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/delete-private-tokens-SERIAL.h b/src/include/taler/taler-merchant/delete-private-tokens-SERIAL.h
@@ -0,0 +1,75 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/delete-private-tokens-SERIAL.h
+ * @brief C interface for DELETE /private/tokens/$SERIAL of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__DELETE_PRIVATE_TOKENS_SERIAL_H
+#define _TALER_MERCHANT__DELETE_PRIVATE_TOKENS_SERIAL_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a DELETE /private/tokens/$SERIAL request.
+ */
+struct TALER_MERCHANT_InstanceTokenDeleteHandle;
+
+
+/**
+ * Callback for a DELETE /private/tokens/$SERIAL request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_InstanceTokenDeleteCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a DELETE /private/tokens/$SERIAL request to revoke an access token.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param instance_id identifier of the instance
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_InstanceTokenDeleteHandle *
+TALER_MERCHANT_instance_token_delete (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance_id,
+ TALER_MERCHANT_InstanceTokenDeleteCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a DELETE /private/tokens/$SERIAL request.
+ *
+ * @param[in] tdh handle to cancel
+ */
+void
+TALER_MERCHANT_instance_token_delete_cancel (
+ struct TALER_MERCHANT_InstanceTokenDeleteHandle *tdh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/delete-private-transfers-TID.h b/src/include/taler/taler-merchant/delete-private-transfers-TID.h
@@ -0,0 +1,75 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/delete-private-transfers-TID.h
+ * @brief C interface for DELETE /private/transfers/$TID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__DELETE_PRIVATE_TRANSFERS_TID_H
+#define _TALER_MERCHANT__DELETE_PRIVATE_TRANSFERS_TID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a DELETE /private/transfers/$TID request.
+ */
+struct TALER_MERCHANT_TransferDeleteHandle;
+
+
+/**
+ * Callback for a DELETE /private/transfers/$TID request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_TransferDeleteCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a DELETE /private/transfers/$TID request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param wire_transfer_serial serial number of the wire transfer to delete
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_TransferDeleteHandle *
+TALER_MERCHANT_transfer_delete (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ uint64_t wire_transfer_serial,
+ TALER_MERCHANT_TransferDeleteCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a DELETE /private/transfers/$TID request.
+ *
+ * @param[in] tdh handle to cancel
+ */
+void
+TALER_MERCHANT_transfer_delete_cancel (
+ struct TALER_MERCHANT_TransferDeleteHandle *tdh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/delete-private-units-UNIT.h b/src/include/taler/taler-merchant/delete-private-units-UNIT.h
@@ -0,0 +1,74 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/delete-private-units-UNIT.h
+ * @brief C interface for DELETE /private/units/$UNIT of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__DELETE_PRIVATE_UNITS_UNIT_H
+#define _TALER_MERCHANT__DELETE_PRIVATE_UNITS_UNIT_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a DELETE /private/units/$UNIT request.
+ */
+struct TALER_MERCHANT_UnitDeleteHandle;
+
+
+/**
+ * Callback for a DELETE /private/units/$UNIT request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_UnitDeleteCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a DELETE /private/units/$UNIT request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param unit_id identifier of the unit to delete
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_UnitDeleteHandle *
+TALER_MERCHANT_unit_delete (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *unit_id,
+ TALER_MERCHANT_UnitDeleteCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a DELETE /private/units/$UNIT request.
+ *
+ * @param[in] udh handle to cancel
+ */
+void
+TALER_MERCHANT_unit_delete_cancel (
+ struct TALER_MERCHANT_UnitDeleteHandle *udh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/delete-private-webhooks-WEBHOOK_ID.h b/src/include/taler/taler-merchant/delete-private-webhooks-WEBHOOK_ID.h
@@ -0,0 +1,74 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/delete-private-webhooks-WEBHOOK_ID.h
+ * @brief C interface for DELETE /private/webhooks/$WEBHOOK_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__DELETE_PRIVATE_WEBHOOKS_WEBHOOK_ID_H
+#define _TALER_MERCHANT__DELETE_PRIVATE_WEBHOOKS_WEBHOOK_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a DELETE /private/webhooks/$WEBHOOK_ID request.
+ */
+struct TALER_MERCHANT_WebhookDeleteHandle;
+
+
+/**
+ * Callback for a DELETE /private/webhooks/$WEBHOOK_ID request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_WebhookDeleteCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a DELETE /private/webhooks/$WEBHOOK_ID request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param webhook_id identifier of the webhook to delete
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_WebhookDeleteHandle *
+TALER_MERCHANT_webhook_delete (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *webhook_id,
+ TALER_MERCHANT_WebhookDeleteCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a DELETE /private/webhooks/$WEBHOOK_ID request.
+ *
+ * @param[in] wdh handle to cancel
+ */
+void
+TALER_MERCHANT_webhook_delete_cancel (
+ struct TALER_MERCHANT_WebhookDeleteHandle *wdh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-config.h b/src/include/taler/taler-merchant/get-config.h
@@ -0,0 +1,209 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-config.h
+ * @brief C interface for GET /config of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_CONFIG_H
+#define _TALER_MERCHANT__GET_CONFIG_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /config request.
+ */
+struct TALER_MERCHANT_ConfigGetHandle;
+
+
+/**
+ * Version compatibility status for the merchant backend.
+ */
+enum TALER_MERCHANT_VersionCompatibility
+{
+ /**
+ * The client and server are at the same version.
+ */
+ TALER_MERCHANT_VC_MATCH = 0,
+
+ /**
+ * The server is running a newer API version.
+ */
+ TALER_MERCHANT_VC_NEWER = 1,
+
+ /**
+ * The server is running an older API version.
+ */
+ TALER_MERCHANT_VC_OLDER = 2,
+
+ /**
+ * The versions are incompatible.
+ */
+ TALER_MERCHANT_VC_INCOMPATIBLE = 4,
+
+ /**
+ * A protocol error occurred.
+ */
+ TALER_MERCHANT_VC_PROTOCOL_ERROR = 8
+};
+
+
+/**
+ * Information about an exchange as returned in the config response.
+ */
+struct TALER_MERCHANT_ExchangeConfigInfo
+{
+
+ /**
+ * Base URL of the exchange.
+ */
+ const char *base_url;
+
+ /**
+ * Currency served by this exchange.
+ */
+ const char *currency;
+
+ /**
+ * Master public key of the exchange.
+ */
+ struct TALER_MasterPublicKeyP master_pub;
+
+};
+
+
+/**
+ * Response details for a GET /config request.
+ */
+struct TALER_MERCHANT_ConfigResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * API version string.
+ */
+ const char *version;
+
+ /**
+ * Currency used by this merchant backend.
+ */
+ const char *currency;
+
+ /**
+ * Compatibility status with the client library.
+ */
+ enum TALER_MERCHANT_VersionCompatibility compat;
+
+ /**
+ * Number of exchanges in @a exchanges.
+ */
+ unsigned int num_exchanges;
+
+ /**
+ * Array of exchange configurations.
+ */
+ const struct TALER_MERCHANT_ExchangeConfigInfo *exchanges;
+
+ /**
+ * Number of currency specifications in @a cspecs.
+ */
+ unsigned int num_cspecs;
+
+ /**
+ * Array of currency specifications.
+ */
+ const struct TALER_CurrencySpecification *cspecs;
+
+ /**
+ * Currency information returned by the backend.
+ */
+ struct
+ {
+ /**
+ * Currency string.
+ */
+ const char *currency;
+
+ /**
+ * Version string.
+ */
+ const char *version;
+ } ci;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /config request.
+ *
+ * @param cls closure
+ * @param cr response details
+ */
+typedef void
+(*TALER_MERCHANT_ConfigCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_ConfigResponse *cr);
+
+
+/**
+ * Issue a GET /config request to the merchant backend.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param config_cb callback to invoke with the result
+ * @param config_cb_cls closure for @a config_cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ConfigGetHandle *
+TALER_MERCHANT_config_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ TALER_MERCHANT_ConfigCallback config_cb,
+ void *config_cb_cls);
+
+
+/**
+ * Cancel a GET /config request.
+ *
+ * @param[in] vgh handle to cancel
+ */
+void
+TALER_MERCHANT_config_get_cancel (
+ struct TALER_MERCHANT_ConfigGetHandle *vgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-management-instances-INSTANCE.h b/src/include/taler/taler-merchant/get-management-instances-INSTANCE.h
@@ -0,0 +1,162 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-management-instances-INSTANCE.h
+ * @brief C interface for GET /management/instances/$INSTANCE of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_INSTANCE_H
+#define _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_INSTANCE_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /management/instances/$INSTANCE request.
+ */
+struct TALER_MERCHANT_InstanceGetHandle;
+
+/**
+ * Detailed information about a merchant instance.
+ */
+struct TALER_MERCHANT_InstanceDetails
+{
+
+ /**
+ * Human-readable name of the instance.
+ */
+ const char *name;
+
+ /**
+ * Public key of the merchant instance.
+ */
+ struct TALER_MerchantPublicKeyP merchant_pub;
+
+ /**
+ * Whether to use the STEFAN curve for fee calculations.
+ */
+ bool use_stefan;
+
+ /**
+ * Default wire transfer delay.
+ */
+ struct GNUNET_TIME_Relative default_wire_transfer_delay;
+
+ /**
+ * Default payment deadline.
+ */
+ struct GNUNET_TIME_Relative default_pay_delay;
+
+ /**
+ * Default refund deadline.
+ */
+ struct GNUNET_TIME_Relative default_refund_delay;
+
+ /**
+ * Default wire transfer rounding interval.
+ */
+ enum GNUNET_TIME_RounderInterval default_wire_transfer_rounding_interval;
+
+ /**
+ * Merchant address (JSON).
+ */
+ const json_t *address;
+
+ /**
+ * Merchant jurisdiction (JSON).
+ */
+ const json_t *jurisdiction;
+
+};
+
+
+/**
+ * Response details for a GET /management/instances/$INSTANCE request.
+ */
+struct TALER_MERCHANT_InstanceGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Detailed information about the instance.
+ */
+ struct TALER_MERCHANT_InstanceDetails details;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /management/instances/$INSTANCE request.
+ *
+ * @param cls closure
+ * @param igr response details
+ */
+typedef void
+(*TALER_MERCHANT_InstanceGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_InstanceGetResponse *igr);
+
+
+/**
+ * Issue a GET /management/instances/$INSTANCE request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param instance_id identifier of the instance to retrieve
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_InstanceGetHandle *
+TALER_MERCHANT_instance_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance_id,
+ TALER_MERCHANT_InstanceGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /management/instances/$INSTANCE request.
+ *
+ * @param[in] igh handle to cancel
+ */
+void
+TALER_MERCHANT_instance_get_cancel (
+ struct TALER_MERCHANT_InstanceGetHandle *igh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-management-instances.h b/src/include/taler/taler-merchant/get-management-instances.h
@@ -0,0 +1,142 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-management-instances.h
+ * @brief C interface for GET /management/instances of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_H
+#define _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /management/instances request.
+ */
+struct TALER_MERCHANT_InstancesGetHandle;
+
+
+/**
+ * Information about one merchant instance.
+ */
+struct TALER_MERCHANT_InstanceInformation
+{
+
+ /**
+ * Instance identifier string.
+ */
+ const char *id;
+
+ /**
+ * Human-readable name of the instance.
+ */
+ const char *name;
+
+ /**
+ * Public key of the instance.
+ */
+ struct TALER_MerchantPublicKeyP merchant_pub;
+
+ /**
+ * JSON array of supported payment targets.
+ */
+ const json_t *payment_targets;
+
+};
+
+
+/**
+ * Response details for a GET /management/instances request.
+ */
+struct TALER_MERCHANT_InstancesGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Number of instances in @a iis.
+ */
+ unsigned int iis_length;
+
+ /**
+ * Array of instance information.
+ */
+ const struct TALER_MERCHANT_InstanceInformation *iis;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /management/instances request.
+ *
+ * @param cls closure
+ * @param igr response details
+ */
+typedef void
+(*TALER_MERCHANT_InstancesGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_InstancesGetResponse *igr);
+
+
+/**
+ * Issue a GET /management/instances request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param instances_cb callback to invoke with the result
+ * @param instances_cb_cls closure for @a instances_cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_InstancesGetHandle *
+TALER_MERCHANT_instances_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ TALER_MERCHANT_InstancesGetCallback instances_cb,
+ void *instances_cb_cls);
+
+
+/**
+ * Cancel a GET /management/instances request.
+ *
+ * @param[in] igh handle to cancel
+ */
+void
+TALER_MERCHANT_instances_get_cancel (
+ struct TALER_MERCHANT_InstancesGetHandle *igh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-orders-ORDER_ID.h b/src/include/taler/taler-merchant/get-orders-ORDER_ID.h
@@ -0,0 +1,149 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-orders-ORDER_ID.h
+ * @brief C interface for GET /orders/$ORDER_ID (wallet-facing) of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_ORDERS_ORDER_ID_H
+#define _TALER_MERCHANT__GET_ORDERS_ORDER_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /orders/$ORDER_ID request (wallet-facing).
+ */
+struct TALER_MERCHANT_OrderWalletGetHandle;
+
+
+/**
+ * Response details for a GET /orders/$ORDER_ID request (wallet-facing).
+ */
+struct TALER_MERCHANT_OrderWalletGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK (order is paid, refund info available).
+ */
+ struct
+ {
+
+ /**
+ * True if a refund has been granted.
+ */
+ bool refunded;
+
+ /**
+ * True if a refund is still pending.
+ */
+ bool refund_pending;
+
+ /**
+ * Total amount refunded.
+ */
+ struct TALER_Amount refund_amount;
+
+ } ok;
+
+ /**
+ * Details on #MHD_HTTP_PAYMENT_REQUIRED (order not yet paid).
+ */
+ struct
+ {
+
+ /**
+ * Taler pay URI for this order.
+ */
+ const char *taler_pay_uri;
+
+ /**
+ * Order ID of a previously paid order that covers this one,
+ * or NULL if none.
+ */
+ const char *already_paid_order_id;
+
+ } payment_required;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /orders/$ORDER_ID request (wallet-facing).
+ *
+ * @param cls closure
+ * @param owgr response details
+ */
+typedef void
+(*TALER_MERCHANT_OrderWalletGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_OrderWalletGetResponse *owgr);
+
+
+/**
+ * Issue a GET /orders/$ORDER_ID request (wallet-facing).
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param order_id identifier of the order to check
+ * @param h_contract hash of the contract terms (to verify), or NULL
+ * @param timeout long-polling timeout
+ * @param session_id session identifier for repurchase, or NULL
+ * @param min_refund minimum refund amount to wait for, or NULL
+ * @param await_refund_obtained if true, wait until refund is confirmed obtained
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrderWalletGetHandle *
+TALER_MERCHANT_wallet_order_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *order_id,
+ const struct TALER_PrivateContractHashP *h_contract,
+ struct GNUNET_TIME_Relative timeout,
+ const char *session_id,
+ const struct TALER_Amount *min_refund,
+ bool await_refund_obtained,
+ TALER_MERCHANT_OrderWalletGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /orders/$ORDER_ID request (wallet-facing).
+ *
+ * @param[in] owgh handle to cancel
+ */
+void
+TALER_MERCHANT_wallet_order_get_cancel (
+ struct TALER_MERCHANT_OrderWalletGetHandle *owgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-accounts-H_WIRE.h b/src/include/taler/taler-merchant/get-private-accounts-H_WIRE.h
@@ -0,0 +1,145 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-accounts-H_WIRE.h
+ * @brief C interface for GET /private/accounts/$H_WIRE of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_ACCOUNTS_H_WIRE_H
+#define _TALER_MERCHANT__GET_PRIVATE_ACCOUNTS_H_WIRE_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/accounts/$H_WIRE request.
+ */
+struct TALER_MERCHANT_AccountGetHandle;
+
+
+/**
+ * Account details for a merchant wire account.
+ */
+struct TALER_MERCHANT_AccountDetails
+{
+
+ /**
+ * Hash of the wire details.
+ */
+ struct TALER_MerchantWireHashP h_wire;
+
+ /**
+ * Salt used in the wire hash computation.
+ */
+ struct TALER_WireSaltP salt;
+
+ /**
+ * Full payto URI of the account.
+ */
+ struct TALER_FullPayto payto_uri;
+
+ /**
+ * URL of the credit facade, or NULL if none.
+ */
+ const char *credit_facade_url;
+
+ /**
+ * True if the account is currently active.
+ */
+ bool active;
+
+};
+
+
+/**
+ * Response details for a GET /private/accounts/$H_WIRE request.
+ */
+struct TALER_MERCHANT_AccountGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Detailed account information.
+ */
+ struct TALER_MERCHANT_AccountDetails ad;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/accounts/$H_WIRE request.
+ *
+ * @param cls closure
+ * @param agr response details
+ */
+typedef void
+(*TALER_MERCHANT_AccountGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_AccountGetResponse *agr);
+
+
+/**
+ * Issue a GET /private/accounts/$H_WIRE request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param instance_id identifier of the merchant instance
+ * @param h_wire hash of the wire details identifying the account
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_AccountGetHandle *
+TALER_MERCHANT_account_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ TALER_MERCHANT_AccountGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/accounts/$H_WIRE request.
+ *
+ * @param[in] tgh handle to cancel
+ */
+void
+TALER_MERCHANT_account_get_cancel (
+ struct TALER_MERCHANT_AccountGetHandle *tgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-accounts.h b/src/include/taler/taler-merchant/get-private-accounts.h
@@ -0,0 +1,132 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-accounts.h
+ * @brief C interface for GET /private/accounts of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_ACCOUNTS_H
+#define _TALER_MERCHANT__GET_PRIVATE_ACCOUNTS_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/accounts request.
+ */
+struct TALER_MERCHANT_AccountsGetHandle;
+
+
+/**
+ * Account details for a merchant wire account.
+ */
+struct TALER_MERCHANT_AccountEntry
+{
+
+ /**
+ * Hash of the wire details.
+ */
+ struct TALER_MerchantWireHashP h_wire;
+
+ /**
+ * Full payto URI of the account.
+ */
+ struct TALER_FullPayto payto_uri;
+
+
+};
+
+
+/**
+ * Response details for a GET /private/accounts request.
+ */
+struct TALER_MERCHANT_AccountsGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Number of accounts in @a accounts.
+ */
+ unsigned int accounts_length;
+
+ /**
+ * Array of account entries.
+ */
+ const struct TALER_MERCHANT_AccountEntry *accounts;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/accounts request.
+ *
+ * @param cls closure
+ * @param agr response details
+ */
+typedef void
+(*TALER_MERCHANT_AccountsGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_AccountsGetResponse *agr);
+
+
+/**
+ * Issue a GET /private/accounts request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_AccountsGetHandle *
+TALER_MERCHANT_accounts_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ TALER_MERCHANT_AccountsGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/accounts request.
+ *
+ * @param[in] tgh handle to cancel
+ */
+void
+TALER_MERCHANT_accounts_get_cancel (
+ struct TALER_MERCHANT_AccountsGetHandle *tgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-donau.h b/src/include/taler/taler-merchant/get-private-donau.h
@@ -0,0 +1,165 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-donau.h
+ * @brief C interface for GET /private/donau of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_DONAU_H
+#define _TALER_MERCHANT__GET_PRIVATE_DONAU_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/donau request.
+ */
+struct TALER_MERCHANT_DonauInstanceGetHandle;
+
+
+/**
+ * Individual Donau instance details.
+ */
+struct TALER_MERCHANT_DonauInstanceEntry
+{
+ /**
+ * Serial number of the Donau instance in merchant database.
+ */
+ uint64_t donau_instance_serial;
+
+ /**
+ * The URL of the Donau service.
+ */
+ const char *donau_url;
+
+ /**
+ * Name of the charity associated with the Donau instance.
+ */
+ const char *charity_name;
+
+ /**
+ * Public key of the charity.
+ */
+ struct DONAU_CharityPublicKeyP charity_pub_key;
+
+ /**
+ * ID of the charity on Donau.
+ */
+ uint64_t charity_id;
+
+ /**
+ * Maximum donation amount per year allowed for the charity.
+ */
+ struct TALER_Amount charity_max_per_year;
+
+ /**
+ * Total donations received by the charity in the current year.
+ */
+ struct TALER_Amount charity_receipts_to_date;
+
+ /**
+ * The current year being tracked for donations.
+ */
+ int64_t current_year;
+
+ /**
+ * Additional key information related to the Donau instance.
+ */
+ const struct DONAU_Keys *donau_keys;
+};
+
+
+/**
+ * Response details for a GET /private/donau request.
+ */
+struct TALER_MERCHANT_DonauInstanceGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Number of Donau instances in @a donau_instances.
+ */
+ unsigned int donau_instances_length;
+
+ /**
+ * Array of Donau instance entries.
+ */
+ const struct TALER_MERCHANT_DonauInstanceEntry *donau_instances;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/donau request.
+ *
+ * @param cls closure
+ * @param igr response details
+ */
+typedef void
+(*TALER_MERCHANT_DonauInstanceGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_DonauInstanceGetResponse *igr);
+
+
+/**
+ * Issue a GET /private/donau request to list registered Donau instances.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_DonauInstanceGetHandle *
+TALER_MERCHANT_donau_instances_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ TALER_MERCHANT_DonauInstanceGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/donau request.
+ *
+ * @param[in] dgh handle to cancel
+ */
+void
+TALER_MERCHANT_donau_instances_get_cancel (
+ struct TALER_MERCHANT_DonauInstanceGetHandle *dgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-kyc.h b/src/include/taler/taler-merchant/get-private-kyc.h
@@ -0,0 +1,231 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-management-instances-INSTANCE-kyc.h
+ * @brief C interface for GET /management/instances/$INSTANCE/kyc of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_INSTANCE_KYC_H
+#define _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_INSTANCE_KYC_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /management/instances/$INSTANCE/kyc (or /private/kyc) request.
+ */
+struct TALER_MERCHANT_KycGetHandle;
+
+
+/**
+ * Information about KYC actions the merchant still must perform.
+ */
+struct TALER_MERCHANT_AccountKycRedirectDetail
+{
+
+ /**
+ * Access token the user needs to start a KYC process,
+ * all zero if a KYC auth transfer must be made first.
+ */
+ struct TALER_AccountAccessTokenP access_token;
+
+ /**
+ * Base URL of the exchange this is about.
+ */
+ const char *exchange_url;
+
+ /**
+ * Our bank wire account this is about.
+ */
+ struct TALER_FullPayto payto_uri;
+
+ /**
+ * Array of length @e limits_array with (exposed) limits that apply to the
+ * account.
+ */
+ const struct TALER_EXCHANGE_AccountLimit *limits;
+
+ /**
+ * Array of payto://-URIs with instructions for wire
+ * transfers to perform a KYC auth wire transfer for
+ * the given account. Needed if @e kyc_url is NULL
+ * and @e limits are to be passed.
+ */
+ struct TALER_FullPayto *payto_kycauths;
+
+ /**
+ * Length of the @e limits array.
+ */
+ unsigned int limits_length;
+
+ /**
+ * Length of the @e payto_kycauths array.
+ */
+ unsigned int pkycauth_length;
+
+ /**
+ * HTTP status code returned by the exchange when we asked for
+ * information about the KYC status.
+ * 0 if there was no response at all.
+ */
+ unsigned int exchange_http_status;
+
+ /**
+ * Error code indicating errors the exchange
+ * returned, or #TALER_EC_NONE for none.
+ */
+ enum TALER_ErrorCode exchange_code;
+
+ /**
+ * Set to true if @e access_token was not given.
+ */
+ bool no_access_token;
+
+ /**
+ * Set to true if the merchant backend could not
+ * get the exchanges ``/keys`` and thus could not
+ * determine default limits or determine an
+ * @e auth_conflict.
+ */
+ bool no_keys;
+
+ /**
+ * Set to true if the given account cannot to KYC at the given exchange
+ * because no wire method exists that could be used to do the KYC auth wire
+ * transfer.
+ */
+ bool auth_conflict;
+};
+
+
+/**
+ * Response details for a KYC status request.
+ */
+struct TALER_MERCHANT_KycResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK (all accounts passed KYC).
+ */
+ struct
+ {
+
+ /**
+ * Number of KYC redirect details in @a kycs.
+ */
+ unsigned int kycs_length;
+
+ /**
+ * Array of KYC redirect details for accounts requiring KYC.
+ */
+ const struct TALER_MERCHANT_AccountKycRedirectDetail *kycs;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a KYC status request.
+ *
+ * @param cls closure
+ * @param kr response details
+ */
+typedef void
+(*TALER_MERCHANT_KycGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_KycResponse *kr);
+
+
+/**
+ * Issue a GET /private/kyc request to check KYC status for accounts
+ * of the current instance.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param h_wire hash of the wire account to check, or NULL for all
+ * @param exchange_url URL of the exchange to check with, or NULL for any
+ * @param lpt long-poll target (what status to wait for)
+ * @param timeout long-polling timeout
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_KycGetHandle *
+TALER_MERCHANT_kyc_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ enum TALER_EXCHANGE_KycLongPollTarget lpt,
+ struct GNUNET_TIME_Relative timeout,
+ TALER_MERCHANT_KycGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Issue a GET /management/instances/$INSTANCE/kyc request to check KYC
+ * status for accounts of a specific instance (management access required).
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param instance_id identifier of the instance to check
+ * @param h_wire hash of the wire account to check, or NULL for all
+ * @param exchange_url URL of the exchange to check with, or NULL for any
+ * @param lpt long-poll target (what status to wait for)
+ * @param timeout long-polling timeout
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_KycGetHandle *
+TALER_MERCHANT_management_kyc_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ enum TALER_EXCHANGE_KycLongPollTarget lpt,
+ struct GNUNET_TIME_Relative timeout,
+ TALER_MERCHANT_KycGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a KYC status request.
+ *
+ * @param[in] kyc handle to cancel
+ */
+void
+TALER_MERCHANT_kyc_get_cancel (
+ struct TALER_MERCHANT_KycGetHandle *kyc);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-orders-ORDER_ID.h b/src/include/taler/taler-merchant/get-private-orders-ORDER_ID.h
@@ -0,0 +1,288 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-orders-ORDER_ID.h
+ * @brief C interface for GET /private/orders/$ORDER_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_ORDERS_ORDER_ID_H
+#define _TALER_MERCHANT__GET_PRIVATE_ORDERS_ORDER_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/orders/$ORDER_ID request.
+ */
+struct TALER_MERCHANT_OrderMerchantGetHandle;
+
+
+/**
+ * Order status code.
+ */
+enum TALER_MERCHANT_OrderStatusCode
+{
+ /**
+ * The order is unpaid.
+ */
+ TALER_MERCHANT_OSC_UNPAID = 0,
+
+ /**
+ * The order has been claimed by a wallet.
+ */
+ TALER_MERCHANT_OSC_CLAIMED = 1,
+
+ /**
+ * The order has been paid.
+ */
+ TALER_MERCHANT_OSC_PAID = 2
+};
+
+
+/**
+ * Refund detail in a paid order (merchant view).
+ */
+struct TALER_MERCHANT_RefundOrderDetail
+{
+
+ /**
+ * Human-readable reason given for the refund.
+ */
+ const char *reason;
+
+ /**
+ * Time when the refund was granted.
+ */
+ struct GNUNET_TIME_Timestamp refund_time;
+
+ /**
+ * Total amount that was refunded.
+ */
+ struct TALER_Amount refund_amount;
+
+};
+
+
+/**
+ * Response details for a GET /private/orders/$ORDER_ID request.
+ */
+struct TALER_MERCHANT_OrderStatusResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Current status of the order.
+ */
+ enum TALER_MERCHANT_OrderStatusCode status;
+
+ /**
+ * Details depending on @a status.
+ */
+ union
+ {
+
+ /**
+ * Details when @a status is #TALER_MERCHANT_OSC_UNPAID.
+ */
+ struct
+ {
+
+ /**
+ * Total amount of the order.
+ */
+ struct TALER_Amount contract_amount;
+
+ /**
+ * Order ID of a previously paid order that covers this one,
+ * or NULL if none.
+ */
+ const char *already_paid_order_id;
+
+ /**
+ * Taler pay URI for this order.
+ */
+ const char *taler_pay_uri;
+
+ /**
+ * Short summary of the order.
+ */
+ const char *summary;
+
+ /**
+ * Timestamp when the order was created.
+ */
+ struct GNUNET_TIME_Timestamp creation_time;
+
+ } unpaid;
+
+ /**
+ * Details when @a status is #TALER_MERCHANT_OSC_CLAIMED.
+ */
+ struct
+ {
+
+ /**
+ * Contract terms (JSON).
+ */
+ const json_t *contract_terms;
+
+ } claimed;
+
+ /**
+ * Details when @a status is #TALER_MERCHANT_OSC_PAID.
+ */
+ struct
+ {
+
+ /**
+ * True if a refund has been granted.
+ */
+ bool refunded;
+
+ /**
+ * True if a refund is still pending at the exchange.
+ */
+ bool refund_pending;
+
+ /**
+ * True if the payment has been wired to the merchant.
+ */
+ bool wired;
+
+ /**
+ * Total amount deposited.
+ */
+ struct TALER_Amount deposit_total;
+
+ /**
+ * Error code from the exchange, or TALER_EC_NONE.
+ */
+ enum TALER_ErrorCode exchange_ec;
+
+ /**
+ * HTTP status returned by the exchange.
+ */
+ unsigned int exchange_hc;
+
+ /**
+ * Total amount refunded.
+ */
+ struct TALER_Amount refund_amount;
+
+ /**
+ * Contract terms (JSON).
+ */
+ const json_t *contract_terms;
+
+ /**
+ * Number of wire transfers in @a wts.
+ */
+ unsigned int wts_len;
+
+ /**
+ * Array of wire transfer details.
+ */
+ struct TALER_MERCHANT_WireTransfer *wts;
+
+ /**
+ * Number of refund details in @a refunds.
+ */
+ unsigned int refunds_len;
+
+ /**
+ * Array of per-coin refund details.
+ */
+ struct TALER_MERCHANT_RefundOrderDetail *refunds;
+
+ /**
+ * Timestamp of the last payment.
+ */
+ struct GNUNET_TIME_Timestamp last_payment;
+
+ } paid;
+
+ } details;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/orders/$ORDER_ID request.
+ *
+ * @param cls closure
+ * @param osr response details
+ */
+typedef void
+(*TALER_MERCHANT_OrderMerchantGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_OrderStatusResponse *osr);
+
+
+/**
+ * Issue a GET /private/orders/$ORDER_ID request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param order_id identifier of the order to retrieve
+ * @param session_id session ID for repurchase detection, or NULL
+ * @param timeout long-polling timeout
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrderMerchantGetHandle *
+TALER_MERCHANT_merchant_order_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *order_id,
+ const char *session_id,
+ struct GNUNET_TIME_Relative timeout,
+ TALER_MERCHANT_OrderMerchantGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/orders/$ORDER_ID request.
+ *
+ * @param[in] omgh handle to cancel
+ */
+void
+TALER_MERCHANT_merchant_order_get_cancel (
+ struct TALER_MERCHANT_OrderMerchantGetHandle *omgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-orders.h b/src/include/taler/taler-merchant/get-private-orders.h
@@ -0,0 +1,233 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-orders.h
+ * @brief C interface for GET /private/orders of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_ORDERS_H
+#define _TALER_MERCHANT__GET_PRIVATE_ORDERS_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/orders request.
+ */
+struct TALER_MERCHANT_OrdersGetHandle;
+
+
+/**
+ * Entry for one order in the GET /private/orders response.
+ */
+struct TALER_MERCHANT_OrderEntry
+{
+
+ /**
+ * The order identifier string.
+ */
+ const char *order_id;
+
+ /**
+ * Timestamp when the order was created.
+ */
+ struct GNUNET_TIME_Timestamp timestamp;
+
+ /**
+ * Serial number of the order in the database.
+ */
+ uint64_t order_serial;
+
+ /**
+ * Total amount of the order.
+ */
+ struct TALER_Amount amount;
+
+ /**
+ * Amount refunded so far.
+ */
+ struct TALER_Amount refund_amount;
+
+ /**
+ * Amount still pending refund.
+ */
+ struct TALER_Amount pending_refund_amount;
+
+ /**
+ * Short summary of the order.
+ */
+ const char *summary;
+
+ /**
+ * True if refund is possible.
+ */
+ bool refundable;
+
+ /**
+ * True if the order has been paid.
+ */
+ bool paid;
+
+};
+
+
+/**
+ * Response details for a GET /private/orders request.
+ */
+struct TALER_MERCHANT_OrdersGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Number of orders in @a orders.
+ */
+ unsigned int orders_length;
+
+ /**
+ * Array of order entries.
+ */
+ const struct TALER_MERCHANT_OrderEntry *orders;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/orders request.
+ *
+ * @param cls closure
+ * @param ogr response details
+ */
+typedef void
+(*TALER_MERCHANT_OrdersGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_OrdersGetResponse *ogr);
+
+
+/**
+ * Issue a GET /private/orders request (simple form).
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrdersGetHandle *
+TALER_MERCHANT_orders_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ TALER_MERCHANT_OrdersGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Issue a GET /private/orders request with filters.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param paid filter by paid status
+ * @param refunded filter by refunded status
+ * @param wired filter by wired status
+ * @param date date to use for pagination
+ * @param start_row row to start from
+ * @param delta number of results to return (negative for backwards)
+ * @param timeout long-polling timeout
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrdersGetHandle *
+TALER_MERCHANT_orders_get2 (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ enum TALER_EXCHANGE_YesNoAll paid,
+ enum TALER_EXCHANGE_YesNoAll refunded,
+ enum TALER_EXCHANGE_YesNoAll wired,
+ struct GNUNET_TIME_Timestamp date,
+ uint64_t start_row,
+ int64_t delta,
+ struct GNUNET_TIME_Relative timeout,
+ TALER_MERCHANT_OrdersGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Issue a GET /private/orders request with extended filters including
+ * session and fulfillment URL filtering.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param paid filter by paid status
+ * @param refunded filter by refunded status
+ * @param wired filter by wired status
+ * @param session_id filter by session ID, or NULL
+ * @param fulfillment_url filter by fulfillment URL, or NULL
+ * @param date date to use for pagination
+ * @param start_row row to start from
+ * @param delta number of results to return (negative for backwards)
+ * @param timeout long-polling timeout
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrdersGetHandle *
+TALER_MERCHANT_orders_get3 (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ enum TALER_EXCHANGE_YesNoAll paid,
+ enum TALER_EXCHANGE_YesNoAll refunded,
+ enum TALER_EXCHANGE_YesNoAll wired,
+ const char *session_id,
+ const char *fulfillment_url,
+ struct GNUNET_TIME_Timestamp date,
+ uint64_t start_row,
+ int64_t delta,
+ struct GNUNET_TIME_Relative timeout,
+ TALER_MERCHANT_OrdersGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/orders request.
+ *
+ * @param[in] ogh handle to cancel
+ */
+void
+TALER_MERCHANT_orders_get_cancel (
+ struct TALER_MERCHANT_OrdersGetHandle *ogh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-otp-devices-DEVICE_ID.h b/src/include/taler/taler-merchant/get-private-otp-devices-DEVICE_ID.h
@@ -0,0 +1,134 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-otp-devices-DEVICE_ID.h
+ * @brief C interface for GET /private/otp-devices/$DEVICE_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_DEVICE_ID_H
+#define _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_DEVICE_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/otp-devices/$DEVICE_ID request.
+ */
+struct TALER_MERCHANT_OtpDeviceGetHandle;
+
+
+/**
+ * Response details for a GET /private/otp-devices/$DEVICE_ID request.
+ */
+struct TALER_MERCHANT_OtpDeviceGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Human-readable description of the OTP device.
+ */
+ const char *otp_device_description;
+
+ /**
+ * Current counter value of the OTP device (for HOTP).
+ */
+ uint64_t otp_ctr;
+
+ /**
+ * Current timestamp in seconds (for TOTP).
+ */
+ uint64_t otp_timestamp_s;
+
+ /**
+ * POS confirmation text with OTP codes that
+ * would be returned for a purchase over the
+ * amount given in the query for the respective
+ * time and algorithm. NULL if the confirmation
+ * could not be computed based on the query and
+ * OTP algorithm.
+ */
+ const char *otp_code;
+
+ /**
+ * OTP algorithm used.
+ */
+ enum TALER_MerchantConfirmationAlgorithm otp_alg;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/otp-devices/$DEVICE_ID request.
+ *
+ * @param cls closure
+ * @param ogr response details
+ */
+typedef void
+(*TALER_MERCHANT_OtpDeviceGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_OtpDeviceGetResponse *ogr);
+
+
+/**
+ * Issue a GET /private/otp-devices/$DEVICE_ID request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param otp_device_id identifier of the OTP device to retrieve
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OtpDeviceGetHandle *
+TALER_MERCHANT_otp_device_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *otp_device_id,
+ TALER_MERCHANT_OtpDeviceGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/otp-devices/$DEVICE_ID request.
+ *
+ * @param[in] tgh handle to cancel
+ */
+void
+TALER_MERCHANT_otp_device_get_cancel (
+ struct TALER_MERCHANT_OtpDeviceGetHandle *tgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-otp-devices.h b/src/include/taler/taler-merchant/get-private-otp-devices.h
@@ -0,0 +1,131 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-otp-devices.h
+ * @brief C interface for GET /private/otp-devices of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_H
+#define _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/otp-devices request.
+ */
+struct TALER_MERCHANT_OtpDevicesGetHandle;
+
+
+/**
+ * Entry for one OTP device.
+ */
+struct TALER_MERCHANT_OtpDeviceEntry
+{
+
+ /**
+ * Identifier of the OTP device.
+ */
+ const char *otp_device_id;
+
+ /**
+ * Human-readable description of the OTP device.
+ */
+ const char *otp_device_description;
+
+};
+
+
+/**
+ * Response details for a GET /private/otp-devices request.
+ */
+struct TALER_MERCHANT_OtpDevicesGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Number of OTP devices in @a otp_devices.
+ */
+ unsigned int otp_devices_length;
+
+ /**
+ * Array of OTP device entries.
+ */
+ const struct TALER_MERCHANT_OtpDeviceEntry *otp_devices;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/otp-devices request.
+ *
+ * @param cls closure
+ * @param ogr response details
+ */
+typedef void
+(*TALER_MERCHANT_OtpDevicesGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_OtpDevicesGetResponse *ogr);
+
+
+/**
+ * Issue a GET /private/otp-devices request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OtpDevicesGetHandle *
+TALER_MERCHANT_otp_devices_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ TALER_MERCHANT_OtpDevicesGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/otp-devices request.
+ *
+ * @param[in] tgh handle to cancel
+ */
+void
+TALER_MERCHANT_otp_devices_get_cancel (
+ struct TALER_MERCHANT_OtpDevicesGetHandle *tgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-products-PRODUCT_ID.h b/src/include/taler/taler-merchant/get-private-products-PRODUCT_ID.h
@@ -0,0 +1,190 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-products-PRODUCT_ID.h
+ * @brief C interface for GET /private/products/$PRODUCT_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_PRODUCTS_PRODUCT_ID_H
+#define _TALER_MERCHANT__GET_PRIVATE_PRODUCTS_PRODUCT_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/products/$PRODUCT_ID request.
+ */
+struct TALER_MERCHANT_ProductGetHandle;
+
+
+/**
+ * Response details for a GET /private/products/$PRODUCT_ID request.
+ */
+struct TALER_MERCHANT_ProductGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Human-readable product name.
+ */
+ const char *product_name;
+
+ /**
+ * Human-readable product description.
+ */
+ const char *description;
+
+ /**
+ * Internationalized descriptions (JSON object), or NULL.
+ */
+ const json_t *description_i18n;
+
+ /**
+ * Unit of measurement for this product.
+ */
+ const char *unit;
+
+ /**
+ * Number of prices in @a unit_price.
+ */
+ size_t unit_price_len;
+
+ /**
+ * Array of unit prices (for different payment options).
+ */
+ const struct TALER_Amount *unit_price;
+
+ /**
+ * Single unit price (first element of @a unit_price, for backwards compatibility).
+ */
+ struct TALER_Amount price;
+
+ /**
+ * Base64-encoded product image, or empty string.
+ */
+ const char *image;
+
+ /**
+ * Tax information (JSON array), or NULL.
+ */
+ const json_t *taxes;
+
+ /**
+ * Total available stock (-1 for unlimited).
+ */
+ int64_t total_stock;
+
+ /**
+ * Total stock in fractional unit representation.
+ * Stock level encoded as a decimal string. Preferred source of truth for fractional stock.
+ */
+ const char *unit_total_stock;
+
+ /**
+ * Whether fractional quantities are allowed.
+ */
+ bool unit_allow_fraction;
+
+ /**
+ * Precision level for fractional quantities.
+ */
+ uint32_t unit_precision_level;
+
+ /**
+ * Total number of units sold.
+ */
+ uint64_t total_sold;
+
+ /**
+ * Total number of units lost/expired.
+ */
+ uint64_t total_lost;
+
+ /**
+ * Storage location (JSON), or NULL.
+ */
+ const json_t *location;
+
+ /**
+ * Expected time of next restock (may be zero if unknown).
+ */
+ struct GNUNET_TIME_Timestamp next_restock;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/products/$PRODUCT_ID request.
+ *
+ * @param cls closure
+ * @param pgr response details
+ */
+typedef void
+(*TALER_MERCHANT_ProductGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_ProductGetResponse *pgr);
+
+
+/**
+ * Issue a GET /private/products/$PRODUCT_ID request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param product_id identifier of the product to retrieve
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ProductGetHandle *
+TALER_MERCHANT_product_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *product_id,
+ TALER_MERCHANT_ProductGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/products/$PRODUCT_ID request.
+ *
+ * @param[in] pgh handle to cancel
+ */
+void
+TALER_MERCHANT_product_get_cancel (
+ struct TALER_MERCHANT_ProductGetHandle *pgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-products.h b/src/include/taler/taler-merchant/get-private-products.h
@@ -0,0 +1,130 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-products.h
+ * @brief C interface for GET /private/products of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_PRODUCTS_H
+#define _TALER_MERCHANT__GET_PRIVATE_PRODUCTS_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/products request.
+ */
+struct TALER_MERCHANT_ProductsGetHandle;
+
+/**
+ * Inventory entry for the GET /private/products response.
+ */
+struct TALER_MERCHANT_InventoryEntry
+{
+
+ /**
+ * Identifier of the product.
+ */
+ const char *product_id;
+
+ /**
+ * Serial ID of the product.
+ */
+ uint64_t product_serial;
+
+};
+
+
+/**
+ * Response details for a GET /private/products request.
+ */
+struct TALER_MERCHANT_GetProductsResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Number of products in @a products.
+ */
+ unsigned int products_length;
+
+ /**
+ * Array of product entries.
+ */
+ const struct TALER_MERCHANT_InventoryEntry *products;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/products request.
+ *
+ * @param cls closure
+ * @param pgr response details
+ */
+typedef void
+(*TALER_MERCHANT_ProductsGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_GetProductsResponse *pgr);
+
+
+/**
+ * Issue a GET /private/products request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ProductsGetHandle *
+TALER_MERCHANT_products_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ TALER_MERCHANT_ProductsGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/products request.
+ *
+ * @param[in] pgh handle to cancel
+ */
+void
+TALER_MERCHANT_products_get_cancel (
+ struct TALER_MERCHANT_ProductsGetHandle *pgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-statistics-amount-SLUG.h b/src/include/taler/taler-merchant/get-private-statistics-amount-SLUG.h
@@ -0,0 +1,198 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-management-instances-INSTANCE-statistics-amount-SLUG.h
+ * @brief C interface for GET .../statistics/amount/$SLUG of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef \
+ _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_INSTANCE_STATISTICS_AMOUNT_SLUG_H
+#define \
+ _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_INSTANCE_STATISTICS_AMOUNT_SLUG_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Statistic amount aggregated by bucket.
+ */
+struct TALER_MERCHANT_StatisticAmountByBucket
+{
+ /**
+ * Start time of the bucket (inclusive).
+ */
+ struct GNUNET_TIME_Timestamp start_time;
+
+ /**
+ * End time of the bucket (exclusive).
+ */
+ struct GNUNET_TIME_Timestamp end_time;
+
+ /**
+ * Range of the bucket
+ */
+ const char *range;
+
+ /**
+ * Sum of all amounts falling under the given
+ * SLUG within this timeframe.
+ */
+ struct TALER_Amount *cumulative_amounts;
+
+ /**
+ * Length of array @a cumulative_amounts
+ */
+ unsigned int cumulative_amount_len;
+};
+
+
+/**
+ * Statistic amount aggregated by interval.
+ */
+struct TALER_MERCHANT_StatisticAmountByInterval
+{
+ /**
+ * Start time of the interval (inclusive).
+ * The interval always ends at the response
+ * generation time.
+ */
+ struct GNUNET_TIME_Timestamp start_time;
+
+ /**
+ * Sum of all amounts falling under the given
+ * SLUG within this timeframe.
+ */
+ struct TALER_Amount *cumulative_amounts;
+
+ /**
+ * Length of array @a cumulative_amounts
+ */
+ unsigned int cumulative_amount_len;
+
+};
+
+
+/**
+ * Handle for a GET .../statistics/amount/$SLUG request.
+ */
+struct TALER_MERCHANT_StatisticsAmountGetHandle;
+
+
+/**
+ * Response details for a GET .../statistics/amount/$SLUG request.
+ */
+struct TALER_MERCHANT_StatisticsAmountGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Number of bucket entries in @a buckets.
+ */
+ unsigned int buckets_length;
+
+ /**
+ * Array of amount statistics per bucket.
+ */
+ const struct TALER_MERCHANT_StatisticAmountByBucket *buckets;
+
+ /**
+ * Description of the bucket aggregation scheme, or NULL.
+ */
+ const char *buckets_description;
+
+ /**
+ * Number of interval entries in @a intervals.
+ */
+ unsigned int intervals_length;
+
+ /**
+ * Array of amount statistics per time interval.
+ */
+ const struct TALER_MERCHANT_StatisticAmountByInterval *intervals;
+
+ /**
+ * Description of the interval aggregation scheme, or NULL.
+ */
+ const char *intervals_description;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET .../statistics/amount/$SLUG request.
+ *
+ * @param cls closure
+ * @param sagr response details
+ */
+typedef void
+(*TALER_MERCHANT_StatisticsAmountGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_StatisticsAmountGetResponse *sagr);
+
+
+/**
+ * Issue a GET .../statistics/amount/$SLUG request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param slug statistics slug to retrieve
+ * @param stype aggregation mode to request
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_StatisticsAmountGetHandle *
+TALER_MERCHANT_statistic_amount_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *slug,
+ enum TALER_MERCHANT_StatisticsType stype,
+ TALER_MERCHANT_StatisticsAmountGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET .../statistics/amount/$SLUG request.
+ *
+ * @param[in] sagh handle to cancel
+ */
+void
+TALER_MERCHANT_statistic_amount_get_cancel (
+ struct TALER_MERCHANT_StatisticsAmountGetHandle *sagh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-statistics-counter-SLUG.h b/src/include/taler/taler-merchant/get-private-statistics-counter-SLUG.h
@@ -0,0 +1,190 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-management-instances-INSTANCE-statistics-counter-SLUG.h
+ * @brief C interface for GET .../statistics/counter/$SLUG of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef \
+ _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_INSTANCE_STATISTICS_COUNTER_SLUG_H
+#define \
+ _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_INSTANCE_STATISTICS_COUNTER_SLUG_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET .../statistics/counter/$SLUG request.
+ */
+struct TALER_MERCHANT_StatisticsCounterGetHandle;
+
+/**
+ * Statistic counter aggregated by bucket.
+ */
+struct TALER_MERCHANT_StatisticCounterByBucket
+{
+
+ /**
+ * Start time of the bucket (inclusive).
+ */
+ struct GNUNET_TIME_Timestamp start_time;
+
+ /**
+ * End time of the bucket (exclusive).
+ */
+ struct GNUNET_TIME_Timestamp end_time;
+
+ /**
+ * Range of the bucket
+ */
+ const char *range;
+
+ /**
+ * Sum of all counters falling under the given
+ * SLUG within this timeframe.
+ */
+ uint64_t cumulative_counter;
+
+};
+
+
+/**
+ * Statistic counter aggregated by interval.
+ */
+struct TALER_MERCHANT_StatisticCounterByInterval
+{
+
+ /**
+ * Start time of the interval (inclusive).
+ * The interval always ends at the response
+ * generation time.
+ */
+ struct GNUNET_TIME_Timestamp start_time;
+
+ /**
+ * Sum of all counters falling under the given
+ * SLUG within this timeframe.
+ */
+ uint64_t cumulative_counter;
+
+};
+
+
+/**
+ * Response details for a GET .../statistics/counter/$SLUG request.
+ */
+struct TALER_MERCHANT_StatisticsCounterGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Number of bucket entries in @a buckets.
+ */
+ unsigned int buckets_length;
+
+ /**
+ * Array of counter statistics per bucket.
+ */
+ const struct TALER_MERCHANT_StatisticCounterByBucket *buckets;
+
+ /**
+ * Description of the bucket aggregation scheme, or NULL.
+ */
+ const char *buckets_description;
+
+ /**
+ * Number of interval entries in @a intervals.
+ */
+ unsigned int intervals_length;
+
+ /**
+ * Array of counter statistics per time interval.
+ */
+ const struct TALER_MERCHANT_StatisticCounterByInterval *intervals;
+
+ /**
+ * Description of the interval aggregation scheme, or NULL.
+ */
+ const char *intervals_description;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET .../statistics/counter/$SLUG request.
+ *
+ * @param cls closure
+ * @param scgr response details
+ */
+typedef void
+(*TALER_MERCHANT_StatisticsCounterGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_StatisticsCounterGetResponse *scgr);
+
+
+/**
+ * Issue a GET .../statistics/counter/$SLUG request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param slug statistics slug to retrieve
+ * @param stype aggregation mode to request
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_StatisticsCounterGetHandle *
+TALER_MERCHANT_statistic_counter_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *slug,
+ enum TALER_MERCHANT_StatisticsType stype,
+ TALER_MERCHANT_StatisticsCounterGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET .../statistics/counter/$SLUG request.
+ *
+ * @param[in] scgh handle to cancel
+ */
+void
+TALER_MERCHANT_statistic_counter_get_cancel (
+ struct TALER_MERCHANT_StatisticsCounterGetHandle *scgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-templates-TEMPLATE_ID.h b/src/include/taler/taler-merchant/get-private-templates-TEMPLATE_ID.h
@@ -0,0 +1,119 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-templates-TEMPLATE_ID.h
+ * @brief C interface for GET /private/templates/$TEMPLATE_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_TEMPLATE_ID_H
+#define _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_TEMPLATE_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/templates/$TEMPLATE_ID request.
+ */
+struct TALER_MERCHANT_TemplateGetHandle;
+
+
+/**
+ * Response details for a GET /private/templates/$TEMPLATE_ID request.
+ */
+struct TALER_MERCHANT_TemplateGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Human-readable description of the template.
+ */
+ const char *template_description;
+
+ /**
+ * OTP device ID associated with this template, or NULL.
+ */
+ const char *otp_id;
+
+ /**
+ * Template contract (JSON).
+ */
+ const json_t *template_contract;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/templates/$TEMPLATE_ID request.
+ *
+ * @param cls closure
+ * @param tgr response details
+ */
+typedef void
+(*TALER_MERCHANT_TemplateGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_TemplateGetResponse *tgr);
+
+
+/**
+ * Issue a GET /private/templates/$TEMPLATE_ID request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param template_id identifier of the template to retrieve
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_TemplateGetHandle *
+TALER_MERCHANT_template_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *template_id,
+ TALER_MERCHANT_TemplateGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/templates/$TEMPLATE_ID request.
+ *
+ * @param[in] tgh handle to cancel
+ */
+void
+TALER_MERCHANT_template_get_cancel (
+ struct TALER_MERCHANT_TemplateGetHandle *tgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-templates.h b/src/include/taler/taler-merchant/get-private-templates.h
@@ -0,0 +1,131 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-templates.h
+ * @brief C interface for GET /private/templates of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_H
+#define _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/templates request.
+ */
+struct TALER_MERCHANT_TemplatesGetHandle;
+
+
+/**
+ * Entry for one order template.
+ */
+struct TALER_MERCHANT_TemplateEntry
+{
+
+ /**
+ * Identifier of the template.
+ */
+ const char *template_id;
+
+ /**
+ * Human-readable description of the template.
+ */
+ const char *template_description;
+
+};
+
+
+/**
+ * Response details for a GET /private/templates request.
+ */
+struct TALER_MERCHANT_TemplatesGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Number of templates in @a templates.
+ */
+ unsigned int templates_length;
+
+ /**
+ * Array of template entries.
+ */
+ const struct TALER_MERCHANT_TemplateEntry *templates;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/templates request.
+ *
+ * @param cls closure
+ * @param tgr response details
+ */
+typedef void
+(*TALER_MERCHANT_TemplatesGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_TemplatesGetResponse *tgr);
+
+
+/**
+ * Issue a GET /private/templates request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_TemplatesGetHandle *
+TALER_MERCHANT_templates_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ TALER_MERCHANT_TemplatesGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/templates request.
+ *
+ * @param[in] tgh handle to cancel
+ */
+void
+TALER_MERCHANT_templates_get_cancel (
+ struct TALER_MERCHANT_TemplatesGetHandle *tgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG.h b/src/include/taler/taler-merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG.h
@@ -0,0 +1,171 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG.h
+ * @brief C interface for GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG
+ * of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_TOKENFAMILIES_TOKEN_FAMILY_SLUG_H
+#define _TALER_MERCHANT__GET_PRIVATE_TOKENFAMILIES_TOKEN_FAMILY_SLUG_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG request.
+ */
+struct TALER_MERCHANT_TokenFamilyGetHandle;
+
+
+/**
+ * Response details for a GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG request.
+ */
+struct TALER_MERCHANT_TokenFamilyGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * URL-safe slug identifier of the token family.
+ */
+ const char *slug;
+
+ /**
+ * Human-readable name.
+ */
+ const char *name;
+
+ /**
+ * Human-readable description.
+ */
+ const char *description;
+
+ /**
+ * Internationalized descriptions (JSON), or NULL.
+ */
+ const json_t *description_i18n;
+
+ /**
+ * Extra data associated with this token family (JSON), or NULL.
+ */
+ const json_t *extra_data;
+
+ /**
+ * Start of validity period.
+ */
+ struct GNUNET_TIME_Timestamp valid_after;
+
+ /**
+ * End of validity period.
+ */
+ struct GNUNET_TIME_Timestamp valid_before;
+
+ /**
+ * Duration of individual token validity.
+ */
+ struct GNUNET_TIME_Relative duration;
+
+ /**
+ * Granularity for validity period alignment.
+ */
+ struct GNUNET_TIME_Relative validity_granularity;
+
+ /**
+ * Offset from purchase time to start of validity.
+ */
+ struct GNUNET_TIME_Relative start_offset;
+
+ /**
+ * Kind of token family ("subscription" or "discount").
+ */
+ const char *kind;
+
+ /**
+ * Total number of tokens issued.
+ */
+ uint64_t issued;
+
+ /**
+ * Total number of tokens used.
+ */
+ uint64_t used;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG request.
+ *
+ * @param cls closure
+ * @param tfgr response details
+ */
+typedef void
+(*TALER_MERCHANT_TokenFamilyGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_TokenFamilyGetResponse *tfgr);
+
+
+/**
+ * Issue a GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param token_family_slug slug of the token family to retrieve
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_TokenFamilyGetHandle *
+TALER_MERCHANT_token_family_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *token_family_slug,
+ TALER_MERCHANT_TokenFamilyGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG request.
+ *
+ * @param[in] handle handle to cancel
+ */
+void
+TALER_MERCHANT_token_family_get_cancel (
+ struct TALER_MERCHANT_TokenFamilyGetHandle *handle);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-transfers.h b/src/include/taler/taler-merchant/get-private-transfers.h
@@ -0,0 +1,173 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-transfers.h
+ * @brief C interface for GET /private/transfers of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_TRANSFERS_H
+#define _TALER_MERCHANT__GET_PRIVATE_TRANSFERS_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/transfers request.
+ */
+struct TALER_MERCHANT_GetTransfersHandle;
+
+
+/**
+ * Transfer data entry.
+ */
+struct TALER_MERCHANT_TransferData
+{
+
+
+ /**
+ * Total amount wired by the exchange (without wire fee)
+ */
+ struct TALER_Amount credit_amount;
+
+ /**
+ * Wire transfer identifier used.
+ */
+ struct TALER_WireTransferIdentifierRawP wtid;
+
+ /**
+ * URI of the target account.
+ */
+ struct TALER_FullPayto payto_uri;
+
+ /**
+ * URL of the exchange that made the transfer.
+ */
+ const char *exchange_url;
+
+ /**
+ * Serial number of the credit operation in the merchant backend.
+ * Needed, for example, to delete the transfer using
+ * #TALER_MERCHANT_transfer_delete().
+ */
+ uint64_t credit_serial;
+
+ /**
+ * Time of the wire transfer, based on when we received
+ * a confirmation for the wire transfer.
+ */
+ struct GNUNET_TIME_Timestamp execution_time;
+
+ /**
+ * True if this wire transfer was expected.
+ */
+ bool expected;
+
+};
+
+
+/**
+ * Response details for a GET /private/transfers request.
+ */
+struct TALER_MERCHANT_GetTransfersResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Number of transfers in @a transfers.
+ */
+ unsigned int transfers_length;
+
+ /**
+ * Array of transfer data entries.
+ */
+ const struct TALER_MERCHANT_TransferData *transfers;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/transfers request.
+ *
+ * @param cls closure
+ * @param gtr response details
+ */
+typedef void
+(*TALER_MERCHANT_GetTransfersCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_GetTransfersResponse *gtr);
+
+
+/**
+ * Issue a GET /private/transfers request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param payto_uri filter by payto URI (may be empty)
+ * @param before filter for transfers before this time
+ * @param after filter for transfers after this time
+ * @param limit maximum number of results (negative for descending order)
+ * @param offset pagination offset
+ * @param expected filter by verification status
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_GetTransfersHandle *
+TALER_MERCHANT_transfers_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ struct TALER_FullPayto payto_uri,
+ const struct GNUNET_TIME_Timestamp before,
+ const struct GNUNET_TIME_Timestamp after,
+ int64_t limit,
+ uint64_t offset,
+ enum TALER_EXCHANGE_YesNoAll expected,
+ TALER_MERCHANT_GetTransfersCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/transfers request.
+ *
+ * @param[in] gth handle to cancel
+ */
+void
+TALER_MERCHANT_transfers_get_cancel (
+ struct TALER_MERCHANT_GetTransfersHandle *gth);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-units-UNIT.h b/src/include/taler/taler-merchant/get-private-units-UNIT.h
@@ -0,0 +1,109 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-units-UNIT.h
+ * @brief C interface for GET /private/units/$UNIT of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_UNITS_UNIT_H
+#define _TALER_MERCHANT__GET_PRIVATE_UNITS_UNIT_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/units/$UNIT request.
+ */
+struct TALER_MERCHANT_UnitGetHandle;
+
+
+/**
+ * Response details for a GET /private/units/$UNIT request.
+ */
+struct TALER_MERCHANT_UnitGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Detailed unit information.
+ */
+ struct TALER_MERCHANT_UnitEntry unit;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/units/$UNIT request.
+ *
+ * @param cls closure
+ * @param ugr response details
+ */
+typedef void
+(*TALER_MERCHANT_UnitGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_UnitGetResponse *ugr);
+
+
+/**
+ * Issue a GET /private/units/$UNIT request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param unit_id identifier of the unit to retrieve
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_UnitGetHandle *
+TALER_MERCHANT_unit_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *unit_id,
+ TALER_MERCHANT_UnitGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/units/$UNIT request.
+ *
+ * @param[in] ugh handle to cancel
+ */
+void
+TALER_MERCHANT_unit_get_cancel (
+ struct TALER_MERCHANT_UnitGetHandle *ugh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-units.h b/src/include/taler/taler-merchant/get-private-units.h
@@ -0,0 +1,112 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-units.h
+ * @brief C interface for GET /private/units of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_UNITS_H
+#define _TALER_MERCHANT__GET_PRIVATE_UNITS_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/units request.
+ */
+struct TALER_MERCHANT_UnitsGetHandle;
+
+
+/**
+ * Response details for a GET /private/units request.
+ */
+struct TALER_MERCHANT_UnitsGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Number of units in @a units.
+ */
+ unsigned int units_length;
+
+ /**
+ * Array of unit entries.
+ */
+ const struct TALER_MERCHANT_UnitEntry *units;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/units request.
+ *
+ * @param cls closure
+ * @param ugr response details
+ */
+typedef void
+(*TALER_MERCHANT_UnitsGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_UnitsGetResponse *ugr);
+
+
+/**
+ * Issue a GET /private/units request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_UnitsGetHandle *
+TALER_MERCHANT_units_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ TALER_MERCHANT_UnitsGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/units request.
+ *
+ * @param[in] ugh handle to cancel
+ */
+void
+TALER_MERCHANT_units_get_cancel (
+ struct TALER_MERCHANT_UnitsGetHandle *ugh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-webhooks-WEBHOOK_ID.h b/src/include/taler/taler-merchant/get-private-webhooks-WEBHOOK_ID.h
@@ -0,0 +1,85 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-webhooks-WEBHOOK_ID.h
+ * @brief C interface for GET /private/webhooks/$WEBHOOK_ID of the merchant backend
+ * @author Priscilla Huang
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_WEBHOOK_ID_H
+#define _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_WEBHOOK_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/webhooks/$WEBHOOK_ID request.
+ */
+struct TALER_MERCHANT_WebhookGetHandle;
+
+
+/**
+ * Callback for a GET /private/webhooks/$WEBHOOK_ID request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ * @param event_type event type that triggers this webhook, or NULL on error
+ * @param url URL to send the webhook notification to, or NULL on error
+ * @param http_method HTTP method to use, or NULL on error
+ * @param header_template template for HTTP headers, or NULL on error
+ * @param body_template template for the HTTP body, or NULL on error
+ */
+typedef void
+(*TALER_MERCHANT_WebhookGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr,
+ const char *event_type,
+ const char *url,
+ const char *http_method,
+ const char *header_template,
+ const char *body_template);
+
+
+/**
+ * Issue a GET /private/webhooks/$WEBHOOK_ID request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param webhook_id identifier of the webhook to retrieve
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_WebhookGetHandle *
+TALER_MERCHANT_webhook_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *webhook_id,
+ TALER_MERCHANT_WebhookGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/webhooks/$WEBHOOK_ID request.
+ *
+ * @param[in] wgh handle to cancel
+ */
+void
+TALER_MERCHANT_webhook_get_cancel (
+ struct TALER_MERCHANT_WebhookGetHandle *wgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-private-webhooks.h b/src/include/taler/taler-merchant/get-private-webhooks.h
@@ -0,0 +1,131 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-private-webhooks.h
+ * @brief C interface for GET /private/webhooks of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_H
+#define _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /private/webhooks request.
+ */
+struct TALER_MERCHANT_WebhooksGetHandle;
+
+
+/**
+ * Entry for one webhook.
+ */
+struct TALER_MERCHANT_WebhookEntry
+{
+
+ /**
+ * Identifier of the webhook.
+ */
+ const char *webhook_id;
+
+ /**
+ * Event type that triggers this webhook.
+ */
+ const char *event_type;
+
+};
+
+
+/**
+ * Response details for a GET /private/webhooks request.
+ */
+struct TALER_MERCHANT_WebhooksGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Number of webhooks in @a webhooks.
+ */
+ unsigned int webhooks_length;
+
+ /**
+ * Array of webhook entries.
+ */
+ const struct TALER_MERCHANT_WebhookEntry *webhooks;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /private/webhooks request.
+ *
+ * @param cls closure
+ * @param wgr response details
+ */
+typedef void
+(*TALER_MERCHANT_WebhooksGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_WebhooksGetResponse *wgr);
+
+
+/**
+ * Issue a GET /private/webhooks request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_WebhooksGetHandle *
+TALER_MERCHANT_webhooks_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ TALER_MERCHANT_WebhooksGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /private/webhooks request.
+ *
+ * @param[in] wgh handle to cancel
+ */
+void
+TALER_MERCHANT_webhooks_get_cancel (
+ struct TALER_MERCHANT_WebhooksGetHandle *wgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-products-IMAGE_HASH-image.h b/src/include/taler/taler-merchant/get-products-IMAGE_HASH-image.h
@@ -0,0 +1,110 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-products-IMAGE_HASH-image.h
+ * @brief C interface for GET /products/$IMAGE_HASH/image of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_PRODUCTS_IMAGE_HASH_IMAGE_H
+#define _TALER_MERCHANT__GET_PRODUCTS_IMAGE_HASH_IMAGE_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /products/$IMAGE_HASH/image request.
+ */
+struct TALER_MERCHANT_ProductImageGetHandle;
+
+
+/**
+ * Response details for a GET /products/$IMAGE_HASH/image request.
+ */
+struct TALER_MERCHANT_ProductImageGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Image data (a data URI).
+ */
+ const char *image;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /products/$IMAGE_HASH/image request.
+ *
+ * @param cls closure
+ * @param pgr response details
+ */
+typedef void
+(*TALER_MERCHANT_ProductImageGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_ProductImageGetResponse *pgr);
+
+
+/**
+ * Issue a GET /products/$IMAGE_HASH/image request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param image_hash hash identifying the image to retrieve
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ProductImageGetHandle *
+TALER_MERCHANT_product_image_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *image_hash,
+ TALER_MERCHANT_ProductImageGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /products/$IMAGE_HASH/image request.
+ *
+ * @param[in] pigh handle to cancel
+ */
+void
+TALER_MERCHANT_product_image_get_cancel (
+ struct TALER_MERCHANT_ProductImageGetHandle *pigh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/get-templates-TEMPLATE_ID.h b/src/include/taler/taler-merchant/get-templates-TEMPLATE_ID.h
@@ -0,0 +1,110 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/get-templates-TEMPLATE_ID.h
+ * @brief C interface for GET /templates/$TEMPLATE_ID (wallet-facing) of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__GET_TEMPLATES_TEMPLATE_ID_H
+#define _TALER_MERCHANT__GET_TEMPLATES_TEMPLATE_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a GET /templates/$TEMPLATE_ID request (wallet-facing).
+ */
+struct TALER_MERCHANT_WalletTemplateGetHandle;
+
+
+/**
+ * Response details for a GET /templates/$TEMPLATE_ID request (wallet-facing).
+ */
+struct TALER_MERCHANT_WalletTemplateGetResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Template contract (JSON).
+ */
+ const json_t *template_contract;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a GET /templates/$TEMPLATE_ID request (wallet-facing).
+ *
+ * @param cls closure
+ * @param wtgr response details
+ */
+typedef void
+(*TALER_MERCHANT_WalletTemplateGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_WalletTemplateGetResponse *wtgr);
+
+
+/**
+ * Issue a GET /templates/$TEMPLATE_ID request (wallet-facing).
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param template_id identifier of the template to retrieve
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_WalletTemplateGetHandle *
+TALER_MERCHANT_wallet_template_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *template_id,
+ TALER_MERCHANT_WalletTemplateGetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /templates/$TEMPLATE_ID request (wallet-facing).
+ *
+ * @param[in] tgh handle to cancel
+ */
+void
+TALER_MERCHANT_wallet_template_get_cancel (
+ struct TALER_MERCHANT_WalletTemplateGetHandle *tgh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/patch-management-instances-INSTANCE.h b/src/include/taler/taler-merchant/patch-management-instances-INSTANCE.h
@@ -0,0 +1,89 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/patch-management-instances-INSTANCE.h
+ * @brief C interface for PATCH /management/instances/$INSTANCE of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__PATCH_MANAGEMENT_INSTANCES_INSTANCE_H
+#define _TALER_MERCHANT__PATCH_MANAGEMENT_INSTANCES_INSTANCE_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a PATCH /management/instances/$INSTANCE request.
+ */
+struct TALER_MERCHANT_InstancePatchHandle;
+
+
+/**
+ * Callback for a PATCH /management/instances/$INSTANCE request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_InstancePatchCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a PATCH /management/instances/$INSTANCE request.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param instance_id identifier of the instance to patch
+ * @param name new human-readable name
+ * @param address new address (JSON), or NULL to keep unchanged
+ * @param jurisdiction new jurisdiction (JSON), or NULL to keep unchanged
+ * @param use_stefan whether to use the STEFAN curve for fee calculations
+ * @param default_wire_transfer_delay default delay for wire transfers
+ * @param default_pay_delay default payment deadline
+ * @param default_refund_delay default refund deadline
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_InstancePatchHandle *
+TALER_MERCHANT_instance_patch (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance_id,
+ const char *name,
+ const json_t *address,
+ const json_t *jurisdiction,
+ bool use_stefan,
+ struct GNUNET_TIME_Relative default_wire_transfer_delay,
+ struct GNUNET_TIME_Relative default_pay_delay,
+ struct GNUNET_TIME_Relative default_refund_delay,
+ TALER_MERCHANT_InstancePatchCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a PATCH /management/instances/$INSTANCE request.
+ *
+ * @param[in] iph handle to cancel
+ */
+void
+TALER_MERCHANT_instance_patch_cancel (
+ struct TALER_MERCHANT_InstancePatchHandle *iph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/patch-private-accounts-H_WIRE.h b/src/include/taler/taler-merchant/patch-private-accounts-H_WIRE.h
@@ -0,0 +1,79 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/patch-private-accounts-H_WIRE.h
+ * @brief C interface for PATCH /private/accounts/$H_WIRE of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__PATCH_PRIVATE_ACCOUNTS_H_WIRE_H
+#define _TALER_MERCHANT__PATCH_PRIVATE_ACCOUNTS_H_WIRE_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a PATCH /private/accounts/$H_WIRE request.
+ */
+struct TALER_MERCHANT_AccountPatchHandle;
+
+
+/**
+ * Callback for a PATCH /private/accounts/$H_WIRE request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_AccountPatchCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a PATCH /private/accounts/$H_WIRE request to update a wire account.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param h_wire hash of the wire details identifying the account
+ * @param credit_facade_url new URL of the credit facade, or NULL
+ * @param credit_facade_credentials new credentials (JSON), or NULL
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_AccountPatchHandle *
+TALER_MERCHANT_account_patch (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *credit_facade_url,
+ const json_t *credit_facade_credentials,
+ TALER_MERCHANT_AccountPatchCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a PATCH /private/accounts/$H_WIRE request.
+ *
+ * @param[in] tph handle to cancel
+ */
+void
+TALER_MERCHANT_account_patch_cancel (
+ struct TALER_MERCHANT_AccountPatchHandle *tph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/patch-private-orders-ORDER_ID-forget.h b/src/include/taler/taler-merchant/patch-private-orders-ORDER_ID-forget.h
@@ -0,0 +1,80 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/patch-private-orders-ORDER_ID-forget.h
+ * @brief C interface for PATCH /private/orders/$ORDER_ID/forget of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__PATCH_PRIVATE_ORDERS_ORDER_ID_FORGET_H
+#define _TALER_MERCHANT__PATCH_PRIVATE_ORDERS_ORDER_ID_FORGET_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a PATCH /private/orders/$ORDER_ID/forget request.
+ */
+struct TALER_MERCHANT_OrderForgetHandle;
+
+
+/**
+ * Callback for a PATCH /private/orders/$ORDER_ID/forget request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_ForgetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a PATCH /private/orders/$ORDER_ID/forget request to redact
+ * specific fields from the contract terms.
+ *
+ * @param ctx CURL context to use
+ * @param merchant_url base URL of the merchant backend
+ * @param order_id identifier of the order
+ * @param fields_length number of field paths in @a fields
+ * @param fields array of JSON pointer paths to redact
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrderForgetHandle *
+TALER_MERCHANT_order_forget (
+ struct GNUNET_CURL_Context *ctx,
+ const char *merchant_url,
+ const char *order_id,
+ unsigned int fields_length,
+ const char *fields[static fields_length],
+ TALER_MERCHANT_ForgetCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a PATCH /private/orders/$ORDER_ID/forget request.
+ *
+ * @param[in] ofh handle to cancel
+ */
+void
+TALER_MERCHANT_order_forget_cancel (
+ struct TALER_MERCHANT_OrderForgetHandle *ofh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/patch-private-otp-devices-DEVICE_ID.h b/src/include/taler/taler-merchant/patch-private-otp-devices-DEVICE_ID.h
@@ -0,0 +1,83 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/patch-private-otp-devices-DEVICE_ID.h
+ * @brief C interface for PATCH /private/otp-devices/$DEVICE_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__PATCH_PRIVATE_OTP_DEVICES_DEVICE_ID_H
+#define _TALER_MERCHANT__PATCH_PRIVATE_OTP_DEVICES_DEVICE_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a PATCH /private/otp-devices/$DEVICE_ID request.
+ */
+struct TALER_MERCHANT_OtpDevicePatchHandle;
+
+
+/**
+ * Callback for a PATCH /private/otp-devices/$DEVICE_ID request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_OtpDevicePatchCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a PATCH /private/otp-devices/$DEVICE_ID request to update an OTP device.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param otp_device_id identifier of the OTP device to update
+ * @param otp_device_description new human-readable description
+ * @param otp_key new base32-encoded OTP secret key, or NULL to keep unchanged
+ * @param mca new OTP algorithm
+ * @param otp_ctr new counter value (for HOTP)
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OtpDevicePatchHandle *
+TALER_MERCHANT_otp_device_patch (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *otp_device_id,
+ const char *otp_device_description,
+ const char *otp_key,
+ enum TALER_MerchantConfirmationAlgorithm mca,
+ uint64_t otp_ctr,
+ TALER_MERCHANT_OtpDevicePatchCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a PATCH /private/otp-devices/$DEVICE_ID request.
+ *
+ * @param[in] tph handle to cancel
+ */
+void
+TALER_MERCHANT_otp_device_patch_cancel (
+ struct TALER_MERCHANT_OtpDevicePatchHandle *tph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/patch-private-products-PRODUCT_ID.h b/src/include/taler/taler-merchant/patch-private-products-PRODUCT_ID.h
@@ -0,0 +1,142 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/patch-private-products-PRODUCT_ID.h
+ * @brief C interface for PATCH /private/products/$PRODUCT_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__PATCH_PRIVATE_PRODUCTS_PRODUCT_ID_H
+#define _TALER_MERCHANT__PATCH_PRIVATE_PRODUCTS_PRODUCT_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a PATCH /private/products/$PRODUCT_ID request.
+ */
+struct TALER_MERCHANT_ProductPatchHandle;
+
+
+/**
+ * Callback for a PATCH /private/products/$PRODUCT_ID request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_ProductPatchCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a PATCH /private/products/$PRODUCT_ID request (simple form).
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param product_id identifier of the product to update
+ * @param description new human-readable description
+ * @param description_i18n internationalized descriptions (JSON)
+ * @param unit unit of measurement
+ * @param price new unit price
+ * @param image new base64-encoded image
+ * @param taxes new tax information (JSON array)
+ * @param total_stock new total stock (-1 for unlimited)
+ * @param total_lost total units lost/expired
+ * @param address storage location (JSON)
+ * @param next_restock expected restock time
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ProductPatchHandle *
+TALER_MERCHANT_product_patch (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *product_id,
+ const char *description,
+ const json_t *description_i18n,
+ const char *unit,
+ const struct TALER_Amount *price,
+ const char *image,
+ const json_t *taxes,
+ int64_t total_stock,
+ uint64_t total_lost,
+ const json_t *address,
+ struct GNUNET_TIME_Timestamp next_restock,
+ TALER_MERCHANT_ProductPatchCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Issue a PATCH /private/products/$PRODUCT_ID request with full unit/fraction support.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param product_id identifier of the product to update
+ * @param description new human-readable description
+ * @param description_i18n internationalized descriptions (JSON)
+ * @param unit unit of measurement
+ * @param unit_prices array of unit prices
+ * @param unit_price_len number of prices in @a unit_prices
+ * @param image new base64-encoded image
+ * @param taxes new tax information (JSON array)
+ * @param total_stock integer part of total stock (-1 for unlimited)
+ * @param total_stock_frac fractional part of total stock
+ * @param unit_allow_fraction whether fractional quantities are allowed
+ * @param unit_precision_level precision level for fractions, or NULL
+ * @param total_lost total units lost/expired
+ * @param address storage location (JSON)
+ * @param next_restock expected restock time
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ProductPatchHandle *
+TALER_MERCHANT_product_patch2 (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *product_id,
+ const char *description,
+ const json_t *description_i18n,
+ const char *unit,
+ const struct TALER_Amount *unit_prices,
+ size_t unit_price_len,
+ const char *image,
+ const json_t *taxes,
+ int64_t total_stock,
+ uint32_t total_stock_frac,
+ bool unit_allow_fraction,
+ const uint32_t *unit_precision_level,
+ uint64_t total_lost,
+ const json_t *address,
+ struct GNUNET_TIME_Timestamp next_restock,
+ TALER_MERCHANT_ProductPatchCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a PATCH /private/products/$PRODUCT_ID request.
+ *
+ * @param[in] pph handle to cancel
+ */
+void
+TALER_MERCHANT_product_patch_cancel (
+ struct TALER_MERCHANT_ProductPatchHandle *pph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/patch-private-templates-TEMPLATE_ID.h b/src/include/taler/taler-merchant/patch-private-templates-TEMPLATE_ID.h
@@ -0,0 +1,81 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/patch-private-templates-TEMPLATE_ID.h
+ * @brief C interface for PATCH /private/templates/$TEMPLATE_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__PATCH_PRIVATE_TEMPLATES_TEMPLATE_ID_H
+#define _TALER_MERCHANT__PATCH_PRIVATE_TEMPLATES_TEMPLATE_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a PATCH /private/templates/$TEMPLATE_ID request.
+ */
+struct TALER_MERCHANT_TemplatePatchHandle;
+
+
+/**
+ * Callback for a PATCH /private/templates/$TEMPLATE_ID request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_TemplatePatchCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a PATCH /private/templates/$TEMPLATE_ID request to update a template.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param template_id identifier of the template to update
+ * @param template_description new human-readable description
+ * @param otp_id new OTP device ID, or NULL to remove association
+ * @param template_contract new template contract (JSON)
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_TemplatePatchHandle *
+TALER_MERCHANT_template_patch (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *template_id,
+ const char *template_description,
+ const char *otp_id,
+ json_t *template_contract,
+ TALER_MERCHANT_TemplatePatchCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a PATCH /private/templates/$TEMPLATE_ID request.
+ *
+ * @param[in] tph handle to cancel
+ */
+void
+TALER_MERCHANT_template_patch_cancel (
+ struct TALER_MERCHANT_TemplatePatchHandle *tph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/patch-private-units-UNIT.h b/src/include/taler/taler-merchant/patch-private-units-UNIT.h
@@ -0,0 +1,89 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/patch-private-units-UNIT.h
+ * @brief C interface for PATCH /private/units/$UNIT of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__PATCH_PRIVATE_UNITS_UNIT_H
+#define _TALER_MERCHANT__PATCH_PRIVATE_UNITS_UNIT_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a PATCH /private/units/$UNIT request.
+ */
+struct TALER_MERCHANT_UnitPatchHandle;
+
+
+/**
+ * Callback for a PATCH /private/units/$UNIT request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_UnitPatchCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a PATCH /private/units/$UNIT request to update a unit.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param unit_id identifier of the unit to update
+ * @param unit_name_long new long name, or NULL to keep unchanged
+ * @param unit_name_short new short symbol, or NULL to keep unchanged
+ * @param unit_name_long_i18n new internationalized long names (JSON), or NULL
+ * @param unit_name_short_i18n new internationalized short names (JSON), or NULL
+ * @param unit_allow_fraction new value for allow_fraction, or NULL to keep unchanged
+ * @param unit_precision_level new precision level, or NULL to keep unchanged
+ * @param unit_active new active status, or NULL to keep unchanged
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_UnitPatchHandle *
+TALER_MERCHANT_unit_patch (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *unit_id,
+ const char *unit_name_long,
+ const char *unit_name_short,
+ const json_t *unit_name_long_i18n,
+ const json_t *unit_name_short_i18n,
+ const bool *unit_allow_fraction,
+ const uint32_t *unit_precision_level,
+ const bool *unit_active,
+ TALER_MERCHANT_UnitPatchCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a PATCH /private/units/$UNIT request.
+ *
+ * @param[in] uph handle to cancel
+ */
+void
+TALER_MERCHANT_unit_patch_cancel (
+ struct TALER_MERCHANT_UnitPatchHandle *uph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/patch-private-webhooks-WEBHOOK_ID.h b/src/include/taler/taler-merchant/patch-private-webhooks-WEBHOOK_ID.h
@@ -0,0 +1,85 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/patch-private-webhooks-WEBHOOK_ID.h
+ * @brief C interface for PATCH /private/webhooks/$WEBHOOK_ID of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__PATCH_PRIVATE_WEBHOOKS_WEBHOOK_ID_H
+#define _TALER_MERCHANT__PATCH_PRIVATE_WEBHOOKS_WEBHOOK_ID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a PATCH /private/webhooks/$WEBHOOK_ID request.
+ */
+struct TALER_MERCHANT_WebhookPatchHandle;
+
+
+/**
+ * Callback for a PATCH /private/webhooks/$WEBHOOK_ID request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_WebhookPatchCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a PATCH /private/webhooks/$WEBHOOK_ID request to update a webhook.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param webhook_id identifier of the webhook to update
+ * @param event_type new event type
+ * @param url new notification URL
+ * @param http_method new HTTP method
+ * @param header_template new header template
+ * @param body_template new body template
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_WebhookPatchHandle *
+TALER_MERCHANT_webhook_patch (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *webhook_id,
+ const char *event_type,
+ const char *url,
+ const char *http_method,
+ const char *header_template,
+ const char *body_template,
+ TALER_MERCHANT_WebhookPatchCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a PATCH /private/webhooks/$WEBHOOK_ID request.
+ *
+ * @param[in] wph handle to cancel
+ */
+void
+TALER_MERCHANT_webhook_patch_cancel (
+ struct TALER_MERCHANT_WebhookPatchHandle *wph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-management-instances-INSTANCE-auth.h b/src/include/taler/taler-merchant/post-management-instances-INSTANCE-auth.h
@@ -0,0 +1,78 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-management-instances-INSTANCE-auth.h
+ * @brief C interface for POST /management/instances/$INSTANCE/auth of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_MANAGEMENT_INSTANCES_INSTANCE_AUTH_H
+#define _TALER_MERCHANT__POST_MANAGEMENT_INSTANCES_INSTANCE_AUTH_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /management/instances/$INSTANCE/auth request.
+ */
+struct TALER_MERCHANT_InstanceAuthPostHandle;
+
+
+/**
+ * Callback for a POST /management/instances/$INSTANCE/auth request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_InstanceAuthPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a POST /management/instances/$INSTANCE/auth request to update
+ * authentication credentials for an instance.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param instance_id identifier of the instance
+ * @param auth_password new authentication password
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_InstanceAuthPostHandle *
+TALER_MERCHANT_instance_auth_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance_id,
+ const char *auth_password,
+ TALER_MERCHANT_InstanceAuthPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /management/instances/$INSTANCE/auth request.
+ *
+ * @param[in] iaph handle to cancel
+ */
+void
+TALER_MERCHANT_instance_auth_post_cancel (
+ struct TALER_MERCHANT_InstanceAuthPostHandle *iaph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-management-instances.h b/src/include/taler/taler-merchant/post-management-instances.h
@@ -0,0 +1,91 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-management-instances.h
+ * @brief C interface for POST /management/instances of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_MANAGEMENT_INSTANCES_H
+#define _TALER_MERCHANT__POST_MANAGEMENT_INSTANCES_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /management/instances request.
+ */
+struct TALER_MERCHANT_InstancesPostHandle;
+
+
+/**
+ * Callback for a POST /management/instances request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_InstancesPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a POST /management/instances request to create a new instance.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param instance_id identifier for the new instance
+ * @param name human-readable name
+ * @param address address (JSON)
+ * @param jurisdiction jurisdiction (JSON)
+ * @param use_stefan whether to use the STEFAN curve for fee calculations
+ * @param default_wire_transfer_delay default delay for wire transfers
+ * @param default_pay_delay default payment deadline
+ * @param default_refund_delay default refund deadline
+ * @param auth_password authentication password for the new instance, or NULL
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_InstancesPostHandle *
+TALER_MERCHANT_instances_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance_id,
+ const char *name,
+ const json_t *address,
+ const json_t *jurisdiction,
+ bool use_stefan,
+ struct GNUNET_TIME_Relative default_wire_transfer_delay,
+ struct GNUNET_TIME_Relative default_pay_delay,
+ struct GNUNET_TIME_Relative default_refund_delay,
+ const char *auth_password,
+ TALER_MERCHANT_InstancesPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /management/instances request.
+ *
+ * @param[in] iph handle to cancel
+ */
+void
+TALER_MERCHANT_instances_post_cancel (
+ struct TALER_MERCHANT_InstancesPostHandle *iph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-orders-ORDER_ID-abort.h b/src/include/taler/taler-merchant/post-orders-ORDER_ID-abort.h
@@ -0,0 +1,177 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-orders-ORDER_ID-abort.h
+ * @brief C interface for POST /orders/$ORDER_ID/abort of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_ORDERS_ORDER_ID_ABORT_H
+#define _TALER_MERCHANT__POST_ORDERS_ORDER_ID_ABORT_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /orders/$ORDER_ID/abort request.
+ */
+struct TALER_MERCHANT_OrderAbortHandle;
+
+
+/**
+ * Coin sent with an abort request.
+ */
+struct TALER_MERCHANT_AbortCoin
+{
+
+ /**
+ * Public key of the coin.
+ */
+ struct TALER_CoinSpendPublicKeyP coin_pub;
+
+ /**
+ * Amount contributed by this coin including deposit fee.
+ */
+ struct TALER_Amount amount_with_fee;
+
+ /**
+ * Hash of the coin's denomination public key.
+ */
+ struct TALER_DenominationHashP h_denom;
+
+ /**
+ * Base URL of the exchange this coin was issued by.
+ */
+ const char *exchange_url;
+
+};
+
+
+/**
+ * Result for one coin in an abort response.
+ */
+struct TALER_MERCHANT_AbortedCoin
+{
+
+ /**
+ * Exchange public key used for the refund.
+ */
+ struct TALER_ExchangePublicKeyP exchange_pub;
+
+ /**
+ * Exchange signature over the refund.
+ */
+ struct TALER_ExchangeSignatureP exchange_sig;
+
+};
+
+
+/**
+ * Response details for a POST /orders/$ORDER_ID/abort request.
+ */
+struct TALER_MERCHANT_AbortResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Public key of the merchant.
+ */
+ const struct TALER_MerchantPublicKeyP *merchant_pub;
+
+ /**
+ * Number of aborted coins in @a aborts.
+ */
+ unsigned int num_aborts;
+
+ /**
+ * Array of per-coin abort results.
+ */
+ const struct TALER_MERCHANT_AbortedCoin *aborts;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a POST /orders/$ORDER_ID/abort request.
+ *
+ * @param cls closure
+ * @param ar response details
+ */
+typedef void
+(*TALER_MERCHANT_AbortCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_AbortResponse *ar);
+
+
+/**
+ * Issue a POST /orders/$ORDER_ID/abort request to abort a payment
+ * and obtain refund signatures for the coins used.
+ *
+ * @param ctx CURL context to use
+ * @param merchant_url base URL of the merchant backend
+ * @param order_id identifier of the order to abort
+ * @param merchant_pub public key of the merchant instance
+ * @param h_contract hash of the contract terms
+ * @param num_coins number of coins in @a coins
+ * @param coins array of coins that were used for payment
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrderAbortHandle *
+TALER_MERCHANT_order_abort (
+ struct GNUNET_CURL_Context *ctx,
+ const char *merchant_url,
+ const char *order_id,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_PrivateContractHashP *h_contract,
+ unsigned int num_coins,
+ const struct TALER_MERCHANT_AbortCoin coins[static num_coins],
+ TALER_MERCHANT_AbortCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /orders/$ORDER_ID/abort request.
+ *
+ * @param[in] oah handle to cancel
+ */
+void
+TALER_MERCHANT_order_abort_cancel (
+ struct TALER_MERCHANT_OrderAbortHandle *oah);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-orders-ORDER_ID-claim.h b/src/include/taler/taler-merchant/post-orders-ORDER_ID-claim.h
@@ -0,0 +1,125 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-orders-ORDER_ID-claim.h
+ * @brief C interface for POST /orders/$ORDER_ID/claim of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_ORDERS_ORDER_ID_CLAIM_H
+#define _TALER_MERCHANT__POST_ORDERS_ORDER_ID_CLAIM_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /orders/$ORDER_ID/claim request.
+ */
+struct TALER_MERCHANT_OrderClaimHandle;
+
+
+/**
+ * Response details for a POST /orders/$ORDER_ID/claim request.
+ */
+struct TALER_MERCHANT_OrderClaimResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Contract terms (JSON).
+ */
+ const json_t *contract_terms;
+
+ /**
+ * Merchant signature over the contract terms.
+ */
+ struct TALER_MerchantSignatureP sig;
+
+ /**
+ * Hash of the contract terms.
+ */
+ struct TALER_PrivateContractHashP h_contract_terms;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a POST /orders/$ORDER_ID/claim request.
+ *
+ * @param cls closure
+ * @param ocr response details
+ */
+typedef void
+(*TALER_MERCHANT_OrderClaimCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_OrderClaimResponse *ocr);
+
+
+/**
+ * Issue a POST /orders/$ORDER_ID/claim request to claim an order
+ * and obtain its contract terms.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param order_id identifier of the order to claim
+ * @param nonce wallet nonce for the claim
+ * @param claim_token claim token (if required), or NULL
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrderClaimHandle *
+TALER_MERCHANT_order_claim (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *order_id,
+ const struct GNUNET_CRYPTO_EddsaPublicKey *nonce,
+ const struct TALER_ClaimTokenP *claim_token,
+ TALER_MERCHANT_OrderClaimCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /orders/$ORDER_ID/claim request.
+ *
+ * @param[in] och handle to cancel
+ */
+void
+TALER_MERCHANT_order_claim_cancel (
+ struct TALER_MERCHANT_OrderClaimHandle *och);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-orders-ORDER_ID-paid.h b/src/include/taler/taler-merchant/post-orders-ORDER_ID-paid.h
@@ -0,0 +1,116 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-orders-ORDER_ID-paid.h
+ * @brief C interface for POST /orders/$ORDER_ID/paid of the merchant backend
+ * @author Jonathan Buchanan
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_ORDERS_ORDER_ID_PAID_H
+#define _TALER_MERCHANT__POST_ORDERS_ORDER_ID_PAID_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /orders/$ORDER_ID/paid request.
+ */
+struct TALER_MERCHANT_OrderPaidHandle;
+
+
+/**
+ * Response details for a POST /orders/$ORDER_ID/paid request.
+ */
+struct TALER_MERCHANT_OrderPaidResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+ /* currently empty */
+ int _dummy;
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a POST /orders/$ORDER_ID/paid request.
+ *
+ * @param cls closure
+ * @param opr response details
+ */
+typedef void
+(*TALER_MERCHANT_OrderPaidCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_OrderPaidResponse *opr);
+
+
+/**
+ * Issue a POST /orders/$ORDER_ID/paid request to confirm payment
+ * (used for session-based repurchase detection).
+ *
+ * @param ctx CURL context to use
+ * @param merchant_url base URL of the merchant backend
+ * @param order_id identifier of the order
+ * @param session_id session identifier
+ * @param h_contract_terms hash of the contract terms
+ * @param wallet_data_hash hash of wallet-specific data, or NULL
+ * @param merchant_sig merchant signature over the session data
+ * @param paid_cb callback to invoke with the result
+ * @param paid_cb_cls closure for @a paid_cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrderPaidHandle *
+TALER_MERCHANT_order_paid (
+ struct GNUNET_CURL_Context *ctx,
+ const char *merchant_url,
+ const char *order_id,
+ const char *session_id,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct GNUNET_HashCode *wallet_data_hash,
+ const struct TALER_MerchantSignatureP *merchant_sig,
+ TALER_MERCHANT_OrderPaidCallback paid_cb,
+ void *paid_cb_cls);
+
+
+/**
+ * Cancel a POST /orders/$ORDER_ID/paid request.
+ *
+ * @param[in] oph handle to cancel
+ */
+void
+TALER_MERCHANT_order_paid_cancel (
+ struct TALER_MERCHANT_OrderPaidHandle *oph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-orders-ORDER_ID-pay.h b/src/include/taler/taler-merchant/post-orders-ORDER_ID-pay.h
@@ -0,0 +1,404 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-orders-ORDER_ID-pay.h
+ * @brief C interface for POST /orders/$ORDER_ID/pay of the merchant backend
+ * @author Christian Grothoff
+ * @author Marcello Stanisci
+ */
+#ifndef _TALER_MERCHANT__POST_ORDERS_ORDER_ID_PAY_H
+#define _TALER_MERCHANT__POST_ORDERS_ORDER_ID_PAY_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /orders/$ORDER_ID/pay request.
+ */
+struct TALER_MERCHANT_OrderPayHandle;
+
+
+/**
+ * One coin used to pay (frontend / external wallet mode).
+ */
+struct TALER_MERCHANT_PaidCoin
+{
+
+ /**
+ * Denomination public key.
+ */
+ struct TALER_DenominationPublicKey denom_pub;
+
+ /**
+ * Hash of the denomination public key.
+ */
+ struct TALER_DenominationHashP denom_pub_hash;
+
+ /**
+ * Denomination signature over the coin.
+ */
+ struct TALER_DenominationSignature denom_sig;
+
+ /**
+ * Face value of the denomination.
+ */
+ struct TALER_Amount denom_value;
+
+ /**
+ * Public key of the coin.
+ */
+ struct TALER_CoinSpendPublicKeyP coin_pub;
+
+ /**
+ * Signature by the coin authorizing the deposit.
+ */
+ struct TALER_CoinSpendSignatureP coin_sig;
+
+ /**
+ * Hash of the age commitment for this coin.
+ */
+ struct TALER_AgeCommitmentHashP h_age_commitment;
+
+ /**
+ * Set to true if this coin has an age commitment.
+ */
+ bool has_age_commitment;
+
+ /**
+ * Total amount contributed including deposit fee.
+ */
+ struct TALER_Amount amount_with_fee;
+
+ /**
+ * Amount contributed without the deposit fee.
+ */
+ struct TALER_Amount amount_without_fee;
+
+ /**
+ * Deposit fee for this coin.
+ */
+ struct TALER_Amount deposit_fee;
+
+ /**
+ * Base URL of the exchange this coin was issued by.
+ */
+ const char *exchange_url;
+
+};
+
+
+/**
+ * One coin used to pay (wallet-internal mode, private key available).
+ */
+struct TALER_MERCHANT_PayCoin
+{
+
+ /**
+ * Denomination public key.
+ */
+ struct TALER_DenominationPublicKey denom_pub;
+
+ /**
+ * Denomination signature over the coin.
+ */
+ struct TALER_DenominationSignature denom_sig;
+
+ /**
+ * Face value of the denomination.
+ */
+ struct TALER_Amount denom_value;
+
+ /**
+ * Private key of the coin (to sign the deposit).
+ */
+ struct TALER_CoinSpendPrivateKeyP coin_priv;
+
+ /**
+ * Hash of the age commitment for this coin, or NULL if none.
+ */
+ const struct TALER_AgeCommitmentHashP *h_age_commitment;
+
+ /**
+ * Total amount contributed including deposit fee.
+ */
+ struct TALER_Amount amount_with_fee;
+
+ /**
+ * Amount contributed without the deposit fee.
+ */
+ struct TALER_Amount amount_without_fee;
+
+ /**
+ * URL of the exchange that issued @e coin_priv.
+ */
+ const char *exchange_url;
+
+};
+
+
+/**
+ * Response details for a POST /orders/$ORDER_ID/pay request.
+ */
+struct TALER_MERCHANT_PayResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Merchant signature confirming the payment.
+ */
+ struct TALER_MerchantSignatureP merchant_sig;
+
+ /**
+ * POS confirmation string, or NULL if not applicable.
+ */
+ const char *pos_confirmation;
+
+ /**
+ * Number of output tokens in @a tokens.
+ */
+ unsigned int num_tokens;
+
+ /**
+ * Array of output tokens issued upon payment.
+ */
+ struct TALER_MERCHANT_OutputToken *tokens;
+
+ } ok;
+
+ /**
+ * Details on #MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS.
+ */
+ struct
+ {
+
+ /**
+ * Number of exchange URLs in @a exchanges.
+ */
+ unsigned int num_exchanges;
+
+ /**
+ * Array of exchange URLs that refused the payment for legal reasons.
+ */
+ const char **exchanges;
+
+ } unavailable_for_legal_reasons;
+
+ } details;
+
+};
+
+
+/**
+ * Token to use for payment (public form, already obtained).
+ */
+struct TALER_MERCHANT_UsedToken
+{
+
+ /**
+ * Signature on TALER_TokenUseRequestPS made with the token use private key.
+ */
+ struct TALER_TokenUseSignatureP token_sig;
+
+ /**
+ * Public key of the token. This was blindly signed by the merchant
+ * during the issuance and is now being revealed to the merchant.
+ */
+ struct TALER_TokenUsePublicKeyP token_pub;
+
+ /**
+ * Unblinded signature made by the token issue public key of the merchant.
+ */
+ struct TALER_TokenIssueSignature ub_sig;
+
+ /**
+ * Token issue public key associated with this token.
+ */
+ struct TALER_TokenIssuePublicKey issue_pub;
+};
+
+
+/**
+ * Information we need from the wallet to use a token for an order.
+ */
+struct TALER_MERCHANT_UseToken
+{
+
+ /**
+ * Private key of the token (to sign the use authorization).
+ */
+ struct TALER_TokenUsePrivateKeyP token_priv;
+
+ /**
+ * Unblinded signature made by the token issue public key of the merchant.
+ */
+ struct TALER_TokenIssueSignature ub_sig;
+
+ /**
+ * Token issue public key associated with this token.
+ */
+ struct TALER_TokenIssuePublicKey issue_pub;
+
+};
+
+
+/**
+ * Output token: used both as input to pay (envelope to be signed)
+ * and as output in the pay response (blind signature received).
+ */
+struct TALER_MERCHANT_OutputToken
+{
+
+ /**
+ * Blinded token envelope to be signed by the issuer (input to pay).
+ */
+ struct TALER_TokenEnvelope envelope;
+
+ /**
+ * Blinded token issue signature received from the issuer (output of pay).
+ */
+ struct TALER_BlindedTokenIssueSignature blinded_sig;
+
+};
+
+
+/**
+ * Callback for a POST /orders/$ORDER_ID/pay request.
+ *
+ * @param cls closure
+ * @param opr response details
+ */
+typedef void
+(*TALER_MERCHANT_OrderPayCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_PayResponse *opr);
+
+
+/**
+ * Issue a POST /orders/$ORDER_ID/pay request in frontend mode
+ * (coins already signed by the wallet).
+ *
+ * @param ctx CURL context to use
+ * @param merchant_url base URL of the merchant backend
+ * @param order_id identifier of the order to pay
+ * @param session_id session identifier, or NULL
+ * @param wallet_data wallet-specific data (JSON), or NULL
+ * @param num_coins number of coins in @a coins
+ * @param coins array of coins to pay with (already signed)
+ * @param num_tokens number of input tokens in @a tokens
+ * @param tokens array of tokens to use for payment
+ * @param j_output_tokens JSON array describing desired output tokens, or NULL
+ * @param pay_cb callback to invoke with the result
+ * @param pay_cb_cls closure for @a pay_cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrderPayHandle *
+TALER_MERCHANT_order_pay_frontend (
+ struct GNUNET_CURL_Context *ctx,
+ const char *merchant_url,
+ const char *order_id,
+ const char *session_id,
+ const json_t *wallet_data,
+ unsigned int num_coins,
+ const struct TALER_MERCHANT_PaidCoin coins[static num_coins],
+ unsigned int num_tokens,
+ const struct TALER_MERCHANT_UsedToken *tokens,
+ json_t *j_output_tokens,
+ TALER_MERCHANT_OrderPayCallback pay_cb,
+ void *pay_cb_cls);
+
+
+/**
+ * Issue a POST /orders/$ORDER_ID/pay request in wallet-internal mode
+ * (signing done internally).
+ *
+ * @param ctx CURL context to use
+ * @param merchant_url base URL of the merchant backend
+ * @param session_id session identifier, or NULL
+ * @param h_contract_terms hash of the contract terms
+ * @param choice_index payment choice index
+ * @param amount total payment amount
+ * @param max_fee maximum acceptable fee
+ * @param merchant_pub merchant public key
+ * @param merchant_sig merchant signature
+ * @param timestamp contract timestamp
+ * @param refund_deadline refund deadline
+ * @param pay_deadline payment deadline
+ * @param h_wire hash of the merchant wire details
+ * @param order_id identifier of the order to pay
+ * @param num_coins number of coins in @a coins
+ * @param coins array of coins with private keys
+ * @param num_tokens number of input tokens in @a tokens
+ * @param tokens array of tokens with private keys
+ * @param num_output_tokens number of output tokens in @a output_tokens
+ * @param output_tokens array of expected output tokens
+ * @param pay_cb callback to invoke with the result
+ * @param pay_cb_cls closure for @a pay_cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrderPayHandle *
+TALER_MERCHANT_order_pay (
+ struct GNUNET_CURL_Context *ctx,
+ const char *merchant_url,
+ const char *session_id,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ int choice_index,
+ const struct TALER_Amount *amount,
+ const struct TALER_Amount *max_fee,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_MerchantSignatureP *merchant_sig,
+ struct GNUNET_TIME_Timestamp timestamp,
+ struct GNUNET_TIME_Timestamp refund_deadline,
+ struct GNUNET_TIME_Timestamp pay_deadline,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *order_id,
+ unsigned int num_coins,
+ const struct TALER_MERCHANT_PayCoin coins[static num_coins],
+ unsigned int num_tokens,
+ const struct TALER_MERCHANT_UseToken *tokens,
+ unsigned int num_output_tokens,
+ const struct TALER_MERCHANT_OutputToken *output_tokens,
+ TALER_MERCHANT_OrderPayCallback pay_cb,
+ void *pay_cb_cls);
+
+
+/**
+ * Cancel a POST /orders/$ORDER_ID/pay request.
+ *
+ * @param[in] oph handle to cancel
+ */
+void
+TALER_MERCHANT_order_pay_cancel (
+ struct TALER_MERCHANT_OrderPayHandle *oph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-orders-ORDER_ID-refund.h b/src/include/taler/taler-merchant/post-orders-ORDER_ID-refund.h
@@ -0,0 +1,181 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-orders-ORDER_ID-refund.h
+ * @brief C interface for POST /orders/$ORDER_ID/refund (wallet-facing) of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_ORDERS_ORDER_ID_REFUND_H
+#define _TALER_MERCHANT__POST_ORDERS_ORDER_ID_REFUND_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /orders/$ORDER_ID/refund request (wallet-facing).
+ */
+struct TALER_MERCHANT_WalletOrderRefundHandle;
+
+
+/**
+ * Refund detail in a wallet refund response.
+ */
+struct TALER_MERCHANT_RefundDetail
+{
+
+ /**
+ * Exchange response details. Full details are only included
+ * upon failure (HTTP status is not #MHD_HTTP_OK).
+ */
+ struct TALER_EXCHANGE_HttpResponse hr;
+
+ /**
+ * Coin this detail is about.
+ */
+ struct TALER_CoinSpendPublicKeyP coin_pub;
+
+ /**
+ * Refund transaction ID used.
+ */
+ uint64_t rtransaction_id;
+
+ /**
+ * Amount to be refunded for this coin.
+ */
+ struct TALER_Amount refund_amount;
+
+ /**
+ * Details depending on exchange HTTP status.
+ */
+ union
+ {
+ /**
+ * Details if exchange status is #MHD_HTTP_OK.
+ */
+ struct
+ {
+ /**
+ * Public key of the exchange affirming the refund,
+ * only valid if the @e hr http_status is #MHD_HTTP_OK.
+ */
+ struct TALER_ExchangePublicKeyP exchange_pub;
+
+ /**
+ * Signature of the exchange affirming the refund,
+ * only valid if the @e hr http_status is #MHD_HTTP_OK.
+ */
+ struct TALER_ExchangeSignatureP exchange_sig;
+ } ok;
+ } details;
+};
+
+
+/**
+ * Response details for a POST /orders/$ORDER_ID/refund request (wallet-facing).
+ */
+struct TALER_MERCHANT_WalletRefundResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Total amount refunded.
+ */
+ struct TALER_Amount refund_amount;
+
+ /**
+ * Public key of the merchant.
+ */
+ struct TALER_MerchantPublicKeyP merchant_pub;
+
+ /**
+ * Number of per-coin refund details in @a refunds.
+ */
+ unsigned int refunds_length;
+
+ /**
+ * Array of per-coin refund details.
+ */
+ const struct TALER_MERCHANT_RefundDetail *refunds;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a POST /orders/$ORDER_ID/refund request (wallet-facing).
+ *
+ * @param cls closure
+ * @param wrr response details
+ */
+typedef void
+(*TALER_MERCHANT_WalletRefundCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_WalletRefundResponse *wrr);
+
+
+/**
+ * Issue a POST /orders/$ORDER_ID/refund request (wallet-facing) to
+ * obtain refund signatures.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param order_id identifier of the order to refund
+ * @param h_contract_terms hash of the contract terms
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_WalletOrderRefundHandle *
+TALER_MERCHANT_wallet_post_order_refund (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *order_id,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ TALER_MERCHANT_WalletRefundCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /orders/$ORDER_ID/refund request (wallet-facing).
+ *
+ * @param[in] orh handle to cancel
+ */
+void
+TALER_MERCHANT_wallet_post_order_refund_cancel (
+ struct TALER_MERCHANT_WalletOrderRefundHandle *orh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-accounts.h b/src/include/taler/taler-merchant/post-private-accounts.h
@@ -0,0 +1,119 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-accounts.h
+ * @brief C interface for POST /private/accounts of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_ACCOUNTS_H
+#define _TALER_MERCHANT__POST_PRIVATE_ACCOUNTS_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/accounts request.
+ */
+struct TALER_MERCHANT_AccountsPostHandle;
+
+
+/**
+ * Response details for a POST /private/accounts request.
+ */
+struct TALER_MERCHANT_AccountsPostResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Hash of the wire details for the newly created account.
+ */
+ struct TALER_MerchantWireHashP h_wire;
+
+ /**
+ * Salt used in the wire hash computation.
+ */
+ struct TALER_WireSaltP salt;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a POST /private/accounts request.
+ *
+ * @param cls closure
+ * @param apr response details
+ */
+typedef void
+(*TALER_MERCHANT_AccountsPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_AccountsPostResponse *apr);
+
+
+/**
+ * Issue a POST /private/accounts request to add a wire account.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param payto_uri payto URI of the account to add
+ * @param credit_facade_url URL of the credit facade, or NULL
+ * @param credit_facade_credentials credentials for the credit facade (JSON), or NULL
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_AccountsPostHandle *
+TALER_MERCHANT_accounts_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ struct TALER_FullPayto payto_uri,
+ const char *credit_facade_url,
+ const json_t *credit_facade_credentials,
+ TALER_MERCHANT_AccountsPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/accounts request.
+ *
+ * @param[in] aph handle to cancel
+ */
+void
+TALER_MERCHANT_accounts_post_cancel (
+ struct TALER_MERCHANT_AccountsPostHandle *aph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-categories.h b/src/include/taler/taler-merchant/post-private-categories.h
@@ -0,0 +1,96 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-categories.h
+ * @brief C interface for POST /private/categories of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_CATEGORIES_H
+#define _TALER_MERCHANT__POST_PRIVATE_CATEGORIES_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/categories request.
+ */
+struct TALER_MERCHANT_CategoriesPostHandle;
+
+
+/**
+ * Response details for a POST /private/categories request.
+ */
+struct TALER_MERCHANT_CategoriesPostResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * On #MHD_HTTP_OK, the numeric identifier of the newly created category.
+ */
+ uint64_t category_id;
+
+};
+
+
+/**
+ * Callback for a POST /private/categories request.
+ *
+ * @param cls closure
+ * @param cpr response details
+ */
+typedef void
+(*TALER_MERCHANT_CategoriesPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_CategoriesPostResponse *cpr);
+
+
+/**
+ * Issue a POST /private/categories request to create a new product category.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param name human-readable name of the category
+ * @param name_i18n internationalized names (JSON), or NULL
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_CategoriesPostHandle *
+TALER_MERCHANT_categories_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *name,
+ const json_t *name_i18n,
+ TALER_MERCHANT_CategoriesPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/categories request.
+ *
+ * @param[in] cph handle to cancel
+ */
+void
+TALER_MERCHANT_categories_post_cancel (
+ struct TALER_MERCHANT_CategoriesPostHandle *cph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-donau.h b/src/include/taler/taler-merchant/post-private-donau.h
@@ -0,0 +1,97 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-donau.h
+ * @brief C interface for POST /private/donau of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_DONAU_H
+#define _TALER_MERCHANT__POST_PRIVATE_DONAU_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/donau request.
+ */
+struct TALER_MERCHANT_DonauInstancePostHandle;
+
+
+/**
+ * Donau charity structure for POST /private/donau.
+ */
+struct TALER_MERCHANT_Charity
+{
+
+ /**
+ * Base URL of the Donau/charity service.
+ */
+ const char *charity_url;
+
+ /**
+ * Charity identifier at the Donau service.
+ */
+ uint64_t charity_id;
+
+};
+
+
+/**
+ * Callback for a POST /private/donau request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_DonauInstancePostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a POST /private/donau request to register a Donau charity.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param charity charity information to register
+ * @param auth_token authentication token for the Donau service, or NULL
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_DonauInstancePostHandle *
+TALER_MERCHANT_donau_instances_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct TALER_MERCHANT_Charity *charity,
+ const char *auth_token,
+ TALER_MERCHANT_DonauInstancePostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/donau request.
+ * This must not be called after the callback has been invoked.
+ *
+ * @param[in] dph handle to cancel
+ */
+void
+TALER_MERCHANT_donau_instances_post_cancel (
+ struct TALER_MERCHANT_DonauInstancePostHandle *dph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-orders-ORDER_ID-refund.h b/src/include/taler/taler-merchant/post-private-orders-ORDER_ID-refund.h
@@ -0,0 +1,119 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-orders-ORDER_ID-refund.h
+ * @brief C interface for POST /private/orders/$ORDER_ID/refund of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_ORDERS_ORDER_ID_REFUND_H
+#define _TALER_MERCHANT__POST_PRIVATE_ORDERS_ORDER_ID_REFUND_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/orders/$ORDER_ID/refund request.
+ */
+struct TALER_MERCHANT_OrderRefundHandle;
+
+
+/**
+ * Response details for a POST /private/orders/$ORDER_ID/refund request.
+ */
+struct TALER_MERCHANT_RefundResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Taler refund URI for the wallet.
+ */
+ const char *taler_refund_uri;
+
+ /**
+ * Hash of the contract terms for this order.
+ */
+ struct TALER_PrivateContractHashP h_contract;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a POST /private/orders/$ORDER_ID/refund request.
+ *
+ * @param cls closure
+ * @param rr response details
+ */
+typedef void
+(*TALER_MERCHANT_RefundCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_RefundResponse *rr);
+
+
+/**
+ * Issue a POST /private/orders/$ORDER_ID/refund request to grant a refund.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param order_id identifier of the order to refund
+ * @param refund amount to refund
+ * @param reason human-readable reason for the refund
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OrderRefundHandle *
+TALER_MERCHANT_post_order_refund (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *order_id,
+ const struct TALER_Amount *refund,
+ const char *reason,
+ TALER_MERCHANT_RefundCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/orders/$ORDER_ID/refund request.
+ *
+ * @param[in] orh handle to cancel
+ */
+void
+TALER_MERCHANT_post_order_refund_cancel (
+ struct TALER_MERCHANT_OrderRefundHandle *orh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-orders.h b/src/include/taler/taler-merchant/post-private-orders.h
@@ -0,0 +1,258 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-orders.h
+ * @brief C interface for POST /private/orders of the merchant backend
+ * @author Christian Grothoff
+ * @author Marcello Stanisci
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_ORDERS_H
+#define _TALER_MERCHANT__POST_PRIVATE_ORDERS_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/orders request.
+ */
+struct TALER_MERCHANT_PostOrdersHandle;
+
+
+/**
+ * One inventory product entry for POST /orders.
+ */
+struct TALER_MERCHANT_InventoryProduct
+{
+
+ /**
+ * Identifier of the product in the inventory.
+ */
+ const char *product_id;
+
+ /**
+ * How many units of this product should be ordered.
+ */
+ uint64_t quantity;
+
+ /**
+ * Fractional component of the quantity in units of 1/1000000 of the
+ * base value.
+ */
+ uint32_t quantity_frac;
+
+ /**
+ * Set to true if this product uses fractional quantity fields.
+ */
+ bool use_fractional_quantity;
+
+};
+
+
+/**
+ * Response details for a POST /private/orders request.
+ */
+struct TALER_MERCHANT_PostOrdersReply
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * The assigned order identifier.
+ */
+ const char *order_id;
+
+ /**
+ * Claim token for the order, or NULL if none was issued.
+ */
+ const struct TALER_ClaimTokenP *token;
+
+ /**
+ * Deadline by which the wallet must pay (may be zero for old backends).
+ */
+ struct GNUNET_TIME_Timestamp pay_deadline;
+
+ } ok;
+
+ /**
+ * Details on #MHD_HTTP_GONE (product out of stock).
+ */
+ struct
+ {
+
+ /**
+ * Identifier of the product that ran out of stock.
+ */
+ const char *product_id;
+
+ /**
+ * Quantity that was requested.
+ */
+ uint64_t requested_quantity;
+
+ /**
+ * Fractional part of the requested quantity.
+ */
+ uint32_t requested_quantity_frac;
+
+ /**
+ * Quantity that is available.
+ */
+ uint64_t available_quantity;
+
+ /**
+ * Fractional part of the available quantity.
+ */
+ uint32_t available_quantity_frac;
+
+ /**
+ * When restocking is expected (may be zero/unset).
+ */
+ struct GNUNET_TIME_Timestamp restock_expected;
+
+ } gone;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a POST /private/orders request.
+ *
+ * @param cls closure
+ * @param por response details
+ */
+typedef void
+(*TALER_MERCHANT_PostOrdersCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_PostOrdersReply *por);
+
+
+/**
+ * Issue a POST /private/orders request (simple form).
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param order JSON object describing the order
+ * @param refund_delay refund delay for this order
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_PostOrdersHandle *
+TALER_MERCHANT_orders_post (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const json_t *order,
+ struct GNUNET_TIME_Relative refund_delay,
+ TALER_MERCHANT_PostOrdersCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Issue a POST /private/orders request with extended options.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param order JSON object describing the order
+ * @param refund_delay refund delay for this order
+ * @param payment_target desired payment target, or NULL for default
+ * @param inventory_products_length number of entries in @a inventory_products
+ * @param inventory_products array of inventory products to lock
+ * @param uuids_length number of entries in @a uuids
+ * @param uuids array of idempotency UUIDs
+ * @param create_token whether to create a claim token
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_PostOrdersHandle *
+TALER_MERCHANT_orders_post2 (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const json_t *order,
+ struct GNUNET_TIME_Relative refund_delay,
+ const char *payment_target,
+ unsigned int inventory_products_length,
+ const struct TALER_MERCHANT_InventoryProduct inventory_products[],
+ unsigned int uuids_length,
+ const char *uuids[],
+ bool create_token,
+ TALER_MERCHANT_PostOrdersCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Issue a POST /private/orders request with all options.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param order JSON object describing the order
+ * @param session_id session identifier, or NULL
+ * @param refund_delay refund delay for this order
+ * @param payment_target desired payment target, or NULL for default
+ * @param inventory_products_length number of entries in @a inventory_products
+ * @param inventory_products array of inventory products to lock
+ * @param uuids_length number of entries in @a uuids
+ * @param uuids array of idempotency UUIDs
+ * @param create_token whether to create a claim token
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_PostOrdersHandle *
+TALER_MERCHANT_orders_post3 (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const json_t *order,
+ const char *session_id,
+ struct GNUNET_TIME_Relative refund_delay,
+ const char *payment_target,
+ unsigned int inventory_products_length,
+ const struct TALER_MERCHANT_InventoryProduct inventory_products[],
+ unsigned int uuids_length,
+ const char *uuids[],
+ bool create_token,
+ TALER_MERCHANT_PostOrdersCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/orders request.
+ *
+ * @param[in] po handle to cancel
+ */
+void
+TALER_MERCHANT_orders_post_cancel (
+ struct TALER_MERCHANT_PostOrdersHandle *po);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-otp-devices.h b/src/include/taler/taler-merchant/post-private-otp-devices.h
@@ -0,0 +1,83 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-otp-devices.h
+ * @brief C interface for POST /private/otp-devices of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_OTP_DEVICES_H
+#define _TALER_MERCHANT__POST_PRIVATE_OTP_DEVICES_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/otp-devices request.
+ */
+struct TALER_MERCHANT_OtpDevicesPostHandle;
+
+
+/**
+ * Callback for a POST /private/otp-devices request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_OtpDevicesPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a POST /private/otp-devices request to register a new OTP device.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param otp_device_id identifier for the new OTP device
+ * @param otp_device_description human-readable description
+ * @param otp_key base32-encoded OTP secret key
+ * @param otp_algorithm OTP algorithm to use
+ * @param otp_ctr initial counter value (for HOTP)
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_OtpDevicesPostHandle *
+TALER_MERCHANT_otp_devices_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *otp_device_id,
+ const char *otp_device_description,
+ const char *otp_key,
+ enum TALER_MerchantConfirmationAlgorithm otp_algorithm,
+ uint64_t otp_ctr,
+ TALER_MERCHANT_OtpDevicesPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/otp-devices request.
+ *
+ * @param[in] tph handle to cancel
+ */
+void
+TALER_MERCHANT_otp_devices_post_cancel (
+ struct TALER_MERCHANT_OtpDevicesPostHandle *tph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-products-PRODUCT_ID-lock.h b/src/include/taler/taler-merchant/post-private-products-PRODUCT_ID-lock.h
@@ -0,0 +1,110 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-products-PRODUCT_ID-lock.h
+ * @brief C interface for POST /private/products/$PRODUCT_ID/lock of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_PRODUCTS_PRODUCT_ID_LOCK_H
+#define _TALER_MERCHANT__POST_PRIVATE_PRODUCTS_PRODUCT_ID_LOCK_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/products/$PRODUCT_ID/lock request.
+ */
+struct TALER_MERCHANT_ProductLockHandle;
+
+
+/**
+ * Callback for a POST /private/products/$PRODUCT_ID/lock request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_ProductLockCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a POST /private/products/$PRODUCT_ID/lock request (simple form,
+ * integer quantities only).
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param product_id identifier of the product to lock
+ * @param uuid idempotency UUID for this lock operation
+ * @param duration how long to lock the inventory
+ * @param quantity number of units to lock
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ProductLockHandle *
+TALER_MERCHANT_product_lock (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *product_id,
+ const char *uuid,
+ struct GNUNET_TIME_Relative duration,
+ uint32_t quantity,
+ TALER_MERCHANT_ProductLockCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Issue a POST /private/products/$PRODUCT_ID/lock request with fractional
+ * quantity support.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param product_id identifier of the product to lock
+ * @param uuid idempotency UUID for this lock operation
+ * @param duration how long to lock the inventory
+ * @param quantity integer part of the quantity to lock
+ * @param quantity_frac fractional part of the quantity
+ * @param use_fractional_quantity if true, use fractional quantity
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ProductLockHandle *
+TALER_MERCHANT_product_lock2 (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *product_id,
+ const char *uuid,
+ struct GNUNET_TIME_Relative duration,
+ uint64_t quantity,
+ uint32_t quantity_frac,
+ bool use_fractional_quantity,
+ TALER_MERCHANT_ProductLockCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/products/$PRODUCT_ID/lock request.
+ *
+ * @param[in] plh handle to cancel
+ */
+void
+TALER_MERCHANT_product_lock_cancel (
+ struct TALER_MERCHANT_ProductLockHandle *plh);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-products.h b/src/include/taler/taler-merchant/post-private-products.h
@@ -0,0 +1,226 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-products.h
+ * @brief C interface for POST /private/products of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_PRODUCTS_H
+#define _TALER_MERCHANT__POST_PRIVATE_PRODUCTS_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/products request.
+ */
+struct TALER_MERCHANT_ProductsPostHandle;
+
+
+/**
+ * Callback for a POST /private/products request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_ProductsPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a POST /private/products request (simple form).
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param product_id identifier for the new product
+ * @param description human-readable product description
+ * @param description_i18n internationalized descriptions (JSON), or NULL
+ * @param unit unit of measurement
+ * @param price unit price
+ * @param image base64-encoded image, or empty string
+ * @param taxes tax information (JSON array), or NULL
+ * @param total_stock total stock (-1 for unlimited)
+ * @param address storage location (JSON), or NULL
+ * @param next_restock expected restock time
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ProductsPostHandle *
+TALER_MERCHANT_products_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *product_id,
+ const char *description,
+ const json_t *description_i18n,
+ const char *unit,
+ const struct TALER_Amount *price,
+ const char *image,
+ const json_t *taxes,
+ int64_t total_stock,
+ const json_t *address,
+ struct GNUNET_TIME_Timestamp next_restock,
+ TALER_MERCHANT_ProductsPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Issue a POST /private/products request with minimum age.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param product_id identifier for the new product
+ * @param description human-readable product description
+ * @param description_i18n internationalized descriptions (JSON), or NULL
+ * @param unit unit of measurement
+ * @param price unit price
+ * @param image base64-encoded image, or empty string
+ * @param taxes tax information (JSON array), or NULL
+ * @param total_stock total stock (-1 for unlimited)
+ * @param address storage location (JSON), or NULL
+ * @param next_restock expected restock time
+ * @param minimum_age minimum age requirement (0 for none)
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ProductsPostHandle *
+TALER_MERCHANT_products_post2 (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *product_id,
+ const char *description,
+ const json_t *description_i18n,
+ const char *unit,
+ const struct TALER_Amount *price,
+ const char *image,
+ const json_t *taxes,
+ int64_t total_stock,
+ const json_t *address,
+ struct GNUNET_TIME_Timestamp next_restock,
+ uint32_t minimum_age,
+ TALER_MERCHANT_ProductsPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Issue a POST /private/products request with category support.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param product_id identifier for the new product
+ * @param description human-readable product description
+ * @param description_i18n internationalized descriptions (JSON), or NULL
+ * @param unit unit of measurement
+ * @param price unit price
+ * @param image base64-encoded image, or empty string
+ * @param taxes tax information (JSON array), or NULL
+ * @param total_stock total stock (-1 for unlimited)
+ * @param address storage location (JSON), or NULL
+ * @param next_restock expected restock time
+ * @param minimum_age minimum age requirement (0 for none)
+ * @param num_cats number of category IDs in @a cats
+ * @param cats array of category IDs
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ProductsPostHandle *
+TALER_MERCHANT_products_post3 (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *product_id,
+ const char *description,
+ const json_t *description_i18n,
+ const char *unit,
+ const struct TALER_Amount *price,
+ const char *image,
+ const json_t *taxes,
+ int64_t total_stock,
+ const json_t *address,
+ struct GNUNET_TIME_Timestamp next_restock,
+ uint32_t minimum_age,
+ unsigned int num_cats,
+ const uint64_t *cats,
+ TALER_MERCHANT_ProductsPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Issue a POST /private/products request with full unit/fraction support.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param product_id identifier for the new product
+ * @param description human-readable product description
+ * @param description_i18n internationalized descriptions (JSON), or NULL
+ * @param unit unit of measurement
+ * @param unit_prices array of unit prices (for different payment options)
+ * @param unit_price_len number of prices in @a unit_prices
+ * @param image base64-encoded image, or empty string
+ * @param taxes tax information (JSON array), or NULL
+ * @param total_stock integer part of total stock (-1 for unlimited)
+ * @param total_stock_frac fractional part of total stock
+ * @param unit_allow_fraction whether fractional quantities are allowed
+ * @param unit_precision_level precision level for fractions, or NULL
+ * @param address storage location (JSON), or NULL
+ * @param next_restock expected restock time
+ * @param minimum_age minimum age requirement (0 for none)
+ * @param num_cats number of category IDs in @a cats
+ * @param cats array of category IDs
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_ProductsPostHandle *
+TALER_MERCHANT_products_post4 (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *product_id,
+ const char *description,
+ const json_t *description_i18n,
+ const char *unit,
+ const struct TALER_Amount *unit_prices,
+ size_t unit_price_len,
+ const char *image,
+ const json_t *taxes,
+ int64_t total_stock,
+ uint32_t total_stock_frac,
+ bool unit_allow_fraction,
+ const uint32_t *unit_precision_level,
+ const json_t *address,
+ struct GNUNET_TIME_Timestamp next_restock,
+ uint32_t minimum_age,
+ unsigned int num_cats,
+ const uint64_t *cats,
+ TALER_MERCHANT_ProductsPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/products request.
+ *
+ * @param[in] pph handle to cancel
+ */
+void
+TALER_MERCHANT_products_post_cancel (
+ struct TALER_MERCHANT_ProductsPostHandle *pph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-templates.h b/src/include/taler/taler-merchant/post-private-templates.h
@@ -0,0 +1,81 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-templates.h
+ * @brief C interface for POST /private/templates of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_TEMPLATES_H
+#define _TALER_MERCHANT__POST_PRIVATE_TEMPLATES_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/templates request.
+ */
+struct TALER_MERCHANT_TemplatesPostHandle;
+
+
+/**
+ * Callback for a POST /private/templates request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_TemplatesPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a POST /private/templates request to create a new template.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param template_id identifier for the new template
+ * @param template_description human-readable description
+ * @param otp_id OTP device ID to associate, or NULL
+ * @param template_contract template contract (JSON)
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_TemplatesPostHandle *
+TALER_MERCHANT_templates_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *template_id,
+ const char *template_description,
+ const char *otp_id,
+ const json_t *template_contract,
+ TALER_MERCHANT_TemplatesPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/templates request.
+ *
+ * @param[in] tph handle to cancel
+ */
+void
+TALER_MERCHANT_templates_post_cancel (
+ struct TALER_MERCHANT_TemplatesPostHandle *tph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-token.h b/src/include/taler/taler-merchant/post-private-token.h
@@ -0,0 +1,81 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-token.h
+ * @brief C interface for POST /private/token of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_TOKEN_H
+#define _TALER_MERCHANT__POST_PRIVATE_TOKEN_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/token request.
+ */
+struct TALER_MERCHANT_InstanceTokenPostHandle;
+
+
+/**
+ * Callback for a POST /private/token request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_InstanceTokenPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a POST /private/token request to obtain an access token.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param instance_id identifier of the instance
+ * @param scope scope for the token
+ * @param duration how long the token should be valid
+ * @param refreshable whether the token may be refreshed
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_InstanceTokenPostHandle *
+TALER_MERCHANT_instance_token_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance_id,
+ const char *scope,
+ struct GNUNET_TIME_Relative duration,
+ bool refreshable,
+ TALER_MERCHANT_InstanceTokenPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/token request.
+ *
+ * @param[in] itph handle to cancel
+ */
+void
+TALER_MERCHANT_instance_token_post_cancel (
+ struct TALER_MERCHANT_InstanceTokenPostHandle *itph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-tokenfamilies.h b/src/include/taler/taler-merchant/post-private-tokenfamilies.h
@@ -0,0 +1,95 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-tokenfamilies.h
+ * @brief C interface for POST /private/tokenfamilies of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_TOKENFAMILIES_H
+#define _TALER_MERCHANT__POST_PRIVATE_TOKENFAMILIES_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/tokenfamilies request.
+ */
+struct TALER_MERCHANT_TokenFamiliesPostHandle;
+
+
+/**
+ * Callback for a POST /private/tokenfamilies request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_TokenFamiliesPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a POST /private/tokenfamilies request to create a new token family.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param slug URL-safe slug identifier for the new token family
+ * @param name human-readable name
+ * @param description human-readable description
+ * @param description_i18n internationalized descriptions (JSON), or NULL
+ * @param extra_data extra data (JSON), or NULL
+ * @param valid_after start of validity period
+ * @param valid_before end of validity period
+ * @param duration duration of individual token validity
+ * @param validity_granularity granularity for validity alignment
+ * @param start_offset offset from purchase to start of validity
+ * @param kind kind of token family ("subscription" or "discount")
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_TokenFamiliesPostHandle *
+TALER_MERCHANT_token_families_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *slug,
+ const char *name,
+ const char *description,
+ const json_t *description_i18n,
+ const json_t *extra_data,
+ struct GNUNET_TIME_Timestamp valid_after,
+ struct GNUNET_TIME_Timestamp valid_before,
+ struct GNUNET_TIME_Relative duration,
+ struct GNUNET_TIME_Relative validity_granularity,
+ struct GNUNET_TIME_Relative start_offset,
+ const char *kind,
+ TALER_MERCHANT_TokenFamiliesPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/tokenfamilies request.
+ *
+ * @param[in] pph handle to cancel
+ */
+void
+TALER_MERCHANT_token_families_post_cancel (
+ struct TALER_MERCHANT_TokenFamiliesPostHandle *pph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-transfers.h b/src/include/taler/taler-merchant/post-private-transfers.h
@@ -0,0 +1,161 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-transfers.h
+ * @brief C interface for POST /private/transfers of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_TRANSFERS_H
+#define _TALER_MERCHANT__POST_PRIVATE_TRANSFERS_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/transfers request.
+ */
+struct TALER_MERCHANT_PostTransfersHandle;
+
+
+/**
+ * Wire transfer information associated with a paid order.
+ */
+struct TALER_MERCHANT_WireTransfer
+{
+
+ /**
+ * Base URL of the exchange that made the transfer.
+ */
+ const char *exchange_url;
+
+ /**
+ * When the transfer took place (note: may not be exact,
+ * as the time at which the exchange initiated the transfer
+ * may differ from the time the bank or the merchant observed).
+ * Zero if not known.
+ */
+ struct GNUNET_TIME_Timestamp execution_time;
+
+ /**
+ * Wire transfer subject.
+ */
+ struct TALER_WireTransferIdentifierRawP wtid;
+
+ /**
+ * Total amount that was transferred.
+ */
+ struct TALER_Amount total_amount;
+
+ /**
+ * Whether this transfer was confirmed by the merchant using
+ * the POST /transfers API, or whether it was merely claimed
+ * by the exchange.
+ */
+ bool confirmed;
+
+};
+
+
+/**
+ * Response details for a POST /private/transfers request.
+ */
+struct TALER_MERCHANT_PostTransfersResponse
+{
+
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on the HTTP status code.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_BAD_GATEWAY (exchange returned an error).
+ */
+ struct
+ {
+
+ /**
+ * Error code returned by the exchange.
+ */
+ enum TALER_ErrorCode exchange_ec;
+
+ /**
+ * HTTP status code returned by the exchange.
+ */
+ unsigned int exchange_http_status;
+
+ } bad_gateway;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a POST /private/transfers request.
+ *
+ * @param cls closure
+ * @param ptr response details
+ */
+typedef void
+(*TALER_MERCHANT_PostTransfersCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_PostTransfersResponse *ptr);
+
+
+/**
+ * Issue a POST /private/transfers request to inform the merchant about
+ * a wire transfer from an exchange.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param credit_amount amount credited in this transfer
+ * @param wtid wire transfer identifier
+ * @param payto_uri payto URI of the merchant account that received the funds
+ * @param exchange_url base URL of the exchange that made the transfer
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_PostTransfersHandle *
+TALER_MERCHANT_transfers_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct TALER_Amount *credit_amount,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ struct TALER_FullPayto payto_uri,
+ const char *exchange_url,
+ TALER_MERCHANT_PostTransfersCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/transfers request.
+ *
+ * @param[in] pth handle to cancel
+ */
+void
+TALER_MERCHANT_transfers_post_cancel (
+ struct TALER_MERCHANT_PostTransfersHandle *pth);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-units.h b/src/include/taler/taler-merchant/post-private-units.h
@@ -0,0 +1,89 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-units.h
+ * @brief C interface for POST /private/units of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_UNITS_H
+#define _TALER_MERCHANT__POST_PRIVATE_UNITS_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/units request.
+ */
+struct TALER_MERCHANT_UnitsPostHandle;
+
+
+/**
+ * Callback for a POST /private/units request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_UnitsPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a POST /private/units request to create a new unit.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param unit_id identifier for the new unit
+ * @param unit_name_long long human-readable name
+ * @param unit_name_short short symbol for the unit
+ * @param unit_allow_fraction whether fractional quantities are allowed
+ * @param unit_precision_level precision level for fractional quantities
+ * @param unit_active whether the unit is active
+ * @param unit_name_long_i18n internationalized long names (JSON), or NULL
+ * @param unit_name_short_i18n internationalized short names (JSON), or NULL
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_UnitsPostHandle *
+TALER_MERCHANT_units_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *unit_id,
+ const char *unit_name_long,
+ const char *unit_name_short,
+ bool unit_allow_fraction,
+ uint32_t unit_precision_level,
+ bool unit_active,
+ const json_t *unit_name_long_i18n,
+ const json_t *unit_name_short_i18n,
+ TALER_MERCHANT_UnitsPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/units request.
+ *
+ * @param[in] uph handle to cancel
+ */
+void
+TALER_MERCHANT_units_post_cancel (
+ struct TALER_MERCHANT_UnitsPostHandle *uph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-private-webhooks.h b/src/include/taler/taler-merchant/post-private-webhooks.h
@@ -0,0 +1,85 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-private-webhooks.h
+ * @brief C interface for POST /private/webhooks of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_PRIVATE_WEBHOOKS_H
+#define _TALER_MERCHANT__POST_PRIVATE_WEBHOOKS_H
+
+#include <taler/taler-merchant/common.h>
+
+
+/**
+ * Handle for a POST /private/webhooks request.
+ */
+struct TALER_MERCHANT_WebhooksPostHandle;
+
+
+/**
+ * Callback for a POST /private/webhooks request.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_WebhooksPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Issue a POST /private/webhooks request to create a new webhook.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param webhook_id identifier for the new webhook
+ * @param event_type event type that triggers this webhook
+ * @param url URL to send notifications to
+ * @param http_method HTTP method to use for notifications
+ * @param header_template template for HTTP request headers
+ * @param body_template template for the HTTP request body
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_WebhooksPostHandle *
+TALER_MERCHANT_webhooks_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *webhook_id,
+ const char *event_type,
+ const char *url,
+ const char *http_method,
+ const char *header_template,
+ const char *body_template,
+ TALER_MERCHANT_WebhooksPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /private/webhooks request.
+ *
+ * @param[in] wph handle to cancel
+ */
+void
+TALER_MERCHANT_webhooks_post_cancel (
+ struct TALER_MERCHANT_WebhooksPostHandle *wph);
+
+
+#endif
diff --git a/src/include/taler/taler-merchant/post-templates-TEMPLATE_ID.h b/src/include/taler/taler-merchant/post-templates-TEMPLATE_ID.h
@@ -0,0 +1,92 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler-merchant/post-templates-TEMPLATE_ID.h
+ * @brief C interface for POST /templates/$TEMPLATE_ID (create order from template)
+ * of the merchant backend
+ * @author Christian Grothoff
+ */
+#ifndef _TALER_MERCHANT__POST_TEMPLATES_TEMPLATE_ID_H
+#define _TALER_MERCHANT__POST_TEMPLATES_TEMPLATE_ID_H
+
+#include <taler/taler-merchant/common.h>
+#include <taler/taler-merchant/post-private-orders.h>
+
+
+/**
+ * Handle for a POST /templates/$TEMPLATE_ID request.
+ */
+struct TALER_MERCHANT_UsingTemplatesPostHandle;
+
+
+/**
+ * Issue a POST /templates/$TEMPLATE_ID request to create an order from
+ * a template using a simple amount and summary.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param template_id identifier of the template to use
+ * @param summary order summary
+ * @param amount total amount for the order
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_UsingTemplatesPostHandle *
+TALER_MERCHANT_using_templates_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *template_id,
+ const char *summary,
+ const struct TALER_Amount *amount,
+ TALER_MERCHANT_PostOrdersCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Issue a POST /templates/$TEMPLATE_ID request to create an order from
+ * a template using detailed contract customization.
+ *
+ * @param ctx CURL context to use
+ * @param backend_url base URL of the merchant backend
+ * @param template_id identifier of the template to use
+ * @param details JSON object with template-specific order details
+ * @param cb callback to invoke with the result
+ * @param cb_cls closure for @a cb
+ * @return handle for the request, NULL on hard error
+ */
+struct TALER_MERCHANT_UsingTemplatesPostHandle *
+TALER_MERCHANT_using_templates_post2 (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *template_id,
+ const json_t *details,
+ TALER_MERCHANT_PostOrdersCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /templates/$TEMPLATE_ID request.
+ *
+ * @param[in] utph handle to cancel
+ */
+void
+TALER_MERCHANT_using_templates_post_cancel (
+ struct TALER_MERCHANT_UsingTemplatesPostHandle *utph);
+
+
+#endif
diff --git a/src/include/taler/taler_merchant_bank_lib.h b/src/include/taler/taler_merchant_bank_lib.h
@@ -0,0 +1,263 @@
+/*
+ This file is part of GNU Taler
+ Copyright (C) 2021-2023 Taler Systems SA
+
+ Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License along with
+ Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler_merchant_bank_lib.h
+ * @brief C interface to access the Taler merchant facade of LibEuFin
+ * See https://docs.taler.net/TBD
+ * @author Christian Grothoff
+ */
+#ifndef TALER_MERCHANT_BANK_LIB_H
+#define TALER_MERCHANT_BANK_LIB_H
+
+#include <taler/taler_error_codes.h>
+#include <jansson.h>
+#include <gnunet/gnunet_curl_lib.h>
+#include <taler/taler_util.h>
+
+
+/**
+ * Authentication method types.
+ */
+enum TALER_MERCHANT_BANK_AuthenticationMethod
+{
+
+ /**
+ * No authentication.
+ */
+ TALER_MERCHANT_BANK_AUTH_NONE,
+
+ /**
+ * Basic authentication with cleartext username and password.
+ */
+ TALER_MERCHANT_BANK_AUTH_BASIC,
+
+ /**
+ * Bearer token authentication.
+ */
+ TALER_MERCHANT_BANK_AUTH_BEARER,
+};
+
+
+/**
+ * Information used to authenticate to the bank.
+ */
+struct TALER_MERCHANT_BANK_AuthenticationData
+{
+
+ /**
+ * Base URL we use to talk to the wire gateway,
+ * which talks to the bank for us.
+ */
+ char *wire_gateway_url;
+
+ /**
+ * Which authentication method should we use?
+ */
+ enum TALER_MERCHANT_BANK_AuthenticationMethod method;
+
+ /**
+ * Further details as per @e method.
+ */
+ union
+ {
+
+ /**
+ * Details for #TALER_MERCHANT_BANK_AUTH_BASIC.
+ */
+ struct
+ {
+ /**
+ * Username to use.
+ */
+ char *username;
+
+ /**
+ * Password to use.
+ */
+ char *password;
+ } basic;
+
+ /**
+ * Details for #TALER_MERCHANT_BANK_AUTH_BASIC.
+ */
+ struct
+ {
+ /**
+ * Token to use.
+ */
+ char *token;
+ } bearer;
+
+ } details;
+
+};
+
+
+/* ********************* /history/incoming *********************** */
+
+/**
+ * Handle for querying the bank for transactions
+ * made to the exchange.
+ */
+struct TALER_MERCHANT_BANK_CreditHistoryHandle;
+
+/**
+ * Details about a wire transfer to the exchange.
+ */
+struct TALER_MERCHANT_BANK_CreditDetails
+{
+ /**
+ * Amount that was transferred
+ */
+ struct TALER_Amount amount;
+
+ /**
+ * Time of the the transfer
+ */
+ struct GNUNET_TIME_Timestamp execution_date;
+
+ /**
+ * The wire transfer subject.
+ */
+ const char *wire_subject;
+
+ /**
+ * payto://-URL of the source account that
+ * send the funds.
+ */
+ struct TALER_FullPayto debit_account_uri;
+
+ /**
+ * payto://-URL of the target account that
+ * received the funds.
+ */
+ struct TALER_FullPayto credit_account_uri;
+};
+
+
+/**
+ * Callbacks of this type are used to serve the result of asking
+ * the bank for the credit transaction history.
+ *
+ * @param cls closure
+ * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
+ * 0 if the bank's reply is bogus (fails to follow the protocol),
+ * #MHD_HTTP_NO_CONTENT if there are no more results; on success the
+ * last callback is always of this status (even if `abs(num_results)` were
+ * already returned).
+ * @param ec detailed error code
+ * @param serial_id monotonically increasing counter corresponding to the transaction
+ * @param details details about the wire transfer
+ * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
+ */
+typedef enum GNUNET_GenericReturnValue
+(*TALER_MERCHANT_BANK_CreditHistoryCallback)(
+ void *cls,
+ unsigned int http_status,
+ enum TALER_ErrorCode ec,
+ uint64_t serial_id,
+ const struct TALER_MERCHANT_BANK_CreditDetails *details);
+
+
+/**
+ * Request the wire credit history of an exchange's bank account.
+ *
+ * @param ctx curl context for the event loop
+ * @param auth authentication data to use
+ * @param start_row from which row on do we want to get results, use UINT64_MAX for the latest; exclusive
+ * @param num_results how many results do we want; negative numbers to go into the past,
+ * positive numbers to go into the future starting at @a start_row;
+ * must not be zero.
+ * @param timeout how long the client is willing to wait for more results
+ * (only useful if @a num_results is positive)
+ * @param hres_cb the callback to call with the transaction history
+ * @param hres_cb_cls closure for the above callback
+ * @return NULL
+ * if the inputs are invalid (i.e. zero value for @e num_results).
+ * In this case, the callback is not called.
+ */
+struct TALER_MERCHANT_BANK_CreditHistoryHandle *
+TALER_MERCHANT_BANK_credit_history (
+ struct GNUNET_CURL_Context *ctx,
+ const struct TALER_MERCHANT_BANK_AuthenticationData *auth,
+ uint64_t start_row,
+ int64_t num_results,
+ struct GNUNET_TIME_Relative timeout,
+ TALER_MERCHANT_BANK_CreditHistoryCallback hres_cb,
+ void *hres_cb_cls);
+
+
+/**
+ * Cancel an history request. This function cannot be used on a request
+ * handle if the last response (anything with a status code other than
+ * 200) is already served for it.
+ *
+ * @param hh the history request handle
+ */
+void
+TALER_MERCHANT_BANK_credit_history_cancel (
+ struct TALER_MERCHANT_BANK_CreditHistoryHandle *hh);
+
+
+/* ******************** Convenience functions **************** */
+
+
+/**
+ * Convenience method for parsing configuration section with bank
+ * authentication data.
+ *
+ * @param cfg configuration to parse
+ * @param section the section with the configuration data
+ * @param[out] auth set to the configuration data found
+ * @return #GNUNET_OK on success
+ */
+enum GNUNET_GenericReturnValue
+TALER_MERCHANT_BANK_auth_parse_cfg (
+ const struct
+ GNUNET_CONFIGURATION_Handle *cfg,
+ const char *section,
+ struct TALER_MERCHANT_BANK_AuthenticationData *auth);
+
+
+/**
+ * Convenience method for parsing JSON with bank
+ * authentication data.
+ *
+ * @param cred configuration to parse
+ * @param backend_url URL of the backend (not in the JSON)
+ * @param[out] auth set to the configuration data found
+ * @return #GNUNET_OK on success
+ */
+enum GNUNET_GenericReturnValue
+TALER_MERCHANT_BANK_auth_parse_json (
+ const json_t *cred,
+ const char *backend_url,
+ struct TALER_MERCHANT_BANK_AuthenticationData *auth);
+
+
+/**
+ * Free memory inside of @a auth (but not @a auth itself).
+ * Dual to #TALER_MERCHANT_BANK_auth_parse_cfg().
+ *
+ * @param auth authentication data to free
+ */
+void
+TALER_MERCHANT_BANK_auth_free (
+ struct TALER_MERCHANT_BANK_AuthenticationData *auth);
+
+
+#endif
+/* _TALER_MERCHANT_BANK_LIB_H */
diff --git a/src/include/taler/taler_merchant_donau.h b/src/include/taler/taler_merchant_donau.h
@@ -0,0 +1,37 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2024 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LIB. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file taler_merchant_donau.h
+ * @brief Structs to interact with the donau.
+ * @author Bohdan Potuzhnyi
+ * @author Vlada Svirsh
+ */
+#ifndef _TALER_MERCHANT_DONAU_H
+#define _TALER_MERCHANT_DONAU_H
+
+#include <taler/taler_util.h>
+#include <taler/taler_error_codes.h>
+#include <taler/taler_exchange_service.h>
+#include "taler_merchant_service.h"
+#include <donau/donau_service.h>
+#include <donau/donau_util.h>
+
+
+#include <taler/taler-merchant/get-private-donau.h>
+#include <taler/taler-merchant/post-private-donau.h>
+#include <taler/taler-merchant/delete-private-donau-DONAU_SERIAL.h>
+
+#endif
diff --git a/src/include/taler/taler_merchant_pay_service.h b/src/include/taler/taler_merchant_pay_service.h
@@ -0,0 +1,610 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2024 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free
+ Software Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LIB. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file taler_merchant_pay_service.h
+ * @brief Payment‑specific interface extracted from taler_merchant_service.h
+ * **Only** declarations and helper‑macros live here – the actual
+ * implementation must be provided in the accompanying *.c file.
+ * This header can be included by both merchant front‑ends and wallets
+ * that want to create or proxy /orders/$ID/pay requests.
+ */
+#ifndef TALER_MERCHANT_PAY_SERVICE_H
+#define TALER_MERCHANT_PAY_SERVICE_H
+
+#include <taler/taler_util.h>
+#include <taler/taler_signatures.h>
+#include <taler/taler_error_codes.h>
+#include <taler/taler_exchange_service.h>
+#include "taler_merchant_service.h"
+#include <gnunet/gnunet_time_lib.h>
+
+
+#ifndef TALER_MERCHANT_ORDER_PAY_CALLBACK_CLOSURE_TYPE
+#define TALER_MERCHANT_ORDER_PAY_CALLBACK_CLOSURE_TYPE void
+#endif
+
+/**
+ * Opaque handle returned by the payment helper APIs declared below.
+ */
+struct TALER_MERCHANT_OrderPayHandle;
+
+/**
+ * Which option is being supplied to #TALER_MERCHANT_order_pay_set_options().
+ */
+enum TALER_MERCHANT_OrderPayOptionType
+{
+ TALER_MERCHANT_OrderPayOptionType_END = 0,
+ TALER_MERCHANT_OrderPayOptionType_MERCHANT_URL,
+ TALER_MERCHANT_OrderPayOptionType_SESSION_ID,
+ TALER_MERCHANT_OrderPayOptionType_H_CONTRACT,
+ TALER_MERCHANT_OrderPayOptionType_CHOICE_INDEX,
+ TALER_MERCHANT_OrderPayOptionType_AMOUNT,
+ TALER_MERCHANT_OrderPayOptionType_MAX_FEE,
+ TALER_MERCHANT_OrderPayOptionType_MERCHANT_PUB,
+ TALER_MERCHANT_OrderPayOptionType_TIMESTAMP,
+ TALER_MERCHANT_OrderPayOptionType_REFUND_DEADLINE,
+ TALER_MERCHANT_OrderPayOptionType_PAY_DEADLINE,
+ TALER_MERCHANT_OrderPayOptionType_H_WIRE,
+ TALER_MERCHANT_OrderPayOptionType_ORDER_ID,
+ TALER_MERCHANT_OrderPayOptionType_COINS,
+ TALER_MERCHANT_OrderPayOptionType_INPUT_TOKENS,
+ TALER_MERCHANT_OrderPayOptionType_OUTPUT_TOKENS,
+ TALER_MERCHANT_OrderPayOptionType_WALLET_DATA, // Used privately so no #define is present for it
+ TALER_MERCHANT_OrderPayOptionType_DONAU_URL,
+ TALER_MERCHANT_OrderPayOptionType_DONAU_YEAR,
+ TALER_MERCHANT_OrderPayOptionType_DONAU_BUDIS,
+ /*New objects go in here*/
+ TALER_MERCHANT_OrderPayOptionType_LENGTH
+};
+
+/**
+ * Container describing *one* option for a payment request.
+ *
+ * Applications should typically not use this struct directly,
+ * only through respective TALER_MERCHANT_ORDER_PAY_OPTION_-macros
+ */
+struct TALER_MERCHANT_OrderPayOption
+{
+ /**
+ * Type of the option being supplied.
+ */
+ enum TALER_MERCHANT_OrderPayOptionType ot;
+
+ union
+ {
+ const char *merchant_url;
+ const char *session_id;
+ const struct TALER_PrivateContractHashP *h_contract;
+ int choice_index;
+ struct TALER_Amount amount;
+ struct TALER_Amount max_fee;
+ struct TALER_MerchantPublicKeyP merchant_pub;
+ struct GNUNET_TIME_Timestamp timestamp;
+ struct GNUNET_TIME_Timestamp refund_deadline;
+ struct GNUNET_TIME_Timestamp pay_deadline;
+ struct TALER_MerchantWireHashP h_wire;
+ const char *order_id;
+ struct
+ {
+ unsigned int num_coins;
+ const struct TALER_MERCHANT_PayCoin *coins;
+ } coins;
+ struct
+ {
+ unsigned int num_tokens;
+ const struct TALER_MERCHANT_UseToken *tokens;
+ } input_tokens;
+ struct
+ {
+ unsigned int num_output_tokens;
+ const struct TALER_MERCHANT_OutputToken *output_tokens;
+ } output_tokens;
+ const char *donau_url;
+ uint64_t donau_year;
+ json_t *donau_budis_json;
+ } details;
+};
+
+
+/**
+ * Status codes returned from #TALER_MERCHANT_order_pay_set_options() and
+ * #TALER_MERCHANT_order_pay_start().
+ */
+enum TALER_MERCHANT_OrderPayErrorCode
+{
+ TALER_MERCHANT_OPOEC_OK = 0, /**< everything fine */
+ TALER_MERCHANT_OPOEC_UNKNOWN_OPTION, /**< unrecognised option kind */
+ TALER_MERCHANT_OPOEC_DUPLICATE_OPTION, /**< option given more than once */
+ TALER_MERCHANT_OPOEC_INVALID_VALUE, /**< semantic/format error in value */
+ TALER_MERCHANT_OPOEC_MISSING_MANDATORY, /**< required field missing at start */
+ TALER_MERCHANT_OPOEC_URL_FAILURE, /**< failed to build request URL */
+ TALER_MERCHANT_OPOEC_CURL_FAILURE /**< failed to init/schedule CURL */
+};
+
+
+/**
+ * Terminate the list of payment options.
+ *
+ * @par Example
+ * \code
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE() \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_END \
+ }
+
+
+/**
+ * Specify the merchant’s URL for the payment request.
+ *
+ * @param _url NULL-terminated string holding the merchant endpoint.
+ *
+ * @par Example
+ * \code
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_MERCHANT_URL("https://shop.example/pay"),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_MERCHANT_URL(_url) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_MERCHANT_URL, \
+ .details.merchant_url = (_url) \
+ }
+
+
+/**
+ * Supply the session identifier for this payment.
+ *
+ * @param _sid session ID string.
+ *
+ * @par Example
+ * \code
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_SESSION_ID("ABC123"),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_SESSION_ID(_sid) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_SESSION_ID, \
+ .details.session_id = (_sid) \
+ }
+
+
+/**
+ * Supply a private contract hash for the order.
+ *
+ * @param _h pointer to a TALER_PrivateContractHashP.
+ *
+ * @par Example
+ * \code
+ * struct TALER_PrivateContractHashP *h = …;
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_H_CONTRACT(h),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_H_CONTRACT(_h) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_H_CONTRACT, \
+ .details.h_contract = (_h) \
+ }
+
+
+/**
+ * Supply which choice index the customer(wallet) selected.
+ * from contract terms.
+ *
+ * @param _idx choice index.
+ *
+ * @par Example
+ * \code
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_CHOICE_INDEX(2),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_CHOICE_INDEX(_idx) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_CHOICE_INDEX, \
+ .details.choice_index = (_idx) \
+ }
+
+
+/**
+ * Specify the amount to be paid.
+ *
+ * @param _amt pointer to a TALER_Amount struct.
+ *
+ * @par Example
+ * \code
+ * struct TALER_Amount amt = ...;
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_AMOUNT(&amt),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_AMOUNT(_amt) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_AMOUNT, \
+ .details.amount = *(_amt) \
+ }
+
+
+/**
+ * Set the maximum acceptable fee.
+ *
+ * @param _fee pointer to a TALER_Amount struct for the fee cap.
+ *
+ * @par Example
+ * \code
+ * struct TALER_Amount fee = ...;
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_MAX_FEE(&fee),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_MAX_FEE(_fee) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_MAX_FEE, \
+ .details.max_fee = *(_fee) \
+ }
+
+
+/**
+ * Provide the merchant’s public key.
+ *
+ * @param _mpub pointer to a TALER_MerchantPublicKeyP.
+ *
+ * @par Example
+ * \code
+ * struct TALER_MerchantPublicKeyP *mp = …;
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_MERCHANT_PUB(mp),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_MERCHANT_PUB(_mpub) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_MERCHANT_PUB, \
+ .details.merchant_pub = *(_mpub) \
+ }
+
+
+/**
+ * Stamp the request with a specific time.
+ *
+ * @param _ts GNUNET_TIME_Timestamp value.
+ *
+ * @par Example
+ * \code
+ * struct GNUNET_TIME_Timestamp now = …;
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TIMESTAMP(now),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_TIMESTAMP(_ts) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_TIMESTAMP, \
+ .details.timestamp = (_ts) \
+ }
+
+
+/**
+ * Set a deadline by which refunds may be issued.
+ *
+ * @param _ts GNUNET_TIME_Timestamp for the refund deadline.
+ *
+ * @par Example
+ * \code
+ * struct GNUNET_TIME_Timestamp rd = …;
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_REFUND_DEADLINE(rd),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_REFUND_DEADLINE(_ts) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_REFUND_DEADLINE, \
+ .details.refund_deadline = (_ts) \
+ }
+
+
+/**
+ * Set a deadline by which payment must be completed.
+ *
+ * @param _ts GNUNET_TIME_Timestamp for the payment deadline.
+ *
+ * @par Example
+ * \code
+ * struct GNUNET_TIME_Timestamp pd = …;
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_PAY_DEADLINE(pd),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_PAY_DEADLINE(_ts) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_PAY_DEADLINE, \
+ .details.pay_deadline = (_ts) \
+ }
+
+
+/**
+ * Supply the merchant wire transaction hash.
+ *
+ * @param _hwire pointer to a TALER_MerchantWireHashP.
+ *
+ * @par Example
+ * \code
+ * struct TALER_MerchantWireHashP *wh = …;
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_H_WIRE(wh),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_H_WIRE(_hwire) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_H_WIRE, \
+ .details.h_wire = *(_hwire) \
+ }
+
+
+/**
+ * Provide the unique order identifier.
+ *
+ * @param _oid NULL-terminated string of the order ID.
+ *
+ * @par Example
+ * \code
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_ORDER_ID("order-42"),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_ORDER_ID(_oid) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_ORDER_ID, \
+ .details.order_id = (_oid) \
+ }
+
+
+/**
+ * Include a list of pay coins.
+ *
+ * @param _num number of coins in the array
+ * @param _coins pointer to array of TALER_MERCHANT_PayCoin.
+ *
+ * @par Example
+ * \code
+ * const struct TALER_MERCHANT_PayCoin coins[2] = { … };
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_COINS(2, coins),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_COINS(_num,_coins) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_COINS, \
+ .details.coins = { .num_coins = (_num), \
+ .coins = (_coins) } \
+ }
+
+
+/**
+ * Include a list of input tokens.
+ *
+ * @param _num number of tokens
+ * @param _tokens pointer to array of TALER_MERCHANT_UseToken.
+ *
+ * @par Example
+ * \code
+ * const struct TALER_MERCHANT_UseToken toks[1] = { … };
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_INPUT_TOKENS(1, toks),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+
+#define TALER_MERCHANT_ORDER_PAY_OPTION_INPUT_TOKENS(_num,_tokens) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_INPUT_TOKENS, \
+ .details.input_tokens = { .num_tokens = (_num), \
+ .tokens = (_tokens) } \
+ }
+
+
+/**
+ * Include a list of output tokens.
+ *
+ * @param _num number of output tokens
+ * @param _otokens pointer to array of TALER_MERCHANT_OutputToken.
+ *
+ * @par Example
+ * \code
+ * const struct TALER_MERCHANT_OutputToken ots[3] = { … };
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_OUTPUT_TOKENS(3, ots),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_OUTPUT_TOKENS(_num,_otokens) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_OUTPUT_TOKENS, \
+ .details.output_tokens = { .num_output_tokens = (_num), \
+ .output_tokens = (_otokens) } \
+ }
+
+
+/**
+ * Supply the Donau service URL.
+ *
+ * @param _u NULL-terminated string of the Donau endpoint.
+ *
+ * @par Example
+ * \code
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_URL("https://donau.example"),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_URL(_u) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_DONAU_URL, \
+ .details.donau_url = (_u) \
+ }
+
+
+/**
+ * Specify the Donau “year” parameter.
+ *
+ * @param _y 64-bit unsigned integer for the Donau year.
+ *
+ * @par Example
+ * \code
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_YEAR(2025),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_YEAR(_y) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_DONAU_YEAR, \
+ .details.donau_year = (_y) \
+ }
+
+
+/**
+ * Supply the Donau “budis” JSON structure.
+ *
+ * @param _js pointer to a json_t* holding the budis data.
+ *
+ * @par Example
+ * \code
+ * json_t *budis = json_pack("{s:i}", "quota", 100);
+ * struct TALER_MERCHANT_OrderPayOption opts[] = {
+ * TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_BUDIS(budis),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE()
+ * };
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_BUDIS(_js) \
+ (struct TALER_MERCHANT_OrderPayOption){ \
+ .ot = TALER_MERCHANT_OrderPayOptionType_DONAU_BUDIS, \
+ .details.donau_budis_json = (_js) \
+ }
+
+
+/**
+ * Helper to call TALER_MERCHANT_order_pay_set_options()
+ * with a compound‐literal array terminated by TERMINATE().
+ *
+ * @param ph the payment handle
+ * @param ... a comma-separated list of `_OPTION_*()` macros
+ *
+ * @par Example
+ * \code
+ * TALER_MERCHANT_ORDER_PAY_SET_OPTIONS(handle,
+ * TALER_MERCHANT_ORDER_PAY_OPTION_MERCHANT_URL("https://…"),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_AMOUNT(&amt),
+ * TALER_MERCHANT_ORDER_PAY_OPTION_MAX_FEE(&fee)
+ * );
+ * \endcode
+ */
+#define TALER_MERCHANT_ORDER_PAY_SET_OPTIONS(ph,...) \
+ MHD_NOWARN_COMPOUND_LITERALS_ \
+ TALER_MERCHANT_order_pay_set_options ( \
+ daemon, \
+ ((const struct TALER_MERCHANT_OrderPayHandle[]) \
+ {__VA_ARGS__, TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE ()}), \
+ MHD_OPTIONS_ARRAY_MAX_SIZE) \
+
+
+/**
+ * @brief Create and initialize a new payment handle.
+ *
+ * @param ctx GNUNET CURL context used for HTTP operations
+ * @param pay_cb callback to invoke when the payment completes or fails
+ * @param pay_cb_cls closure data passed back to @a pay_cb
+ * @return pointer to a newly allocated handle, or NULL on error
+ */
+struct TALER_MERCHANT_OrderPayHandle *
+TALER_MERCHANT_order_pay_create (struct GNUNET_CURL_Context *ctx,
+ TALER_MERCHANT_OrderPayCallback pay_cb,
+ TALER_MERCHANT_ORDER_PAY_CALLBACK_CLOSURE_TYPE
+ *pay_cb_cls);
+
+
+/**
+ * @brief Configure payment options on a handle.
+ *
+ * @param ph payment handle to configure
+ * @param options NULL-terminated array of options (use
+ * TALER_MERCHANT_ORDER_PAY_OPTION_* macros)
+ * @param max_options maximum number of options in the @a options array
+ * @return #TALER_MERCHANT_OPOEC_OK on success;
+ * error code otherwise
+ */
+enum TALER_MERCHANT_OrderPayErrorCode
+TALER_MERCHANT_order_pay_set_options (struct TALER_MERCHANT_OrderPayHandle *ph,
+ const struct TALER_MERCHANT_OrderPayOption
+ options[],
+ size_t max_options);
+
+
+/**
+ * @brief Start processing the payment request.
+ *
+ * @param ph fully configured payment handle
+ * @return #TALER_MERCHANT_OPOEC_OK on successful dispatch;
+ * error code on validation or dispatch failure
+ */
+enum TALER_MERCHANT_OrderPayErrorCode
+TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph);
+
+
+/**
+ * @brief Cancel an in-flight or pending payment.
+ *
+ * @param ph payment handle to cancel and free
+ */
+void
+TALER_MERCHANT_order_pay_cancel1 (struct TALER_MERCHANT_OrderPayHandle *ph);
+
+#endif /* TALER_MERCHANT_PAY_SERVICE_H */
diff --git a/src/include/taler/taler_merchant_service.h b/src/include/taler/taler_merchant_service.h
@@ -0,0 +1,101 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING.LGPL. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler/taler_merchant_service.h
+ * @brief C interface of libtalermerchant, a C library to use merchant's HTTP API
+ * This library is not thread-safe, all APIs must only be used from a single thread.
+ * This library calls abort() if it runs out of memory. Be aware of these limitations.
+ * @author Christian Grothoff
+ * @author Priscilla Huang
+ * @author Marcello Stanisci
+ */
+#ifndef _TALER_MERCHANT_SERVICE_H
+#define _TALER_MERCHANT_SERVICE_H
+
+/**
+ * Version of the Taler Merchant API, in hex.
+ * Thus 0.12.0-0 = 0x000C0000.
+ */
+#define TALER_MERCHANT_API_VERSION 0x000C0000
+
+#include <taler/taler-merchant/common.h>
+#include <taler/taler-merchant/get-config.h>
+#include <taler/taler-merchant/get-management-instances.h>
+#include <taler/taler-merchant/get-management-instances-INSTANCE.h>
+#include <taler/taler-merchant/get-private-kyc.h>
+#include <taler/taler-merchant/get-private-statistics-amount-SLUG.h>
+#include <taler/taler-merchant/get-private-statistics-counter-SLUG.h>
+#include <taler/taler-merchant/delete-management-instances-INSTANCE.h>
+#include <taler/taler-merchant/patch-management-instances-INSTANCE.h>
+#include <taler/taler-merchant/post-management-instances.h>
+#include <taler/taler-merchant/post-management-instances-INSTANCE-auth.h>
+#include <taler/taler-merchant/post-private-token.h>
+#include <taler/taler-merchant/delete-private-tokens-SERIAL.h>
+#include <taler/taler-merchant/get-private-orders.h>
+#include <taler/taler-merchant/post-private-orders.h>
+#include <taler/taler-merchant/get-private-orders-ORDER_ID.h>
+#include <taler/taler-merchant/get-orders-ORDER_ID.h>
+#include <taler/taler-merchant/delete-private-orders-ORDER_ID.h>
+#include <taler/taler-merchant/post-orders-ORDER_ID-abort.h>
+#include <taler/taler-merchant/post-orders-ORDER_ID-claim.h>
+#include <taler/taler-merchant/post-orders-ORDER_ID-paid.h>
+#include <taler/taler-merchant/post-orders-ORDER_ID-pay.h>
+#include <taler/taler-merchant/post-private-orders-ORDER_ID-refund.h>
+#include <taler/taler-merchant/post-orders-ORDER_ID-refund.h>
+#include <taler/taler-merchant/patch-private-orders-ORDER_ID-forget.h>
+#include <taler/taler-merchant/get-private-products.h>
+#include <taler/taler-merchant/get-private-products-PRODUCT_ID.h>
+#include <taler/taler-merchant/post-private-products.h>
+#include <taler/taler-merchant/patch-private-products-PRODUCT_ID.h>
+#include <taler/taler-merchant/delete-private-products-PRODUCT_ID.h>
+#include <taler/taler-merchant/post-private-products-PRODUCT_ID-lock.h>
+#include <taler/taler-merchant/get-products-IMAGE_HASH-image.h>
+#include <taler/taler-merchant/get-private-transfers.h>
+#include <taler/taler-merchant/post-private-transfers.h>
+#include <taler/taler-merchant/delete-private-transfers-TID.h>
+#include <taler/taler-merchant/get-private-accounts.h>
+#include <taler/taler-merchant/get-private-accounts-H_WIRE.h>
+#include <taler/taler-merchant/post-private-accounts.h>
+#include <taler/taler-merchant/patch-private-accounts-H_WIRE.h>
+#include <taler/taler-merchant/delete-private-accounts-H_WIRE.h>
+#include <taler/taler-merchant/get-private-otp-devices.h>
+#include <taler/taler-merchant/get-private-otp-devices-DEVICE_ID.h>
+#include <taler/taler-merchant/post-private-otp-devices.h>
+#include <taler/taler-merchant/patch-private-otp-devices-DEVICE_ID.h>
+#include <taler/taler-merchant/delete-private-otp-devices-DEVICE_ID.h>
+#include <taler/taler-merchant/get-private-templates.h>
+#include <taler/taler-merchant/get-private-templates-TEMPLATE_ID.h>
+#include <taler/taler-merchant/post-private-templates.h>
+#include <taler/taler-merchant/patch-private-templates-TEMPLATE_ID.h>
+#include <taler/taler-merchant/delete-private-templates-TEMPLATE_ID.h>
+#include <taler/taler-merchant/post-templates-TEMPLATE_ID.h>
+#include <taler/taler-merchant/get-templates-TEMPLATE_ID.h>
+#include <taler/taler-merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG.h>
+#include <taler/taler-merchant/post-private-tokenfamilies.h>
+#include <taler/taler-merchant/get-private-webhooks.h>
+#include <taler/taler-merchant/get-private-webhooks-WEBHOOK_ID.h>
+#include <taler/taler-merchant/post-private-webhooks.h>
+#include <taler/taler-merchant/patch-private-webhooks-WEBHOOK_ID.h>
+#include <taler/taler-merchant/delete-private-webhooks-WEBHOOK_ID.h>
+#include <taler/taler-merchant/get-private-units.h>
+#include <taler/taler-merchant/get-private-units-UNIT.h>
+#include <taler/taler-merchant/post-private-units.h>
+#include <taler/taler-merchant/patch-private-units-UNIT.h>
+#include <taler/taler-merchant/delete-private-units-UNIT.h>
+#include <taler/taler-merchant/post-private-categories.h>
+
+#endif
diff --git a/src/include/taler/taler_merchant_testing_lib.h b/src/include/taler/taler_merchant_testing_lib.h
@@ -0,0 +1,2514 @@
+/*
+ This file is part of TALER
+ (C) 2018-2023 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 3, or
+ (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with TALER; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file taler_merchant_testing_lib.h
+ * @brief API for writing an interpreter to test Taler components
+ * @author Christian Grothoff <christian@grothoff.org>
+ * @author Marcello Shtanisci
+ * @author Priscilla HUANG
+ */
+#ifndef TALER_MERCHANT_TESTING_LIB_H
+#define TALER_MERCHANT_TESTING_LIB_H
+
+#include <gnunet/gnunet_time_lib.h>
+#include <taler/taler_testing_lib.h>
+#include "taler_merchant_service.h"
+#ifdef HAVE_DONAU_DONAU_SERVICE_H
+#include "donau/donau_service.h"
+#endif // HAVE_DONAU_DONAU_SERVICE_H
+
+/* ********************* Helper functions ********************* */
+
+
+#define MERCHANT_FAIL() \
+ do {GNUNET_break (0); return NULL; } while (0)
+
+
+/**
+ * Extract hostname (and port) from merchant base URL.
+ *
+ * @param merchant_url full merchant URL (e.g. "http://host:8080/foo/bar/")
+ * @return just the hostname and port ("hostname:8080")
+ */
+char *
+TALER_MERCHANT_TESTING_extract_host (const char *merchant_url);
+
+
+/* ************** Specific interpreter commands ************ */
+
+
+/**
+ * Define a "config" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * "config" request.
+ * @param http_code expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_config (const char *label,
+ const char *merchant_url,
+ unsigned int http_code);
+
+
+/**
+ * Define a "GET /instances" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * GET /instances request.
+ * @param http_status expected HTTP response code.
+ * @param ... NULL-terminated list of labels (const char *) of
+ * product (commands) we expect to be returned in the list
+ * (assuming @a http_code is #MHD_HTTP_OK)
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_instances (const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ ...);
+
+
+/**
+ * Define a "POST /instances" CMD, simple version
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /instances request.
+ * @param instance_id the ID of the instance to create
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_instances (const char *label,
+ const char *merchant_url,
+ const char *instance_id,
+ unsigned int http_status);
+
+
+/**
+ * Define a "POST /private/auth" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /instances request.
+ * @param instance_id the ID of the instance, or NULL
+ * @param auth_token new auth token to use, can be NULL for no auth
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_instance_auth (const char *label,
+ const char *merchant_url,
+ const char *instance_id,
+ const char *auth_token,
+ unsigned int http_status);
+
+
+/**
+ * Define a "POST /private/token" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /instances request.
+ * @param instance_id the ID of the instance, or NULL
+ * @param scope scope to request, can be NULL
+ * @param duration requested token validity duration
+ * @param refreshable should token be refreshable
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_instance_token (const char *label,
+ const char *merchant_url,
+ const char *instance_id,
+ const char *scope,
+ struct GNUNET_TIME_Relative
+ duration,
+ bool refreshable,
+ unsigned int http_status);
+
+/**
+ * Set the access token gotten through another CMD
+ *
+ * @param label command label.
+ * @param cmd_job_label the other command exposing the bearer_token trait.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_set_instance_token (const char *label,
+ const char *cmd_job_label);
+
+/**
+ * Define a "DELETE /private/token" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /instances request.
+ * @param instance_id the ID of the instance, or NULL
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_delete_instance_token (const char *label,
+ const char *merchant_url,
+ const char *instance_id,
+ unsigned int http_status);
+
+/**
+ * Define a "POST /instances" CMD. Comprehensive version.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /instances request.
+ * @param instance_id the ID of the instance to query
+ * @param name name of the merchant instance
+ * @param address physical address of the merchant instance
+ * @param jurisdiction jurisdiction of the merchant instance
+ * @param use_stefan enable STEFAN curve
+ * @param default_wire_transfer_delay default wire transfer delay merchant will ask for
+ * @param default_pay_delay default validity period for offers merchant makes
+ * @param auth_token authorization token needed to access the instance, can be NULL
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_instances2 (
+ const char *label,
+ const char *merchant_url,
+ const char *instance_id,
+ const char *name,
+ json_t *address,
+ json_t *jurisdiction,
+ bool use_stefan,
+ struct GNUNET_TIME_Relative default_wire_transfer_delay,
+ struct GNUNET_TIME_Relative default_pay_delay,
+ const char *auth_token,
+ unsigned int http_status);
+
+
+/**
+ * Define a "POST /account" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /instances request.
+ * @param payto_uri URIs of the bank account to add to the merchant instance
+ * @param credit_facade_url credit facade URL to configure, can be NULL
+ * @param credit_facade_credentials credit facade credentials to use, can be NULL
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_account (
+ const char *label,
+ const char *merchant_url,
+ struct TALER_FullPayto payto_uri,
+ const char *credit_facade_url,
+ const json_t *credit_facade_credentials,
+ unsigned int http_status);
+
+
+/**
+ * Define a "PATCH /account" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /instances request.
+ * @param create_account_ref reference to account setup command
+ * @param credit_facade_url credit facade URL to configure, can be NULL
+ * @param credit_facade_credentials credit facade credentials to use, can be NULL
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_patch_account (
+ const char *label,
+ const char *merchant_url,
+ const char *create_account_ref,
+ const char *credit_facade_url,
+ const json_t *credit_facade_credentials,
+ unsigned int http_status);
+
+
+/**
+ * Define a "DELETE /account" CMD.
+ *
+ * @param label command label.
+ * @param create_account_ref reference to account setup command
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_delete_account (
+ const char *label,
+ const char *create_account_ref,
+ unsigned int http_status);
+
+
+/**
+ * Define a "PATCH /instances/$ID" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * PATCH /instance request.
+ * @param instance_id the ID of the instance to query
+ * @param name name of the merchant instance
+ * @param address physical address of the merchant instance
+ * @param jurisdiction jurisdiction of the merchant instance
+ * @param use_stefan use STEFAN curve
+ * @param default_wire_transfer_delay default wire transfer delay merchant will ask for
+ * @param default_pay_delay default validity period for offers merchant makes
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_patch_instance (
+ const char *label,
+ const char *merchant_url,
+ const char *instance_id,
+ const char *name,
+ json_t *address,
+ json_t *jurisdiction,
+ bool use_stefan,
+ struct GNUNET_TIME_Relative default_wire_transfer_delay,
+ struct GNUNET_TIME_Relative default_pay_delay,
+ unsigned int http_status);
+
+
+/**
+ * Define a "GET instance" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * GET /instances/$ID request.
+ * @param instance_id the ID of the instance to query
+ * @param http_status expected HTTP response code.
+ * @param instance_reference reference to a "POST /instances" or "PATCH /instances/$ID" CMD
+ * that will provide what we expect the backend to return to us
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_instance (const char *label,
+ const char *merchant_url,
+ const char *instance_id,
+ unsigned int http_status,
+ const char *instance_reference);
+
+
+/**
+ * Define a "PURGE instance" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * PURGE /instances/$ID request.
+ * @param instance_id the ID of the instance to query
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_purge_instance (const char *label,
+ const char *merchant_url,
+ const char *instance_id,
+ unsigned int http_status);
+
+
+/**
+ * Define a "DELETE instance" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * DELETE /instances/$ID request.
+ * @param instance_id the ID of the instance to query
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_delete_instance (const char *label,
+ const char *merchant_url,
+ const char *instance_id,
+ unsigned int http_status);
+
+
+/* ******************* /products **************** */
+
+
+/**
+ * Define a "POST /products" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /products request.
+ * @param product_id the ID of the product to query
+ * @param description description of the product
+ * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
+ * @param unit unit in which the product is measured (liters, kilograms, packages, etc.)
+ * @param price the price for one @a unit of the product, zero is used to imply that
+ * this product is not sold separately or that the price is not fixed and
+ * must be supplied by the front-end. If non-zero, price must include
+ * applicable taxes.
+ * @param image base64-encoded product image
+ * @param taxes list of taxes paid by the merchant
+ * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books)
+ * @param minimum_age minimum age required for buying this product
+ * @param address where the product is in stock
+ * @param next_restock when the next restocking is expected to happen, 0 for unknown,
+ * #GNUNET_TIME_UNIT_FOREVER_TS for 'never'.
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_products2 (
+ const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ const char *description,
+ json_t *description_i18n,
+ const char *unit,
+ const char *price,
+ const char *image,
+ json_t *taxes,
+ int64_t total_stock,
+ uint32_t minimum_age,
+ json_t *address,
+ struct GNUNET_TIME_Timestamp next_restock,
+ unsigned int http_status);
+
+
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_products3 (
+ const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ const char *description,
+ json_t *description_i18n,
+ const char *unit,
+ const char *price,
+ const char *image,
+ json_t *taxes,
+ int64_t total_stock,
+ uint32_t total_stock_frac,
+ bool unit_allow_fraction,
+ uint32_t minimum_age,
+ json_t *address,
+ struct GNUNET_TIME_Timestamp next_restock,
+ unsigned int http_status);
+
+/**
+ * Define a "POST /products" CMD with explicit unit_price array.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /products request.
+ * @param product_id the ID of the product to create
+ * @param description name of the product
+ * @param unit unit in which the product is measured
+ * @param unit_prices array of unit prices as strings
+ * @param unit_prices_len length of @a unit_prices
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_products_with_unit_prices (
+ const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ const char *description,
+ const char *unit,
+ const char *const *unit_prices,
+ size_t unit_prices_len,
+ unsigned int http_status);
+
+
+/**
+ * Define a "POST /products" CMD, simple version
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /products request.
+ * @param product_id the ID of the product to create
+ * @param description name of the product
+ * @param price price of the product
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_products (const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ const char *description,
+ const char *price,
+ unsigned int http_status);
+
+/**
+ * Define a "POST /products" CMD with category IDs.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /products request.
+ * @param product_id the ID of the product to create
+ * @param description name of the product
+ * @param price price of the product
+ * @param num_cats length of the @a cats array
+ * @param cats array of category IDs
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_products_with_categories (
+ const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ const char *description,
+ const char *unit,
+ const char *price,
+ unsigned int num_cats,
+ const uint64_t *cats,
+ bool unit_allow_fraction,
+ uint32_t unit_precision_level,
+ unsigned int http_status);
+
+/**
+ * Define a "POST /private/categories" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the request.
+ * @param name category name
+ * @param name_i18n category name translations
+ * @param expected_category_id expected category id (0 to ignore)
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_categories (
+ const char *label,
+ const char *merchant_url,
+ const char *name,
+ json_t *name_i18n,
+ uint64_t expected_category_id,
+ unsigned int http_status);
+
+/**
+ * Define a "GET /templates/$ID" wallet CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the request.
+ * @param template_id template ID to fetch
+ * @param expected_products_len expected number of products (0 to ignore)
+ * @param expected_product_id first expected product id (can be NULL)
+ * @param expected_unit expected unit for @a expected_product_id (can be NULL)
+ * @param expected_unit_allow_fraction expected fractional flag
+ * @param expected_unit_precision_level expected precision
+ * @param expected_product_id2 second expected product id (can be NULL)
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_wallet_get_template (
+ const char *label,
+ const char *merchant_url,
+ const char *template_id,
+ size_t expected_products_len,
+ const char *expected_product_id,
+ const char *expected_unit,
+ bool expected_unit_allow_fraction,
+ uint32_t expected_unit_precision_level,
+ json_t *expected_unit_name_short_i18n,
+ const char *expected_product_id2,
+ const char *expected_product_id3,
+ uint64_t expected_category_id1,
+ uint64_t expected_category_id2,
+ unsigned int http_status);
+
+
+/**
+ * Define a "PATCH /products/$ID" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * PATCH /product request.
+ * @param product_id the ID of the product to query
+ * @param description description of the product
+ * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
+ * @param unit unit in which the product is measured (liters, kilograms, packages, etc.)
+ * @param price the price for one @a unit of the product, zero is used to imply that
+ * this product is not sold separately or that the price is not fixed and
+ * must be supplied by the front-end. If non-zero, price must include
+ * applicable taxes.
+ * @param image base64-encoded product image
+ * @param taxes list of taxes paid by the merchant
+ * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books)
+ * @param total_lost in @a units, must be larger than previous values, and may
+ * not exceed total_stock minus total_sold; if it does, the transaction
+ * will fail with a #MHD_HTTP_CONFLICT HTTP status code
+ * @param address where the product is in stock
+ * @param next_restock when the next restocking is expected to happen, 0 for unknown,
+ * #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_patch_product (
+ const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ const char *description,
+ json_t *description_i18n,
+ const char *unit,
+ const char *price,
+ const char *image,
+ json_t *taxes,
+ int64_t total_stock,
+ uint64_t total_lost,
+ json_t *address,
+ struct GNUNET_TIME_Timestamp next_restock,
+ unsigned int http_status);
+
+
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_patch_product2 (
+ const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ const char *description,
+ json_t *description_i18n,
+ const char *unit,
+ const char *price,
+ const char *image,
+ json_t *taxes,
+ int64_t total_stock,
+ uint32_t total_stock_frac,
+ bool unit_allow_fraction,
+ uint64_t total_lost,
+ json_t *address,
+ struct GNUNET_TIME_Timestamp next_restock,
+ unsigned int http_status);
+
+/**
+ * Define a "PATCH /products/$ID" CMD with explicit unit_price array.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * PATCH /product request.
+ * @param product_id the ID of the product to query
+ * @param description description of the product
+ * @param unit unit in which the product is measured
+ * @param unit_prices array of unit prices as strings
+ * @param unit_prices_len length of @a unit_prices
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_patch_product_with_unit_prices (
+ const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ const char *description,
+ const char *unit,
+ const char *const *unit_prices,
+ size_t unit_prices_len,
+ unsigned int http_status);
+
+
+/**
+ * Define a "GET /products" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * GET /products request.
+ * @param http_status expected HTTP response code.
+ * @param ... NULL-terminated list of labels (const char *) of
+ * product (commands) we expect to be returned in the list
+ * (assuming @a http_code is #MHD_HTTP_OK)
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_products (const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ ...);
+
+/**
+ * Expectations for fractional unit fields when checking a product.
+ */
+struct TALER_TESTING_ProductUnitExpectations
+{
+ /**
+ * Whether @e unit_allow_fraction is provided.
+ */
+ bool have_unit_allow_fraction;
+
+ /**
+ * Expected fractional flag.
+ */
+ bool unit_allow_fraction;
+
+ /**
+ * Whether @e unit_precision_level is provided.
+ */
+ bool have_unit_precision_level;
+
+ /**
+ * Expected fractional precision.
+ */
+ uint32_t unit_precision_level;
+};
+
+
+/**
+ * Define a "GET product" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * GET /products/$ID request.
+ * @param product_id the ID of the product to query
+ * @param http_status expected HTTP response code.
+ * @param product_reference reference to a "POST /products" or "PATCH /products/$ID" CMD
+ * that will provide what we expect the backend to return to us
+ * @param unit_expectations optional explicit expectations for the fractional fields
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_product2 (
+ const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ unsigned int http_status,
+ const char *product_reference,
+ const struct TALER_TESTING_ProductUnitExpectations *unit_expectations);
+
+
+/**
+ * Legacy helper kept for compatibility.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_product (const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ unsigned int http_status,
+ const char *product_reference);
+
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_get_product_image (const char *label,
+ const char *merchant_url,
+ const char *product_reference,
+ const char *image_hash,
+ unsigned int http_status);
+
+
+/**
+ * Define a "LOCK /products/$ID" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * LOCK /product request.
+ * @param product_id the ID of the product to lock.
+ * @param duration how long the lock should last.
+ * @param quantity how money units to lock.
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_lock_product (
+ const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ struct GNUNET_TIME_Relative duration,
+ uint32_t quantity,
+ unsigned int http_status);
+
+
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_lock_product2 (
+ const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ struct GNUNET_TIME_Relative duration,
+ uint32_t quantity,
+ uint32_t quantity_frac,
+ bool use_fractional_quantity,
+ unsigned int http_status);
+
+
+/**
+ * Define a "DELETE product" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * DELETE /products/$ID request.
+ * @param product_id the ID of the product to query
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_delete_product (const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ unsigned int http_status);
+
+
+/* ******************* /orders **************** */
+
+/**
+ * Make the "proposal" command.
+ *
+ * @param label command label
+ * @param cfg configuration to use
+ * @param merchant_url base URL of the merchant serving
+ * the proposal request.
+ * @param http_status expected HTTP status.
+ * @param order_id the name of the order to add.
+ * @param refund_deadline the deadline for refunds on this order.
+ * @param pay_deadline the deadline for payment on this order.
+ * @param amount the amount this order is for.
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_orders (
+ const char *label,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *order_id,
+ struct GNUNET_TIME_Timestamp refund_deadline,
+ struct GNUNET_TIME_Timestamp pay_deadline,
+ const char *amount);
+
+
+/**
+ * Make the "proposal" command AVOIDING claiming the order.
+ *
+ * @param label command label
+ * @param merchant_url base URL of the merchant serving
+ * the proposal request.
+ * @param http_status expected HTTP status.
+ * @param order_id the name of the order to add.
+ * @param refund_deadline the deadline for refunds on this order.
+ * @param pay_deadline the deadline for payment on this order.
+ * @param amount the amount this order is for.
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_orders_no_claim (
+ const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *order_id,
+ struct GNUNET_TIME_Timestamp refund_deadline,
+ struct GNUNET_TIME_Timestamp pay_deadline,
+ const char *amount);
+
+
+/**
+ * Make the "proposal" command.
+ *
+ * @param label command label
+ * @param cfg configuration to use
+ * @param merchant_url base URL of the merchant serving
+ * the proposal request.
+ * @param http_status expected HTTP status.
+ * @param order_id the name of the order to add.
+ * @param refund_deadline the deadline for refunds on this order.
+ * @param pay_deadline the deadline for payment on this order.
+ * @param claim_token whether to generate a claim token.
+ * @param amount the amount this order is for.
+ * @param payment_target payment target for the order.
+ * @param products a string indicating the products this order will be
+ * purchasing. Should be formatted as
+ * "[product_id]/[quantity];...".
+ * @param locks a string of references to lock product commands that should
+ * be formatted as "[lock_1];[lock_2];...".
+ * @param duplicate_of if not NULL, a reference to a previous order command
+ * that should be duplicated and checked for an identical response.
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_orders2 (
+ const char *label,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *order_id,
+ struct GNUNET_TIME_Timestamp refund_deadline,
+ struct GNUNET_TIME_Timestamp pay_deadline,
+ bool claim_token,
+ const char *amount,
+ const char *payment_target,
+ const char *products,
+ const char *locks,
+ const char *duplicate_of);
+
+
+/**
+ * Create an order with a specific fulfillment URL.
+ * Does not claim the order.
+ *
+ * @param label command label
+ * @param cfg configuration to use
+ * @param merchant_url base URL of the merchant serving
+ * the proposal request
+ * @param http_status expected HTTP status
+ * @param order_id ID of the order to create
+ * @param refund_deadline the deadline for refunds on this order
+ * @param pay_deadline the deadline for payment on this order
+ * @param fulfillment_url the fulfillment URL to use
+ * @param amount the amount this order is for
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_orders3 (
+ const char *label,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *order_id,
+ struct GNUNET_TIME_Timestamp refund_deadline,
+ struct GNUNET_TIME_Timestamp pay_deadline,
+ const char *fulfillment_url,
+ const char *amount);
+
+
+/**
+ * Create an order with a choices array with input and output tokens.
+ *
+ * @param label command label
+ * @param cfg configuration to use
+ * @param merchant_url base URL of the merchant serving
+ * the proposal request.
+ * @param http_status expected HTTP status.
+ * @param token_family_slug slug of the token family to use
+ * @param choice_description description of the choice
+ * @param choice_description_i18n json of description translations
+ * @param num_inputs number of input tokens.
+ * @param num_outputs number of output tokens.
+ * @param order_id the name of the order to add.
+ * @param refund_deadline the deadline for refunds on this order.
+ * @param pay_deadline the deadline for payment on this order.
+ * @param amount the amount this order is for.
+ * @return the command
+ */
+
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_orders_choices (
+ const char *label,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *token_family_slug,
+ const char *choice_description,
+ json_t *choice_description_i18n,
+ unsigned int num_inputs,
+ unsigned int num_outputs,
+ const char *order_id,
+ struct GNUNET_TIME_Timestamp refund_deadline,
+ struct GNUNET_TIME_Timestamp pay_deadline,
+ const char *amount);
+
+
+/**
+ * Create an order with a choices array with output choice for donau.
+ *
+ * @param label command label
+ * @param cfg configuration to use
+ * @param merchant_url base URL of the merchant serving
+ * the proposal request.
+ * @param http_status expected HTTP status.
+ * @param order_id the name of the order to add.
+ * @param refund_deadline the deadline for refunds on this order.
+ * @param pay_deadline the deadline for payment on this order.
+ * @param amount the amount this order is for.
+ * @return the command
+ */
+
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_orders_donau (
+ const char *label,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *order_id,
+ struct GNUNET_TIME_Timestamp refund_deadline,
+ struct GNUNET_TIME_Timestamp pay_deadline,
+ const char *amount);
+
+/**
+ * Define a "GET /orders" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * GET /orders request.
+ * @param http_status expected HTTP response code.
+ * @param ... NULL-terminated list of labels (const char *) of
+ * order (commands) we expect to be returned in the list
+ * (assuming @a http_code is #MHD_HTTP_OK)
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_orders (const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ ...);
+
+
+/**
+ * Start a long poll for GET /private/orders.
+ *
+ * FIXME: needs additional arguments to specify range to long poll for!
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * serve the request.
+ * @param timeout how long to wait for the request to complete
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_poll_orders_start (const char *label,
+ const char *merchant_url,
+ struct GNUNET_TIME_Relative timeout);
+
+
+/**
+ * Complete a long poll for GET /private/orders.
+ *
+ * @param label the command label
+ * @param http_status expected HTTP response code
+ * @param poll_start_reference reference to the #TALER_TESTING_cmd_poll_orders_start command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_poll_orders_conclude (
+ const char *label,
+ unsigned int http_status,
+ const char *poll_start_reference);
+
+
+/**
+ * Define a GET /orders/$ORDER_ID CMD.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * serve the request.
+ * @param order_reference reference to a command that created an order.
+ * @param paid whether the order has been paid for or not.
+ * @param refunded whether the order has been refunded.
+ * @param refund_pending whether the order has refunds that haven't been obtained.
+ * @param http_status expected HTTP response code for the request.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_wallet_get_order (
+ const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ bool paid,
+ bool refunded,
+ bool refund_pending,
+ unsigned int http_status);
+
+
+/**
+ * Define a GET /orders/$ORDER_ID CMD.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * serve the request.
+ * @param order_reference reference to a command that created an order.
+ * @param session_id session ID to check for
+ * @param paid whether the order has been paid for or not.
+ * @param refunded whether the order has been refunded.
+ * @param refund_pending whether the order has refunds that haven't been obtained.
+ * @param repurchase_order_ref command of a paid equivalent order the merchant should be referring us to, or NULL
+ * @param http_status expected HTTP response code for the request.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_wallet_get_order2 (
+ const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ const char *session_id,
+ bool paid,
+ bool refunded,
+ bool refund_pending,
+ const char *repurchase_order_ref,
+ unsigned int http_status);
+
+
+/**
+ * Start a long poll for GET /orders/$ORDER_ID.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * serve the request.
+ * @param order_ref reference to a command that created an order.
+ * @param timeout how long to wait for the request to complete
+ * @param await_refund NULL to not wait for refund, amount of value
+ * zero to wait for any refund amount, non-zero to poll
+ * for refund exceeding the given amount
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_wallet_poll_order_start (
+ const char *label,
+ const char *merchant_url,
+ const char *order_ref,
+ struct GNUNET_TIME_Relative timeout,
+ const char *await_refund);
+
+
+/**
+ * Start a long poll for GET /orders/$ORDER_ID.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * serve the request.
+ * @param order_ref reference to a command that created an order.
+ * @param timeout how long to wait for the request to complete
+ * @param await_refund NULL to not wait for refund, amount of value
+ * zero to wait for any refund amount, non-zero to poll
+ * for refund exceeding the given amount
+ * @param session_id which session ID to use
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_wallet_poll_order_start2 (
+ const char *label,
+ const char *merchant_url,
+ const char *order_ref,
+ struct GNUNET_TIME_Relative timeout,
+ const char *await_refund,
+ const char *session_id);
+
+
+/**
+ * Complete a long poll for GET /orders/$ORDER_ID.
+ *
+ * @param label the command label
+ * @param expected_http_status expected HTTP response code
+ * @param expected_refund_amount refund expected, NULL for no refund expected
+ * @param poll_start_reference reference to the #TALER_TESTING_cmd_wallet_poll_order_start command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_wallet_poll_order_conclude (
+ const char *label,
+ unsigned int expected_http_status,
+ const char *expected_refund_amount,
+ const char *poll_start_reference);
+
+
+/**
+ * Complete a long poll for GET /orders/$ORDER_ID.
+ *
+ * @param label the command label
+ * @param expected_http_status expected HTTP response code
+ * @param expected_refund_amount refund expected, NULL for no refund expected
+ * @param poll_start_reference reference to the #TALER_TESTING_cmd_wallet_poll_order_start command
+ * @param already_paid_order_id ID of an already paid order we expect to get returned
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_wallet_poll_order_conclude2 (
+ const char *label,
+ unsigned int expected_http_status,
+ const char *expected_refund_amount,
+ const char *poll_start_reference,
+ const char *already_paid_order_id);
+
+
+/**
+ * Define a GET /private/orders/$ORDER_ID CMD.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * serve the request.
+ * @param order_reference reference to a command that created an order.
+ * @param osc expected order status
+ * @param refunded whether the order has been refunded.
+ * @param http_status expected HTTP response code for the request.
+ * @param ... NULL-terminated list of labels (const char *) of
+ * refunds (commands) we expect to be aggregated in the transfer
+ * (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false,
+ * this parameter is ignored.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_order (
+ const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ enum TALER_MERCHANT_OrderStatusCode osc,
+ bool refunded,
+ unsigned int http_status,
+ ...);
+
+
+/**
+ * Define a GET /private/orders/$ORDER_ID CMD.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * serve the request.
+ * @param order_reference reference to a command that created an order.
+ * @param osc expected order status
+ * @param wired whether the order has been wired or not.
+ * @param transfers NULL-terminated list of labels (const char *) of
+ * wire transfers (commands) we expect to be aggregated in the order
+ * (assuming @a http_code is #MHD_HTTP_OK). If @e paid is false, this
+ * parameter is ignored.
+ * @param refunded whether the order has been refunded.
+ * @param refunds NULL-terminated list of labels (const char *) of
+ * refunds (commands) we expect to be aggregated in the order
+ * (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false,
+ * this parameter is ignored.
+ * @param forgets a NULL-terminated list of references to forget commands
+ * that apply to the order we are querying. If NULL, this is
+ * interpreted as no forgets are expected.
+ * @param http_status expected HTTP response code for the request.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_order2 (
+ const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ enum TALER_MERCHANT_OrderStatusCode osc,
+ bool wired,
+ const char **transfers,
+ bool refunded,
+ const char **refunds,
+ const char **forgets,
+ unsigned int http_status);
+
+
+/**
+ * Define a GET /private/orders/$ORDER_ID CMD.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * serve the request.
+ * @param order_reference reference to a command that created an order.
+ * @param osc expected order status
+ * @param session_id session ID the payment must be bound to
+ * @param repurchase_order_ref command of a paid equivalent order the merchant should be referring us to, or NULL
+ * @param expected_http_status expected HTTP response code for the request.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_order3 (
+ const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ enum TALER_MERCHANT_OrderStatusCode osc,
+ const char *session_id,
+ const char *repurchase_order_ref,
+ unsigned int expected_http_status);
+
+
+/**
+ * Define a GET /private/orders/$ORDER_ID CMD.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * serve the request.
+ * @param order_reference reference to a command that created an order.
+ * @param osc expected order status
+ * @param expected_min_age expected minimum age for the contract
+ * @param expected_http_status expected HTTP response code for the request.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_order4 (
+ const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ enum TALER_MERCHANT_OrderStatusCode osc,
+ uint32_t expected_min_age,
+ unsigned int expected_http_status);
+
+
+/**
+ * Start a long poll for GET /private/orders/$ORDER_ID.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_poll_order_start (const char *label,
+ const char *merchant_url,
+ const char *order_id,
+ struct GNUNET_TIME_Relative timeout);
+
+
+/**
+ * Complete a long poll for GET /private/orders/$ORDER_ID.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_poll_order_conclude (const char *label,
+ unsigned int http_status,
+ const char *poll_start_reference);
+
+/**
+ * Make a "claim order" command.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant backend
+ * serving the proposal lookup request.
+ * @param http_status expected HTTP response code.
+ * @param order_reference reference to a POST order CMD, can be NULL if @a order_id given
+ * @param order_id order id to lookup, can be NULL (then we use @a order_reference)
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_claim_order (const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *order_reference,
+ const char *order_id);
+
+
+/**
+ * Make a "pay" test command.
+ *
+ * @param label command label.
+ * @param merchant_url merchant base url
+ * @param http_status expected HTTP response code.
+ * @param proposal_reference the proposal whose payment status
+ * is going to be checked.
+ * @param coin_reference reference to any command which is able
+ * to provide coins to use for paying.
+ * @param amount_with_fee amount to pay, including the deposit
+ * fee
+ * @param amount_without_fee amount to pay, no fees included.
+ * @param session_id the session id to use for the payment (can be NULL).
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_pay_order (
+ const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *proposal_reference,
+ const char *coin_reference,
+ const char *amount_with_fee,
+ const char *amount_without_fee,
+ const char *session_id);
+
+
+/**
+ * Make a "pay" test command for an order with choices.
+ *
+ * @param label command label.
+ * @param merchant_url merchant base url
+ * @param http_status expected HTTP response code.
+ * @param proposal_reference the proposal whose payment status
+ * is going to be checked.
+ * @param coin_reference reference to any command which is able
+ * to provide coins to use for paying.
+ * @param amount_with_fee amount to pay, including the deposit
+ * fee
+ * @param amount_without_fee amount to pay, no fees included.
+ * @param session_id the session id to use for the payment (can be NULL).
+ * @param choice_index index of the selected choice for the payment.
+ * @param input_reference reference to a previous pay command that issued some
+ outputs to be used as inputs to this pay request.
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_pay_order_choices (
+ const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *proposal_reference,
+ const char *coin_reference,
+ const char *amount_with_fee,
+ const char *amount_without_fee,
+ const char *session_id,
+ int choice_index,
+ const char *input_reference);
+
+#ifdef HAVE_DONAU_DONAU_SERVICE_H
+
+/**
+ * Make a "pay" test command for an order with choices.
+ *
+ * @param label command label.
+ * @param merchant_url merchant base url
+ * @param http_status expected HTTP response code.
+ * @param proposal_reference the proposal whose payment status
+ * is going to be checked.
+ * @param coin_reference reference to any command which is able
+ * to provide coins to use for paying.
+ * @param amount_with_fee amount to pay, including the deposit
+ * fee
+ * @param amount_without_fee amount to pay, no fees included.
+ * @param amount_donation amount for which the BKPS will be received.
+ * @param session_id the session id to use for the payment (can be NULL).
+ * @param choice_index index of the selected choice for the payment.
+ * @param year year of the donation
+ * @param donor_tax_id tax ID of the donor
+ * @param salt salt for the donation
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_pay_order_donau (
+ const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *proposal_reference,
+ const char *coin_reference,
+ const char *amount_with_fee,
+ const char *amount_without_fee,
+ const char *amount_donation,
+ const char *session_id,
+ int choice_index,
+ const char *charity_reference,
+ uint64_t year,
+ const char *donor_tax_id,
+ const char *salt);
+
+#endif
+
+/**
+ * Make an "order paid" test command.
+ *
+ * @param label command label
+ * @param merchant_url merchant base URL
+ * @param pay_reference reference to the payment to verify
+ * @param session_id the session to use for the verification.
+ * @param http_status expected HTTP response code
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_orders_paid (
+ const char *label,
+ const char *merchant_url,
+ const char *pay_reference,
+ const char *session_id,
+ unsigned int http_status);
+
+
+/**
+ * Make an "abort" test command.
+ *
+ * @param label command label
+ * @param merchant_url merchant base URL
+ * @param pay_reference reference to the payment to abort
+ * @param http_status expected HTTP response code
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_order_abort (
+ const char *label,
+ const char *merchant_url,
+ const char *pay_reference,
+ unsigned int http_status);
+
+
+/**
+ * Make a "order forget" command.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant backend
+ * serving the order claim request.
+ * @param http_status expected HTTP response code.
+ * @param order_reference reference to a POST order CMD, can be NULL if @a order_id given
+ * @param order_id order id to forget for, can be NULL (then we use @a order_reference)
+ * @param ... NULL-terminated list of paths (const char *) to forget in
+ * the contract terms.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_forget_order (
+ const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *order_reference,
+ const char *order_id,
+ ...);
+
+
+/**
+ * Define a "refund" order CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the backend serving the
+ * "refund increase" request.
+ * @param reason refund justification, human-readable.
+ * @param order_id order id of the contract to refund.
+ * @param refund_amount amount to be refund-increased.
+ * @param http_code expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_order_refund (
+ const char *label,
+ const char *merchant_url,
+ const char *reason,
+ const char *order_id,
+ const char *refund_amount,
+ unsigned int http_code);
+
+
+/**
+ * Define a "refund order" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the backend serving the
+ * "refund increase" request.
+ * @param order_ref order id of the contract to refund.
+ * @param http_code expected HTTP response code.
+ * @param ... NULL-terminated list of labels (const char *) of
+ * refunds (commands) we expect to be aggregated in the transfer
+ * (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false,
+ * this parameter is ignored.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_wallet_order_refund (
+ const char *label,
+ const char *merchant_url,
+ const char *order_ref,
+ unsigned int http_code,
+ ...);
+
+
+/**
+ * Define a "DELETE order" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * DELETE /instances/$ID request.
+ * @param order_id the ID of the instance to query
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_delete_order (
+ const char *label,
+ const char *merchant_url,
+ const char *order_id,
+ unsigned int http_status);
+
+
+/* ******************* /transfers *************** */
+
+
+/**
+ * Define a POST /transfers CMD. Details like the WTID and
+ * other required parameters will be extracted from the bank
+ * history, using the latest transfer of the specified
+ * @a credit_amount to the @a merchant_url.
+ *
+ * @param label command label.
+ * @param auth credentials to access the exchange's bank account
+ * @param payto_uri URL of the exchange's bank account
+ * @param merchant_url base URL of the backend serving the
+ * "refund increase" request.
+ * @param credit_amount amount credited
+ * @param http_code expected HTTP response code
+ * @param ... NULL-terminated list of labels (const char *) of
+ * deposit (commands) we expect to be aggregated in the transfer
+ * (assuming @a http_code is #MHD_HTTP_OK)
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_transfer (
+ const char *label,
+ const struct TALER_BANK_AuthenticationData *auth,
+ struct TALER_FullPayto payto_uri,
+ const char *merchant_url,
+ const char *credit_amount,
+ unsigned int http_code,
+ ...);
+
+
+/**
+ * Define a POST /transfers CMD. Details like the WTID and
+ * other required parameters are explicitly provided.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the backend
+ * @param payto_uri URL of the exchange's bank account
+ * @param credit_amount amount credited
+ * @param wtid wire transfer ID to use, NULL to pick one at random
+ * @param exchange_url URL of the exchange to use
+ * @param http_code expected HTTP response code
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_transfer2 (
+ const char *label,
+ const char *merchant_url,
+ struct TALER_FullPayto payto_uri,
+ const char *credit_amount,
+ const char *wtid,
+ const char *exchange_url,
+ unsigned int http_code);
+
+
+/**
+ * We have discovered the @a serial for a POST transfer
+ * command. Store it (for the bank row trait).
+ *
+ * @param cmd command to update
+ * @param serial serial number to store (identifies the row)
+ */
+void
+TALER_TESTING_cmd_merchant_post_transfer_set_serial (
+ struct TALER_TESTING_Command *cmd,
+ uint64_t serial);
+
+
+/**
+ * Define a GET /transfers CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the backend serving the
+ * "refund increase" request.
+ * @param payto_uri payto URI to filter by, NULL for no filter
+ * @param http_code expected HTTP response code
+ * @param ... NULL-terminated list of labels (const char *) of
+ * transfer (commands) we expect to be returned in the list
+ * (assuming @a http_code is #MHD_HTTP_OK)
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_transfers (
+ const char *label,
+ const char *merchant_url,
+ struct TALER_FullPayto payto_uri,
+ unsigned int http_code,
+ ...);
+
+
+/**
+ * Define a "DELETE transfer" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant for the
+ * DELETE /transfers/$ID request.
+ * @param transfer_ref reference to a command that
+ * yields the transfer ID to delete
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_delete_transfer (const char *label,
+ const char *merchant_url,
+ const char *transfer_ref,
+ unsigned int http_status);
+
+
+/**
+ * Run a command to fetch the KYC status of a merchant.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant
+ * @param instance_id instance to use, NULL if instance is part of @a merchant_url
+ * @param h_wire_ref label of command with a merchant wire hash trait
+ * of the bank account to check KYC for; NULL to check all accounts
+ * @param exchange_url base URL of the exchange to check KYC status for
+ * @param lpt target for long polling
+ * @param expected_http_status expected HTTP status
+ * @param expected_kyc_state expected KYC state (only effective if @e expected_http_status is #MHD_HTTP_OK/#MHD_HTTP_ACCEPTED)
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_kyc_get (
+ const char *label,
+ const char *merchant_url,
+ const char *instance_id,
+ const char *h_wire_ref,
+ const char *exchange_url,
+ enum TALER_EXCHANGE_KycLongPollTarget lpt,
+ unsigned int expected_http_status,
+ bool expected_kyc_state);
+
+
+/* ****** OTP devices ******* */
+
+
+/**
+ * Define a "POST /otp-devices" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /otps request.
+ * @param otp_id the ID of the otp device to modify
+ * @param otp_description description of the otp device
+ * @param otp_key base32-encoded key to verify the payment
+ * @param otp_alg is an option that show the amount of the order. it is linked with the @a otp_key
+ * @param otp_ctr counter to use (if in counter mode)
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_otp_devices (
+ const char *label,
+ const char *merchant_url,
+ const char *otp_id,
+ const char *otp_description,
+ const char *otp_key,
+ enum TALER_MerchantConfirmationAlgorithm otp_alg,
+ uint64_t otp_ctr,
+ unsigned int http_status);
+
+
+/**
+ * Define a "PATCH /otp-devices/$ID" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * PATCH /otp-devices request.
+ * @param otp_id the ID of the otp device to modify
+ * @param otp_description description of the otp device
+ * @param otp_key base32-encoded key to verify the payment
+ * @param otp_alg is an option that show the amount of the order. it is linked with the @a otp_key
+ * @param otp_ctr counter to use (if in counter mode)
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_patch_otp_device (
+ const char *label,
+ const char *merchant_url,
+ const char *otp_id,
+ const char *otp_description,
+ const char *otp_key,
+ enum TALER_MerchantConfirmationAlgorithm otp_alg,
+ uint64_t otp_ctr,
+ unsigned int http_status);
+
+
+/**
+ * Define a "GET /otp-devices" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * GET /otp-devices request.
+ * @param http_status expected HTTP response code.
+ * @param ... NULL-terminated list of labels (const char *) of
+ * otp (commands) we expect to be returned in the list
+ * (assuming @a http_code is #MHD_HTTP_OK)
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_otp_devices (const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ ...);
+
+
+/**
+ * Define a "GET otp device" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * GET /otp-devices/$ID request.
+ * @param otp_id the ID of the otp to query
+ * @param http_status expected HTTP response code.
+ * @param otp_reference reference to a "POST /otp-devices" or "PATCH /otp-devices/$ID" CMD
+ * that will provide what we expect the backend to return to us
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_otp_device (const char *label,
+ const char *merchant_url,
+ const char *otp_id,
+ unsigned int http_status,
+ const char *otp_reference);
+
+
+/**
+ * Define a "DELETE otp device" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * DELETE /otp-devices/$ID request.
+ * @param otp_id the ID of the otp to query
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_delete_otp_device (const char *label,
+ const char *merchant_url,
+ const char *otp_id,
+ unsigned int http_status);
+
+
+/* ****** Templates ******* */
+
+/**
+ * Define a "POST /units" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the request.
+ * @param unit_id identifier of the unit.
+ * @param unit_name_long long label to store.
+ * @param unit_name_short short label to store.
+ * @param unit_allow_fraction whether fractional quantities are allowed.
+ * @param unit_precision_level fractional precision level.
+ * @param unit_active whether the unit starts active.
+ * @param unit_name_long_i18n optional translations for the long label.
+ * @param unit_name_short_i18n optional translations for the short label.
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_units (const char *label,
+ const char *merchant_url,
+ const char *unit_id,
+ const char *unit_name_long,
+ const char *unit_name_short,
+ bool unit_allow_fraction,
+ uint32_t unit_precision_level,
+ bool unit_active,
+ json_t *unit_name_long_i18n,
+ json_t *unit_name_short_i18n,
+ unsigned int http_status);
+
+
+/**
+ * Define a "PATCH /units/$ID" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the request.
+ * @param unit_id identifier of the unit to patch.
+ * @param unit_name_long optional new long label (NULL to skip).
+ * @param unit_name_short optional new short label (NULL to skip).
+ * @param unit_name_long_i18n optional new long label translations (NULL to skip).
+ * @param unit_name_short_i18n optional new short label translations (NULL to skip).
+ * @param unit_allow_fraction optional pointer to new fractional flag (NULL to skip).
+ * @param unit_precision_level optional pointer to new precision level (NULL to skip).
+ * @param unit_active optional pointer to new active flag (NULL to skip).
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_patch_unit (
+ const char *label,
+ const char *merchant_url,
+ const char *unit_id,
+ const char *unit_name_long,
+ const char *unit_name_short,
+ json_t *unit_name_long_i18n,
+ json_t *unit_name_short_i18n,
+ const bool unit_allow_fraction,
+ const uint32_t unit_precision_level,
+ const bool unit_active,
+ unsigned int http_status);
+
+
+/**
+ * Define a "GET /units" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the request.
+ * @param http_status expected HTTP response code.
+ * @param ... NULL-terminated list of labels (const char *) whose units must
+ * appear in the response (verified when @a http_status is #MHD_HTTP_OK).
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_units (const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ ...);
+
+
+/**
+ * Define a "GET /units/$ID" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the request.
+ * @param unit_id identifier to fetch.
+ * @param http_status expected HTTP response code.
+ * @param reference optional label of a command providing expected unit traits.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_unit (const char *label,
+ const char *merchant_url,
+ const char *unit_id,
+ unsigned int http_status,
+ const char *reference);
+
+
+/**
+ * Define a "DELETE /units/$ID" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the request.
+ * @param unit_id identifier to delete.
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_delete_unit (const char *label,
+ const char *merchant_url,
+ const char *unit_id,
+ unsigned int http_status);
+
+
+/**
+ * Define a "POST /templates" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /templates request.
+ * @param template_id the ID of the template to query
+ * @param template_description description of the template
+ * @param otp_id OTP device ID, NULL for none
+ * @param template_contract where the contract of the company is
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_templates2 (
+ const char *label,
+ const char *merchant_url,
+ const char *template_id,
+ const char *template_description,
+ const char *otp_id,
+ json_t *template_contract,
+ unsigned int http_status);
+
+
+/**
+ * Define a "POST /templates" CMD, simple version
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /templates request.
+ * @param template_id the ID of the template to create
+ * @param template_description description of the template
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_templates (const char *label,
+ const char *merchant_url,
+ const char *template_id,
+ const char *template_description,
+ unsigned int http_status);
+
+
+/**
+ * Define a "PATCH /templates/$ID" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * PATCH /template request.
+ * @param template_id the ID of the template to query
+ * @param template_description description of the template
+ * @param otp_id OTP device to use
+ * @param template_contract contract of the company
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_patch_template (
+ const char *label,
+ const char *merchant_url,
+ const char *template_id,
+ const char *template_description,
+ const char *otp_id,
+ json_t *template_contract,
+ unsigned int http_status);
+
+
+/**
+ * Define a "GET /templates" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * GET /templates request.
+ * @param http_status expected HTTP response code.
+ * @param ... NULL-terminated list of labels (const char *) of
+ * template (commands) we expect to be returned in the list
+ * (assuming @a http_code is #MHD_HTTP_OK)
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_templates (const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ ...);
+
+
+/**
+ * Define a "GET template" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * GET /templates/$ID request.
+ * @param template_id the ID of the template to query
+ * @param http_status expected HTTP response code.
+ * @param template_reference reference to a "POST /templates" or "PATCH /templates/$ID" CMD
+ * that will provide what we expect the backend to return to us
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_template (const char *label,
+ const char *merchant_url,
+ const char *template_id,
+ unsigned int http_status,
+ const char *template_reference);
+
+
+/**
+ * Define a "DELETE template" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * DELETE /templates/$ID request.
+ * @param template_id the ID of the template to query
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_delete_template (const char *label,
+ const char *merchant_url,
+ const char *template_id,
+ unsigned int http_status);
+
+
+/**
+ * Define a "POST /using-templates" CMD, simple version
+ *
+ * @param label command label.
+ * @param template_ref label of command that created the template to use
+ * @param otp_ref label of command that created OTP device we use (or NULL for no OTP)
+ * @param merchant_url base URL of the merchant serving the
+ * POST /using-templates request.
+ * @param using_template_id template ID to use
+ * @param summary given by the customer to know what they did pay
+ * @param amount given by the customer to pay
+ * @param refund_deadline refund deadline to use for the contract
+ * @param pay_deadline pay deadline to use for the contract
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_using_templates (
+ const char *label,
+ const char *template_ref,
+ const char *otp_ref,
+ const char *merchant_url,
+ const char *using_template_id,
+ const char *summary,
+ const char *amount,
+ struct GNUNET_TIME_Timestamp refund_deadline,
+ struct GNUNET_TIME_Timestamp pay_deadline,
+ unsigned int http_status);
+
+/**
+ * Define a "POST /using-templates" CMD with a raw JSON request body.
+ *
+ * @param label command label.
+ * @param template_ref label of command that created the template to use
+ * @param otp_ref label of command that created OTP device we use (or NULL for no OTP)
+ * @param merchant_url base URL of the merchant serving the
+ * POST /using-templates request.
+ * @param using_template_id template ID to use
+ * @param details raw JSON request body to send
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_using_templates2 (
+ const char *label,
+ const char *template_ref,
+ const char *otp_ref,
+ const char *merchant_url,
+ const char *using_template_id,
+ const json_t *details,
+ unsigned int http_status);
+
+
+/* ****** Token Families ******* */
+
+
+/**
+ * Define a "POST /tokenfamilies" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /tokenfamilies request.
+ * @param http_status expected HTTP response code.
+ * @param slug slug of the token family.
+ * @param name name of the token family.
+ * @param description description of the token family.
+ * @param description_i18n internationalized description of the token family.
+ * @param valid_after start of the validity time of the token family.
+ * @param valid_before end of the validity time of the token family.
+ * @param duration validity duration of an issued token of the token family.
+ * @param rounding to multiples of what duration should start times be rounded
+ * @param kind kind of the token family. either "subscription" or "discount".
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_tokenfamilies (
+ const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *slug,
+ const char *name,
+ const char *description,
+ json_t *description_i18n,
+ struct GNUNET_TIME_Timestamp valid_after,
+ struct GNUNET_TIME_Timestamp valid_before,
+ struct GNUNET_TIME_Relative duration,
+ struct GNUNET_TIME_Relative rounding,
+ const char *kind);
+
+/* ****** Webhooks ******* */
+
+
+/**
+ * Define a "POST /webhooks" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /webhooks request.
+ * @param webhook_id the ID of the webhook to query
+ * @param event_type event of the webhook
+ * @param url use by the customer
+ * @param http_method use by the merchant
+ * @param header_template of the webhook
+ * @param body_template of the webhook
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_webhooks2 (
+ const char *label,
+ const char *merchant_url,
+ const char *webhook_id,
+ const char *event_type,
+ const char *url,
+ const char *http_method,
+ const char *header_template,
+ const char *body_template,
+ unsigned int http_status);
+
+
+/**
+ * Define a "POST /webhooks" CMD, simple version
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * POST /webhooks request.
+ * @param webhook_id the ID of the webhook to query
+ * @param event_type event of the webhook
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_webhooks (const char *label,
+ const char *merchant_url,
+ const char *webhook_id,
+ const char *event_type,
+ unsigned int http_status);
+
+
+/**
+ * Define a "PATCH /webhooks/$ID" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * PATCH /webhook request.
+ * @param webhook_id the ID of the webhook to query
+ * @param event_type event of the webhook
+ * @param url use by the customer
+ * @param http_method use by the merchant
+ * @param header_template of the webhook
+ * @param body_template of the webhook
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_patch_webhook (
+ const char *label,
+ const char *merchant_url,
+ const char *webhook_id,
+ const char *event_type,
+ const char *url,
+ const char *http_method,
+ const char *header_template,
+ const char *body_template,
+ unsigned int http_status);
+
+
+/**
+ * Define a "GET /webhooks" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * GET /webhooks request.
+ * @param http_status expected HTTP response code.
+ * @param ... NULL-terminated list of labels (const char *) of
+ * webhook (commands) we expect to be returned in the list
+ * (assuming @a http_code is #MHD_HTTP_OK)
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_webhooks (const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ ...);
+
+
+/**
+ * Define a "GET webhook" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * GET /templates/$ID request.
+ * @param webhook_id the ID of the webhook to query
+ * @param http_status expected HTTP response code.
+ * @param webhook_reference reference to a "POST /webhooks" or "PATCH /webhooks/$ID" CMD
+ * that will provide what we expect the backend to return to us
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_webhook (const char *label,
+ const char *merchant_url,
+ const char *webhook_id,
+ unsigned int http_status,
+ const char *webhook_reference);
+
+
+/**
+ * Define a "DELETE webhook" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the merchant serving the
+ * DELETE /webhooks/$ID request.
+ * @param webhook_id the ID of the webhook to query
+ * @param http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_delete_webhook (const char *label,
+ const char *merchant_url,
+ const char *webhook_id,
+ unsigned int http_status);
+
+/**
+ * Command to run the 'taler-merchant-webhook' program.
+ *
+ * @param label command label.
+ * @param config_filename configuration file used by the webhook.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_webhook (const char *label,
+ const char *config_filename);
+
+
+/**
+ * Command to run the 'taler-merchant-depositcheck' program.
+ *
+ * @param label command label.
+ * @param config_filename configuration file used by the deposit check helper.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_depositcheck (const char *label,
+ const char *config_filename);
+
+
+/**
+ * Command to run the 'taler-merchant-exchange' program.
+ *
+ * @param label command label.
+ * @param config_filename configuration file used by the webhook.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_run_tme (const char *label,
+ const char *config_filename);
+
+
+/**
+ * This function is used to start the web server.
+ *
+ * @param label command label
+ * @param port is the port of the web server
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_testserver (const char *label,
+ uint16_t port);
+
+
+/**
+ * This function is used to check the web server got the
+ * expected request from the web hook.
+ *
+ * @param label command label
+ * @param ref_operation reference to command to the previous set server status operation.
+ * @param index index to know which web server we check.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_checkserver (const char *label,
+ const char *ref_operation,
+ unsigned int index);
+
+
+/**
+ * This function is used to check that the web server
+ * got the expected request from the web hook.
+ *
+ * @param label command label
+ * @param ref_operation reference to command to the previous set server status operation.
+ * @param index index to know which web server we check.
+ * @param expected_url url of the webhook
+ * @param expected_method method of the webhook
+ * @param expected_header header of the webhook
+ * @param expected_body body of the webhook
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_checkserver2 (const char *label,
+ const char *ref_operation,
+ unsigned int index,
+ const char *expected_url,
+ const char *expected_method,
+ const char *expected_header,
+ const char *expected_body);
+
+
+#ifdef HAVE_DONAU_DONAU_SERVICE_H
+/**
+ * This function is the similar to the TALER_TESSTING_cmd_charity_post from DONAU
+ * with only difference that it reuses the merchant public key, from the merchant test-suite.
+ *
+ * @param label command label
+ * @param name name of the charity
+ * @param url url of the charity
+ * @param max_per_year maximum amount of donations per year
+ * @param bearer
+ * @param merchant_reference reference to fetch the merchant public key
+ * @param expected_response_code expected HTTP response code
+ * @return
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_charity_post_merchant (
+ const char *label,
+ const char *name,
+ const char *url,
+ const char *max_per_year,
+ const struct DONAU_BearerToken *bearer,
+ const char *merchant_reference,
+ unsigned int expected_response_code);
+
+#endif /* HAVE_DONAU_DONAU_SERVICE_H */
+
+/**
+ * Define a "GET /donau" CMD.
+ *
+ * @param label command label.
+ * @param url base URL of the Donau we are looking for instances of.
+ * @param instance_count number of instances we expect to be returned.
+ * @param expected_http_status expected HTTP response code.
+ * @param ... NULL-terminated list of labels (const char *) of
+ * donau instances (commands) we expect to be returned in the list
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_donau_instances (const char *label,
+ const char *url,
+ unsigned int instance_count,
+ unsigned int
+ expected_http_status,
+ ...);
+
+
+/**
+ * Define a "POST /donau" CMD.
+ *
+ * @param label command label.
+ * @param url base URL of the Donau service serving the
+ * GET /donau_instances request.
+ * @param merchant_reference string reference to get the testing traits
+ * @param expected_http_status expected HTTP response code.
+ * @param ... NULL-terminated list of labels (const char *) of
+ * donau instances (commands) we expect to be returned in the list
+ * (assuming @a expected_http_status is #MHD_HTTP_OK)
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_donau_instance (const char *label,
+ const char *url,
+ const char *merchant_reference,
+ unsigned int
+ expected_http_status,
+ ...);
+
+
+/**
+ * Define a "DELETE /donau/$charity_id" CMD.
+ *
+ * @param label command label.
+ * @param url base URL of the Donau service serving the
+ * DELETE /donau/$charity_id request.
+ * @param charity_id the ID of the charity to delete.
+ * @param expected_http_status expected HTTP response code.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_delete_donau_instance (const char *label,
+ const char *url,
+ uint64_t charity_id,
+ unsigned int
+ expected_http_status);
+
+/**
+ * This function is used to check the statistics counter API
+ *
+ * @param label command label
+ * @param merchant_url base URL of the merchant serving the API
+ * @param slug base statistics slug
+ * @param buckets_length expected length of buckets array
+ * @param intervals_length expected length of intervals array
+ * @param http_status expected HTTP response code.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_statisticscounter (const char *label,
+ const char *merchant_url,
+ const char *slug,
+ uint64_t buckets_length,
+ uint64_t intervals_length,
+ unsigned int http_status);
+
+/**
+ * This function is used to check the statistics amount API
+ *
+ * @param label command label
+ * @param merchant_url base URL of the merchant serving the API
+ * @param slug base statistics slug
+ * @param buckets_length expected length of buckets array
+ * @param intervals_length expected length of intervals array
+ * @param http_status expected HTTP response code.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_statisticsamount (const char *label,
+ const char *merchant_url,
+ const char *slug,
+ uint64_t buckets_length,
+ uint64_t intervals_length,
+ unsigned int http_status);
+
+
+/**
+ * Run the taler-merchant-donaukeyupdate command (with -t).
+ *
+ * @param label command label
+ * @param config_filename configuration file to pass to the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_exec_donaukeyupdate (const char *label,
+ const char *config_filename);
+
+
+/* ****** Specific traits supported by this component ******* */
+
+
+/**
+ * Call @a op on all simple traits.
+ *
+ * @param op macro to call
+ */
+// FIXME: rename: refund_entry->refund_detail
+#define TALER_MERCHANT_TESTING_SIMPLE_TRAITS(op) \
+ op (claim_nonce, const struct GNUNET_CRYPTO_EddsaPublicKey) \
+ op (pickup_id, const struct TALER_PickupIdentifierP) \
+ op (instance_name, const char) \
+ op (instance_id, const char) \
+ op (address, const json_t) \
+ op (category_id, const uint64_t) \
+ op (product_description, const char) \
+ op (product_image, const char) \
+ op (product_stock, const int64_t) \
+ op (product_unit_total_stock, const char) \
+ op (product_unit_precision_level, const uint32_t) \
+ op (product_unit_allow_fraction, const bool) \
+ op (product_unit, const char) \
+ op (product_id, const char) \
+ op (unit_id, const char) \
+ op (unit_name_long, const char) \
+ op (unit_name_short, const char) \
+ op (unit_allow_fraction, const bool) \
+ op (unit_precision_level, const uint32_t) \
+ op (unit_active, const bool) \
+ op (unit_builtin, const bool) \
+ op (unit_name_long_i18n, const json_t) \
+ op (unit_name_short_i18n, const json_t) \
+ op (reason, const char) \
+ op (lock_uuid, const char) \
+ op (auth_token, const char) \
+ op (bearer_token, const char) \
+ op (paths_length, const uint32_t) \
+ op (payto_length, const uint32_t) \
+ op (num_planchets, const uint32_t) \
+ op (i18n_description, const json_t) \
+ op (taxes, const json_t) \
+ op (fee, const struct TALER_Amount) \
+ op (use_stefan, const bool) \
+ op (jurisdiction, const json_t) \
+ op (wire_delay, const struct GNUNET_TIME_Relative) \
+ op (pay_delay, const struct GNUNET_TIME_Relative) \
+ op (refund_entry, const struct TALER_MERCHANT_RefundDetail) \
+ op (order_terms, const json_t) \
+ op (h_contract_terms, const struct TALER_PrivateContractHashP) \
+ op (h_wire, const struct TALER_MerchantWireHashP) \
+ op (proposal_reference, const char) \
+ op (template_description, const char) \
+ op (otp_device_description, const char) \
+ op (otp_id, const char) \
+ op (otp_key, const char) \
+ op (otp_alg, const enum TALER_MerchantConfirmationAlgorithm) \
+ op (template_id, const char) \
+ op (template_contract, const json_t) \
+ op (event_type, const char) \
+ op (webhook_id, const char) \
+ op (merchant_base_url, const char) \
+ op (url, const char) \
+ op (http_method, const char) \
+ op (header_template, const char) \
+ op (body_template, const char) \
+ op (summary, const char) \
+ op (token_family_slug, const char) \
+ op (token_family_duration, const struct GNUNET_TIME_Relative) \
+ op (token_family_kind, const char)
+
+
+/**
+ * Call @a op on all indexed traits.
+ *
+ * @param op macro to call
+ */
+#define TALER_MERCHANT_TESTING_INDEXED_TRAITS(op) \
+ op (coin_reference, const char) \
+ op (paths, const char) \
+ op (payto_uris, const struct TALER_FullPayto) \
+ op (h_wires, const struct TALER_MerchantWireHashP) \
+ op (amounts, const struct TALER_Amount) \
+ op (urls, const char) \
+ op (http_methods, const char) \
+ op (http_header, const char) \
+ op (http_body, const void) \
+ op (http_body_size, const size_t) \
+ op (planchet_secrets, const struct TALER_PlanchetMasterSecretP) \
+ op (token_priv, const struct TALER_TokenUsePrivateKeyP) \
+ op (token_issue_sig, const struct TALER_TokenIssueSignature) \
+ op (token_issue_pub, const struct TALER_TokenIssuePublicKey)
+
+
+TALER_MERCHANT_TESTING_SIMPLE_TRAITS (TALER_TESTING_MAKE_DECL_SIMPLE_TRAIT)
+TALER_MERCHANT_TESTING_INDEXED_TRAITS (TALER_TESTING_MAKE_DECL_INDEXED_TRAIT)
+
+
+#endif
diff --git a/src/include/taler/taler_merchant_util.h b/src/include/taler/taler_merchant_util.h
@@ -0,0 +1,1535 @@
+/*
+ This file is part of GNU Taler
+ Copyright (C) 2024, 2025 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler_merchant_util.h
+ * @brief Interface for common utility functions
+ * @author Christian Grothoff
+ */
+#ifndef TALER_MERCHANT_UTIL_H
+#define TALER_MERCHANT_UTIL_H
+
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_json_lib.h>
+
+#include <stdint.h>
+#include <taler/taler_util.h>
+#include <jansson.h>
+
+/**
+ * Fixed-point base for inventory quantities (powers of 10).
+ * Six decimal digits are supported to match the maximum unit precision.
+ */
+#define TALER_MERCHANT_UNIT_FRAC_BASE 1000000U
+#define TALER_MERCHANT_UNIT_FRAC_MAX_DIGITS 6U
+
+/**
+ * Return default project data used by Taler merchant.
+ */
+const struct GNUNET_OS_ProjectData *
+TALER_MERCHANT_project_data (void);
+
+
+/**
+ * Kind of fixed-decimal value the helpers operate on.
+ * Primarily distinguishes how special sentinel values (such as "-1"
+ * meaning infinity for stock) must be encoded.
+ */
+enum TALER_MERCHANT_ValueKind
+{
+ TALER_MERCHANT_VK_QUANTITY, /* -1 is illegal */
+ TALER_MERCHANT_VK_STOCK /* -1 means "infinity" */
+};
+
+
+/**
+ * Parse decimal quantity expressed as string for request handling.
+ *
+ * @param value string to parse
+ * @param[out] integer_part result integer component
+ * @param[out] fractional_part result fractional component (0..TALER_MERCHANT_UNIT_FRAC_BASE-1)
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on validation failure
+ */
+enum GNUNET_GenericReturnValue
+TALER_MERCHANT_vk_parse_fractional_string (
+ const char *value,
+ int64_t *integer_part,
+ uint32_t *fractional_part);
+
+
+/**
+ * Extract a fixed-decimal number that may be supplied either
+ * - as pure integer (e.g. "total_stock"), or
+ * - as decimal text (e.g. "unit_total_stock").
+ *
+ * Rules:
+ * - If both forms are missing -> error.
+ * - If both are present -> they must match and the decimal must have no fraction.
+ * - For kind == TALER_MERCHANT_VK_STOCK the integer value -1 represents infinity.
+ *
+ * @param kind See #TALER_MERCHANT_ValueKind
+ * @param allow_fractional False: any fractional part is rejected
+ * @param int_missing True if client omitted the integer field
+ * @param int_raw Raw integer (undefined if @a int_missing is true)
+ * @param str_missing True if client omitted the string field
+ * @param str_raw Raw UTF-8 string (undefined if @a str_missing is true)
+ * @param[out] int_out Canonicalised integer part
+ * @param[out] frac_out Canonicalised fractional part
+ * @param[out] error_param Set to offending field name on failure
+ * @param int_field Integer field name (for error reporting)
+ * @param str_field String field name (for error reporting)
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
+ */
+enum GNUNET_GenericReturnValue
+TALER_MERCHANT_vk_process_quantity_inputs (
+ enum TALER_MERCHANT_ValueKind kind,
+ bool allow_fractional,
+ bool int_missing,
+ int64_t int_raw,
+ bool str_missing,
+ const char *str_raw,
+ uint64_t *int_out,
+ uint32_t *frac_out,
+ const char **error_param);
+
+/**
+ * Format a fixed-decimal pair into canonical string representation.
+ * Recognises INT64_MAX / INT32_MAX as the "-1" sentinel used for
+ * infinite stock if @a kind equals #TALER_MERCHANT_VK_STOCK.
+ *
+ * @param kind specifies whether sentinel values are permitted
+ * @param integer integer portion
+ * @param fractional fractional portion (0..TALER_MERCHANT_UNIT_FRAC_BASE-1 or sentinel)
+ * @param buffer output buffer
+ * @param buffer_length length of @a buffer
+ */
+void
+TALER_MERCHANT_vk_format_fractional_string (
+ enum TALER_MERCHANT_ValueKind kind,
+ uint64_t integer,
+ uint32_t fractional,
+ size_t buffer_length,
+ char buffer[static buffer_length]);
+
+
+/**
+ * Check if @a image_data_url is a valid image
+ * data URL. Does not validate the actual payload,
+ * only the syntax and that it properly claims to
+ * be an image.
+ *
+ * FIXME: use in TALER_MERCHANT_parse_product!
+ *
+ * @param image_data_url string to check
+ * @return true if @a image_data_url is a data
+ * URL with an "image/" mime-type
+ */
+bool
+TALER_MERCHANT_image_data_url_valid (const char *image_data_url);
+
+
+/**
+ * Check if @a email is a valid email address.
+ *
+ * FIXME: move to libgnunetutil?
+ *
+ * @param email string to check
+ * @return true if @a email is a valid e-mail address
+ */
+bool
+TALER_MERCHANT_email_valid (const char *email);
+
+
+/**
+ * Check if @a email is a valid international phone number
+ * with "+CC" prefix.
+ *
+ * @param phone phone number to check
+ * @param allow_letters to allow "A-Z" letters representing digits
+ * @return normalized phone number if @a phone is valid,
+ * NULL if @a phone is not a phone number
+ */
+char *
+TALER_MERCHANT_phone_validate_normalize (const char *phone,
+ bool allow_letters);
+
+
+/**
+ * Channel used to transmit MFA authorization request.
+ */
+enum TALER_MERCHANT_MFA_Channel
+{
+ /**
+ * No MFA channel.
+ */
+ TALER_MERCHANT_MFA_CHANNEL_NONE = 0,
+
+ /**
+ * SMS ("sms")
+ */
+ TALER_MERCHANT_MFA_CHANNEL_SMS = 1,
+
+ /**
+ * E-mail ("email")
+ */
+ TALER_MERCHANT_MFA_CHANNEL_EMAIL,
+
+ /**
+ * TOTP ("totp"). (Not yet implemented, #10327.)
+ */
+ TALER_MERCHANT_MFA_CHANNEL_TOTP
+};
+
+
+/**
+ * Types of critical operations of a merchant backend that may require
+ * multi-factor authorization.
+ */
+enum TALER_MERCHANT_MFA_CriticalOperation
+{
+ /**
+ * Marker used to indicate that this is NOT a critical operation.
+ */
+ TALER_MERCHANT_MFA_CO_NONE = 0,
+
+ /**
+ * Instance provisioning ("instance_provision").
+ */
+ TALER_MERCHANT_MFA_CO_INSTANCE_PROVISION,
+
+ /**
+ * Bank account configuration or reconfiguration ("account_config").
+ */
+ TALER_MERCHANT_MFA_CO_ACCOUNT_CONFIGURATION,
+
+ /**
+ * Authentication configuration change ("auth_config").
+ */
+ TALER_MERCHANT_MFA_CO_AUTH_CONFIGURATION,
+
+ /**
+ * Instance deletion ("instance_deletion").
+ */
+ TALER_MERCHANT_MFA_CO_INSTANCE_DELETION,
+
+ /**
+ * Authentication token creation ("auth_token_creation").
+ */
+ TALER_MERCHANT_MFA_CO_AUTH_TOKEN_CREATION
+
+
+};
+
+/**
+ * Template type discriminator.
+ */
+enum TALER_MERCHANT_TemplateType
+{
+ TALER_MERCHANT_TEMPLATE_TYPE_INVALID = 0,
+ TALER_MERCHANT_TEMPLATE_TYPE_FIXED_ORDER,
+ TALER_MERCHANT_TEMPLATE_TYPE_INVENTORY_CART,
+ TALER_MERCHANT_TEMPLATE_TYPE_PAIVANA
+};
+
+/**
+ * Determine template type from string.
+ *
+ * @param template_type string value (NULL means fixed-order)
+ * @return template type (defaults to fixed order)
+ */
+enum TALER_MERCHANT_TemplateType
+TALER_MERCHANT_template_type_from_string (const char *template_type);
+
+/**
+ * Convert template type to its string representation.
+ *
+ * @param template_type template type to convert
+ * @return string name or NULL for invalid types
+ */
+const char *
+TALER_MERCHANT_template_type_to_string (
+ enum TALER_MERCHANT_TemplateType template_type);
+
+/**
+ * Determine template type from a template contract.
+ *
+ * @param template_contract contract JSON
+ * @return template type (defaults to fixed order)
+ */
+enum TALER_MERCHANT_TemplateType
+TALER_MERCHANT_template_type_from_contract (const json_t *template_contract);
+
+/**
+ * Template contract fields for inventory templates.
+ */
+struct TALER_MERCHANT_TemplateContractInventory
+{
+ /**
+ * Selected categories from the template contract.
+ */
+ const json_t *selected_categories;
+
+ /**
+ * Selected products from the template contract.
+ */
+ const json_t *selected_products;
+
+ /**
+ * Whether all products are selectable.
+ */
+ bool selected_all;
+
+ /**
+ * Template requires exactly one selection.
+ */
+ bool choose_one;
+
+};
+
+/**
+ * Template contract fields for paivana templates.
+ */
+struct TALER_MERCHANT_TemplateContractPaivana
+{
+ /**
+ * Paivana website regular expression.
+ * NULL to allow any site.
+ */
+ const char *website_regex;
+
+ /**
+ * Array of possible specific contracts the wallet/customer may choose
+ * from by selecting the respective index when signing the deposit
+ * confirmation.
+ */
+ struct TALER_MERCHANT_ContractChoice *choices;
+
+ /**
+ * Length of the @e choices array.
+ */
+ unsigned int choices_len;
+
+};
+
+/**
+ * Parsed template contract.
+ */
+struct TALER_MERCHANT_TemplateContract
+{
+ /**
+ * Template type.
+ */
+ enum TALER_MERCHANT_TemplateType type;
+
+ /**
+ * Summary from the template contract.
+ */
+ const char *summary;
+
+ /**
+ * Currency from the template contract.
+ */
+ const char *currency;
+
+ /**
+ * Amount from the template contract.
+ */
+ struct TALER_Amount amount;
+
+ /**
+ * True if @e amount was not provided.
+ */
+ bool no_amount;
+
+ /**
+ * Template allows tips.
+ */
+ bool request_tip;
+
+ /**
+ * Minimum age required by the template.
+ */
+ uint32_t minimum_age;
+
+ /**
+ * How long does the customer have to pay for the order.
+ * 0 if not specified (use instance default).
+ */
+ struct GNUNET_TIME_Relative pay_duration;
+
+ union
+ {
+
+ /**
+ * Parsed fields for inventory templates.
+ */
+ struct TALER_MERCHANT_TemplateContractInventory inventory;
+
+ /**
+ * Parsed fields for paivana templates.
+ */
+ struct TALER_MERCHANT_TemplateContractPaivana paivana;
+
+ } details;
+
+};
+
+/**
+ * Parse template contract JSON into @a out.
+ *
+ * @param template_contract JSON object containing the template contract
+ * @param[out] out parsed template contract
+ * @param[out] error_name pointer to the name of the failed field, or NULL
+ * @return #GNUNET_SYSERR if @a template_contract is malformed; #GNUNET_OK otherwise
+ */
+enum GNUNET_GenericReturnValue
+TALER_MERCHANT_template_contract_parse (
+ const json_t *template_contract,
+ struct TALER_MERCHANT_TemplateContract *out,
+ const char **error_name);
+
+/**
+ * Check if @a template_contract is valid.
+ *
+ * @param template_contract template contract to validate
+ * @return true if @a template_contract is valid
+ */
+bool
+TALER_MERCHANT_template_contract_valid (const json_t *template_contract);
+
+
+/**
+ * Convert critical operation enumeration value to string
+ * suitable for human readers.
+ *
+ * @param co input to convert
+ * @return operation value as string
+ */
+const char *
+TALER_MERCHANT_MFA_co2s (
+ enum TALER_MERCHANT_MFA_CriticalOperation co);
+
+
+/**
+ * Convert critical operation enumeration value to string.
+ *
+ * @param co input to convert
+ * @return operation value as string
+ */
+const char *
+TALER_MERCHANT_MFA_co_to_string (
+ enum TALER_MERCHANT_MFA_CriticalOperation co);
+
+
+/**
+ * Convert string to critical operation enumeration value.
+ *
+ * @param str input to convert
+ * @return #TALER_MERCHANT_MFA_CO_NONE on failure
+ */
+enum TALER_MERCHANT_MFA_CriticalOperation
+TALER_MERCHANT_MFA_co_from_string (const char *str);
+
+
+/**
+ * Convert MFA channel enumeration value to string.
+ *
+ * @param ch input to convert
+ * @return operation value as string
+ */
+const char *
+TALER_MERCHANT_MFA_channel_to_string (
+ enum TALER_MERCHANT_MFA_Channel ch);
+
+
+/**
+ * Convert string to MFA channel enumeration value.
+ *
+ * @param str input to convert
+ * @return #TALER_MERCHANT_MFA_CHANNEL_NONE on failure
+ */
+enum TALER_MERCHANT_MFA_Channel
+TALER_MERCHANT_MFA_channel_from_string (const char *str);
+
+
+/**
+ * @brief Salted hash of a body for a request that required MFA.
+ */
+struct TALER_MERCHANT_MFA_BodyHash
+{
+ /**
+ * Hash of the body and salt.
+ */
+ struct GNUNET_ShortHashCode hash;
+};
+
+
+/**
+ * @brief Salt used when computing a `struct TALER_MERCHANT_MFA_BodyHash`
+ */
+struct TALER_MERCHANT_MFA_BodySalt
+{
+ /**
+ * Salt.
+ */
+ uint64_t salt[128 / 64];
+};
+
+
+/**
+ * @brief Token used to authorize report generation.
+ */
+struct TALER_MERCHANT_ReportToken
+{
+ /**
+ * Salt.
+ */
+ uint64_t salt[256 / 64];
+};
+
+
+/**
+ * Hash the given request @a body with the given @a salt to
+ * produce @a h_body for MFA checks.
+ *
+ * @param body HTTP request body, NULL if body was empty
+ * @param salt salt to use
+ * @param h_body resulting hash
+ */
+void
+TALER_MERCHANT_mfa_body_hash (
+ const json_t *body,
+ const struct TALER_MERCHANT_MFA_BodySalt *salt,
+ struct TALER_MERCHANT_MFA_BodyHash *h_body);
+
+
+/**
+ * Possible versions of the contract terms.
+ */
+enum TALER_MERCHANT_ContractVersion
+{
+
+ /**
+ * Version 0
+ */
+ TALER_MERCHANT_CONTRACT_VERSION_0 = 0,
+
+ /**
+ * Version 1
+ */
+ TALER_MERCHANT_CONTRACT_VERSION_1 = 1
+};
+
+/**
+ * Possible token kinds.
+ */
+enum TALER_MERCHANT_ContractTokenKind
+{
+ /**
+ * Token kind invalid
+ */
+ TALER_MERCHANT_CONTRACT_TOKEN_KIND_INVALID = 0,
+
+ /**
+ * Subscription token kind
+ */
+ TALER_MERCHANT_CONTRACT_TOKEN_KIND_SUBSCRIPTION = 1,
+
+ /**
+ * Discount token kind
+ */
+ TALER_MERCHANT_CONTRACT_TOKEN_KIND_DISCOUNT = 2,
+};
+
+/**
+ * Possible input types for the contract terms.
+ */
+enum TALER_MERCHANT_ContractInputType
+{
+
+ /**
+ * Input type invalid
+ */
+ TALER_MERCHANT_CONTRACT_INPUT_TYPE_INVALID = 0,
+
+#if FUTURE
+ /**
+ * Input type coin
+ */
+ TALER_MERCHANT_CONTRACT_INPUT_TYPE_COIN = 1,
+#endif
+ /**
+ * Input type token
+ */
+ TALER_MERCHANT_CONTRACT_INPUT_TYPE_TOKEN = 2
+};
+
+/**
+ * Contract input (part of the v1 contract terms).
+ */
+struct TALER_MERCHANT_ContractInput
+{
+ /**
+ * Type of the input.
+ */
+ enum TALER_MERCHANT_ContractInputType type;
+
+ union
+ {
+#if FUTURE
+ /**
+ * Coin-based input (ration). (Future work, only here for reference)
+ */
+ struct
+ {
+ /**
+ * Price to be paid.
+ */
+ struct TALER_Amount price;
+
+ /**
+ * Base URL of the ration authority.
+ */
+ const char *ration_authority_url;
+ } coin;
+#endif
+
+ /**
+ * Token-based input.
+ */
+ struct
+ {
+ /**
+ * Slug of the token family to be used.
+ */
+ const char *token_family_slug;
+
+ /**
+ * Number of tokens of this type required. Defaults to one if the
+ * field is not provided.
+ */
+ unsigned int count;
+ } token;
+ } details;
+};
+
+/**
+ * Possible output types for the contract terms.
+ */
+enum TALER_MERCHANT_ContractOutputType
+{
+
+ /**
+ * Invalid output type
+ */
+ TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_INVALID = 0,
+
+ /**
+ * Output type token
+ */
+ TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_TOKEN = 1,
+
+ /**
+ * Output type donation-receipt
+ */
+ TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_DONATION_RECEIPT = 2,
+#if FUTURE
+ /**
+ * Output type coin
+ */
+ TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_COIN = 3
+#endif
+
+};
+
+/**
+ * Contract output (part of the v1 contract terms).
+ */
+struct TALER_MERCHANT_ContractOutput
+{
+ /**
+ * Type of the output.
+ */
+ enum TALER_MERCHANT_ContractOutputType type;
+
+ union
+ {
+#if FUTURE
+ /**
+ * Coin-based output.
+ */
+ struct
+ {
+ /**
+ * Coins that will be yielded. This excludes any applicable withdraw fees.
+ */
+ struct TALER_Amount brutto_yield;
+
+ /**
+ * Base URL of the exchange that will issue the coins.
+ *
+ * NOTE: Once implemented, check if we need to allocate this here or if
+ * we again reference the JSON as we do in other places.
+ */
+ char *exchange_url;
+
+ } coin;
+#endif
+ /**
+ * DONAU-receipt output.
+ */
+ struct
+ {
+ /**
+ * Amount of the donation. (optional)
+ */
+ struct TALER_Amount amount;
+
+ /**
+ * Base URLs of the donation authorities that will issue the tax receipt.
+ */
+ char **donau_urls;
+
+ /**
+ * Length of the @e donau_urls array.
+ */
+ unsigned int donau_urls_len;
+
+ } donation_receipt;
+
+ /**
+ * Token-based output.
+ */
+ struct
+ {
+ /**
+ * Slug of the token family to be issued.
+ * Note: this is a pointer into the JSON of the
+ * respective contract/request and not owned here.
+ */
+ const char *token_family_slug;
+
+ /**
+ * Index of the public key in the @a token_family_slug's token family
+ * ``keys`` array that this output token will have.
+ */
+ unsigned int key_index;
+
+ /**
+ * Number of tokens of this type required. Defaults to one if the
+ * field is not provided.
+ */
+ unsigned int count;
+
+ /**
+ * Determines when the output token should be valid.
+ * Optional, set to zero for not specified (then we
+ * use the current time).
+ */
+ struct GNUNET_TIME_Timestamp valid_at;
+
+ } token;
+
+ } details;
+
+};
+
+/**
+ * Contract choice (part of the v1 contract terms).
+ */
+struct TALER_MERCHANT_ContractChoice
+{
+
+ /**
+ * Amount to be paid for this choice.
+ */
+ struct TALER_Amount amount;
+
+ /**
+ * Tip included by the customer (part of the total amount).
+ */
+ struct TALER_Amount tip;
+
+ /**
+ * True if @e tip was not provided.
+ */
+ bool no_tip;
+
+ /**
+ * Human readable description of the semantics of the choice within the
+ * contract to be shown to the user at payment.
+ */
+ char *description;
+
+ /**
+ * Map from IETF BCP 47 language tags to localized description.
+ */
+ json_t *description_i18n;
+
+ /**
+ * Maximum fee the merchant is willing to pay for this choice.
+ * Set to an invalid amount to use instance defaults (zero or STEFAN).
+ */
+ struct TALER_Amount max_fee;
+
+ /**
+ * List of inputs the wallet must provision (all of them) to satisfy the
+ * conditions for the contract.
+ */
+ struct TALER_MERCHANT_ContractInput *inputs;
+
+ /**
+ * Length of the @e inputs array.
+ */
+ unsigned int inputs_len;
+
+ /**
+ * List of outputs the merchant promises to yield (all of them) once
+ * the contract is paid.
+ */
+ struct TALER_MERCHANT_ContractOutput *outputs;
+
+ /**
+ * Length of the @e outputs array.
+ */
+ unsigned int outputs_len;
+};
+
+/**
+ * Public key and corresponding metadata for a token family.
+ */
+struct TALER_MERCHANT_ContractTokenFamilyKey
+{
+ /**
+ * Public key.
+ */
+ struct TALER_TokenIssuePublicKey pub;
+
+ /**
+ * Start time of the token family duration.
+ */
+ struct GNUNET_TIME_Timestamp valid_after;
+
+ /**
+ * Tokens signed by this key will be valid until this time.
+ */
+ struct GNUNET_TIME_Timestamp valid_before;
+};
+
+
+/**
+ * Represents a family of tokens issued by merchants that can be used in contracts.
+ */
+struct TALER_MERCHANT_ContractTokenFamily
+{
+ /**
+ * Slug of the token family.
+ */
+ char *slug;
+
+ /**
+ * Human-readable name of the token family.
+ */
+ char *name;
+
+ /**
+ * Human-readable description of the semantics of the tokens issued by
+ * this token family.
+ */
+ char *description;
+
+ /**
+ * Map from IETF BCP 47 language tags to localized description.
+ */
+ json_t *description_i18n;
+
+ /**
+ * Relevant public keys of this token family for the given contract.
+ */
+ struct TALER_MERCHANT_ContractTokenFamilyKey *keys;
+
+ /**
+ * Length of the @e keys array.
+ */
+ unsigned int keys_len;
+
+ /**
+ * Must a wallet understand this token type to process contracts that
+ * consume or yield it?
+ */
+ bool critical;
+
+ /**
+ * Kind of the token family.
+ */
+ enum TALER_MERCHANT_ContractTokenKind kind;
+
+ /**
+ * Kind-specific information about the token.
+ */
+ union
+ {
+ /**
+ * Subscription token.
+ */
+ struct
+ {
+ /**
+ * Array of domain names where this subscription can be safely used
+ * (e.g. the issuer warrants that these sites will re-issue tokens of
+ * this type if the respective contract says so). May contain "*" for
+ * any domain or subdomain.
+ */
+ char **trusted_domains;
+
+ /**
+ * Length of the @e trusted_domains array.
+ */
+ unsigned int trusted_domains_len;
+ } subscription;
+
+ /**
+ * Discount token.
+ */
+ struct
+ {
+ /**
+ * Array of domain names where this discount token is intended to be
+ * used. May contain "*" for any domain or subdomain. Users should be
+ * warned about sites proposing to consume discount tokens of this
+ * type that are not in this list that the merchant is accepting a
+ * coupon from a competitor and thus may be attaching different
+ * semantics (like get 20% discount for my competitors 30% discount
+ * token).
+ */
+ char **expected_domains;
+
+ /**
+ * Length of the @e expected_domains array.
+ */
+ unsigned int expected_domains_len;
+
+ } discount;
+ } details;
+};
+
+/**
+ * Specifies the quantity of a product (to be) sold.
+ */
+struct TALER_MERCHANT_ProductQuantity
+{
+ /**
+ * Integer component of the quantity.
+ */
+ uint64_t integer;
+
+ /**
+ * Fractional component of the quantity, in the
+ * range of 0..TALER_MERCHANT_UNIT_FRAC_BASE-1.
+ */
+ uint32_t fractional;
+
+};
+
+
+/**
+ * How to round when computing with amounts?
+ */
+enum TALER_MERCHANT_RoundMode
+{
+ TALER_MERCHANT_ROUND_NEAREST,
+ TALER_MERCHANT_ROUND_UP,
+ TALER_MERCHANT_ROUND_DOWN
+};
+
+
+/**
+ * Multiply the @a unit_price by the quantity given in @a factor.
+ * Round the result using the given rounding mode @a rm to a
+ * multiple of the @a atomic_amount.
+ *
+ * @param[out] result where to store the result
+ * @param unit_price price for one item
+ * @param factor quantity to purchase, can be factional
+ * @param rm rounding mode to apply
+ * @param atomic_amount granularity to round to
+ * @return #GNUNET_OK on success
+ * #GNUNET_NO on integer overflow (resulting amount cannot be represented)
+ * #GNUNET_SYSERR on internal failure (e.g. currency
+ * @a unit_price and @a atomic_amount do not match)
+ */
+enum GNUNET_GenericReturnValue
+TALER_MERCHANT_amount_multiply_by_quantity (
+ struct TALER_Amount *result,
+ const struct TALER_Amount *unit_price,
+ const struct TALER_MERCHANT_ProductQuantity *factor,
+ enum TALER_MERCHANT_RoundMode rm,
+ const struct TALER_Amount *atomic_amount);
+
+
+/**
+ * Details about a product (to be) sold.
+ */
+struct TALER_MERCHANT_ProductSold
+{
+
+ /**
+ * Merchant-internal identifier for the product. NULL for none.
+ */
+ char *product_id;
+
+ /**
+ * Name of the product. NULL for pre **v20** contract terms.
+ */
+ char *product_name;
+
+ /**
+ * Human-readable product description.
+ */
+ char *description;
+
+ /**
+ * Map from IETF BCP 47 language tags to localized descriptions.
+ * NULL if no translations are available.
+ */
+ json_t *description_i18n;
+
+ /**
+ * Quantity (in multiples of @e unit) to be sold.
+ */
+ struct TALER_MERCHANT_ProductQuantity unit_quantity;
+
+ /**
+ * Unit in which the product is measured (liters, kilograms, packages,
+ * etc.). Can be NULL if not specified.
+ */
+ char *unit;
+
+ /**
+ * Length of the @e prices array.
+ */
+ unsigned int prices_length;
+
+ /**
+ * Array of prices (in different currencies) for @e unit_quantity
+ * units of this product (these are longer the per-unit prices!).
+ */
+ struct TALER_Amount *prices;
+
+ /**
+ * True if the @e prices given are the net price,
+ * false if they are the gross price. Note that even @e prices are the
+ * gross price, @e taxes may be missing if the merchant configured
+ * gross @e prices but did not configure any @e taxes.
+ * Similarly, the merchant may have configured net @e prices
+ * for products but deals with taxes on a per-order basis. Thus, it
+ * may not always be possible to compute the gross price from the net
+ * price for an individual product, necessitating this flag.
+ */
+ bool prices_are_net;
+
+ /**
+ * An optional base64-encoded image of the product.
+ */
+ char *image;
+
+ /**
+ * A list of taxes paid by the merchant for this product. Can be NULL.
+ * Will likely change soon!
+ */
+ json_t *taxes;
+
+ /**
+ * Time indicating when this product should be delivered.
+ * #GNUNET_TIME_UNIT_FOREVER_TS for unknown / not specified.
+ */
+ struct GNUNET_TIME_Timestamp delivery_date;
+
+ /**
+ * Money pot to use for this product, overrides value from
+ * the inventory if given. Not useful to wallets, only for
+ * merchant-internal accounting.
+ */
+ uint64_t product_money_pot;
+
+};
+
+
+/**
+ * Struct to hold contract terms.
+ */
+struct TALER_MERCHANT_Contract
+{
+ /**
+ * URL where the same contract could be ordered again (if available).
+ */
+ char *public_reorder_url;
+
+ /**
+ * Our order ID.
+ */
+ char *order_id;
+
+ /**
+ * Merchant base URL.
+ */
+ char *merchant_base_url;
+
+ /**
+ * Merchant information.
+ */
+ struct
+ {
+ /**
+ * Legal name of the instance
+ */
+ char *name;
+
+ /**
+ * Merchant's site url
+ */
+ char *website;
+
+ /**
+ * Email contact for customers
+ */
+ char *email;
+
+ /**
+ * merchant's logo data uri
+ */
+ char *logo;
+
+ /**
+ * Merchant address
+ */
+ json_t *address;
+
+ /**
+ * Jurisdiction of the business
+ */
+ json_t *jurisdiction;
+
+ } merchant;
+
+ /**
+ * Summary of the contract.
+ */
+ char *summary;
+
+ /**
+ * Internationalized summary.
+ */
+ json_t *summary_i18n;
+
+ /**
+ * URL that will show that the contract was successful
+ * after it has been paid for.
+ */
+ char *fulfillment_url;
+
+ /**
+ * Message shown to the customer after paying for the contract.
+ * Either fulfillment_url or fulfillment_message must be specified.
+ */
+ char *fulfillment_message;
+
+ /**
+ * Map from IETF BCP 47 language tags to localized fulfillment messages.
+ */
+ json_t *fulfillment_message_i18n;
+
+ /**
+ * Length of the @e products array.
+ */
+ size_t products_len;
+
+ /**
+ * Array of products that are part of the purchase.
+ */
+ struct TALER_MERCHANT_ProductSold *products;
+
+ /**
+ * Timestamp of the contract.
+ */
+ struct GNUNET_TIME_Timestamp timestamp;
+
+ /**
+ * Deadline for refunds.
+ */
+ struct GNUNET_TIME_Timestamp refund_deadline;
+
+ /**
+ * Specifies for how long the wallet should try to get an
+ * automatic refund for the purchase.
+ */
+ struct GNUNET_TIME_Relative auto_refund;
+
+ /**
+ * Payment deadline.
+ */
+ struct GNUNET_TIME_Timestamp pay_deadline;
+
+ /**
+ * Wire transfer deadline.
+ */
+ struct GNUNET_TIME_Timestamp wire_deadline;
+
+ /**
+ * Delivery date.
+ */
+ struct GNUNET_TIME_Timestamp delivery_date;
+
+ /**
+ * Merchant public key.
+ */
+ struct TALER_MerchantPublicKeyP merchant_pub;
+
+ /**
+ * The hash of the merchant instance's wire details.
+ */
+ struct TALER_MerchantWireHashP h_wire;
+
+ /**
+ * Wire transfer method identifier for the wire method associated with
+ * @e h_wire.
+ */
+ char *wire_method;
+
+ /**
+ * Exchanges that the merchant accepts even if it does not accept any auditors that audit them.
+ * TODO: appropriate type
+ */
+ json_t *exchanges;
+
+ /**
+ * Delivery location.
+ */
+ json_t *delivery_location;
+
+ /**
+ * Nonce generated by the wallet and echoed by the merchant
+ * in this field when the proposal is generated.
+ */
+ char *nonce;
+
+ /**
+ * Extra data that is only interpreted by the merchant frontend.
+ */
+ json_t *extra;
+
+ /**
+ * Minimum age the buyer must have (in years).
+ */
+ uint8_t minimum_age;
+
+ /**
+ * Default money pot to use for this product, applies to the
+ * amount remaining that was not claimed by money pots of
+ * products or taxes. Not useful to wallets, only for
+ * merchant-internal accounting. If zero, the remaining
+ * account is simply not accounted for in any money pot.
+ */
+ uint64_t default_money_pot;
+
+ /**
+ * Specified version of the contract.
+ */
+ enum TALER_MERCHANT_ContractVersion version;
+
+ /**
+ * Details depending on the @e version.
+ */
+ union
+ {
+
+ /**
+ * Details for v0 contracts.
+ */
+ struct
+ {
+
+ /**
+ * Price to be paid for the transaction. Could be 0. The price is in addition
+ * to other instruments, such as rations and tokens.
+ * The exchange will subtract deposit fees from that amount
+ * before transferring it to the merchant.
+ */
+ struct TALER_Amount brutto;
+
+ /**
+ * Tip included by the customer (part of the total amount).
+ */
+ struct TALER_Amount tip;
+
+ /**
+ * True if @e tip was not provided.
+ */
+ bool no_tip;
+
+ /**
+ * Maximum fee as given by the client request.
+ */
+ struct TALER_Amount max_fee;
+
+ } v0;
+
+ /**
+ * Details for v1 contracts.
+ */
+ struct
+ {
+
+ /**
+ * Array of possible specific contracts the wallet/customer may choose
+ * from by selecting the respective index when signing the deposit
+ * confirmation.
+ */
+ struct TALER_MERCHANT_ContractChoice *choices;
+
+ /**
+ * Length of the @e choices array.
+ */
+ unsigned int choices_len;
+
+ /**
+ * Array of token authorities.
+ */
+ struct TALER_MERCHANT_ContractTokenFamily *token_authorities;
+
+ /**
+ * Length of the @e token_authorities array.
+ */
+ unsigned int token_authorities_len;
+
+ } v1;
+
+ } details;
+
+};
+
+
+/**
+ * Parse JSON contract terms in @a input.
+ *
+ * @param[in] input JSON object containing contract terms
+ * @param nonce_optional whether `nonce' field is optional
+ * @return parsed contract terms; NULL if @a input is malformed
+ */
+struct TALER_MERCHANT_Contract *
+TALER_MERCHANT_contract_parse (json_t *input,
+ bool nonce_optional);
+
+
+/**
+ * Provide specification to parse an JSON contract input type.
+ * The value is provided as a descriptive string.
+ *
+ * @param name name of the JSON member with the contract type
+ * @param[out] cit where to store the contract input type
+ * @return spec for parsing a contract input type
+ */
+struct GNUNET_JSON_Specification
+TALER_MERCHANT_json_spec_cit (const char *name,
+ enum TALER_MERCHANT_ContractInputType *cit);
+
+
+/**
+ * Provide specification to parse given JSON array to contract terms
+ * choices. All fields from @a choices elements are copied.
+ *
+ * @param name name of the choices field in the JSON
+ * @param[out] choices where the contract choices array has to be written
+ * @param[out] choices_len length of the @a choices array
+ */
+struct GNUNET_JSON_Specification
+TALER_MERCHANT_spec_choices (
+ const char *name,
+ struct TALER_MERCHANT_ContractChoice **choices,
+ unsigned int *choices_len);
+
+
+/**
+ * Parse JSON contract terms choice input.
+ *
+ * @param[in] root JSON object containing choice input
+ * @param[out] input parsed choice input, NULL if @a input is malformed
+ * @param index index of choice input in inputs array
+ * @param order whether @a input is contained in order or contract terms
+ * @return #GNUNET_SYSERR if @a input is malformed; #GNUNET_OK otherwise
+ */
+enum GNUNET_GenericReturnValue
+TALER_MERCHANT_parse_choice_input (
+ json_t *root,
+ struct TALER_MERCHANT_ContractInput *input,
+ size_t index,
+ bool order);
+
+
+/**
+ * Check if @a taxes is an array of valid Taxes in the sense of
+ * Taler's API definition.
+ *
+ * @param taxes array to check
+ * @return true if @a taxes is an array and all
+ * entries are valid Taxes.
+ */
+bool
+TALER_MERCHANT_taxes_array_valid (const json_t *taxes);
+
+
+/**
+ * Parse JSON product given in @a p, returning the result in
+ * @a r.
+ *
+ * @param p JSON specifying a ``ProductSold`` to parse
+ * @param[out] r where to write the result
+ * @return #GNUNET_OK on success
+ */
+enum GNUNET_GenericReturnValue
+TALER_MERCHANT_parse_product_sold (const json_t *p,
+ struct TALER_MERCHANT_ProductSold *r);
+
+
+/**
+ * Provide specification to parse an JSON contract output type.
+ * The value is provided as a descriptive string.
+ *
+ * @param name name of the JSON member with the contract type
+ * @param[out] cot where to store the contract output type
+ * @return spec for parsing a contract output type
+ */
+struct GNUNET_JSON_Specification
+TALER_MERCHANT_json_spec_cot (const char *name,
+ enum TALER_MERCHANT_ContractOutputType *cot);
+
+
+/**
+ * Parse JSON contract terms choice output.
+ *
+ * @param[in] root JSON object containing choice output
+ * @param[out] output parsed choice output, NULL if @a output is malformed
+ * @param index index of choice output in outputs array
+ * @param order whether @a output is contained in order or contract terms
+ * @return #GNUNET_SYSERR if @a output is malformed; #GNUNET_OK otherwise
+ */
+enum GNUNET_GenericReturnValue
+TALER_MERCHANT_parse_choice_output (
+ json_t *root,
+ struct TALER_MERCHANT_ContractOutput *output,
+ size_t index,
+ bool order);
+
+
+/**
+ * Serialize @a p to JSON.
+ *
+ * @param p product to serialize
+ * @return JSON object representing the product @a p
+ */
+json_t *
+TALER_MERCHANT_product_sold_serialize (
+ const struct TALER_MERCHANT_ProductSold *p);
+
+
+/**
+ * Serialize contract terms into JSON object.
+ *
+ * @param[in] input contract terms to serialize
+ * @param nonce_optional whether `nonce' field is optional
+ * @return JSON representation of @a input; NULL on error
+ */
+json_t *
+TALER_MERCHANT_contract_serialize (
+ const struct TALER_MERCHANT_Contract *input,
+ bool nonce_optional);
+
+
+/**
+ * Get JSON representation of contract choice.
+ *
+ * @param[in] choice contract choice to serialize
+ * @param order whether @a choice is contained in order or contract terms
+ * @return JSON representation of @a choice; NULL on error
+ */
+json_t *
+TALER_MERCHANT_json_from_contract_choice (
+ const struct TALER_MERCHANT_ContractChoice *choice,
+ bool order);
+
+
+/**
+ * Get JSON representation of contract token family.
+ *
+ * @param[in] family contract token family to serialize
+ * @return JSON representation of @a family; NULL on error
+ */
+json_t *
+TALER_MERCHANT_json_from_token_family (
+ const struct TALER_MERCHANT_ContractTokenFamily *family);
+
+
+/**
+ * Find token family in contract terms from slug and validity date.
+ *
+ * @param slug slug of the token family
+ * @param valid_after validity start of the token family
+ * @param[in] families array of token families in the contract terms
+ * @param families_len length of @a families array
+ * @param[out] family matching token family; NULL if no result
+ * @param[out] key key of matching token family; NULL if no result
+ * @return #GNUNET_SYSERR if no matching family found; #GNUNET_OK otherwise
+ */
+enum GNUNET_GenericReturnValue
+TALER_MERCHANT_find_token_family_key (
+ const char *slug,
+ struct GNUNET_TIME_Timestamp valid_after,
+ const struct TALER_MERCHANT_ContractTokenFamily *families,
+ unsigned int families_len,
+ struct TALER_MERCHANT_ContractTokenFamily *family,
+ struct TALER_MERCHANT_ContractTokenFamilyKey *key);
+
+
+/**
+ * Free all the fields in the given @a choice, but not @a choice itself, since
+ * it is normally part of an array.
+ *
+ * @param[in] choice contract terms choice to free
+ */
+void
+TALER_MERCHANT_contract_choice_free (
+ struct TALER_MERCHANT_ContractChoice *choice);
+
+
+/**
+ * Release memory inside of @a product, but not @a product itself.
+ *
+ * @param[in] product data structure to clean up
+ */
+void
+TALER_MERCHANT_product_sold_free (struct TALER_MERCHANT_ProductSold *product);
+
+
+/**
+ * Free the @a contract and all fields in it.
+ *
+ * @param[in] contract contract to free
+ */
+void
+TALER_MERCHANT_contract_free (struct TALER_MERCHANT_Contract *contract);
+
+
+#endif
diff --git a/src/include/taler/taler_merchantdb_lib.h b/src/include/taler/taler_merchantdb_lib.h
@@ -0,0 +1,121 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014, 2015, 2016, 2020 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file taler_merchantdb_lib.h
+ * @brief database helper functions used by the merchant backend
+ * @author Sree Harsha Totakura <sreeharsha@totakura.in>
+ */
+#ifndef TALER_MERCHANTDB_LIB_H
+#define TALER_MERCHANTDB_LIB_H
+
+#include <taler/taler_util.h>
+#include "taler_merchantdb_plugin.h"
+
+/**
+ * Handle to interact with the database.
+ */
+struct TALER_MERCHANTDB_Plugin;
+
+/**
+ * Connect to postgresql database
+ *
+ * @param cfg the configuration handle
+ * @return connection to the database; NULL upon error
+ */
+struct TALER_MERCHANTDB_Plugin *
+TALER_MERCHANTDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg);
+
+
+/**
+ * Disconnect from the database
+ *
+ * @param dbh database handle to close
+ */
+void
+TALER_MERCHANTDB_plugin_unload (struct TALER_MERCHANTDB_Plugin *dbh);
+
+
+/**
+ * Free members of @a pd, but not @a pd itself.
+ *
+ * @param[in] pd product details to clean up
+ */
+void
+TALER_MERCHANTDB_product_details_free (
+ struct TALER_MERCHANTDB_ProductDetails *pd);
+
+
+/**
+ * Free members of @a tp, but not @a tp itself.
+ *
+ * @param[in] tp template details to clean up
+ */
+void
+TALER_MERCHANTDB_template_details_free (
+ struct TALER_MERCHANTDB_TemplateDetails *tp);
+
+
+/**
+ * Free members of @a wb, but not @a wb itself.
+ *
+ * @param[in] wb webhook details to clean up
+ */
+void
+TALER_MERCHANTDB_webhook_details_free (
+ struct TALER_MERCHANTDB_WebhookDetails *wb);
+
+/**
+ * Free members of @a pwb, but not @a pwb itself.
+ *
+ * @param[in] pwb pending webhook details to clean up
+ */
+void
+TALER_MERCHANTDB_pending_webhook_details_free (
+ struct TALER_MERCHANTDB_PendingWebhookDetails *pwb);
+
+
+/**
+ * Free members of @a tf, but not @a tf itself.
+ *
+ * @param[in] tf token family details to clean up
+ */
+void
+TALER_MERCHANTDB_token_family_details_free (
+ struct TALER_MERCHANTDB_TokenFamilyDetails *tf);
+
+
+/**
+ * Free members of @a cd, but not @a cd itself.
+ *
+ * @param[in] cd token family details to clean up
+ */
+void
+TALER_MERCHANTDB_category_details_free (
+ struct TALER_MERCHANTDB_CategoryDetails *cd);
+
+/**
+ * Free members of @a ud, but not @a ud itself.
+ *
+ * @param[in] ud unit details to clean up
+ */
+void
+TALER_MERCHANTDB_unit_details_free (
+ struct TALER_MERCHANTDB_UnitDetails *ud);
+
+#endif /* MERCHANT_DB_H */
+
+/* end of taler_merchantdb_lib.h */
diff --git a/src/include/taler/taler_merchantdb_plugin.h b/src/include/taler/taler_merchantdb_plugin.h
@@ -0,0 +1,5932 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file taler_merchantdb_plugin.h
+ * @brief database access for the merchant
+ * @author Florian Dold
+ * @author Christian Grothoff
+ * @author Priscilla Huang
+ */
+#ifndef TALER_MERCHANTDB_PLUGIN_H
+#define TALER_MERCHANTDB_PLUGIN_H
+
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_time_lib.h>
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_db_lib.h>
+#include <taler/taler_merchant_util.h>
+#include <taler/taler_exchange_service.h>
+#include <jansson.h>
+
+#ifdef HAVE_DONAU_DONAU_SERVICE_H
+#include <donau/donau_service.h>
+#include "taler_merchant_donau.h"
+#endif
+
+/**
+ * Handle to interact with the database.
+ */
+struct TALER_MERCHANTDB_Plugin;
+
+
+GNUNET_NETWORK_STRUCT_BEGIN
+
+
+/**
+ * Format of the data hashed to generate the notification
+ * string whenever the KYC status for an account has
+ * changed.
+ */
+struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP
+{
+ /**
+ * Type is TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED.
+ */
+ struct GNUNET_DB_EventHeaderP header;
+
+ /**
+ * Salted hash of the affected account.
+ */
+ struct TALER_MerchantWireHashP h_wire;
+};
+
+/**
+ * Event triggered when an order is paid.
+ */
+struct TMH_OrderPayEventP
+{
+ /**
+ * Type is #TALER_DBEVENT_MERCHANT_ORDER_PAID
+ */
+ struct GNUNET_DB_EventHeaderP header;
+
+ /**
+ * Always zero (for alignment).
+ */
+ uint32_t reserved GNUNET_PACKED;
+
+ /**
+ * Merchant's public key
+ */
+ struct TALER_MerchantPublicKeyP merchant_pub;
+
+ /**
+ * Hash of the order ID.
+ */
+ struct GNUNET_HashCode h_order_id;
+};
+
+
+GNUNET_NETWORK_STRUCT_END
+
+/**
+ * Current exposed deposit limits by an exchange
+ * for a merchant (until other rules may apply).
+ */
+struct TALER_MERCHANTDB_DepositLimits
+{
+ /**
+ * Maximum amount to be deposited within @a timeframe.
+ */
+ struct TALER_Amount threshold;
+
+ /**
+ * Timeframe over which the limit applies.
+ */
+ struct GNUNET_TIME_Relative timeframe;
+
+ /**
+ * True if this is a soft limit that could be
+ * raised (by AML staff or by passing KYC checks).
+ */
+ bool soft_limit;
+};
+
+/**
+ * Details about a wire account of the merchant.
+ */
+struct TALER_MERCHANTDB_AccountDetails
+{
+ /**
+ * Hash of the wire details (@e payto_uri and @e salt).
+ */
+ struct TALER_MerchantWireHashP h_wire;
+
+ /**
+ * Salt value used for hashing @e payto_uri.
+ */
+ struct TALER_WireSaltP salt;
+
+ /**
+ * Instance ID. Do not free (may be aliased with
+ * the instance ID given in the query!).
+ * FIXME: set in all functions involving this struct!
+ */
+ const char *instance_id;
+
+ /**
+ * Actual account address as a payto://-URI.
+ */
+ struct TALER_FullPayto payto_uri;
+
+ /**
+ * Where can the taler-merchant-wirewatch helper
+ * download information about incoming transfers?
+ * NULL if not available.
+ */
+ char *credit_facade_url;
+
+ /**
+ * JSON with credentials to use to access the
+ * @e credit_facade_url.
+ */
+ json_t *credit_facade_credentials;
+
+ /**
+ * Additional meta data to include in wire transfers to this
+ * account. Can be NULL if not used.
+ */
+ char *extra_wire_subject_metadata;
+
+ /**
+ * Is the account set for active use in new contracts?
+ */
+ bool active;
+
+};
+
+
+/**
+ * Binary login token. Just a vanilla token made out
+ * of random bits.
+ */
+struct TALER_MERCHANTDB_LoginTokenP
+{
+ /**
+ * 32 bytes of entropy.
+ */
+ uint64_t data[32 / 8];
+};
+
+/**
+ * Authentication settings for an instance.
+ */
+struct TALER_MERCHANTDB_InstanceAuthSettings
+{
+ /**
+ * Hash used for authentication. All zero if authentication is off.
+ */
+ struct TALER_MerchantAuthenticationHashP auth_hash;
+
+ /**
+ * Salt used to hash the "Authentication" header, the result must then
+ * match the @e auth_hash.
+ */
+ struct TALER_MerchantAuthenticationSaltP auth_salt;
+};
+
+/**
+ * General settings for an instance.
+ */
+struct TALER_MERCHANTDB_InstanceSettings
+{
+ /**
+ * prefix for the instance under "/instances/"
+ */
+ char *id;
+
+ /**
+ * legal name of the instance
+ */
+ char *name;
+
+ /**
+ * merchant's site url
+ */
+ char *website;
+
+ /**
+ * email contact for password reset / possibly admin / customers
+ */
+ char *email;
+
+ /**
+ * phone contact for password reset / possibly admin / customers
+ */
+ char *phone;
+
+ /**
+ * merchant's logo data uri
+ */
+ char *logo;
+
+ /**
+ * Address of the business
+ */
+ json_t *address;
+
+ /**
+ * jurisdiction of the business
+ */
+ json_t *jurisdiction;
+
+ /**
+ * Use STEFAN curves to determine acceptable
+ * fees by default (otherwise: accept no fees by default).
+ */
+ bool use_stefan;
+
+ /**
+ * True of @e phone was validated.
+ */
+ bool phone_validated;
+
+ /**
+ * True of @e email was validated.
+ */
+ bool email_validated;
+
+ /**
+ * If the frontend does NOT specify an execution date, how long should
+ * we tell the exchange to wait to aggregate transactions before
+ * executing the wire transfer? This delay is added to the current
+ * time when we generate the advisory execution time for the exchange.
+ */
+ struct GNUNET_TIME_Relative default_wire_transfer_delay;
+
+ /**
+ * If the frontend does NOT specify a payment deadline, how long should
+ * offers we make be valid by default?
+ */
+ struct GNUNET_TIME_Relative default_pay_delay;
+
+ /**
+ * If the frontend does NOT specify a refund deadline, how long should
+ * refunds be possible?
+ */
+ struct GNUNET_TIME_Relative default_refund_delay;
+
+ /**
+ * How much should we round up the wire transfer deadline computed by
+ * adding the @e default_wire_transfer_delay to the refund deadline.
+ */
+ enum GNUNET_TIME_RounderInterval default_wire_transfer_rounding_interval;
+
+};
+
+
+/**
+ * Typically called by `lookup_instances`.
+ *
+ * @param cls closure
+ * @param merchant_pub public key of the instance
+ * @param merchant_priv private key of the instance, NULL if not available
+ * @param is general instance settings
+ * @param ias instance authentication settings
+ */
+typedef void
+(*TALER_MERCHANTDB_InstanceCallback)(
+ void *cls,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_MerchantPrivateKeyP *merchant_priv,
+ const struct TALER_MERCHANTDB_InstanceSettings *is,
+ const struct TALER_MERCHANTDB_InstanceAuthSettings *ias);
+
+
+/**
+ * Callback invoked with information about a bank account.
+ *
+ * @param cls closure
+ * @param merchant_priv private key of the merchant instance
+ * @param ad details about the account
+ */
+typedef void
+(*TALER_MERCHANTDB_AccountCallback)(
+ void *cls,
+ const struct TALER_MerchantPrivateKeyP *merchant_priv,
+ const struct TALER_MERCHANTDB_AccountDetails *ad);
+
+
+/**
+ * Determines the maximum @a amount for a particular
+ * type of operation for a given @a exchange_url.
+ *
+ * @param cls closure
+ * @param exchange_url base URL of the exchange to get
+ * the limit for
+ * @param[in,out] amount lowered to the maximum amount
+ * allowed at the exchange
+ */
+typedef void
+(*TALER_MERCHANTDB_OperationLimitCallback)(
+ void *cls,
+ const char *exchange_url,
+ struct TALER_Amount *amount);
+
+
+/**
+ * Typically called by `lookup_products`.
+ *
+ * @param cls a `json_t *` JSON array to build
+ * @param product_serial row ID of the product
+ * @param product_id ID of the product
+ */
+typedef void
+(*TALER_MERCHANTDB_ProductsCallback)(
+ void *cls,
+ uint64_t product_serial,
+ const char *product_id);
+
+
+/**
+ * Details about a product.
+ *
+ * FIXME: reuse TALER_MERCHANT_Product as a member in this structure!
+ */
+struct TALER_MERCHANTDB_ProductDetails
+{
+ /**
+ * Name of the product.
+ */
+ char *product_name;
+
+ /**
+ * Description of the product.
+ */
+ char *description;
+
+ /**
+ * Internationalized description.
+ */
+ json_t *description_i18n;
+
+ /**
+ * Unit in which the product is sold.
+ */
+ char *unit;
+
+ /**
+ * Optional list of per-unit prices. When NULL or empty, @e price
+ * must be used as the canonical single price.
+ */
+ struct TALER_Amount *price_array;
+
+ /**
+ * Number of entries in @e price_array.
+ */
+ size_t price_array_length;
+
+ /**
+ * Base64-encoded product image, or an empty string.
+ */
+ char *image;
+
+ /**
+ * Hash of the product image data, or NULL.
+ */
+ char *image_hash;
+
+ /**
+ * List of taxes the merchant pays for this product. Never NULL,
+ * but can be an empty array.
+ */
+ json_t *taxes;
+
+ /**
+ * Number of units of the product in stock in sum in total, including all
+ * existing sales and lost product, in product-specific units. UINT64_MAX
+ * indicates "infinite".
+ */
+ uint64_t total_stock;
+
+ /**
+ * Fractional part of stock in units of 1/1000000 of the base value.
+ */
+ uint32_t total_stock_frac;
+
+ /**
+ * Honor fractional stock if TRUE, else only integer stock.
+ */
+ bool allow_fractional_quantity;
+
+ /**
+ * Precision level (number of decimal places) to apply when
+ * fractional quantities are enabled.
+ */
+ uint32_t fractional_precision_level;
+
+ /**
+ * Number of units of the product in sold, in product-specific units.
+ */
+ uint64_t total_sold;
+
+ /**
+ * Fractional part of units sold in units of 1/1000000 of the base value.
+ */
+ uint32_t total_sold_frac;
+
+ /**
+ * Number of units of stock lost.
+ */
+ uint64_t total_lost;
+
+ /**
+ * Fractional part of lost units in units of 1/1000000 of the base value.
+ */
+ uint32_t total_lost_frac;
+
+ /**
+ * Identifies where the product is in stock, possibly an empty map.
+ */
+ json_t *address;
+
+ /**
+ * Identifies when the product will be restocked. 0 for unknown,
+ * #GNUNET_TIME_UNIT_FOREVER_ABS for never.
+ */
+ struct GNUNET_TIME_Timestamp next_restock;
+
+ /**
+ * Minimum required age for consumers buying this product.
+ * Default is 0. Only enforced of an exchange supports age
+ * restrictions.
+ */
+ uint32_t minimum_age;
+
+ /**
+ * Group in which the product is in. 0 for default group.
+ */
+ uint64_t product_group_id;
+
+ /**
+ * Money pot into which sales of this product should go into by default.
+ */
+ uint64_t money_pot_id;
+
+ /**
+ * True if the price for this product is given in net,
+ * False if its the gross price.
+ */
+ bool price_is_net;
+
+};
+
+/**
+ * Minimal product details for inventory templates.
+ */
+struct TALER_MERCHANTDB_InventoryProductDetails
+{
+ /**
+ * Name of the product.
+ */
+ char *product_name;
+
+ /**
+ * Description of the product.
+ */
+ char *description;
+
+ /**
+ * Internationalized description.
+ */
+ json_t *description_i18n;
+
+ /**
+ * Unit in which the product is sold.
+ */
+ char *unit;
+
+ /**
+ * List of per-unit prices.
+ */
+ struct TALER_Amount *price_array;
+
+ /**
+ * Number of entries in @e price_array.
+ */
+ size_t price_array_length;
+
+ /**
+ * Hash of the product image data, or NULL.
+ */
+ char *image_hash;
+
+ /**
+ * Honor fractional stock if TRUE, else only integer stock.
+ */
+ bool allow_fractional_quantity;
+
+ /**
+ * Precision level (number of decimal places) to apply when
+ * fractional quantities are enabled.
+ */
+ uint32_t fractional_precision_level;
+
+ /**
+ * Remaining units after sold/lost/locked deductions.
+ */
+ uint64_t remaining_stock;
+
+ /**
+ * Fractional part of remaining units in units of 1/1000000 of the base value.
+ */
+ uint32_t remaining_stock_frac;
+
+ /**
+ * List of taxes the merchant pays for this product. Never NULL,
+ * but can be an empty array.
+ */
+ json_t *taxes;
+};
+
+
+/**
+ * Details about an inventory measurement unit.
+ */
+struct TALER_MERCHANTDB_UnitDetails
+{
+
+ /**
+ * Database serial.
+ */
+ uint64_t unit_serial;
+
+ /**
+ * Backend identifier used in product payloads.
+ */
+ char *unit;
+
+ /**
+ * Default long label (fallback string).
+ */
+ char *unit_name_long;
+
+ /**
+ * Default short label (fallback string).
+ */
+ char *unit_name_short;
+
+ /**
+ * Internationalised long labels.
+ */
+ json_t *unit_name_long_i18n;
+
+ /**
+ * Internationalised short labels.
+ */
+ json_t *unit_name_short_i18n;
+
+ /**
+ * Whether fractional quantities are enabled by default.
+ */
+ bool unit_allow_fraction;
+
+ /**
+ * Maximum number of fractional digits honoured by default.
+ */
+ uint32_t unit_precision_level;
+
+ /**
+ * Hidden from selectors when false.
+ */
+ bool unit_active;
+
+ /**
+ * Built-in units cannot be deleted.
+ */
+ bool unit_builtin;
+};
+
+
+/**
+ * Typically called by `lookup_all_products`.
+ *
+ * @param cls a `json_t *` JSON array to build
+ * @param product_serial row ID of the product
+ * @param product_id ID of the product
+ * @param pd full product details
+ * @param num_categories length of @a categories array
+ * @param categories array of categories the
+ * product is in
+ */
+typedef void
+(*TALER_MERCHANTDB_ProductCallback)(
+ void *cls,
+ uint64_t product_serial,
+ const char *product_id,
+ const struct TALER_MERCHANTDB_ProductDetails *pd,
+ size_t num_categories,
+ const uint64_t *categories);
+
+/**
+ * Typically called by `lookup_inventory_products`.
+ *
+ * @param cls a `json_t *` JSON array to build
+ * @param product_id ID of the product
+ * @param pd inventory product details
+ * @param num_categories length of @a categories array
+ * @param categories array of categories the
+ * product is in
+ */
+typedef void
+(*TALER_MERCHANTDB_InventoryProductCallback)(
+ void *cls,
+ const char *product_id,
+ const struct TALER_MERCHANTDB_InventoryProductDetails *pd,
+ size_t num_categories,
+ const uint64_t *categories);
+
+
+/**
+ * Callback function typically used by `select_donau_instances` to handle
+ * the details of each Donau instance retrieved from the database.
+ *
+ * @param cls Closure to pass additional context or data to the callback function.
+ * @param donau_url The URL of the Donau instance.
+ */
+typedef void
+(*TALER_MERCHANTDB_DonauInstanceFilteredCallback)(
+ void *cls,
+ const char *donau_url
+ );
+
+/**
+ * Callback function typically used by `select_donau_instances` to handle
+ * the details of each Donau instance retrieved from the database.
+ *
+ * @param cls Closure to pass additional context or data to the callback function.
+ * @param donau_instance_serial Serial number of the Donau instance in the merchant database.
+ * @param donau_url The URL of the Donau instance.
+ * @param charity_name The name of the charity associated with the Donau instance.
+ * @param charity_pub_key Pointer to the charity's public key used for cryptographic operations.
+ * @param charity_id The unique identifier for the charity within the Donau instance.
+ * @param charity_max_per_year Maximum allowed donations to the charity for the current year.
+ * @param charity_receipts_to_date Total donations received by the charity so far in the current year.
+ * @param current_year The year for which the donation data is being tracked.
+ * @param donau_keys_json JSON object containing additional key-related information for the Donau instance, NULL if not (yet) available.
+ */
+typedef void
+(*TALER_MERCHANTDB_DonauInstanceCallback)(
+ void *cls,
+ uint64_t donau_instance_serial,
+ const char *donau_url,
+ const char *charity_name,
+ const struct DONAU_CharityPublicKeyP *charity_pub_key,
+ uint64_t charity_id,
+ const struct TALER_Amount *charity_max_per_year,
+ const struct TALER_Amount *charity_receipts_to_date,
+ int64_t current_year,
+ const json_t *donau_keys_json
+ );
+
+
+/**
+ * Structure to hold Donau instance details from the database.
+ */
+struct TALER_MERCHANTDB_DonauInstance
+{
+ /**
+ * Donau instance serial
+ */
+ uint64_t donau_instance_serial;
+
+ /**
+ * The URL for the Donau instance.
+ */
+ char *donau_url;
+
+ /**
+ * The name of the charity associated with the Donau instance.
+ */
+ char *charity_name;
+
+ /**
+ * Pointer to the public key of the charity, used for cryptographic operations.
+ * This is represented as an EDDSA public key structure.
+ */
+ struct DONAU_CharityPublicKeyP *charity_pub_key;
+
+ /**
+ * A unique identifier for the charity in the Donau instance.
+ */
+ uint64_t charity_id;
+
+ /**
+ * The maximum allowable amount for donations to this charity in the current year.
+ * This is tracked for regulatory or internal business constraints.
+ */
+ struct TALER_Amount charity_max_per_year;
+
+ /**
+ * The total amount of donations received by the charity in the current year.
+ * This field helps track progress toward the yearly donation limit.
+ */
+ struct TALER_Amount charity_receipts_to_date;
+
+ /**
+ * The current year being tracked for donations.
+ * This is used to differentiate donation data between years.
+ */
+ int64_t current_year;
+
+ /**
+ * A JSON object containing key information specific to the Donau instance,
+ * such as cryptographic keys or other relevant details.
+ */
+ json_t *donau_keys_json;
+};
+
+/**
+ * Typically called by `lookup_login_tokens`.
+ *
+ * @param cls a `json_t *` JSON array to build
+ * @param creation_time creation time of the token
+ * @param expiration_time expiration time of the token
+ * @param scope validity scope of the token
+ * @param description description of the token
+ * @param serial serial number of the token
+ */
+typedef void
+(*TALER_MERCHANTDB_LoginTokensCallback)(
+ void *cls,
+ struct GNUNET_TIME_Timestamp creation_time,
+ struct GNUNET_TIME_Timestamp expiration_time,
+ uint32_t scope,
+ const char *description,
+ uint64_t serial);
+
+
+/**
+ * Typically called by `lookup_templates`.
+ *
+ * @param cls closure
+ * @param template_id ID of the template
+ * @param template_description description of the template
+ */
+typedef void
+(*TALER_MERCHANTDB_TemplatesCallback)(
+ void *cls,
+ const char *template_id,
+ const char *template_description);
+
+
+/**
+ * Typically called by `lookup_otp_devices`.
+ *
+ * @param cls closure
+ * @param otp_id ID of the OTP device
+ * @param otp_description description of the OTP device
+ */
+typedef void
+(*TALER_MERCHANTDB_OtpDeviceCallback)(
+ void *cls,
+ const char *otp_id,
+ const char *otp_description);
+
+
+/**
+ * Details about a template.
+ */
+struct TALER_MERCHANTDB_TemplateDetails
+{
+ /**
+ * Description of the template.
+ */
+ char *template_description;
+
+ /**
+ * In this template contract, we can have additional information.
+ */
+ json_t *template_contract;
+
+ /**
+ * ID of the OTP device linked to the template, or NULL.
+ */
+ char *otp_id;
+
+ /**
+ * Editable default values for fields not specified
+ * in the @e template_contract. NULL if the user
+ * cannot edit anything.
+ */
+ json_t *editable_defaults;
+
+};
+
+
+/**
+ * Details about an OTP device.
+ */
+struct TALER_MERCHANTDB_OtpDeviceDetails
+{
+
+ /**
+ * Description of the device.
+ */
+ char *otp_description;
+
+ /**
+ * Current usage counter value.
+ */
+ uint64_t otp_ctr;
+
+ /**
+ * Base64-encoded key.
+ */
+ char *otp_key;
+
+ /**
+ * Algorithm used to compute purchase confirmations.
+ */
+ enum TALER_MerchantConfirmationAlgorithm otp_algorithm;
+};
+
+
+/**
+ * Typically called by `lookup_categories`.
+ *
+ * @param cls closure
+ * @param category_id ID of the category
+ * @param category_name name of the category
+ * @param category_name_i18n translations of the @a category_name
+ * @param product_count number of products in the category
+ */
+typedef void
+(*TALER_MERCHANTDB_CategoriesCallback)(
+ void *cls,
+ uint64_t category_id,
+ const char *category_name,
+ const json_t *category_name_i18n,
+ uint64_t product_count);
+
+
+/**
+ * Typically called by `lookup_units`.
+ *
+ * @param cls closure
+ * @param unit_serial database identifier
+ * @param ud measurement unit details (borrowed)
+ */
+typedef void
+(*TALER_MERCHANTDB_UnitsCallback)(
+ void *cls,
+ uint64_t unit_serial,
+ const struct TALER_MERCHANTDB_UnitDetails *ud);
+
+
+/**
+ * Details about a product category.
+ */
+struct TALER_MERCHANTDB_CategoryDetails
+{
+
+ /**
+ * Name of the category.
+ */
+ char *category_name;
+
+ /**
+ * Translations of the name of the category.
+ */
+ json_t *category_name_i18n;
+
+};
+
+
+/**
+ * Typically called by `lookup_webhooks`.
+ *
+ * @param cls a `json_t *` JSON array to build
+ * @param webhook_id ID of the webhook
+ * @param event_type event of the webhook
+ */
+typedef void
+(*TALER_MERCHANTDB_WebhooksCallback)(
+ void *cls,
+ const char *webhook_id,
+ const char *event_type);
+
+
+/**
+ * Details about a webhook.
+ */
+struct TALER_MERCHANTDB_WebhookDetails
+{
+
+ /**
+ * event of the webhook.
+ */
+ char *event_type;
+
+ /**
+ * URL of the webhook. The customer will be redirected on this url.
+ */
+ char *url;
+
+ /**
+ * Http method used by the webhook.
+ */
+ char *http_method;
+
+ /**
+ * Header template of the webhook.
+ */
+ char *header_template;
+
+ /**
+ * Body template of the webhook.
+ */
+ char *body_template;
+
+};
+
+
+/**
+ * Typically called by `lookup_webhook_by_event`.
+ *
+ * @param cls a `json_t *` JSON array to build
+ * @param webhook_serial reference to the configured webhook template.
+ * @param event_type which type of event triggers this type of webhook
+ * @param url the HTTP URL to make the webhook request to
+ * @param http_method HTTP method use for the webhook
+ * @param header_template template for the header of the webhook
+ * @param body_template template for the body of the webhook
+ */
+typedef void
+(*TALER_MERCHANTDB_WebhookDetailCallback)(
+ void *cls,
+ uint64_t webhook_serial,
+ const char *event_type,
+ const char *url,
+ const char *http_method,
+ const char *header_template,
+ const char *body_template);
+
+
+/**
+ * Typically called by `lookup_pending_webhooks`.
+ *
+ * @param cls a `json_t *` JSON array to build
+ * @param webhook_pending_serial reference to the configured webhook template.
+ * @param next_attempt is the time we should make the next request to the webhook.
+ * @param retries how often have we tried this request to the webhook.
+ * @param url to make request to
+ * @param http_method use for the webhook
+ * @param header of the webhook
+ * @param body of the webhook
+ */
+typedef void
+(*TALER_MERCHANTDB_PendingWebhooksCallback)(
+ void *cls,
+ uint64_t webhook_pending_serial,
+ struct GNUNET_TIME_Absolute
+ next_attempt,
+ uint32_t retries,
+ const char *url,
+ const char *http_method,
+ const char *header,
+ const char *body);
+
+
+/**
+ * Details about the pending webhook.
+ */
+struct TALER_MERCHANTDB_PendingWebhookDetails
+{
+
+ /**
+ * Identifies when we should make the next request to the webhook. 0 for unknown,
+ * #GNUNET_TIME_UNIT_FOREVER_ABS for never.
+ */
+ struct GNUNET_TIME_Absolute next_attempt;
+
+ /**
+ * How often have we tried this request so far.
+ */
+ uint32_t retries;
+
+ /**
+ * URL of the webhook. The customer will be redirected on this url.
+ */
+ char *url;
+
+ /**
+ * Http method used for the webhook.
+ */
+ char *http_method;
+
+ /**
+ * Header of the webhook.
+ */
+ char *header;
+
+ /**
+ * Body of the webhook.
+ */
+ char *body;
+
+};
+
+
+/**
+ * Filter preferences.
+ */
+struct TALER_MERCHANTDB_OrderFilter
+{
+ /**
+ * Filter orders by this fulfillment URL.
+ */
+ const char *fulfillment_url;
+
+ /**
+ * Filter orders by this session ID.
+ */
+ const char *session_id;
+
+ /**
+ * Filter by payment status.
+ */
+ enum TALER_EXCHANGE_YesNoAll paid;
+
+ /**
+ * Filter by refund status.
+ */
+ enum TALER_EXCHANGE_YesNoAll refunded;
+
+ /**
+ * Filter by wire transfer status.
+ */
+ enum TALER_EXCHANGE_YesNoAll wired;
+
+ /**
+ * Filter orders by date, exact meaning depends on @e delta.
+ */
+ struct GNUNET_TIME_Timestamp date;
+
+ /**
+ * Filter orders by order serial number, exact meaning depends on @e delta.
+ */
+ uint64_t start_row;
+
+ /**
+ * takes value of the form N (-N), so that at most N values strictly older
+ * (younger) than start and date are returned.
+ */
+ int64_t delta;
+
+ /**
+ * Timeout for long-polling.
+ */
+ struct GNUNET_TIME_Relative timeout;
+
+ /**
+ * Filter to apply on the summary of the order.
+ */
+ const char *summary_filter;
+
+};
+
+
+/**
+ * Typically called by `lookup_orders`.
+ *
+ * @param cls a `json_t *` JSON array to build
+ * @param order_id ID of the order
+ * @param order_serial row of the order in the database
+ * @param timestamp creation time of the order in the database
+ */
+typedef void
+(*TALER_MERCHANTDB_OrdersCallback)(void *cls,
+ const char *order_id,
+ uint64_t order_serial,
+ struct GNUNET_TIME_Timestamp timestamp);
+
+
+/**
+ * Typically called by `select_order_blinded_sigs`
+ *
+ * @param cls closure
+ * @param hash hash of the token
+ * @param blinded_sig blinded signature for the token
+ */
+typedef void
+(*TALER_MERCHANTDB_BlindedSigCallback)(
+ void *cls,
+ struct GNUNET_HashCode *hash,
+ struct GNUNET_CRYPTO_BlindedSignature *blinded_sig);
+
+/**
+ * Function called with information about a coin that was deposited.
+ *
+ * @param cls closure
+ * @param exchange_url exchange where @a coin_pub was deposited
+ * @param coin_pub public key of the coin
+ * @param amount_with_fee amount the exchange will deposit for this coin
+ * @param deposit_fee fee the exchange will charge for this coin
+ * @param refund_fee fee the exchange will charge for refunding this coin
+ */
+typedef void
+(*TALER_MERCHANTDB_DepositsCallback)(
+ void *cls,
+ const char *exchange_url,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const struct TALER_Amount *amount_with_fee,
+ const struct TALER_Amount *deposit_fee,
+ const struct TALER_Amount *refund_fee);
+
+
+/**
+ * Function called with information about a refund.
+ *
+ * @param cls closure
+ * @param coin_pub public coin from which the refund comes from
+ * @param refund_amount refund amount which is being taken from @a coin_pub
+ */
+typedef void
+(*TALER_MERCHANTDB_RefundCallback)(
+ void *cls,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const struct TALER_Amount *refund_amount);
+
+
+/**
+ * Typically called by `lookup_transfer_details_by_order`.
+ *
+ * @param cls closure
+ * @param wtid wire transfer subject of the wire transfer for the coin
+ * @param exchange_url base URL of the exchange that made the payment
+ * @param execution_time when was the payment made
+ * @param deposit_value contribution of the coin to the total wire transfer value
+ * @param deposit_fee deposit fee charged by the exchange for the coin
+ * @param transfer_confirmed did the merchant confirm that a wire transfer with
+ * @a wtid over the total amount happened?
+ * @param expected_credit_serial row of the expected wire transfer, usable
+ * as ``offset`` for the ``/private/incoming`` endpoint
+ */
+typedef void
+(*TALER_MERCHANTDB_OrderTransferDetailsCallback)(
+ void *cls,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const char *exchange_url,
+ struct GNUNET_TIME_Timestamp execution_time,
+ const struct TALER_Amount *deposit_value,
+ const struct TALER_Amount *deposit_fee,
+ bool transfer_confirmed,
+ uint64_t expected_credit_serial);
+
+
+/**
+ * Function called with detailed information about a refund.
+ *
+ * @param cls closure
+ * @param refund_serial unique serial number of the refund
+ * @param timestamp time of the refund (for grouping of refunds in the wallet UI)
+ * @param coin_pub public coin from which the refund comes from
+ * @param exchange_url URL of the exchange that issued @a coin_pub
+ * @param rtransaction_id identificator of the refund
+ * @param reason human-readable explanation of the refund
+ * @param refund_amount refund amount which is being taken from @a coin_pub
+ * @param pending true if the this refund was not yet processed by the wallet/exchange
+ */
+typedef void
+(*TALER_MERCHANTDB_RefundDetailCallback)(
+ void *cls,
+ uint64_t refund_serial,
+ struct GNUNET_TIME_Timestamp timestamp,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const char *exchange_url,
+ uint64_t rtransaction_id,
+ const char *reason,
+ const struct TALER_Amount *refund_amount,
+ bool pending);
+
+
+/**
+ * Function called from ``account_kyc_get_status``
+ * with KYC status information for this merchant.
+ *
+ * @param cls closure
+ * @param h_wire hash of the wire account
+ * @param payto_uri payto:// URI of the merchant's bank account
+ * @param exchange_url base URL of the exchange for which this is a status
+ * @param last_check when did we last get an update on our KYC status from the exchange
+ * @param kyc_ok true if we satisfied the KYC requirements
+ * @param access_token access token for the KYC SPA, NULL if we cannot access it yet (need KYC auth wire transfer)
+ * @param last_http_status last HTTP status from /kyc-check
+ * @param last_ec last Taler error code from /kyc-check
+ * @param in_aml_review true if the account is pending review
+ * @param jlimits JSON array of applicable AccountLimits, or NULL if unknown (like defaults apply)
+ */
+typedef void
+(*TALER_MERCHANTDB_KycCallback)(
+ void *cls,
+ const struct TALER_MerchantWireHashP *h_wire,
+ struct TALER_FullPayto payto_uri,
+ const char *exchange_url,
+ struct GNUNET_TIME_Timestamp last_check,
+ bool kyc_ok,
+ const struct TALER_AccountAccessTokenP *access_token,
+ unsigned int last_http_status,
+ enum TALER_ErrorCode last_ec,
+ bool in_aml_review,
+ const json_t *jlimits);
+
+
+/**
+ * Function called from ``account_kyc_get_outdated``
+ * with information about outdated KYC status information.
+ *
+ * @param cls closure
+ * @param instance_id which instance is this about
+ * @param exchange_url base URL of the exchange for which the status is dated
+ * @param h_wire hash of the wire account for which the status is dated
+ */
+typedef void
+(*TALER_MERCHANTDB_KycOutdatedCallback)(
+ void *cls,
+ const char *instance_id,
+ const char *exchange_url,
+ const struct TALER_MerchantWireHashP *h_wire);
+
+
+/**
+ * Function called about the ``/keys`` status of every exchange
+ * we are working with.
+ *
+ * @param cls closure
+ * @param exchange_url base URL of the exchange
+ * @param next_download when will be the next download
+ * @param keys_expiration when does the current ``/keys`` response expire
+ * @param http_status last HTTP status from ``/keys``
+ * @param ec last error code from fetching ``/keys``
+ */
+typedef void
+(*TALER_MERCHANTDB_ExchangesCallback)(
+ void *cls,
+ const char *exchange_url,
+ struct GNUNET_TIME_Absolute next_download,
+ struct GNUNET_TIME_Absolute keys_expiration,
+ unsigned int http_status,
+ enum TALER_ErrorCode ec);
+
+/**
+ * Results from trying to increase a refund.
+ */
+enum TALER_MERCHANTDB_RefundStatus
+{
+
+ /**
+ * Refund amount exceeds legal exchange limits.
+ */
+ TALER_MERCHANTDB_RS_LEGAL_FAILURE = -5,
+
+ /**
+ * Refund amount currency does not match original payment.
+ */
+ TALER_MERCHANTDB_RS_BAD_CURRENCY = -4,
+
+ /**
+ * Refund amount exceeds original payment.
+ */
+ TALER_MERCHANTDB_RS_TOO_HIGH = -3,
+
+ /**
+ * Hard database failure.
+ */
+ TALER_MERCHANTDB_RS_HARD_ERROR = -2,
+
+ /**
+ * Soft database failure.
+ */
+ TALER_MERCHANTDB_RS_SOFT_ERROR = -1,
+
+ /**
+ * Order not found.
+ */
+ TALER_MERCHANTDB_RS_NO_SUCH_ORDER = 0,
+
+ /**
+ * Refund is now at or above the requested amount.
+ */
+ TALER_MERCHANTDB_RS_SUCCESS = 1
+
+};
+
+
+/**
+ * Function called with information about a wire transfer identifier.
+ *
+ * @param cls closure
+ * @param order_id the order to which the deposits belong
+ * @param deposit_value the amount deposited under @a order_id
+ * @param deposit_fee the fee charged for @a deposit_value
+ */
+typedef void
+(*TALER_MERCHANTDB_TransferSummaryCallback)(
+ void *cls,
+ const char *order_id,
+ const struct TALER_Amount *deposit_value,
+ const struct TALER_Amount *deposit_fee);
+
+
+/**
+ * Function called with information about wire transfers
+ * that taler-merchant-exchange still needs to process.
+ *
+ * @param cls closure
+ * @param rowid row of the transfer in the merchant database
+ * @param instance_id instance that received the transfer
+ * @param exchange_url URL of the exchange that is making the deposit
+ * @param payto_uri account of the merchant that received the transfer
+ * @param wtid wire transfer subject identifying the aggregation
+ * @param next_attempt when should we next try to interact with the exchange
+ */
+typedef void
+(*TALER_MERCHANTDB_OpenTransferCallback)(
+ void *cls,
+ uint64_t rowid,
+ const char *instance_id,
+ const char *exchange_url,
+ struct TALER_FullPayto payto_uri,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ struct GNUNET_TIME_Absolute next_attempt);
+
+
+/**
+ * Callback for results from `lookup_pending_deposits`.
+ *
+ * @param cls NULL
+ * @param deposit_serial identifies the deposit operation
+ * @param wire_deadline when is the wire due
+ * @param retry_time when to next try the exchange again
+ * @param h_contract_terms hash of the contract terms
+ * @param merchant_priv private key of the merchant
+ * @param instance_id name of the instance
+ * @param h_wire hash of the merchant's wire account into
+ * @param amount_with_fee amount the exchange will deposit for this coin
+ * @param deposit_fee fee the exchange will charge for this coin which the deposit was made
+ * @param coin_pub public key of the deposited coin
+ */
+typedef void
+(*TALER_MERCHANTDB_PendingDepositsCallback) (
+ void *cls,
+ uint64_t deposit_serial,
+ struct GNUNET_TIME_Absolute wire_deadline,
+ struct GNUNET_TIME_Absolute retry_time,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct TALER_MerchantPrivateKeyP *merchant_priv,
+ const char *instance_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const struct TALER_Amount *amount_with_fee,
+ const struct TALER_Amount *deposit_fee,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub);
+
+
+/**
+ * Function called with detailed information about a wire transfer and
+ * the underlying deposits that are being aggregated.
+ *
+ * @param cls closure
+ * @param current_offset offset in the exchange reply we are at
+ * @param ttd details about the transfer at @a current_offset
+ */
+typedef void
+(*TALER_MERCHANTDB_TransferDetailsCallback)(
+ void *cls,
+ unsigned int current_offset,
+ const struct TALER_TrackTransferDetails *ttd);
+
+
+/**
+ * Function called with information about a accounts
+ * the wirewatcher should monitor.
+ *
+ * @param cls closure
+ * @param instance instance that owns the account
+ * @param payto_uri account URI
+ * @param credit_facade_url URL for the credit facade
+ * @param credit_facade_credentials account access credentials
+ * @param last_serial last transaction serial (inclusive) we have seen from this account
+ */
+typedef void
+(*TALER_MERCHANTDB_WirewatchWorkCallback)(
+ void *cls,
+ const char *instance,
+ struct TALER_FullPayto payto_uri,
+ const char *credit_facade_url,
+ const json_t *credit_facade_credentials,
+ uint64_t last_serial);
+
+
+/**
+ * Function called with information about a wire transfer.
+ *
+ * @param cls closure with a `json_t *` array to build up the response
+ * @param expected_credit_amount how we expect to see wired to the merchant (minus fees), NULL if unknown
+ * @param wtid wire transfer identifier
+ * @param payto_uri target account that received the wire transfer
+ * @param exchange_url base URL of the exchange that made the wire transfer
+ * @param transfer_serial_id serial number identifying the transfer in the backend
+ * @param expected_transfer_serial_id serial number identifying the expected transfer in the backend, 0 if not @a expected
+ * @param execution_time when did the exchange make the transfer, #GNUNET_TIME_UNIT_FOREVER_ABS
+ * if it did not yet happen
+ * @param expected true if the merchant acknowledged the wire transfer reception
+ */
+typedef void
+(*TALER_MERCHANTDB_TransferCallback)(
+ void *cls,
+ const struct TALER_Amount *expected_credit_amount,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ struct TALER_FullPayto payto_uri,
+ const char *exchange_url,
+ uint64_t transfer_serial_id,
+ uint64_t expected_transfer_serial_id,
+ struct GNUNET_TIME_Absolute execution_time,
+ bool expected);
+
+
+/**
+ * Function called with information about expected incoming wire transfers.
+ *
+ * @param cls closure with a `json_t *` array to build up the response
+ * @param expected_credit_amount how we expect to see wired to the merchant (minus fees), NULL if unknown
+ * @param wtid wire transfer identifier
+ * @param payto_uri target account that received the wire transfer
+ * @param exchange_url base URL of the exchange that made the wire transfer
+ * @param expected_transfer_serial_id serial number identifying the expected transfer in the backend
+ * @param execution_time when did the exchange claim to have made the transfer
+ * @param confirmed true if the merchant confirmed this wire transfer
+ * false if it is so far only claimed to have been made by the exchange
+ * @param validated true if the reconciliation succeeded
+ * @param last_http_status HTTP status of our last request to the exchange for this transfer
+ * @param last_ec last error code we got back (otherwise #TALER_EC_NONE)
+ * @param last_error_detail last detail we got back (or NULL for none)
+ */
+typedef void
+(*TALER_MERCHANTDB_IncomingCallback)(
+ void *cls,
+ const struct TALER_Amount *expected_credit_amount,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ struct TALER_FullPayto payto_uri,
+ const char *exchange_url,
+ uint64_t expected_transfer_serial_id,
+ struct GNUNET_TIME_Timestamp execution_time,
+ bool confirmed,
+ bool validated,
+ unsigned int last_http_status,
+ enum TALER_ErrorCode last_ec,
+ const char *last_error_detail);
+
+
+/**
+ * If the given account is feasible, add it to the array
+ * of accounts we return.
+ *
+ * @param cls closure
+ * @param payto_uri URI of the account
+ * @param conversion_url URL of a conversion service
+ * @param debit_restrictions restrictions for debits from account
+ * @param credit_restrictions restrictions for credits to account
+ * @param master_sig signature affirming the account
+ */
+typedef void
+(*TALER_MERCHANTDB_ExchangeAccountCallback) (
+ void *cls,
+ struct TALER_FullPayto payto_uri,
+ const char *conversion_url,
+ const json_t *debit_restrictions,
+ const json_t *credit_restrictions,
+ const struct TALER_MasterSignatureP *master_sig);
+
+
+/**
+ * Function called with information about a coin that was deposited.
+ *
+ * @param cls closure
+ * @param deposit_serial which deposit operation is this about
+ * @param exchange_url URL of the exchange that issued the coin
+ * @param h_wire hash of merchant's wire details
+ * @param deposit_timestamp when was the deposit made
+ * @param amount_with_fee amount the exchange will deposit for this coin
+ * @param deposit_fee fee the exchange will charge for this coin
+ * @param coin_pub public key of the coin
+ */
+typedef void
+(*TALER_MERCHANTDB_DepositedCoinsCallback)(
+ void *cls,
+ uint64_t deposit_serial,
+ const char *exchange_url,
+ const struct TALER_MerchantWireHashP *h_wire,
+ struct GNUNET_TIME_Timestamp deposit_timestamp,
+ const struct TALER_Amount *amount_with_fee,
+ const struct TALER_Amount *deposit_fee,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub);
+
+
+/**
+ * Function called with information about a coin that was deposited.
+ *
+ * @param cls closure
+ * @param exchange_url URL of the exchange that issued the coin
+ * @param amount_with_fee amount the exchange will deposit for this coin
+ * @param deposit_fee fee the exchange will charge for this coin
+ * @param refund_fee fee the exchange will charge for refunding this coin
+ * @param wire_fee wire fee the exchange charges
+ * @param h_wire hash of merchant's wire details
+ * @param deposit_timestamp when did the exchange receive the deposit
+ * @param refund_deadline until when are refunds allowed
+ * @param exchange_sig signature by the exchange
+ * @param exchange_pub exchange signing key used for @a exchange_sig
+ */
+typedef void
+(*TALER_MERCHANTDB_CoinDepositCallback)(
+ void *cls,
+ const char *exchange_url,
+ const struct TALER_Amount *amount_with_fee,
+ const struct TALER_Amount *deposit_fee,
+ const struct TALER_Amount *refund_fee,
+ const struct TALER_Amount *wire_fee,
+ const struct TALER_MerchantWireHashP *h_wire,
+ struct GNUNET_TIME_Timestamp deposit_timestamp,
+ struct GNUNET_TIME_Timestamp refund_deadline,
+ const struct TALER_ExchangeSignatureP *exchange_sig,
+ const struct TALER_ExchangePublicKeyP *exchange_pub);
+
+
+/**
+ * Possible token family kinds.
+ */
+enum TALER_MERCHANTDB_TokenFamilyKind
+{
+
+ /**
+ * Token family representing a discount token
+ */
+ TALER_MERCHANTDB_TFK_Discount = 0,
+
+ /**
+ * Token family representing a subscription token
+ */
+ TALER_MERCHANTDB_TFK_Subscription = 1,
+
+};
+
+
+/**
+ * Typically called by `lookup_token_families`.
+ *
+ * @param cls closure
+ * @param slug slug of the token family
+ * @param name name of the token family
+ * @param description description of the token family
+ * @param description_i18n Internationalized token family description.
+ * @param start_time start time of the token family's validity period
+ * @param expiration end time of the token family's validity period
+ * @param kind kind of the token family
+ */
+typedef void
+(*TALER_MERCHANTDB_TokenFamiliesCallback)(
+ void *cls,
+ const char *slug,
+ const char *name,
+ const char *description,
+ const json_t *description_i18n,
+ struct GNUNET_TIME_Timestamp start_time,
+ struct GNUNET_TIME_Timestamp expiration,
+ const char *kind);
+
+
+/**
+ * Typically called by `select_money_pots`.
+ *
+ * @param cls closure
+ * @param name set to name of the pot
+ * @param pot_total_len length of @a pot_totals array
+ * @param pot_totals amounts currently in the pot
+ */
+typedef void
+(*TALER_MERCHANTDB_MoneyPotsCallback)(
+ void *cls,
+ uint64_t money_pot_id,
+ const char *name,
+ size_t pot_total_len,
+ const struct TALER_Amount *pot_totals);
+
+
+/**
+ * Typically called by `select_reports`.
+ *
+ * @param cls closure
+ * @param name name of the report
+ * @param description description of the report
+ * @param frequency the report frequency
+ */
+typedef void
+(*TALER_MERCHANTDB_ReportsCallback)(
+ void *cls,
+ uint64_t report_id,
+ const char *report_description,
+ struct GNUNET_TIME_Relative frequency);
+
+
+/**
+ * Typically called by `lookup_reports_pending`.
+ *
+ * @param cls closure
+ * @param instance_id name of the instance
+ * @param report_id serial number of the report
+ * @param report_program_section configuration section of program
+ * for report generation
+ * @param report_description text describing the report
+ * @param mime_type mime type to request
+ * @param report_token token to authorize access to the data source
+ * @param target_address where to send report data
+ * @param frequency report frequency
+ * @param frequency_shift how much to shift the report time from a
+ * multiple of the report @a frequency
+ * @param next_transmission when is the next transmission of this report
+ * due
+ */
+typedef void
+(*TALER_MERCHANTDB_ReportsPendingCallback)(
+ void *cls,
+ const char *instance_id,
+ uint64_t report_id,
+ const char *report_program_section,
+ const char *report_description,
+ const char *mime_type,
+ const struct TALER_MERCHANT_ReportToken *report_token,
+ const char *target_address,
+ struct GNUNET_TIME_Relative frequency,
+ struct GNUNET_TIME_Relative frequency_shift,
+ struct GNUNET_TIME_Absolute next_transmission);
+
+
+/**
+ * Typically called by `select_product_groups`.
+ *
+ * @param cls closure
+ * @param product_group_id ID of the product group
+ * @param group_name set to name of the group
+ * @param group_description set to description of the group
+ */
+typedef void
+(*TALER_MERCHANTDB_ProductGroupsCallback)(
+ void *cls,
+ uint64_t product_group_id,
+ const char *group_name,
+ const char *group_description);
+
+
+/**
+ * Details about a token family.
+ */
+struct TALER_MERCHANTDB_TokenFamilyDetails
+{
+ /**
+ * Token family slug used for identification.
+ */
+ char *slug;
+
+ /**
+ * User readable name of the token family.
+ */
+ char *name;
+
+ /**
+ * Description of the token family.
+ */
+ char *description;
+
+ /**
+ * Internationalized token family description.
+ */
+ json_t *description_i18n;
+
+ /**
+ * Meta-data associated with the token family.
+ * Includes information like "trusted_domains" or
+ * "expected_domains", if set.
+ */
+ json_t *extra_data;
+
+ /**
+ * Cipher that should be used for this token family. Note: We do not expose
+ * this over the API and do not let clients set it. NULL for default (when
+ * calling database).
+ */
+ char *cipher_spec;
+
+ /**
+ * Start time of the token family duration.
+ */
+ struct GNUNET_TIME_Timestamp valid_after;
+
+ /**
+ * End time of the token family duration.
+ */
+ struct GNUNET_TIME_Timestamp valid_before;
+
+ /**
+ * Validity duration of the token family. Must be larger or
+ * equal to @a rounding plus @a start_offset_s.
+ */
+ struct GNUNET_TIME_Relative duration;
+
+ /**
+ * Rounding duration of the token family.
+ */
+ struct GNUNET_TIME_Relative validity_granularity;
+
+ /**
+ * Offset (in seconds) to subtract from the rounded
+ * validity start period.
+ */
+ struct GNUNET_TIME_Relative start_offset;
+
+ /**
+ * Token family kind.
+ */
+ enum TALER_MERCHANTDB_TokenFamilyKind kind;
+
+ /**
+ * Counter for each issued token of this family.
+ */
+ uint64_t issued;
+
+ /**
+ * Counter for each used token of this family.
+ */
+ uint64_t used;
+};
+
+
+/**
+ * Details about a token key.
+ */
+struct TALER_MERCHANTDB_TokenFamilyKeyDetails
+{
+ /**
+ * Tokens signed with this key are valid from this date on.
+ * This is the time the key was created.
+ */
+ struct GNUNET_TIME_Timestamp signature_validity_start; // valid_after;
+
+ /**
+ * Tokens signed with this key are valid until this date.
+ */
+ struct GNUNET_TIME_Timestamp signature_validity_end; // valid_before;
+
+ /**
+ * Private key expires for use at this time. Signatures can
+ * only be created until this point.
+ */
+ struct GNUNET_TIME_Timestamp private_key_deleted_at;
+
+ /**
+ * Token family public key.
+ */
+ struct TALER_TokenIssuePublicKey pub;
+
+ /**
+ * Token family private key.
+ */
+ struct TALER_TokenIssuePrivateKey priv;
+
+ /**
+ * Details about the token family this key belongs to.
+ */
+ struct TALER_MERCHANTDB_TokenFamilyDetails token_family;
+};
+
+
+/**
+ * Function called with applicable token keys.
+ *
+ * @param cls closure
+ * @param details details about an applicable key
+ */
+typedef void
+(*TALER_MERCHANTDB_TokenKeyCallback) (
+ void *cls,
+ const struct TALER_MERCHANTDB_TokenFamilyKeyDetails *details);
+
+
+/**
+ * Details about a spent token.
+ */
+struct TALER_MERCHANTDB_SpentTokenDetails
+{
+ /**
+ * Public key of the spent token.
+ */
+ struct TALER_TokenUsePublicKeyP pub;
+
+ /**
+ * Signature that this token was spent on the specified order.
+ */
+ struct TALER_TokenUseSignatureP sig;
+
+ /**
+ * Blind signature for the spent token to prove validity of it.
+ */
+ struct TALER_BlindedTokenIssueSignature blind_sig;
+};
+
+
+/**
+ * Function called with information about a token that was used.
+ *
+ * @param cls closure
+ * @param spent_token_serial which used token is this about
+ * @param h_contract_terms hash of the contract terms this token was used on
+ * @param h_issue_pub hash of the token issue public key
+ * @param use_pub token use public key
+ * @param use_sig token use signature
+ * @param issue_sig unblinded token issue signature
+ */
+typedef void
+(*TALER_MERCHANTDB_UsedTokensCallback)(
+ void *cls,
+ uint64_t spent_token_serial,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub,
+ const struct TALER_TokenUsePublicKeyP *use_pub,
+ const struct TALER_TokenUseSignatureP *use_sig,
+ const struct TALER_TokenIssueSignature *issue_sig);
+
+
+/**
+ * Returns amount-valued statistics by bucket.
+ * Called by `lookup_statistics_amount_by_bucket`.
+ *
+ * @param cls closure
+ * @param description description of the statistic
+ * @param bucket_start start time of the bucket
+ * @param bucket_end end time of the bucket
+ * @param bucket_range range of the bucket
+ * @param cumulative_amounts_len the length of @a cumulative_amounts
+ * @param cumulative_amounts the cumulative amounts array
+ */
+typedef void
+(*TALER_MERCHANTDB_AmountByBucketStatisticsCallback)(
+ void *cls,
+ const char *description,
+ struct GNUNET_TIME_Timestamp bucket_start,
+ struct GNUNET_TIME_Timestamp bucket_end,
+ const char *bucket_range,
+ unsigned int cumulative_amounts_len,
+ const struct TALER_Amount cumulative_amounts[static cumulative_amounts_len]);
+
+
+/**
+ * Returns amount-valued statistics by bucket.
+ * Called by `lookup_statistics_amount_by_bucket2`.
+ *
+ * @param cls closure
+ * @param bucket_start start time of the bucket
+ * @param cumulative_amounts_len the length of @a cumulative_amounts
+ * @param cumulative_amounts the cumulative amounts array
+ */
+typedef void
+(*TALER_MERCHANTDB_AmountByBucketStatisticsCallback2)(
+ void *cls,
+ struct GNUNET_TIME_Timestamp bucket_start,
+ unsigned int cumulative_amounts_len,
+ const struct TALER_Amount cumulative_amounts[static cumulative_amounts_len]);
+
+
+/**
+ * Returns amount-valued statistics over a particular time interval.
+ * Called by `lookup_statistics_amount_by_interval`.
+ *
+ * @param cls closure
+ * @param description description of the statistic
+ * @param interval_start start time of the bucket
+ * @param cumulative_amounts_len the length of @a cumulative_amounts
+ * @param cumulative_amounts the cumulative amounts array
+ */
+typedef void
+(*TALER_MERCHANTDB_AmountByIntervalStatisticsCallback)(
+ void *cls,
+ const char *description,
+ struct GNUNET_TIME_Timestamp interval_start,
+ unsigned int cumulative_amounts_len,
+ const struct TALER_Amount cumulative_amounts[static cumulative_amounts_len]);
+
+
+/**
+ * Function returning integer-valued statistics for a bucket.
+ * Called by `lookup_statistics_counter_by_bucket`.
+ *
+ * @param cls closure
+ * @param description description of the statistic
+ * @param bucket_start start time of the bucket
+ * @param bucket_end end time of the bucket
+ * @param bucket_range range of the bucket
+ * @param cumulative_counter counter value
+ */
+typedef void
+(*TALER_MERCHANTDB_CounterByBucketStatisticsCallback)(
+ void *cls,
+ const char *description,
+ struct GNUNET_TIME_Timestamp bucket_start,
+ struct GNUNET_TIME_Timestamp bucket_end,
+ const char *bucket_range,
+ uint64_t cumulative_counter);
+
+
+/**
+ * Function returning reconciliation details for an
+ * expected incoming wire transfer.
+ * Called by `lookup_reconciliation_details`.
+ *
+ * @param cls closure
+ * @param order_id order that was paid and then aggregated
+ * @param remaining_deposit deposited amount minus any refunds
+ * @param deposit_fee deposit fees paid to the exchange for the order
+ */
+typedef void
+(*TALER_MERCHANTDB_ReconciliationDetailsCallback)(
+ void *cls,
+ const char *order_id,
+ const struct TALER_Amount *remaining_deposit,
+ const struct TALER_Amount *deposit_fee);
+
+
+/**
+ * Details about a statistic with counter.
+ */
+struct TALER_MERCHANTDB_StatisticsCounterByBucketDetails
+{
+ /**
+ * Start time of the bucket (inclusive).
+ */
+ struct GNUNET_TIME_Timestamp start_time;
+
+ /**
+ * End time of the bucket (exclusive).
+ */
+ struct GNUNET_TIME_Timestamp end_time;
+
+ /**
+ * Description of the statistic
+ */
+ char*description;
+
+ /**
+ * Range of the bucket
+ */
+ char *range;
+
+ /**
+ * Sum of all counters falling under the given
+ * SLUG within this timeframe
+ */
+ uint64_t cumulative_number;
+};
+
+/**
+ * Details about a statistic with counter.
+ */
+struct TALER_MERCHANTDB_StatisticsCounterByIntervalDetails
+{
+ /**
+ * Start time of the interval.
+ * The interval always ends at the response generation time.
+ */
+ struct GNUNET_TIME_Timestamp start_time;
+
+ /**
+ * Sum of all counters falling under the given
+ * SLUG within this timeframe
+ */
+ uint64_t cumulative_counter;
+};
+
+
+/**
+ * Function returning integer-valued statistics for a time interval.
+ * Called by `lookup_statistics_counter_by_interval`.
+ *
+ * @param cls closure
+ * @param description description of the statistic
+ * @param interval_start start time of the interval
+ * @param cumulative_counter counter value
+ */
+typedef void
+(*TALER_MERCHANTDB_CounterByIntervalStatisticsCallback)(
+ void *cls,
+ const char *description,
+ struct GNUNET_TIME_Timestamp interval_start,
+ uint64_t cumulative_counter);
+
+
+/**
+ * Function returning integer-valued statistics for a bucket.
+ * Called by `lookup_statistics_counter_by_bucket2`.
+ *
+ * @param cls closure
+ * @param bucket_start start time of the bucket
+ * @param counters_len the length of @a cumulative_amounts
+ * @param descriptions description for the counter in the bucket
+ * @param counters the counters in the bucket
+ */
+typedef void
+(*TALER_MERCHANTDB_CounterByBucketStatisticsCallback2)(
+ void *cls,
+ struct GNUNET_TIME_Timestamp bucket_start,
+ unsigned int counters_len,
+ const char *descriptions[static counters_len],
+ uint64_t counters[static counters_len]);
+
+
+/**
+ * Handle to interact with the database.
+ *
+ * Functions ending with "_TR" run their OWN transaction scope
+ * and MUST NOT be called from within a transaction setup by the
+ * caller. Functions ending with "_NT" require the caller to
+ * setup a transaction scope. Functions without a suffix are
+ * simple, single SQL queries that MAY be used either way.
+ */
+struct TALER_MERCHANTDB_Plugin
+{
+
+ /**
+ * Closure for all callbacks.
+ */
+ void *cls;
+
+ /**
+ * Name of the library which generated this plugin. Set by the
+ * plugin loader.
+ */
+ char *library_name;
+
+ /**
+ * Connect to the database.
+ *
+ * @param cls closure
+ */
+ enum GNUNET_GenericReturnValue
+ (*connect)(void *cls);
+
+ /**
+ * Drop merchant tables. Used for testcases and to reset the DB.
+ *
+ * @param cls closure
+ * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
+ */
+ enum GNUNET_GenericReturnValue
+ (*drop_tables)(void *cls);
+
+ /**
+ * Garbage collect database. Removes unnecessary data.
+ *
+ * @param cls closure
+ * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
+ */
+ enum GNUNET_GenericReturnValue
+ (*gc)(void *cls);
+
+ /**
+ * Initialize merchant tables
+ *
+ * @param cls closure
+ * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
+ */
+ enum GNUNET_GenericReturnValue
+ (*create_tables)(void *cls);
+
+ /**
+ * Register callback to be invoked on events of type @a es.
+ *
+ * @param cls database context to use
+ * @param es specification of the event to listen for
+ * @param timeout how long to wait for the event
+ * @param cb function to call when the event happens, possibly
+ * multiple times (until cancel is invoked)
+ * @param cb_cls closure for @a cb
+ * @return handle useful to cancel the listener
+ */
+ struct GNUNET_DB_EventHandler *
+ (*event_listen)(void *cls,
+ const struct GNUNET_DB_EventHeaderP *es,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_DB_EventCallback cb,
+ void *cb_cls);
+
+ /**
+ * Stop notifications.
+ *
+ * @param eh handle to unregister.
+ */
+ void
+ (*event_listen_cancel)(struct GNUNET_DB_EventHandler *eh);
+
+
+ /**
+ * Notify all that listen on @a es of an event.
+ *
+ * @param cls database context to use
+ * @param es specification of the event to generate
+ * @param extra additional event data provided
+ * @param extra_size number of bytes in @a extra
+ */
+ void
+ (*event_notify)(void *cls,
+ const struct GNUNET_DB_EventHeaderP *es,
+ const void *extra,
+ size_t extra_size);
+
+
+ /**
+ * Do a pre-flight check that we are not in an uncommitted transaction. If
+ * we are, die. Does not return anything, as we will continue regardless of
+ * the outcome.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ */
+ void
+ (*preflight) (void *cls);
+
+ /**
+ * Start a transaction.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ * @param name unique name identifying the transaction (for debugging),
+ * must point to a constant
+ * @return #GNUNET_OK on success
+ */
+ enum GNUNET_GenericReturnValue
+ (*start)(void *cls,
+ const char *name);
+
+ /**
+ * Start a transaction with isolation level 'read committed'.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ * @param name unique name identifying the transaction (for debugging),
+ * must point to a constant
+ * @return #GNUNET_OK on success
+ */
+ enum GNUNET_GenericReturnValue
+ (*start_read_committed)(void *cls,
+ const char *name);
+
+ /**
+ * Roll back the current transaction of a database connection.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ */
+ void
+ (*rollback) (void *cls);
+
+ /**
+ * Commit the current transaction of a database connection.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*commit)(void *cls);
+
+ /**
+ * Lookup all of the instances this backend has configured.
+ *
+ * @param cls closure
+ * @param active_only only find 'active' instances
+ * @param cb function to call on all instances found
+ * @param cb_cls closure for @a cb
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_instances)(void *cls,
+ bool active_only,
+ TALER_MERCHANTDB_InstanceCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup one of the instances this backend has configured.
+ *
+ * @param cls closure
+ * @param id ID of instance to look up
+ * @param active_only only find 'active' instances
+ * @param cb function to call on all instances found
+ * @param cb_cls closure for @a cb
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_instance)(void *cls,
+ const char *id,
+ bool active_only,
+ TALER_MERCHANTDB_InstanceCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup authentication data of an instance.
+ *
+ * @param cls closure
+ * @param instance_id instance to query
+ * @param[out] ias where to store the auth data
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_instance_auth)(void *cls,
+ const char *instance_id,
+ struct TALER_MERCHANTDB_InstanceAuthSettings *ias);
+
+
+ /**
+ * Insert information about an instance into our database.
+ *
+ * @param cls closure
+ * @param merchant_pub public key of the instance
+ * @param merchant_priv private key of the instance
+ * @param is details about the instance
+ * @param validation_needed true if validation is
+ * required before the instance can be used
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_instance)(void *cls,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_MerchantPrivateKeyP *merchant_priv,
+ const struct TALER_MERCHANTDB_InstanceSettings *is,
+ const struct TALER_MERCHANTDB_InstanceAuthSettings *ias,
+ bool validation_needed);
+
+
+ /**
+ * Insert information about an instance's account into our database.
+ *
+ * @param cls closure
+ * @param account_details details about the account
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_account)(
+ void *cls,
+ const struct TALER_MERCHANTDB_AccountDetails *account_details);
+
+
+ /**
+ * Insert instance login token into our database.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param token value of the token
+ * @param creation_time the current time
+ * @param expiration_time when does the token expire
+ * @param validity_scope scope of the token
+ * @param description description of the token
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_login_token)(
+ void *cls,
+ const char *id,
+ const struct TALER_MERCHANTDB_LoginTokenP *token,
+ struct GNUNET_TIME_Timestamp creation_time,
+ struct GNUNET_TIME_Timestamp expiration_time,
+ uint32_t validity_scope,
+ const char *description);
+
+
+ /**
+ * Lookup information about a login token from database.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param token value of the token
+ * @param[out] expiration_time set to expiration time
+ * @param[out] validity_scope set to scope of the token
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_login_token)(
+ void *cls,
+ const char *id,
+ const struct TALER_MERCHANTDB_LoginTokenP *token,
+ struct GNUNET_TIME_Timestamp *expiration_time,
+ uint32_t *validity_scope);
+
+ /**
+ * Lookup login tokens for instance.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup tokens for
+ * @param offset transfer_serial number of the transfer we want to offset from
+ * @param limit number of entries to return, negative for descending,
+ * positive for ascending
+ * @param cb function to call on all products found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_login_tokens)(void *cls,
+ const char *instance_id,
+ uint64_t offset,
+ int64_t limit,
+ TALER_MERCHANTDB_LoginTokensCallback cb,
+ void *cb_cls);
+
+ /**
+ * Delete login token from database.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param token value of the token
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_login_token)(
+ void *cls,
+ const char *id,
+ const struct TALER_MERCHANTDB_LoginTokenP *token);
+
+ /**
+ * Delete login token from database by serial.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param serial serial of the token
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_login_token_serial)(
+ void *cls,
+ const char *id,
+ uint64_t serial);
+
+
+ /**
+ * Update information about an instance's account into our database.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param h_wire which account to update
+ * @param extra_wire_subject_metadata additional metadata to include in wire transfer subjects
+ * @param credit_facade_url new facade URL, can be NULL
+ * @param credit_facade_credentials new credentials, can be NULL
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_account)(
+ void *cls,
+ const char *id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *extra_wire_subject_metadata,
+ const char *credit_facade_url,
+ const json_t *credit_facade_credentials);
+
+
+ /**
+ * Obtain information about an instance's accounts.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param cb function to call on each account
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_accounts)(
+ void *cls,
+ const char *id,
+ TALER_MERCHANTDB_AccountCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Obtain detailed information about an instance's account.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param h_wire wire hash of the account
+ * @param[out] ad account details returned
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_account)(
+ void *cls,
+ const char *id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ struct TALER_MERCHANTDB_AccountDetails *ad);
+
+
+ /**
+ * Obtain detailed information about an instance's account.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param payto_uri URI of the account
+ * @param[out] ad account details returned
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_account_by_uri)(
+ void *cls,
+ const char *id,
+ struct TALER_FullPayto payto_uri,
+ struct TALER_MERCHANTDB_AccountDetails *ad);
+
+
+ /**
+ * Delete private key of an instance from our database.
+ *
+ * @param cls closure
+ * @param merchant_id identifier of the instance
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_instance_private_key)(
+ void *cls,
+ const char *merchant_id);
+
+ /**
+ * Purge an instance and all associated information from our database.
+ * Highly likely to cause undesired data loss. Use with caution.
+ *
+ * @param cls closure
+ * @param merchant_id identifier of the instance
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*purge_instance)(void *cls,
+ const char *merchant_id);
+
+ /**
+ * Update information about an instance into our database.
+ *
+ * @param cls closure
+ * @param is details about the instance
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_instance)(void *cls,
+ const struct TALER_MERCHANTDB_InstanceSettings *is);
+
+ /**
+ * Update information about an instance's authentication settings
+ * into our database.
+ *
+ * @param cls closure
+ * @param merchant_id merchant backend instance ID
+ * @param ias instance auth settings
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_instance_auth)(
+ void *cls,
+ const char *merchant_id,
+ const struct TALER_MERCHANTDB_InstanceAuthSettings *ias);
+
+ /**
+ * Set an instance's account in our database to "inactive".
+ *
+ * @param cls closure
+ * @param merchant_id merchant backend instance ID
+ * @param h_wire hash of the wire account to set to inactive
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*inactivate_account)(void *cls,
+ const char *merchant_id,
+ const struct TALER_MerchantWireHashP *h_wire);
+
+
+ /**
+ * Set an instance's account in our database to "active".
+ *
+ * @param cls closure
+ * @param merchant_id merchant backend instance ID
+ * @param h_wire hash of the wire account to set to active
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*activate_account)(void *cls,
+ const char *merchant_id,
+ const struct TALER_MerchantWireHashP *h_wire);
+
+
+ /**
+ * Check an instance's account's KYC status. Triggers
+ * a request to taler-merchant-kyccheck to get a
+ * KYC status update as a side-effect!
+ *
+ * @param cls closure
+ * @param merchant_id merchant backend instance ID
+ * @param h_wire hash of the wire account to check,
+ * NULL to check all accounts of the merchant
+ * @param exchange_url base URL of the exchange to check,
+ * NULL to check all exchanges
+ * @param kyc_cb KYC status callback to invoke
+ * @param kyc_cb_cls closure for @a kyc_cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*account_kyc_get_status)(
+ void *cls,
+ const char *merchant_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ TALER_MERCHANTDB_KycCallback kyc_cb,
+ void *kyc_cb_cls);
+
+
+ /**
+ * Find accounts requiring KYC checks.
+ *
+ * @param cls closure
+ * @param kyc_cb status callback to invoke
+ * @param kyc_cb_cls closure for @a kyc_cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*account_kyc_get_outdated)(
+ void *cls,
+ TALER_MERCHANTDB_KycOutdatedCallback kyc_cb,
+ void *kyc_cb_cls);
+
+
+ /**
+ * Check an account's KYC status at an exchange.
+ *
+ * @param cls closure
+ * @param merchant_payto_uri merchant backend instance ID
+ * @param instance_id the instance for which to check
+ * @param exchange_url base URL of the exchange
+ * @param[out] auth_ok true if @a access_token was set
+ * @param[out] access_token set to access token for /kyc-info
+ * @param[out] kyc_ok true if no urgent KYC work must be done for this account
+ * @param[out] last_http_status set to last HTTP status from exchange on /kyc-check
+ * @param[out] last_ec set to last Taler error code from exchange on /kyc-check
+ * @param[out] rule_gen set to decision row at the exchange, 0 if no
+ * known decision of the exchange exists for this record; used
+ * for long-polling for changes to exchange decisions
+ * @param[out] last_kyc_check set to time of last KYC check
+ * @param[out] next_kyc_poll when should we check the KYC status next
+ * @param[out] kyc_backoff current back-off frequency for KYC checks
+ * @param[out] aml_review set to true if the account is under AML review (if this exposed)
+ * @param[out] jlimits set to JSON array with AccountLimits, NULL if unknown (and likely defaults apply or KYC auth is urgently needed, see @a auth_ok)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*get_kyc_status)(
+ void *cls,
+ struct TALER_FullPayto merchant_account_uri,
+ const char *instance_id,
+ const char *exchange_url,
+ bool *auth_ok,
+ struct TALER_AccountAccessTokenP *access_token,
+ bool *kyc_ok,
+ unsigned int *last_http_status,
+ enum TALER_ErrorCode *last_ec,
+ uint64_t *rule_gen,
+ struct GNUNET_TIME_Timestamp *last_kyc_check,
+ struct GNUNET_TIME_Absolute *next_kyc_poll,
+ struct GNUNET_TIME_Relative *kyc_backoff,
+ bool *aml_review,
+ json_t **jlimits);
+
+
+ /**
+ * Check an account's KYC limits at an exchange.
+ *
+ * @param cls closure
+ * @param merchant_payto_uri merchant backend instance ID
+ * @param instance_id the instance for which to check
+ * @param exchange_url base URL of the exchange
+ * @param[out] kyc_ok true if no urgent KYC work must be done for this account
+ * @param[out] no_access_token true if we do not have a valid KYC access token (KYC auth missing)
+ * @param[out] jlimits set to JSON array with AccountLimits, NULL if unknown (and likely defaults apply or KYC auth is urgently needed, see @a auth_ok)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*get_kyc_limits)(
+ void *cls,
+ struct TALER_FullPayto merchant_account_uri,
+ const char *instance_id,
+ const char *exchange_url,
+ bool *kyc_ok,
+ bool *no_access_token,
+ json_t **jlimits);
+
+
+ /**
+ * Update an instance's account's KYC status.
+ *
+ * @param cls closure
+ * @param merchant_id merchant backend instance ID
+ * @param h_wire hash of the wire account to check
+ * @param exchange_url base URL of the exchange to check
+ * @param timestamp timestamp to store
+ * @param next_time when should we next check the KYC status
+ * @param kyc_backoff what is the current backoff between KYC status checks
+ * @param exchange_http_status HTTP status code returned last by the exchange
+ * @param exchange_ec_code Taler error code returned last by the exchange
+ * @param rule_gen generation of the rule in the exchange database
+ * (useful for long-polling to wait for rule changes)
+ * @param access_token access token for the KYC process, NULL for none
+ * @param jlimits JSON array with AccountLimits returned by the exchange
+ * @param in_aml_review true if the exchange says the account is under review
+ * @param kyc_ok current KYC status (true for satisfied)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*account_kyc_set_status)(
+ void *cls,
+ const char *merchant_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ struct GNUNET_TIME_Timestamp timestamp,
+ struct GNUNET_TIME_Absolute next_time,
+ struct GNUNET_TIME_Relative kyc_backoff,
+ unsigned int exchange_http_status,
+ enum TALER_ErrorCode exchange_ec_code,
+ uint64_t rule_gen,
+ const struct TALER_AccountAccessTokenP *access_token,
+ const json_t *jlimits,
+ bool in_aml_review,
+ bool kyc_ok);
+
+
+ /**
+ * Set an instance's account's KYC status to failed.
+ *
+ * @param cls closure
+ * @param merchant_id merchant backend instance ID
+ * @param h_wire hash of the wire account to check
+ * @param exchange_url base URL of the exchange to check
+ * @param timestamp timestamp to store
+ * @param exchange_http_status HTTP status code returned last by the exchange
+ * @param kyc_ok current KYC status (should be false)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*account_kyc_set_failed)(
+ void *cls,
+ const char *merchant_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ struct GNUNET_TIME_Timestamp timestamp,
+ unsigned int exchange_http_status,
+ bool kyc_ok);
+
+
+ /**
+ * Lookup all of the products the given instance has configured.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup products for
+ * @param offset transfer_serial number of the transfer we want to offset from
+ * @param limit number of entries to return, negative for descending,
+ * positive for ascending
+ * @param category_filter filter products by category, NULL to not filter;
+ * uses the Postgresql "LIKE" pattern matcher, so
+ * "%" stands for any sequence of zero or more characters,
+ * "_" stands for any single character;
+ * use "\%" and "\_" to exactly match "%" or "_".
+ * We will always use case-insensitive searches, for case-sensitive
+ * matching the client should filter the result set.
+ * @param name_filter filter products by name, NULL to not filter
+ * uses the Postgresql "LIKE" pattern matcher, so
+ * "%" stands for any sequence of zero or more characters,
+ * "_" stands for any single character
+ * use "\%" and "\_" to exactly match "%" or "_".
+ * We will always use case-insensitive searches, for case-sensitive
+ * matching the client should filter the result set.
+ * @param description_filter filter products by description, NULL to not filter
+ * uses the Postgresql "LIKE" pattern matcher, so
+ * "%" stands for any sequence of zero or more characters,
+ * "_" stands for any single character
+ * use "\%" and "\_" to exactly match "%" or "_".
+ * We will always use case-insensitive searches, for case-sensitive
+ * matching the client should filter the result set.
+ * @param cb function to call on all products found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_products)(void *cls,
+ const char *instance_id,
+ uint64_t offset,
+ int64_t limit,
+ const char *category_filter,
+ const char *name_filter,
+ const char *description_filter,
+ TALER_MERCHANTDB_ProductsCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup full details of all of the products the given instance has configured (expensive).
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup products for
+ * @param cb function to call on all products found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_all_products)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_ProductCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup inventory details for all products of an instance.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup products for
+ * @param cb function to call on all products found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_inventory_products)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_InventoryProductCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup inventory details for a subset of products.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup products for
+ * @param product_ids product IDs to include (can be NULL/empty)
+ * @param num_product_ids number of entries in @a product_ids
+ * @param categories category IDs to include (can be NULL/empty)
+ * @param num_categories number of entries in @a categories
+ * @param cb function to call on all products found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_inventory_products_filtered)(
+ void *cls,
+ const char *instance_id,
+ const char *const *product_ids,
+ size_t num_product_ids,
+ const uint64_t *categories,
+ size_t num_categories,
+ TALER_MERCHANTDB_InventoryProductCallback cb,
+ void *cb_cls);
+
+ /**
+ * Call @a cb on each exchange we have in the database.
+ *
+ * @param cls closure
+ * @param cb callback to invoke
+ * @param cb_cls closure for @a cb
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_exchanges) (void *cls,
+ TALER_MERCHANTDB_ExchangesCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup details about a particular product.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup products for
+ * @param product_id product to lookup
+ * @param[out] pd set to the product details on success, can be NULL
+ * (in that case we only want to check if the product exists)
+ * @param[out] num_categories set to length of @a categories array
+ * @param[out] categories set to array of categories the
+ * product is in, caller must free() it.
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_product)(void *cls,
+ const char *instance_id,
+ const char *product_id,
+ struct TALER_MERCHANTDB_ProductDetails *pd,
+ size_t *num_categories,
+ uint64_t **categories);
+
+ /**
+ * Lookup product image by its hash.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup products for
+ * @param image_hash lowercase hexadecimal representation of the SHA256 hash
+ * @param[out] image set to base64-encoded data URL on success, caller must free()
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_product_image_by_hash)(void *cls,
+ const char *instance_id,
+ const char *image_hash,
+ char **image);
+
+ /**
+ * Delete information about a product. Note that the transaction must
+ * enforce that no stocks are currently locked.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete product of
+ * @param product_id product to delete
+ * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * if locks prevent deletion OR product unknown
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_product)(void *cls,
+ const char *instance_id,
+ const char *product_id);
+
+ /**
+ * Insert details about a particular product.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert product for
+ * @param product_id product identifier of product to insert
+ * @param pd the product details to insert
+ * @param num_cats length of @a cats array
+ * @param cats array of categories the product is in
+ * @param[out] no_instance set to true if @a instance_id is unknown
+ * @param[out] conflict set to true if a conflicting
+ * product already exists in the database
+ * @param[out] no_cat set to index of non-existing category from @a cats, or -1 if all @a cats were found
+ * @param[out] no_group set to true if the product group in @a pd is unknown
+ * @param[out] no_pot set to true if the money pot in @a pd is unknown
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_product)(void *cls,
+ const char *instance_id,
+ const char *product_id,
+ const struct TALER_MERCHANTDB_ProductDetails *pd,
+ size_t num_cats,
+ const uint64_t *cats,
+ bool *no_instance,
+ bool *conflict,
+ ssize_t *no_cat,
+ bool *no_group,
+ bool *no_pot);
+
+ /**
+ * Update details about a particular product. Note that the
+ * transaction must enforce that the sold/stocked/lost counters
+ * are not reduced (i.e. by expanding the WHERE clause on the existing
+ * values).
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup products for
+ * @param product_id product to lookup
+ * @param pd product details with updated values
+ * @param num_cats length of @a cats array
+ * @param cats number of categories the product is in
+ * @param[out] no_instance the update failed as the instance is unknown
+ * @param[out] no_cat set to -1 on success, otherwise the update failed and this is set
+ * to the index of a category in @a cats that is unknown
+ * @param[out] no_product the @a product_id is unknown
+ * @param[out] lost_reduced the update failed as the counter of units lost would have been lowered
+ * @param[out] sold_reduced the update failed as the counter of units sold would have been lowered
+ * @param[out] stocked_reduced the update failed as the counter of units stocked would have been lowered
+ * @param[out] no_group set to true if the product group in @a pd is unknown
+ * @param[out] no_pot set to true if the money pot in @a pd is unknown
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_product)(void *cls,
+ const char *instance_id,
+ const char *product_id,
+ const struct TALER_MERCHANTDB_ProductDetails *pd,
+ size_t num_cats,
+ const uint64_t *cats,
+ bool *no_instance,
+ ssize_t *no_cat,
+ bool *no_product,
+ bool *lost_reduced,
+ bool *sold_reduced,
+ bool *stocked_reduced,
+ bool *no_group,
+ bool *no_pot);
+
+
+ /**
+ * Lock stocks of a particular product. Note that the transaction must
+ * enforce that the "stocked-sold-lost >= locked" constraint holds.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup products for
+ * @param product_id product to lookup
+ * @param uuid the UUID that holds the lock
+ * @param quantity how many units should be locked
+ * @param quantity_frac fractional component of units to lock, in units of
+ * 1/1000000 of the base value
+ * @param expiration_time when should the lock expire
+ * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the
+ * product is unknown OR if there insufficient stocks remaining
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lock_product)(void *cls,
+ const char *instance_id,
+ const char *product_id,
+ const struct GNUNET_Uuid *uuid,
+ uint64_t quantity,
+ uint32_t quantity_frac,
+ struct GNUNET_TIME_Timestamp expiration_time);
+
+
+ /**
+ * Release all expired product locks, including
+ * those from expired offers -- across all
+ * instances.
+ *
+ * @param cls closure
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*expire_locks)(void *cls);
+
+
+ /**
+ * Delete information about an order. Note that the transaction must
+ * enforce that the order is not awaiting payment anymore.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete order of
+ * @param order_id order to delete
+ * @param force force deletion of claimed but unpaid orders
+ * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * if locks prevent deletion OR order unknown
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_order)(void *cls,
+ const char *instance_id,
+ const char *order_id,
+ bool force);
+
+
+ /**
+ * Retrieve order given its @a order_id and the @a instance_id.
+ *
+ * @param cls closure
+ * @param instance_id instance to obtain order of
+ * @param order_id order id used to perform the lookup
+ * @param[out] claim_token the claim token generated for the order,
+ * NULL to only test if the order exists
+ * @param[out] h_post_data set to the hash of the POST data that created the order
+ * @param[out] contract_terms where to store the retrieved contract terms,
+ * NULL to only test if the order exists
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_order)(void *cls,
+ const char *instance_id,
+ const char *order_id,
+ struct TALER_ClaimTokenP *claim_token,
+ struct TALER_MerchantPostDataHashP *h_post_data,
+ json_t **contract_terms);
+
+
+ /**
+ * Retrieve order summary given its @a order_id and the @a instance_id.
+ *
+ * @param cls closure
+ * @param instance_id instance to obtain order of
+ * @param order_id order id used to perform the lookup
+ * @param[out] timestamp when was the order created
+ * @param[out] order_serial under which serial do we keep this order
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_order_summary)(void *cls,
+ const char *instance_id,
+ const char *order_id,
+ struct GNUNET_TIME_Timestamp *timestamp,
+ uint64_t *order_serial);
+
+
+ /**
+ * Retrieve orders given the @a instance_id.
+ *
+ * @param cls closure
+ * @param instance_id instance to obtain order of
+ * @param of filter to apply when looking up orders
+ * @param[out] contract_terms where to store the retrieved contract terms,
+ * NULL to only test if the order exists
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_orders)(void *cls,
+ const char *instance_id,
+ const struct TALER_MERCHANTDB_OrderFilter *of,
+ TALER_MERCHANTDB_OrdersCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Insert order into db.
+ *
+ * @param cls closure
+ * @param instance_id identifies the instance responsible for the order
+ * @param order_id alphanumeric string that uniquely identifies the order
+ * @param session_id session ID for the order
+ * @param h_post_data hash of the POST data for idempotency checks
+ * @param pay_deadline how long does the customer have to pay for the order
+ * @param claim_token token to use for access control
+ * @param contract_terms proposal data to store
+ * @param pos_key encoded key for payment verification
+ * @param pos_algorithm algorithm to compute the payment verification
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_order)(void *cls,
+ const char *instance_id,
+ const char *order_id,
+ const char *session_id,
+ const struct TALER_MerchantPostDataHashP *h_post_data,
+ struct GNUNET_TIME_Timestamp pay_deadline,
+ const struct TALER_ClaimTokenP *claim_token,
+ const json_t *contract_terms,
+ const char *pos_key,
+ enum TALER_MerchantConfirmationAlgorithm pos_algorithm);
+
+
+ /**
+ * Insert unclaim signature into DB and unclaim the order.
+ *
+ * @param cls closure
+ * @param instance_id instance of the operation (checked)
+ * @param merchant_pub public key of the instance (for notifications)
+ * @param order_id identifies the order to unclaim
+ * @param nonce claim nonce of the original claim
+ * @param h_contract hash of the contract to unclaim
+ * @param nsig signature by the nonce private key authorizing the unclaim
+ * @return transaction status, 0 if an order with this @a nonce
+ * and @a h_contract was not found; 1 if the request is idempotent
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_unclaim_signature)(
+ void *cls,
+ const char *instance_id,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const char *order_id,
+ const struct GNUNET_CRYPTO_EddsaPublicKey *nonce,
+ const struct GNUNET_HashCode *h_contract,
+ const struct GNUNET_CRYPTO_EddsaSignature *nsig);
+
+
+ /**
+ * Insert blinded signatures for an order.
+ *
+ * @param cls closure
+ * @param order_id order ID to insert blinded signatures for
+ * @param i index of the blinded signature in the output array
+ * @param hash hash of the token
+ * @param blinded_sigs JSON array of blinded signatures
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_order_blinded_sigs)(
+ void *cls,
+ const char *order_id,
+ uint32_t i,
+ const struct GNUNET_HashCode *hash,
+ const struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
+
+
+ /**
+ * Release an inventory lock by UUID. Releases ALL stocks locked under
+ * the given UUID.
+ *
+ * @param cls closure
+ * @param uuid the UUID to release locks for
+ * @return transaction status,
+ * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS means there are no locks under @a uuid
+ * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT indicates success
+ */
+ enum GNUNET_DB_QueryStatus
+ (*unlock_inventory)(void *cls,
+ const struct GNUNET_Uuid *uuid);
+
+
+ /**
+ * Lock inventory stock to a particular order.
+ *
+ * @param cls closure
+ * @param instance_id identifies the instance responsible for the order
+ * @param order_id alphanumeric string that uniquely identifies the order
+ * @param product_id uniquely identifies the product to be locked
+ * @param quantity how many units should be locked to the @a order_id
+ * @param quantity_frac fractional component of the quantity to be locked,
+ * in units of 1/1000000 of the base value
+ * @return transaction status,
+ * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS means there are insufficient stocks
+ * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT indicates success
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_order_lock)(void *cls,
+ const char *instance_id,
+ const char *order_id,
+ const char *product_id,
+ uint64_t quantity,
+ uint32_t quantity_frac);
+
+
+ /**
+ * Select blinded signatures for an order.
+ *
+ * @param cls closure
+ * @param order_id order ID to select blinded signatures for
+ * @param cb callback to call for each blinded signature found
+ * @param cb_cls closure for @a cb
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_order_blinded_sigs)(
+ void *cls,
+ const char *order_id,
+ TALER_MERCHANTDB_BlindedSigCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Retrieve contract terms given its @a order_id
+ *
+ * @param cls closure
+ * @param instance_id instance's identifier
+ * @param order_id order_id used to lookup.
+ * @param[out] contract_terms where to store the result, NULL to only check for existence
+ * @param[out] order_serial set to the order's serial number
+ * @param[out] paid set to true if the order is fully paid
+ * @param[out] claim_token set to the claim token, NULL to only check for existence
+ * @param[out] pos_key encoded key for payment verification
+ * @param[out] pos_algorithm set to algorithm to compute the payment verification
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_contract_terms2)(
+ void *cls,
+ const char *instance_id,
+ const char *order_id,
+ json_t **contract_terms,
+ uint64_t *order_serial,
+ bool *paid,
+ struct TALER_ClaimTokenP *claim_token,
+ char **pos_key,
+ enum TALER_MerchantConfirmationAlgorithm *pricing_algorithm);
+
+
+ /**
+ * Retrieve contract terms given its @a order_id
+ *
+ * @param cls closure
+ * @param instance_id instance's identifier
+ * @param order_id order_id used to lookup
+ * @param session_id session_id to compare, can be NULL
+ * @param[out] contract_terms where to store the result, NULL to only check for existence
+ * @param[out] order_serial set to the order's serial number
+ * @param[out] paid set to true if the order is fully paid
+ * @param[out] wired set to true if the exchange wired the funds
+ * @param[out] session_matches set to true if @a session_id matches session stored for this contract
+ * @param[out] claim_token set to the claim token, NULL to only check for existence
+ * @param[out] choice_index set to the choice index, -1 if not set
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_contract_terms3)(
+ void *cls,
+ const char *instance_id,
+ const char *order_id,
+ const char *session_id,
+ json_t **contract_terms,
+ uint64_t *order_serial,
+ bool *paid,
+ bool *wired,
+ bool *session_matches,
+ struct TALER_ClaimTokenP *claim_token,
+ int16_t *choice_index);
+
+
+ /**
+ * Retrieve contract terms given its @a order_id
+ *
+ * @param cls closure
+ * @param instance_id instance's identifier
+ * @param order_id order_id used to lookup.
+ * @param[out] contract_terms where to store the result, NULL to only check for existence
+ * @param[out] order_serial set to the order's serial number
+ * @param[out] claim_token set to the claim token, NULL to only check for existence
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_contract_terms)(
+ void *cls,
+ const char *instance_id,
+ const char *order_id,
+ json_t **contract_terms,
+ uint64_t *order_serial,
+ struct TALER_ClaimTokenP *claim_token);
+
+
+ /**
+ * Store contract terms given its @a order_id. Note that some attributes are
+ * expected to be calculated inside of the function, like the hash of the
+ * contract terms (to be hashed), the creation_time and pay_deadline (to be
+ * obtained from the merchant_orders table). The "session_id" should be
+ * initially set to the empty string. The "fulfillment_url" and "refund_deadline"
+ * must be extracted from @a contract_terms.
+ *
+ * @param cls closure
+ * @param instance_id instance's identifier
+ * @param order_id order_id used to store
+ * @param claim_token the token belonging to the order
+ * @param[out] order_serial set to the serial of the order
+ * @return transaction status, #GNUNET_DB_STATUS_HARD_ERROR if @a contract_terms
+ * is malformed
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_contract_terms)(
+ void *cls,
+ const char *instance_id,
+ const char *order_id,
+ json_t *contract_terms,
+ uint64_t *order_serial);
+
+
+ /**
+ * Update the contract terms stored for @a order_id. Note that some attributes are
+ * expected to be calculated inside of the function, like the hash of the
+ * contract terms (to be hashed), the creation_time and pay_deadline (to be
+ * obtained from the merchant_orders table). The "session_id" should be
+ * initially set to the empty string. The "fulfillment_url" and "refund_deadline"
+ * must be extracted from @a contract_terms.
+ *
+ * @param cls closure
+ * @param instance_id instance's identifier
+ * @param order_id order_id used to store
+ * @param contract_terms contract to store
+ * @return transaction status, #GNUNET_DB_STATUS_HARD_ERROR if @a contract_terms
+ * is malformed
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_contract_terms)(void *cls,
+ const char *instance_id,
+ const char *order_id,
+ json_t *contract_terms);
+
+
+ /**
+ * Delete information about a contract. Note that the transaction must
+ * enforce that the contract is not awaiting payment anymore AND was not
+ * paid, or is past the legal expiration.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete order of
+ * @param order_id order to delete
+ * @param legal_expiration how long do we need to keep (paid) contracts on
+ * file for legal reasons (i.e. taxation)
+ * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * if locks prevent deletion OR order unknown
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_contract_terms)(void *cls,
+ const char *instance_id,
+ const char *order_id,
+ struct GNUNET_TIME_Relative legal_expiration);
+
+
+ /**
+ * Lookup information about coins that were successfully deposited for a
+ * given contract.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup deposits for
+ * @param h_contract_terms proposal data's hashcode
+ * @param cb function to call with payment data
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_deposits)(void *cls,
+ const char *instance_id,
+ const struct TALER_PrivateContractHashP *h_contract_terms
+ ,
+ TALER_MERCHANTDB_DepositsCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Insert an exchange signing key into our database.
+ *
+ * @param cls closure
+ * @param master_pub exchange master public key used for @a master_sig
+ * @param exchange_pub exchange signing key to insert
+ * @param start_date when does the signing key become valid
+ * @param expire_date when does the signing key stop being used
+ * @param end_date when does the signing key become void as proof
+ * @param master_sig signature of @a master_pub over the @a exchange_pub and the dates
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_exchange_signkey)(
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const struct TALER_ExchangePublicKeyP *exchange_pub,
+ struct GNUNET_TIME_Timestamp start_date,
+ struct GNUNET_TIME_Timestamp expire_date,
+ struct GNUNET_TIME_Timestamp end_date,
+ const struct TALER_MasterSignatureP *master_sig);
+
+
+ /**
+ * Insert deposit confirmation from the exchange into the database.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup deposits for
+ * @param deposit_timestamp time when the exchange generated the deposit confirmation
+ * @param h_contract_terms proposal data's hashcode
+ * @param exchange_url URL of the exchange that issued @a coin_pub
+ * @param wire_transfer_deadline when do we expect the wire transfer from the exchange
+ * @param total_without_fees deposited total in the batch without fees
+ * @param wire_fee wire fee the exchange charges
+ * @param h_wire hash of the wire details of the target account of the merchant
+ * @param exchange_sig signature from exchange that coin was accepted
+ * @param exchange_pub signing key that was used for @a exchange_sig
+ * @param[out] batch_deposit_serial_id set to the table row
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_deposit_confirmation)(
+ void *cls,
+ const char *instance_id,
+ struct GNUNET_TIME_Timestamp deposit_timestamp,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const char *exchange_url,
+ struct GNUNET_TIME_Timestamp wire_transfer_deadline,
+ const struct TALER_Amount *total_without_fees,
+ const struct TALER_Amount *wire_fee,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const struct TALER_ExchangeSignatureP *exchange_sig,
+ const struct TALER_ExchangePublicKeyP *exchange_pub,
+ uint64_t *batch_deposit_serial_id);
+
+
+ /**
+ * Insert information about coin deposited as part of
+ * a batch into the database.
+ *
+ * @param cls closure
+ * @param offset offset of the coin in the batch
+ * @param deposit_confirmation_serial_id deposit confirmation for the batch the coin is part of
+ * @param coin_pub public key of the coin
+ * @param coin_sig deposit signature of the coin
+ * @param amount_with_fee amount the exchange will deposit for this coin
+ * @param deposit_fee fee the exchange will charge for this coin
+ * @param refund_fee fee the exchange will charge for refunds of coin
+ * @param check_time at what time should we check the deposit status
+ * with the exchange (for settlement)
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_deposit)(
+ void *cls,
+ uint32_t offset,
+ uint64_t deposit_confirmation_serial_id,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const struct TALER_CoinSpendSignatureP *coin_sig,
+ const struct TALER_Amount *amount_with_fee,
+ const struct TALER_Amount *deposit_fee,
+ const struct TALER_Amount *refund_fee,
+ struct GNUNET_TIME_Absolute check_time);
+
+
+ /**
+ * Obtain refunds associated with a contract.
+ *
+ * @param cls closure, typically a connection to the db
+ * @param instance_id instance to lookup refunds for
+ * @param h_contract_terms hash code of the contract
+ * @param rc function to call for each coin on which there is a refund
+ * @param rc_cls closure for @a rc
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_refunds)(void *cls,
+ const char *instance_id,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ TALER_MERCHANTDB_RefundCallback rc,
+ void *rc_cls);
+
+
+ /**
+ * Retrieve details about tokens that were used for an order.
+ *
+ * @param cls closure
+ * @param order_serial identifies the order
+ * @param cb function to call for each used token
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_spent_tokens_by_order)(void *cls,
+ uint64_t order_serial,
+ TALER_MERCHANTDB_UsedTokensCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Mark contract as paid and store the current @a session_id
+ * for which the contract was paid. Deletes the underlying order
+ * and marks the locked stocks of the order as sold.
+ *
+ * @param cls closure
+ * @param instance_id instance to mark contract as paid for
+ * @param h_contract_terms hash of the contract that is now paid
+ * @param session_id the session that paid the contract
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*mark_contract_paid)(
+ void *cls,
+ const char *instance_id,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const char *session_id,
+ int16_t choice_index);
+
+
+ /**
+ * Update session associated with a contract and return
+ * the fulfillment URL and the refund status.
+ *
+ * @param cls closure
+ * @param instance_id instance to mark contract as paid for
+ * @param h_contract_terms hash of the contract that is now paid
+ * @param session_id the session that paid the contract
+ * @param[out] fulfillment_url set to the fulfillment URL (possibly NULL)
+ * @param[out] refunded set to true if the order was refunded
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_contract_session)(
+ void *cls,
+ const char *instance_id,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const char *session_id,
+ char **fulfillment_url,
+ bool *refunded);
+
+
+ /**
+ * Function called during aborts to refund a coin. Marks the
+ * respective coin as refunded.
+ *
+ * @param cls closure
+ * @param instance_id instance to refund payment for
+ * @param h_contract_terms hash of the contract to refund coin for
+ * @param refund_timestamp timestamp of when the coin was refunded
+ * @param coin_pub public key of the coin to refund (fully)
+ * @param reason text justifying the refund
+ * @return transaction status
+ * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if @a coin_pub is unknown to us;
+ * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if the request is valid,
+ * regardless of whether it actually increased the refund
+ */
+ enum GNUNET_DB_QueryStatus
+ (*refund_coin)(void *cls,
+ const char *instance_id,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ struct GNUNET_TIME_Timestamp refund_timestamp,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const char *reason);
+
+
+ /**
+ * Retrieve contract terms given its @a order_id
+ *
+ * @param cls closure
+ * @param instance_id instance's identifier
+ * @param order_id order to lookup contract for
+ * @param[out] h_contract_terms set to the hash of the contract.
+ * @param[out] paid set to the payment status of the contract
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_order_status)(void *cls,
+ const char *instance_id,
+ const char *order_id,
+ struct TALER_PrivateContractHashP *h_contract_terms,
+ bool *paid);
+
+ /**
+ * Retrieve contract terms given its @a order_serial
+ *
+ * @param cls closure
+ * @param instance_id instance's identifier
+ * @param order_serial serial ID of the order to look up
+ * @param[out] order_id set to ID of the order
+ * @param[out] h_contract_terms set to the hash of the contract.
+ * @param[out] paid set to the payment status of the contract
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_order_status_by_serial)(void *cls,
+ const char *instance_id,
+ uint64_t order_serial,
+ char **order_id,
+ struct TALER_PrivateContractHashP *
+ h_contract_terms,
+ bool *paid);
+
+
+ /**
+ * Retrieve details about coins that were deposited for an order.
+ *
+ * @param cls closure
+ * @param order_serial identifies the order
+ * @param cb function to call for each deposited coin
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_deposits_by_order)(void *cls,
+ uint64_t order_serial,
+ TALER_MERCHANTDB_DepositedCoinsCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Retrieve wire transfer details for all deposits associated with
+ * a given @a order_serial.
+ *
+ * @param cls closure
+ * @param order_serial identifies the order
+ * @param cb function called with the wire transfer details
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_transfer_details_by_order)(
+ void *cls,
+ uint64_t order_serial,
+ TALER_MERCHANTDB_OrderTransferDetailsCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Update transfer status.
+ *
+ * @param cls closure
+ * @param exchange_url the exchange that made the transfer
+ * @param wtid wire transfer subject
+ * @param next_attempt when should we try again (if ever)
+ * @param http_status last HTTP status code from the server, 0 for timeout
+ * @param ec current error state of checking the transfer
+ * @param detail last error detail from the server, possibly NULL
+ * @param needs_retry true if we should retry the request
+ * @return database transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_transfer_status)(
+ void *cls,
+ const char *exchange_url,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ struct GNUNET_TIME_Absolute next_attempt,
+ unsigned int http_status,
+ enum TALER_ErrorCode ec,
+ const char *detail,
+ bool needs_retry);
+
+
+ /**
+ * Finalize transfer status with success.
+ *
+ * @param cls closure
+ * @param exchange_url the exchange that made the transfer
+ * @param wtid wire transfer subject
+ * @param h_details hash over all of the aggregated deposits
+ * @param total_amount total amount exchange claimed to have transferred
+ * @param wire_fee wire fee charged by the exchange
+ * @param exchange_pub key used to make @e exchange_sig
+ * @param exchange_sig signature of the exchange over reconciliation data
+ * @return database transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*finalize_transfer_status)(
+ void *cls,
+ const char *exchange_url,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct GNUNET_HashCode *h_details,
+ const struct TALER_Amount *total_amount,
+ const struct TALER_Amount *wire_fee,
+ const struct TALER_ExchangePublicKeyP *exchange_pub,
+ const struct TALER_ExchangeSignatureP *exchange_sig);
+
+
+ /**
+ * Retrieve wire transfer details of wire details
+ * that taler-merchant-exchange still needs to
+ * investigate.
+ *
+ * @param cls closure
+ * @param limit maximum number of results to return
+ * @param cb function called with the wire transfer data
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_open_transfers)(
+ void *cls,
+ uint64_t limit,
+ TALER_MERCHANTDB_OpenTransferCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Insert wire transfer details for a deposit.
+ *
+ * @param cls closure
+ * @param deposit_serial serial number of the deposit
+ * @param h_wire hash of the merchant's account that should receive the deposit
+ * @param exchange_url URL of the exchange that is making the deposit
+ * @param dd deposit transfer data from the exchange to store
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_deposit_to_transfer)(void *cls,
+ uint64_t deposit_serial,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ const struct TALER_EXCHANGE_DepositData *dd);
+
+
+ /**
+ * Set 'wired' status for an order to 'true'.
+ *
+ * @param cls closure
+ * @param order_serial serial number of the order
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*mark_order_wired)(void *cls,
+ uint64_t order_serial);
+
+
+ /**
+ * Function called when some backoffice staff decides to award or
+ * increase the refund on an existing contract. This function
+ * MUST be called from within a transaction scope setup by the
+ * caller as it executes multiple SQL statements.
+ *
+ * @param cls closure
+ * @param instance_id instance identifier
+ * @param order_id the order to increase the refund for
+ * @param refund maximum refund to return to the customer for this contract
+ * @param olc function to call to obtain legal refund
+ * limits per exchange, NULL for no limits
+ * @param olc_cls closure for @a olc
+ * @param reason 0-terminated UTF-8 string giving the reason why the customer
+ * got a refund (free form, business-specific)
+ * @return transaction status
+ * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if @a refund is ABOVE the amount we
+ * were originally paid and thus the transaction failed;
+ * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if the request is valid,
+ * regardless of whether it actually increased the refund beyond
+ * what was already refunded (idempotency!)
+ */
+ enum TALER_MERCHANTDB_RefundStatus
+ (*increase_refund)(
+ void *cls,
+ const char *instance_id,
+ const char *order_id,
+ const struct TALER_Amount *refund,
+ TALER_MERCHANTDB_OperationLimitCallback olc,
+ void *olc_cls,
+ const char *reason);
+
+
+ /**
+ * Obtain detailed refund data associated with a contract.
+ *
+ * @param cls closure, typically a connection to the db
+ * @param instance_id instance to lookup refunds for
+ * @param h_contract_terms hash code of the contract
+ * @param rc function to call for each coin on which there is a refund
+ * @param rc_cls closure for @a rc
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_refunds_detailed)(
+ void *cls,
+ const char *instance_id,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ TALER_MERCHANTDB_RefundDetailCallback rc,
+ void *rc_cls);
+
+ /**
+ * Insert refund proof data from the exchange into the database.
+ *
+ * @param cls closure
+ * @param refund_serial serial number of the refund
+ * @param exchange_sig signature from exchange that coin was refunded
+ * @param exchange_pub signing key that was used for @a exchange_sig
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_refund_proof)(
+ void *cls,
+ uint64_t refund_serial,
+ const struct TALER_ExchangeSignatureP *exchange_sig,
+ const struct TALER_ExchangePublicKeyP *exchange_pub);
+
+
+ /**
+ * Insert used token into the database.
+ *
+ * @param cls closure
+ * @param h_contract_terms hash of the contract the token was used for
+ * @param h_issue_pub hash of the token issue public key
+ * @param use_pub token use public key
+ * @param use_sig token use signature
+ * @param issue_sig token issue signature
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_spent_token)(
+ void *cls,
+ const struct TALER_PrivateContractHashP *
+ h_contract_terms,
+ const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub,
+ const struct TALER_TokenUsePublicKeyP *use_pub,
+ const struct TALER_TokenUseSignatureP *use_sig,
+ const struct TALER_TokenIssueSignature *issue_sig);
+
+
+ /**
+ * Insert issued token into the database.
+ *
+ * @param cls closure
+ * @param h_contract_terms hash of the contract the token was issued for
+ * @param h_issue_pub hash of the token issue public key used to sign the issued token
+ * @param blind_sig resulting blind token issue signature
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_issued_token)(
+ void *cls,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub,
+ const struct TALER_BlindedTokenIssueSignature *blind_sig);
+
+
+ /**
+ * Lookup refund proof data.
+ *
+ * @param cls closure
+ * @param refund_serial serial number of the refund
+ * @param[out] exchange_sig set to signature from exchange
+ * @param[out] exchange_pub signing key that was used for @a exchange_sig
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_refund_proof)(
+ void *cls,
+ uint64_t refund_serial,
+ struct TALER_ExchangeSignatureP *exchange_sig,
+ struct TALER_ExchangePublicKeyP *exchange_pub);
+
+
+ /**
+ * Retrieve the order ID that was used to pay for a resource within a session.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup the order from
+ * @param fulfillment_url URL that canonically identifies the resource
+ * being paid for
+ * @param session_id session id
+ * @param allow_refunded_for_repurchase true to include refunded orders in repurchase detection
+ * @param[out] order_id location to store the order ID that was used when
+ * paying for the resource URL
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_order_by_fulfillment)(
+ void *cls,
+ const char *instance_id,
+ const char *fulfillment_url,
+ const char *session_id,
+ bool allow_refunded_for_repurchase,
+ char **order_id);
+
+ /**
+ * Update information about progress made by taler-merchant-wirewatch.
+ *
+ * @param cls closure
+ * @param instance which instance does the account belong to
+ * @param payto_uri which account is this about
+ * @param last_serial last serial imported from the bank
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_wirewatch_progress)(
+ void *cls,
+ const char *instance,
+ struct TALER_FullPayto payto_uri,
+ uint64_t last_serial);
+
+
+ /**
+ * Select information about accounts which taler-merchant-wirewatch should work on.
+ *
+ * @param cls closure
+ * @param cb function to call with results
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_wirewatch_accounts)(
+ void *cls,
+ TALER_MERCHANTDB_WirewatchWorkCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Insert information about a wire transfer the merchant has received.
+ * Idempotent, will do nothing if the same wire transfer is already known.
+ * Updates the @a bank_serial_id if an equivalent transfer exists where
+ * the @a bank_serial_id was set to 0 (unknown).
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup the order from
+ * @param exchange_url which exchange made the transfer
+ * @param wtid identifier of the wire transfer
+ * @param credit_amount how much did we receive
+ * @param payto_uri what is the merchant's bank account that received the transfer
+ * @param bank_serial_id bank serial transfer ID, 0 for none (use NULL in DB!)
+ * @param[out] no_instance instance unknown to backend
+ * @param[out] no_account bank account with @a payto_uri unknown to backend
+ * @param[out] conflict transfer with same @a wtid but different @a credit_amount exists
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_transfer)(
+ void *cls,
+ const char *instance_id,
+ const char *exchange_url,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_Amount *credit_amount,
+ struct TALER_FullPayto payto_uri,
+ uint64_t bank_serial_id,
+ bool *no_instance,
+ bool *no_account,
+ bool *conflict);
+
+
+ /**
+ * Delete information about a transfer. Note that transfers
+ * confirmed by the exchange cannot be deleted anymore.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete transfer of
+ * @param transfer_serial_id transfer to delete
+ * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * if deletion is prohibited OR transfer is unknown
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_transfer)(void *cls,
+ const char *instance_id,
+ uint64_t transfer_serial_id);
+
+
+ /**
+ * Check if information about a transfer exists with the
+ * backend. Returns no data, only the query status.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete transfer of
+ * @param transfer_serial_id transfer to delete
+ * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT
+ * if the transfer record exists
+ */
+ enum GNUNET_DB_QueryStatus
+ (*check_transfer_exists)(void *cls,
+ const char *instance_id,
+ uint64_t transfer_serial_id);
+
+
+ /**
+ * Lookup account serial by payto URI.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup the account from
+ * @param payto_uri what is the merchant's bank account to lookup
+ * @param[out] account_serial serial number of the account
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_account)(void *cls,
+ const char *instance_id,
+ struct TALER_FullPayto payto_uri,
+ uint64_t *account_serial);
+
+
+ /**
+ * Insert information about a wire transfer the merchant has received.
+ *
+ * @param cls closure
+ * @param instance_id instance to provide transfer details for
+ * @param exchange_url which exchange made the transfer
+ * @param payto_uri what is the merchant's bank account that received the transfer
+ * @param wtid identifier of the wire transfer
+ * @param td transfer details to store
+ * @return transaction status,
+ * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the @a wtid and @a exchange_uri are not known for this @a instance_id
+ * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT on success
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_transfer_details)(
+ void *cls,
+ const char *instance_id,
+ const char *exchange_url,
+ struct TALER_FullPayto payto_uri,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_EXCHANGE_TransferData *td);
+
+
+ /**
+ * Obtain information about wire fees charged by an exchange,
+ * including signature (so we have proof).
+ *
+ * @param cls closure
+ * @param master_pub master public key of the exchange
+ * @param h_wire_method hash of wire method
+ * @param contract_date date of the contract to use for the lookup
+ * @param[out] fees set to wire fees charged
+ * @param[out] start_date start of fee being used
+ * @param[out] end_date end of fee being used
+ * @param[out] master_sig signature of exchange over fee structure
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_wire_fee)(
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const char *wire_method,
+ struct GNUNET_TIME_Timestamp contract_date,
+ struct TALER_WireFeeSet *fees,
+ struct GNUNET_TIME_Timestamp *start_date,
+ struct GNUNET_TIME_Timestamp *end_date,
+ struct TALER_MasterSignatureP *master_sig);
+
+
+ /**
+ * Obtain information about an expected incoming wire transfer.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup payments for
+ * @param expected_incoming_serial serial number of the transfer
+ * @param[out] expected_time expected date of the transfer
+ * @param[out] wtid expected wire transfer subject
+ * @param[out] payto_uri target bank account
+ * @param[out] exchange_url URL of the exchange
+ * @param[out] execution_time, set to 0 if unknown
+ * @param[out] confirmed set if the transfer was confirmed
+ * @param[out] master_pub master public key of the exchange
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_expected_transfer)(
+ void *cls,
+ const char *instance_id,
+ uint64_t expected_incoming_serial,
+ struct GNUNET_TIME_Timestamp *expected_time,
+ struct TALER_Amount *expected_credit_amount,
+ struct TALER_WireTransferIdentifierRawP *wtid,
+ struct TALER_FullPayto *payto_uri,
+ char **exchange_url,
+ struct GNUNET_TIME_Timestamp *execution_time,
+ bool *confirmed,
+ struct TALER_MasterPublicKeyP *master_pub);
+
+
+ /**
+ * Obtain reconciliation details for an expected incoming wire transfer.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup payments for
+ * @param expected_incoming_serial serial number of the transfer
+ * @param cb callback to invoke
+ * @param cb_cls closure for @a cb
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_reconciliation_details)(
+ void *cls,
+ const char *instance_id,
+ uint64_t expected_incoming_serial,
+ TALER_MERCHANTDB_ReconciliationDetailsCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup information about coin payments by @a h_contract_terms and
+ * @a coin_pub.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup payments for
+ * @param h_contract_terms proposal data's hashcode
+ * @param coin_pub public key to use for the search
+ * @param cb function to call with payment data
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_deposits_by_contract_and_coin)(
+ void *cls,
+ const char *instance_id,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ TALER_MERCHANTDB_CoinDepositCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup transfer summary (used if we already verified the details).
+ *
+ * @param cls closure
+ * @param exchange_url the exchange that made the transfer
+ * @param wtid wire transfer subject
+ * @param cb function to call with detailed transfer data
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_transfer_summary)(
+ void *cls,
+ const char *exchange_url,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ TALER_MERCHANTDB_TransferSummaryCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup transfer details. Used if we still need to verify the details.
+ *
+ * @param cls closure
+ * @param exchange_url the exchange that made the transfer
+ * @param wtid wire transfer subject
+ * @param cb function to call with detailed transfer data
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_transfer_details)(
+ void *cls,
+ const char *exchange_url,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ TALER_MERCHANTDB_TransferDetailsCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup transfers.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup payments for
+ * @param payto_uri account that we are interested in transfers to
+ * @param before timestamp for the earliest transfer we care about
+ * @param after timestamp for the last transfer we care about
+ * @param limit number of entries to return, negative for descending in execution time,
+ * positive for ascending in execution time
+ * @param offset transfer_serial number of the transfer we want to offset from
+ * @param expected filter for transfers that were expected
+ * @param cb function to call with detailed transfer data
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_transfers)(
+ void *cls,
+ const char *instance_id,
+ struct TALER_FullPayto payto_uri,
+ struct GNUNET_TIME_Timestamp before,
+ struct GNUNET_TIME_Timestamp after,
+ int64_t limit,
+ uint64_t offset,
+ enum TALER_EXCHANGE_YesNoAll expected,
+ TALER_MERCHANTDB_TransferCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup expected incoming transfers.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup payments for
+ * @param payto_uri account that we are interested in transfers to
+ * @param before timestamp for the earliest transfer we care about
+ * @param after timestamp for the last transfer we care about
+ * @param limit number of entries to return, negative for descending in execution time,
+ * positive for ascending in execution time
+ * @param offset expected_transfer_serial number of the transfer we want to offset from
+ * @param confirmed filter by confirmation status
+ * @param verified filter by verification status
+ * @param cb function to call with detailed transfer data
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_expected_transfers)(
+ void *cls,
+ const char *instance_id,
+ struct TALER_FullPayto payto_uri,
+ struct GNUNET_TIME_Timestamp before,
+ struct GNUNET_TIME_Timestamp after,
+ int64_t limit,
+ uint64_t offset,
+ enum TALER_EXCHANGE_YesNoAll confirmed,
+ enum TALER_EXCHANGE_YesNoAll verified,
+ TALER_MERCHANTDB_IncomingCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Store information about wire fees charged by an exchange,
+ * including signature (so we have proof).
+ *
+ * @param cls closure
+ * @param master_pub master public key of the exchange
+ * @param h_wire_method hash of wire method
+ * @param fees wire fees charged
+ * @param start_date start of fee being used
+ * @param end_date end of fee being used
+ * @param master_sig signature of exchange over fee structure
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*store_wire_fee_by_exchange)(
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const struct GNUNET_HashCode *h_wire_method,
+ const struct TALER_WireFeeSet *fees,
+ struct GNUNET_TIME_Timestamp start_date,
+ struct GNUNET_TIME_Timestamp end_date,
+ const struct TALER_MasterSignatureP *master_sig);
+
+
+ /**
+ * Delete information about wire accounts of an exchange. (Used when we got new account data.)
+ *
+ * @param cls closure
+ * @param master_pub public key of the exchange
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_exchange_accounts)(
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub);
+
+
+ /**
+ * Return information about wire accounts of an exchange.
+ *
+ * @param cls closure
+ * @param master_pub public key of the exchange
+ * @param cb function to call on each account
+ * @param cb_cls closure for @a cb
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_accounts_by_exchange)(
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ TALER_MERCHANTDB_ExchangeAccountCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Insert information about a wire account of an exchange.
+ *
+ * @param cls closure
+ * @param master_pub public key of the exchange
+ * @param payto_uri URI of the bank account
+ * @param conversion_url conversion service, NULL if there is no conversion required
+ * @param debit_restrictions JSON array of debit restrictions on the account
+ * @param credit_restrictions JSON array of debit restrictions on the account
+ * @param master_sig signature affirming the account of the exchange
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_exchange_account)(
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const struct TALER_FullPayto payto_uri,
+ const char *conversion_url,
+ const json_t *debit_restrictions,
+ const json_t *credit_restrictions,
+ const struct TALER_MasterSignatureP *master_sig);
+
+
+ /**
+ * Lookup all of the templates the given instance has configured.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup template for
+ * @param cb function to call on all template found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_templates)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_TemplatesCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup details about a particular template.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup template for
+ * @param template_id template to lookup
+ * @param[out] td set to the template details on success, can be NULL
+ * (in that case we only want to check if the template exists)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_template)(void *cls,
+ const char *instance_id,
+ const char *template_id,
+ struct TALER_MERCHANTDB_TemplateDetails *td);
+
+ /**
+ * Delete information about a template.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete template of
+ * @param template_id template to delete
+ * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * if template unknown.
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_template)(void *cls,
+ const char *instance_id,
+ const char *template_id);
+
+
+ /**
+ * Insert details about a particular template.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert template for
+ * @param template_id template identifier of template to insert
+ * @param otp_serial_id 0 if no OTP device is associated
+ * @param td the template details to insert
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_template)(void *cls,
+ const char *instance_id,
+ const char *template_id,
+ uint64_t otp_serial_id,
+ const struct TALER_MERCHANTDB_TemplateDetails *td);
+
+
+ /**
+ * Update details about a particular template.
+ *
+ * @param cls closure
+ * @param instance_id instance to update template for
+ * @param template_id template to update
+ * @param td update to the template details on success, can be NULL
+ * (in that case we only want to check if the template exists)
+ * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the template
+ * does not yet exist.
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_template)(void *cls,
+ const char *instance_id,
+ const char *template_id,
+ const struct TALER_MERCHANTDB_TemplateDetails *td);
+
+
+ /**
+ * Delete information about an OTP device.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete OTP device of
+ * @param otp_id otp device to delete
+ * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * if template unknown.
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_otp)(void *cls,
+ const char *instance_id,
+ const char *otp_id);
+
+ /**
+ * Insert details about a particular OTP device.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert OTP device for
+ * @param otp_id otp identifier of OTP device to insert
+ * @param td the OTP device details to insert
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_otp)(void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ const struct TALER_MERCHANTDB_OtpDeviceDetails *td);
+
+
+ /**
+ * Update details about a particular OTP device.
+ *
+ * @param cls closure
+ * @param instance_id instance to update OTP device for
+ * @param otp_id OTP device to update
+ * @param td update to the OTP device details on success, can be NULL
+ * (in that case we only want to check if the template exists)
+ * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the template
+ * does not yet exist.
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_otp)(void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ const struct TALER_MERCHANTDB_OtpDeviceDetails *td);
+
+ /**
+ * Lookup all of the OTP devices the given instance has configured.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup OTP devices for
+ * @param cb function to call on all OTP devices found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_otp_devices)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_OtpDeviceCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup details about an OTP device.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup template for
+ * @param otp_id OTP device to lookup
+ * @param[out] td set to the OTP device details on success, can be NULL
+ * (in that case we only want to check if the template exists)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_otp)(void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ struct TALER_MERCHANTDB_OtpDeviceDetails *td);
+
+
+ /**
+ * Lookup serial number of an OTP device.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup template for
+ * @param otp_id OTP device to lookup
+ * @param[out] serial set to the OTP device serial number * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_otp_serial)(void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ uint64_t *serial);
+
+ /**
+ * Delete information about a measurement unit.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete unit from
+ * @param unit_id symbolic identifier of the unit
+ * @param[out] no_instance set to true if @a instance_id is unknown
+ * @param[out] no_unit set to true if the unit does not exist
+ * @param[out] builtin_conflict set to true if the unit is builtin and may not be deleted
+ * @return DB status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_unit)(void *cls,
+ const char *instance_id,
+ const char *unit_id,
+ bool *no_instance,
+ bool *no_unit,
+ bool *builtin_conflict);
+
+ /**
+ * Insert a measurement unit definition.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert unit for
+ * @param ud unit details to store (unit_serial ignored)
+ * @param[out] no_instance set to true if @a instance_id is unknown
+ * @param[out] conflict set to true if a conflicting unit already exists
+ * @param[out] unit_serial set to the inserted serial on success
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_unit)(void *cls,
+ const char *instance_id,
+ const struct TALER_MERCHANTDB_UnitDetails *ud,
+ bool *no_instance,
+ bool *conflict,
+ uint64_t *unit_serial);
+
+ /**
+ * Update a measurement unit definition.
+ *
+ * @param cls closure
+ * @param instance_id instance owning the unit
+ * @param unit_id symbolic identifier of the unit
+ * @param unit_name_long optional new long label (NULL to keep current)
+ * @param unit_name_long_i18n optional new long-label translations (NULL to keep current)
+ * @param unit_name_short optional new short label (NULL to keep current)
+ * @param unit_name_short_i18n optional new short-label translations (NULL to keep current)
+ * @param unit_allow_fraction optional new fractional toggle (NULL to keep current)
+ * @param unit_precision_level optional new fractional precision (NULL to keep current)
+ * @param unit_active optional new visibility flag (NULL to keep current)
+ * @param[out] no_instance set if instance unknown
+ * @param[out] no_unit set if unit unknown
+ * @param[out] builtin_conflict set if immutable builtin fields touched
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_unit)(void *cls,
+ const char *instance_id,
+ const char *unit_id,
+ const char *unit_name_long,
+ const json_t *unit_name_long_i18n,
+ const char *unit_name_short,
+ const json_t *unit_name_short_i18n,
+ const bool *unit_allow_fraction,
+ const uint32_t *unit_precision_level,
+ const bool *unit_active,
+ bool *no_instance,
+ bool *no_unit,
+ bool *builtin_conflict);
+
+ /**
+ * Lookup all measurement units of an instance.
+ *
+ * @param cls closure
+ * @param instance_id instance to fetch units for
+ * @param cb function to call per unit
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_units)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_UnitsCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup custom measurement units by name.
+ *
+ * @param cls closure
+ * @param instance_id instance to fetch units for
+ * @param units array of unit identifiers
+ * @param num_units length of @a units
+ * @param cb function to call per unit
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_custom_units_by_names)(void *cls,
+ const char *instance_id,
+ const char *const *units,
+ size_t num_units,
+ TALER_MERCHANTDB_UnitsCallback cb,
+ void *cb_cls);
+ /**
+ * Lookup a single measurement unit.
+ *
+ * @param cls closure
+ * @param instance_id instance to fetch unit for
+ * @param unit_id symbolic identifier
+ * @param[out] ud unit details on success; may be NULL to test existence
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_unit)(void *cls,
+ const char *instance_id,
+ const char *unit_id,
+ struct TALER_MERCHANTDB_UnitDetails *ud);
+
+
+ /**
+ * Delete information about a product category.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete category of
+ * @param category_id identifies the category to delete
+ * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * if template unknown.
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_category)(void *cls,
+ const char *instance_id,
+ uint64_t category_id);
+
+ /**
+ * Insert new product category.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert OTP device for
+ * @param category_name name of the category
+ * @param category_name_i18n translations of the category name
+ * @param[out] category_id set to the category id on success
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_category)(void *cls,
+ const char *instance_id,
+ const char *category_name,
+ const json_t *category_name_i18n,
+ uint64_t *category_id);
+
+
+ /**
+ * Update descriptions of a product category.
+ *
+ * @param cls closure
+ * @param instance_id instance to update OTP device for
+ * @param category_id category to update
+ * @param category_name name of the category
+ * @param category_name_i18n translations of the category name
+ * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the template
+ * does not yet exist.
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_category)(void *cls,
+ const char *instance_id,
+ uint64_t category_id,
+ const char *category_name,
+ const json_t *category_name_i18n);
+
+ /**
+ * Lookup all of the product categories the given instance has configured.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup OTP devices for
+ * @param cb function to call on all categories found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_categories)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_CategoriesCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup product categories by ID.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup categories for
+ * @param category_ids array of category IDs
+ * @param num_category_ids length of @a category_ids
+ * @param cb function to call on all categories found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_categories_by_ids)(void *cls,
+ const char *instance_id,
+ const uint64_t *category_ids,
+ size_t num_category_ids,
+ TALER_MERCHANTDB_CategoriesCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup details about product category.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup template for
+ * @param category_id category to update
+ * @param[out] cd set to the category details on success, can be NULL
+ * (in that case we only want to check if the category exists)
+ * @param[out] num_products set to length of @a products array
+ * @param[out] products set to buffer with @a num_products 0-terminated strings with the product IDs, caller must free() it.
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_category)(void *cls,
+ const char *instance_id,
+ uint64_t category_id,
+ struct TALER_MERCHANTDB_CategoryDetails *cd,
+ size_t *num_products,
+ char **products);
+
+
+ /**
+ * Lookup details about product category by name.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup template for
+ * @param category_name category name to look for
+ * @param[out] name_i18n category name translation
+ * @param[out] category_id category ID
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_category_by_name)(void *cls,
+ const char *instance_id,
+ const char *category_name,
+ json_t **name_i18n,
+ uint64_t *category_id);
+
+
+ /**
+ * Lookup all of the webhooks the given instance has configured.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup webhook for
+ * @param cb function to call on all webhook found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_webhooks)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_WebhooksCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup details about a particular webhook.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup webhook for
+ * @param webhook_id webhook to lookup
+ * @param[out] wb set to the webhook details on success, can be NULL
+ * (in that case we only want to check if the webhook exists)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_webhook)(void *cls,
+ const char *instance_id,
+ const char *webhook_id,
+ struct TALER_MERCHANTDB_WebhookDetails *wb);
+
+ /**
+ * Delete information about a webhook.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete webhook of
+ * @param webhook_id webhook to delete
+ * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * if webhook unknown.
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_webhook)(void *cls,
+ const char *instance_id,
+ const char *webhook_id);
+
+
+ /**
+ * Insert details about a particular webhook.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert webhook for
+ * @param webhook_id webhook identifier of webhook to insert
+ * @param wb the webhook details to insert
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_webhook)(void *cls,
+ const char *instance_id,
+ const char *webhook_id,
+ const struct TALER_MERCHANTDB_WebhookDetails *wb);
+
+
+ /**
+ * Update details about a particular webhook.
+ *
+ * @param cls closure
+ * @param instance_id instance to update webhook for
+ * @param webhook_id webhook to update
+ * @param wb update to the webhook details on success, can be NULL
+ * (in that case we only want to check if the webhook exists)
+ * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the webhook
+ * does not yet exist.
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_webhook)(void *cls,
+ const char *instance_id,
+ const char *webhook_id,
+ const struct TALER_MERCHANTDB_WebhookDetails *wb);
+
+ /**
+ * Lookup webhook by event
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup webhook for
+ * @param event_type event that we need to put in the pending webhook
+ * @param[out] cb set to the webhook details on success
+ * @param cb_cls callback closure
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_webhook_by_event)(void *cls,
+ const char *instance_id,
+ const char *event_type,
+ TALER_MERCHANTDB_WebhookDetailCallback cb,
+ void *cb_cls);
+
+ /**
+ * Insert webhook in the pending webhook.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert webhook for
+ * @param webhook_serial webhook to insert in the pending webhook
+ * @param url to make the request to
+ * @param http_method for the webhook
+ * @param header of the webhook
+ * @param body of the webhook
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_pending_webhook)(void *cls,
+ const char *instance_id,
+ uint64_t webhook_serial,
+ const char *url,
+ const char *http_method,
+ const char *header,
+ const char *body);
+ /**
+ * Lookup the webhook that need to be send in priority. These webhooks are not successfully
+ * send.
+ *
+ * @param cls closure
+ * @param cb pending webhook callback
+ * @param cb_cls callback closure
+ */
+ // WHERE next_attempt <= now ORDER BY next_attempt ASC
+ enum GNUNET_DB_QueryStatus
+ (*lookup_pending_webhooks)(void *cls,
+ TALER_MERCHANTDB_PendingWebhooksCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup future webhook in the pending webhook that need to be send.
+ * With that we can know how long the system can 'sleep'.
+ *
+ * @param cls closure
+ * @param cb pending webhook callback
+ * @param cb_cls callback closure
+ */
+ // ORDER BY next_attempt ASC LIMIT 1
+ enum GNUNET_DB_QueryStatus
+ (*lookup_future_webhook)(void *cls,
+ TALER_MERCHANTDB_PendingWebhooksCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup all the webhooks in the pending webhook.
+ * Use by the administrator
+ *
+ * @param cls closure
+ * @param instance_id to lookup webhooks for this instance particularly
+ * @param min_row to see the list of the pending webhook that it is started with this minimum row.
+ * @param max_results to see the list of the pending webhook that it is end with this max results.
+ * @param cb pending webhook callback
+ * @param cb_cls callback closure
+ */
+ // WHERE webhook_pending_serial > min_row ORDER BY webhook_pending_serial ASC LIMIT max_results
+ enum GNUNET_DB_QueryStatus
+ (*lookup_all_webhooks)(void *cls,
+ const char *instance_id,
+ uint64_t min_row,
+ uint32_t max_results,
+ TALER_MERCHANTDB_PendingWebhooksCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Update the pending webhook. It is use if the webhook can't be send.
+ *
+ * @param cls closure
+ * @param webhook_serial webhook that need to be update
+ * @param next_attempt when we should make the next request to the webhook
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_pending_webhook)(void *cls,
+ uint64_t webhook_pending_serial,
+ struct GNUNET_TIME_Absolute next_attempt);
+ // maybe add: http status of failure?
+
+
+ /**
+ * Delete a webhook in the pending webhook after the
+ * webhook was completed successfully.
+ *
+ * @param cls closure
+ * @param webhook_serial webhook that need to be delete in the pending webhook
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_pending_webhook)(void *cls,
+ uint64_t webhook_pending_serial);
+
+
+ /**
+ * Retrieve exchange's keys from the database.
+ *
+ * @param cls plugin closure
+ * @param exchange_url base URL of the exchange
+ * @param[out] first_retry set to earliest we may retry fetching the keys
+ * @param[out] keys set to the keys of the exchange
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_exchange_keys)(void *cls,
+ const char *exchange_url,
+ struct GNUNET_TIME_Absolute *first_retry,
+ struct TALER_EXCHANGE_Keys **keys);
+
+
+ /**
+ * Insert or update @a keys into the database.
+ *
+ * @param cls plugin closure
+ * @param exchange_url base URL of the exchange
+ * @param keys data to store
+ * @param first_retry earliest we may retry fetching the keys
+ * @param http_status latest HTTP status of the exchange
+ * @param ec latest error code from fetching /keys
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_exchange_keys)(void *cls,
+ const char *exchange_url,
+ const struct TALER_EXCHANGE_Keys *keys,
+ struct GNUNET_TIME_Absolute first_retry,
+ uint32_t http_status,
+ enum TALER_ErrorCode ec);
+
+
+ /**
+ * Lookup all of the token families the given instance has configured.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup token families for
+ * @param cb function to call on all token families found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_token_families)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_TokenFamiliesCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup details about a particular token family.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup token family for
+ * @param token_family_slug token family to lookup
+ * @param[out] details set to the token family details on success, can be NULL
+ * (in that case we only want to check if the token family exists)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_token_family)(void *cls,
+ const char *instance_id,
+ const char *token_family_slug,
+ struct TALER_MERCHANTDB_TokenFamilyDetails *details);
+
+ /**
+ * Delete information about a token family.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete token family of
+ * @param token_family_slug slug of token family to delete
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_token_family)(void *cls,
+ const char *instance_id,
+ const char *token_family_slug);
+
+ /**
+ * Update details about a particular token family.
+ *
+ * @param cls closure
+ * @param instance_id instance to update token family for
+ * @param token_family_slug slug of token family to update
+ * @param details set to the updated token family on success, can be NULL
+ * (in that case we only want to check if the token family exists)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_token_family)(
+ void *cls,
+ const char *instance_id,
+ const char *token_family_slug,
+ const struct TALER_MERCHANTDB_TokenFamilyDetails *details);
+
+
+ /**
+ * Insert details about a particular token family.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert token family for
+ * @param token_family_slug slug of token family to insert
+ * @param details the token family details to insert
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_token_family)(
+ void *cls,
+ const char *instance_id,
+ const char *token_family_slug,
+ const struct TALER_MERCHANTDB_TokenFamilyDetails *details);
+
+
+ /**
+ * Lookup details about a particular token family key.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup token family key for
+ * @param token_family_slug slug of token family to lookup
+ * @param valid_at find a key with a validity period that includes this time
+ * @param sign_until find a private key that can sign until this time
+ * @param[out] details set to the token family key details on success, can be NULL
+ * (in that case we only want to check if the token family key exists)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_token_family_key)(
+ void *cls,
+ const char *instance_id,
+ const char *token_family_slug,
+ struct GNUNET_TIME_Timestamp valid_at,
+ struct GNUNET_TIME_Timestamp sign_until,
+ struct TALER_MERCHANTDB_TokenFamilyKeyDetails *details);
+
+
+ /**
+ * Lookup token family keys that may be used for a payment.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup token family key for
+ * @param token_family_slug slug of token family to lookup
+ * @param start_time signature validity start the keys must fall into
+ * @param end_time signature validity end the keys must fall into
+ * @param cb function to call with each matching key
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_token_family_keys)(
+ void *cls,
+ const char *instance_id,
+ const char *token_family_slug,
+ struct GNUNET_TIME_Timestamp start_time,
+ struct GNUNET_TIME_Timestamp end_time,
+ TALER_MERCHANTDB_TokenKeyCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Insert details a key pair for a token family.
+ *
+ * @param cls closure
+ * @param merchant_id instance name
+ * @param token_family_slug slug of token family to insert the key pair for
+ * @param pub token family public key
+ * @param priv token family private key
+ * @param key_expires when does the private key expire (because
+ * the validity period of the next token family key starts)
+ * @param valid_after start of validity period for signatures with this key
+ * @param valid_before end of validity period for signatures with this key
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_token_family_key)(
+ void *cls,
+ const char *merchant_id,
+ const char *token_family_slug,
+ const struct TALER_TokenIssuePublicKey *pub,
+ const struct TALER_TokenIssuePrivateKey *priv,
+ struct GNUNET_TIME_Timestamp key_expires,
+ struct GNUNET_TIME_Timestamp valid_after,
+ struct GNUNET_TIME_Timestamp valid_before);
+
+ /**
+ * Lookup deposits that are finished and awaiting a wire transfer.
+ *
+ * @param cls closure
+ * @param exchange_url exchange to filter deposits by
+ * @param limit maximum number of deposits to return
+ * @param allow_future true to allow deposits with wire deadline in the future
+ * @param cb function to call with deposit data
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_pending_deposits)(
+ void *cls,
+ const char *exchange_url,
+ uint64_t limit,
+ bool allow_future,
+ TALER_MERCHANTDB_PendingDepositsCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Update the deposit confirmation status associated with
+ * the given @a deposit_serial.
+ *
+ * @param cls closure
+ * @param deposit_serial deposit to update status for
+ * @param retry_needed true if the HTTP request should be retried
+ * @param retry_time when should we ask the exchange again
+ * @param last_http_status HTTP status code of the last reply
+ * @param last_ec Taler error code of the last reply
+ * @param last_detail detail from error message to record, possibly NULL
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_deposit_confirmation_status)(
+ void *cls,
+ uint64_t deposit_serial,
+ bool retry_needed,
+ struct GNUNET_TIME_Timestamp retry_time,
+ uint32_t last_http_status,
+ enum TALER_ErrorCode last_ec,
+ const char *last_detail);
+
+
+ /**
+ * Update the amount of receipts for a Donau instance.
+ *
+ * @param cls closure
+ * @param donau_instances_serial serial number of the Donau instance
+ * @param new_amount new receipts_to_date amount
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_donau_instance_receipts_amount)(
+ void *cls,
+ uint64_t *donau_instances_serial,
+ const struct TALER_Amount *new_amount
+ );
+
+
+ /**
+ * Check if a new matching multi-factor authorization (MFA) challenge
+ * exists in the database.
+ *
+ * @param cls closure
+ * @param challenge_id set to the ID of the challenge
+ * @param h_body hash of the request body
+ * @param[out] salt salt used to compute @a h_body
+ * @param[out] required address set to where the challenge is to be send
+ * @param[out] op operation that triggered the MFA request
+ * @param[out] confirmation_date when was the challenge solved,
+ * set to "GNUNET_TIME_ABSOLUTE_NEVER" if unsolved
+ * @param[out] retransmission_date set to when a fresh challenge
+ * may be transmitted
+ * @param[out] retry_counter set to the number of attempts that remain
+ * for solving the challenge (after this time)
+ * @param[out] tan_channel which channel was used
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_mfa_challenge)(
+ void *cls,
+ uint64_t challenge_id,
+ const struct TALER_MERCHANT_MFA_BodyHash *h_body,
+ struct TALER_MERCHANT_MFA_BodySalt *salt,
+ char **required_address,
+ enum TALER_MERCHANT_MFA_CriticalOperation *op,
+ struct GNUNET_TIME_Absolute *confirmation_date,
+ struct GNUNET_TIME_Absolute *retransmission_date,
+ uint32_t *retry_counter,
+ enum TALER_MERCHANT_MFA_Channel *tan_channel);
+
+
+ /**
+ * Attempt to solve new multi-factor authorization (MFA) challenge.
+ * Checks the solution against the code in the database and updates
+ * the solution state and (on failure) retry counter depending on
+ * the result.
+ *
+ * @param cls closure
+ * @param challenge_id challenge ID to be solved
+ * @param h_body body of the operation the challenge authorizes
+ * @param solution proposed solution to be checked against the actual code
+ * @param[out] solved set to true if the challenge was solved by
+ * @a solution
+ * @param[out] retry_counter set to the number of attempts that remain
+ * for solving the challenge (after this time)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*solve_mfa_challenge)(
+ void *cls,
+ uint64_t challenge_id,
+ const struct TALER_MERCHANT_MFA_BodyHash *h_body,
+ const char *solution,
+ bool *solved,
+ uint32_t *retry_counter);
+
+
+ /**
+ * Update the state of an MFA challenge as we have now
+ * retransmitted the challenge code.
+ *
+ * @param cls closure
+ * @param challenge_id challenge ID to be solved
+ * @param code new challenge code
+ * @param retry_counter number of attempts that remain
+ * for solving the challenge
+ * @param expiration_date when should the challenge expire
+ * @param retransmission_date set to when a fresh challenge
+ * may be transmitted next
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_mfa_challenge)(
+ void *cls,
+ uint64_t challenge_id,
+ const char *code,
+ uint32_t retry_counter,
+ struct GNUNET_TIME_Absolute expiration_date,
+ struct GNUNET_TIME_Absolute retransmission_date);
+
+
+ /**
+ * Create new multi-factor authorization (MFA) challenge in the database.
+ *
+ * @param cls closure
+ * @param op operation that triggered the MFA request
+ * @param h_body hash of the request body
+ * @param salt salt used to compute @a h_body
+ * @param code challenge code sent to the user
+ * @param expiration_date when should the challenge expire
+ * @param retansmission_date when do we next allow retransmission
+ * of the challenge
+ * @param tan_channel which channel was used
+ * @param required_address address
+ * where the challenge is to be sent
+ * @param[out] challenge_id set to the ID of the new challenge
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*create_mfa_challenge)(
+ void *cls,
+ enum TALER_MERCHANT_MFA_CriticalOperation op,
+ const struct TALER_MERCHANT_MFA_BodyHash *h_body,
+ const struct TALER_MERCHANT_MFA_BodySalt *salt,
+ const char *code,
+ struct GNUNET_TIME_Absolute expiration_date,
+ struct GNUNET_TIME_Absolute retransmission_date,
+ enum TALER_MERCHANT_MFA_Channel tan_channel,
+ const char *required_address,
+ uint64_t *challenge_id);
+
+
+#ifdef HAVE_DONAU_DONAU_SERVICE_H
+ /**
+ * Insert information about a Donau instance.
+ *
+ * @param cls closure
+ * @param donau_url URL of the Donau instance
+ * @param charity details of the charity
+ * @param charity_id charity ID of the Donau instance
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_donau_instance)(
+ void *cls,
+ const char *donau_url,
+ const struct DONAU_Charity *charity,
+ uint64_t charity_id
+ );
+
+
+ /**
+ * Check if information about a Donau instance exists.
+ *
+ * @param cls closure
+ * @param merchant_pub public key of the instance
+ * @param donau_url URL of the Donau instance
+ * @param charity_id charity ID of the Donau instance
+ */
+ enum GNUNET_DB_QueryStatus
+ (*check_donau_instance)(
+ void *cls,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const char *donau_url,
+ uint64_t charity_id
+ );
+
+ /**
+ * Select donau instance by serial number.
+ *
+ * @param cls closure
+ * @param serial serial number of the Donau instance in DB
+ * @param[out] donau_url set to the URL of the Donau instance
+ * @param[out] charity_id set to the charity ID of the Donau instance
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_donau_instance_by_serial)(
+ void *cls,
+ uint64_t serial,
+ char **donau_url,
+ uint64_t *charity_id);
+
+ /**
+ * Select all Donau instances. Note that this callback only
+ * returns Donau instances for which we have successfully
+ * retrieved /keys.
+ *
+ * @param cls closure
+ * @param id instance to restrict to
+ * @param cb function to call on all Donau instances found
+ * @param cb_cls closure for @a cb
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_donau_instances)(
+ void *cls,
+ const char *id,
+ TALER_MERCHANTDB_DonauInstanceCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Select all Donau instances, regardless of instance and also
+ * regardless of whether we got a /keys response.
+ *
+ * @param cls closure
+ * @param cb function to call on all Donau instances found
+ * @param cb_cls closure for @a cb
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_all_donau_instances)(
+ void *cls,
+ TALER_MERCHANTDB_DonauInstanceCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Select all Donau instances, but only the donau_url
+ * and charity_max_per_year.
+ *
+ * @param cls closure
+ * @param cb function to call on all Donau instances found
+ * @param cb_cls closure for @a cb
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_donau_instances_filtered)(
+ void *cls,
+ const char *currency,
+ TALER_MERCHANTDB_DonauInstanceFilteredCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup Donau keys by URL.
+ *
+ * @param cls closure
+ * @param donau_url URL of the Donau instance
+ * @param[out] keys set to the Donau keys on success
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_donau_keys)(
+ void *cls,
+ const char *donau_url,
+ struct GNUNET_TIME_Absolute *first_retry,
+ struct DONAU_Keys **keys);
+
+ /**
+ * Lookup a Donau instance by its instance ID and URL.
+ *
+ * @param cls closure
+ * @param instance_id instance ID of the Donau instance
+ * @param donau_url URL of the Donau instance
+ * @param charity_id set to the charity ID of the Donau instance
+ * @param charity_priv set to the private key of the charity
+ * @param charity_max_per_year set to the maximum amount
+ * the charity can receive per year
+ * @param charity_receipts_to_date set to the total amount
+ * the charity has received to date
+ * @param donau_keys_json set to the JSON representation of the
+ * Donau keys
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_order_charity)(
+ void *cls,
+ const char *instance_id,
+ const char *donau_url,
+ uint64_t *charity_id,
+ struct DONAU_CharityPrivateKeyP *charity_priv,
+ struct TALER_Amount *charity_max_per_year,
+ struct TALER_Amount *charity_receipts_to_date,
+ json_t **donau_keys_json,
+ uint64_t *donau_instance_serial);
+
+ /**
+ * Upsert Donau keys into the database.
+ *
+ * @param cls closure
+ * @param keys Donau keys to insert or update
+ */
+ enum GNUNET_DB_QueryStatus
+ (*upsert_donau_keys)(
+ void *cls,
+ const struct DONAU_Keys *keys,
+ struct GNUNET_TIME_Absolute first_retry);
+
+ /**
+ * Update information about a Donau instance.
+ *
+ * @param cls closure
+ * @param donau_url URL of the Donau instance
+ * @param charity details of the charity
+ * @param charity_id charity ID of the Donau instance
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_donau_instance)(
+ void *cls,
+ const char *donau_url,
+ const struct DONAU_Charity *charity,
+ uint64_t charity_id);
+
+#endif
+
+ /**
+ * Delete information about a Donau instance.
+ *
+ * @param cls closure
+ * @param charity_id charity ID of the Donau instance to delete
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_donau_instance)(
+ void *cls,
+ const char *id,
+ uint64_t charity_id);
+
+ /**
+ * Lookup amount statistics for instance and slug by bucket.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup statistics for
+ * @param slug instance to lookup statistics for
+ * @param cb function to call on all token families found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_statistics_amount_by_bucket)(
+ void *cls,
+ const char *instance_id,
+ const char *slug,
+ TALER_MERCHANTDB_AmountByBucketStatisticsCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup amount statistics for instance and slug by bucket,
+ * restricting to a fixed number of buckets at a given granularity.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup statistics for
+ * @param slug instance to lookup statistics for
+ * @param granularity limit to buckets of this size
+ * @param counter requested number of buckets
+ * @param cb function to call on all token families found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_statistics_amount_by_bucket2)(
+ void *cls,
+ const char *instance_id,
+ const char *slug,
+ const char *granularity,
+ uint64_t counter,
+ TALER_MERCHANTDB_AmountByBucketStatisticsCallback2 cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup counter statistics for instance and slug by bucket.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup statistics for
+ * @param slug instance to lookup statistics for
+ * @param cb function to call on all token families found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_statistics_counter_by_bucket)(
+ void *cls,
+ const char *instance_id,
+ const char *slug,
+ TALER_MERCHANTDB_CounterByBucketStatisticsCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup counter statistics for instance and slug-prefix by bucket.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup statistics for
+ * @param prefix slug prefix to lookup statistics under
+ * @param granularity limit to buckets of this size
+ * @param counter requested number of buckets
+ * @param cb function to call on all token families found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_statistics_counter_by_bucket2)(
+ void *cls,
+ const char *instance_id,
+ const char *prefix,
+ const char *granularity,
+ uint64_t counter,
+ TALER_MERCHANTDB_CounterByBucketStatisticsCallback2 cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup amount statistics for instance and slug by interval.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup statistics for
+ * @param slug instance to lookup statistics for
+ * @param cb function to call on all token families found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_statistics_amount_by_interval)(
+ void *cls,
+ const char *instance_id,
+ const char *slug,
+ TALER_MERCHANTDB_AmountByIntervalStatisticsCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup counter statistics for instance and slug by interval.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup statistics for
+ * @param slug instance to lookup statistics for
+ * @param cb function to call on all token families found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_statistics_counter_by_interval)(
+ void *cls,
+ const char *instance_id,
+ const char *slug,
+ TALER_MERCHANTDB_CounterByIntervalStatisticsCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup all of the money pots the given instance has configured.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup money pots for
+ * @param limit number of entries to return, negative for descending in execution time,
+ * positive for ascending in execution time
+ * @param offset number of the money pot we want to offset from
+ * @param cb function to call on all money pots found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_money_pots)(void *cls,
+ const char *instance_id,
+ int64_t limit,
+ uint64_t offset,
+ TALER_MERCHANTDB_MoneyPotsCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Check that all of the money pots given exist at the instance,
+ * returning one that does *not* exist (for generating an error)
+ * if the check fails.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup token families for
+ * @param pots_len length of the @a pots array
+ * @param pots money pot identifiers to check if they exist
+ * @param[out] pot_missing set to ID of pot not known at the instance
+ * @return transaction status,
+ * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS means that all pots exist
+ * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT indicates that
+ * @a pot_missing was initialized to a missing pot
+ */
+ enum GNUNET_DB_QueryStatus
+ (*check_money_pots)(void *cls,
+ const char *instance_id,
+ unsigned int pots_len,
+ uint64_t pots[static pots_len],
+ uint64_t *pot_missing);
+
+ /**
+ * Lookup details about a particular money pot.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup money pot for
+ * @param money_pot_id serial number of the pot to lookup
+ * @param [out] name set to name of the pot,
+ * must be freed by caller
+ * @param[out] description set to description of the pot,
+ * must be freed by caller
+ * @param[out] pot_total_len set to length of @a pot_totals array
+ * @param[out] pot_totals set to amounts currently in the pot;
+ * array must be freed by caller
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_money_pot)(void *cls,
+ const char *instance_id,
+ uint64_t money_pot_id,
+ char **name,
+ char **description,
+ size_t *pot_total_len,
+ struct TALER_Amount **pot_totals);
+
+ /**
+ * Delete information about a money pot.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete money pot of
+ * @param money_pot_id serial number of the pot to delete
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_money_pot)(void *cls,
+ const char *instance_id,
+ uint64_t money_pot_id);
+
+ /**
+ * Update details about a particular money pot.
+ *
+ * @param cls closure
+ * @param instance_id instance to update money pot for
+ * @param money_pot_id serial number of the pot to delete
+ * @param name set to name of the pot
+ * @param description set to description of the pot
+ * @param opt_len length of @a old_pot_totals
+ * @param old_pot_totals amounts expected currently in the pot,
+ * NULL to not check (non-NULL but @a opt_len=0 checks for [])
+ * @param npt_len length of @a new_pot_totals
+ * @param new_pot_totals new amounts in the pot,
+ * NULL to not update (non-NULL but @a npt_len=0 resets to [])
+ * @param[out] conflict_total set to true if @a old_pot_total does not match
+ * @param[out] conflict_name set to true if @a name is used by another pot
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_money_pot)(
+ void *cls,
+ const char *instance_id,
+ uint64_t money_pot_id,
+ const char *name,
+ const char *description,
+ size_t opt_len,
+ const struct TALER_Amount *old_pot_totals,
+ size_t npt_len,
+ const struct TALER_Amount *new_pot_totals,
+ bool *conflict_total,
+ bool *conflict_name);
+
+
+ /**
+ * Increment amounts in money pots. If a money pot does not exist,
+ * it is simply skipped (without causing an error!).
+ *
+ * @param cls closure
+ * @param instance_id instance to update money pot for
+ * @param money_pots_len length of the @a money_pots_ids
+ * and @a pot_increments arrays
+ * @param money_pot_ids serial numbers of the pots to increment
+ * @param pot_increments new amounts to add to the respective pot
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*increment_money_pots)(
+ void *cls,
+ const char *instance_id,
+ size_t money_pots_len,
+ const uint64_t *money_pot_ids,
+ const struct TALER_Amount *pot_increments);
+
+
+ /**
+ * Insert details about a particular pot.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert pot for
+ * @param name set to name of the pot
+ * @param description set to description of the pot
+ * @param[out] money_pot_id serial number of the new pot
+ * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * on conflict (@a name already in use at @a instance_id).
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_money_pot)(
+ void *cls,
+ const char *instance_id,
+ const char *name,
+ const char *description,
+ uint64_t *money_pot_id);
+
+ // Reports
+
+ /**
+ * Lookup all of the reports the given instance has configured.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup reports for
+ * @param limit number of entries to return, negative for descending in execution time,
+ * positive for ascending in execution time
+ * @param offset expected_transfer_serial number of the transfer we want to offset from
+ * @param cb function to call on all reports found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_reports)(void *cls,
+ const char *instance_id,
+ int64_t limit,
+ uint64_t offset,
+ TALER_MERCHANTDB_ReportsCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup all of the reports pending for the given backend.
+ *
+ * @param cls closure
+ * @param cb function to call on all reports found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_reports_pending)(void *cls,
+ TALER_MERCHANTDB_ReportsPendingCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup details about a particular report.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup reports for
+ * @param report_id serial number of the report to lookup
+ * @param[out] report_program_section configuration section of program
+ * for report generation
+ * @param[out] report_description text describing the report
+ * @param[out] mime_type mime type to request from the @a data_source
+ * @param[out] data_source relative URL (to instance base URL)
+ * to request report data from
+ * @param[out] target_address where to send report data
+ * @param[out] frequency report frequency
+ * @param[out] frequency_shift how much to shift the report time from a
+ * multiple of the report @a frequency
+ * @param[out] next_transmission when will the report be generated next
+ * @param[out] last_error_code status of the last report
+ * @param[out] last_error_detail details about failures of last generation
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_report)(void *cls,
+ const char *instance_id,
+ uint64_t report_id,
+ char **report_program_section,
+ char **report_description,
+ char **mime_type,
+ char **data_source,
+ char **target_address,
+ struct GNUNET_TIME_Relative *frequency,
+ struct GNUNET_TIME_Relative *frequency_shift,
+ struct GNUNET_TIME_Absolute *next_transmission,
+ enum TALER_ErrorCode *last_error_code,
+ char **last_error_detail);
+
+ /**
+ * Check that a particular report is scheduled under the
+ * given @a report_id and @a report_token. Does not
+ * validate that the report is actually due.
+ *
+ * @param cls closure
+ * @param report_id serial number of the report to lookup
+ * @param report_token report token to check
+ * @param mime_type mime type to request from the @a data_source
+ * @param[out] instance_id instance to lookup reports for
+ * @param[out] data_source relative URL (to instance base URL)
+ * to request report data from
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*check_report)(void *cls,
+ uint64_t report_id,
+ const struct TALER_MERCHANT_ReportToken *report_token,
+ const char *mime_type,
+ char **instance_id,
+ char **data_source);
+
+
+ /**
+ * Delete information about a report.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete report of
+ * @param report_id serial number of the pot to delete
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_report)(void *cls,
+ const char *instance_id,
+ uint64_t report_id);
+
+ /**
+ * Update transmission status about a particular report.
+ *
+ * @param cls closure
+ * @param instance_id instance to update report for
+ * @param report_id serial number of the pot to update
+ * @param next_tranmission when should the report be generated next
+ * @param last_error_code #TALER_EC_NONE on success
+ * @param last_error_detail NULL on success
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_report_status)(
+ void *cls,
+ const char *instance_id,
+ uint64_t report_id,
+ struct GNUNET_TIME_Timestamp next_transmission,
+ enum TALER_ErrorCode last_error_code,
+ const char *last_error_detail);
+
+
+ /**
+ * Update details about a particular report.
+ *
+ * @param cls closure
+ * @param instance_id instance to update report for
+ * @param report_id serial number of the report to update
+ * @param report_program_section configuration section of program
+ * for report generation
+ * @param report_description text describing the report
+ * @param mime_type mime type to request from the @a data_source
+ * @param data_source relative URL (to instance base URL)
+ * to request report data from
+ * @param target_address where to send report data
+ * @param frequency report frequency
+ * @param frequency_shift how much to shift the report time from a
+ * multiple of the report @a frequency
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_report)(
+ void *cls,
+ const char *instance_id,
+ uint64_t report_id,
+ const char *report_program_section,
+ const char *report_description,
+ const char *mime_type,
+ const char *data_source,
+ const char *target_address,
+ struct GNUNET_TIME_Relative frequency,
+ struct GNUNET_TIME_Relative frequency_shift);
+
+
+ /**
+ * Insert details about a particular report.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert report for
+ * @param report_program_section configuration section of program
+ * for report generation
+ * @param report_description text describing the report
+ * @param mime_type mime type to request from the @a data_source
+ * @param data_source relative URL (to instance base URL)
+ * to request report data from
+ * @param target_address where to send report data
+ * @param frequency report frequency
+ * @param frequency_shift how much to shift the report time from a
+ * multiple of the report @a frequency
+ * @param[out] report_id serial number of the new pot
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_report)(
+ void *cls,
+ const char *instance_id,
+ const char *report_program_section,
+ const char *report_description,
+ const char *mime_type,
+ const char *data_source,
+ const char *target_address,
+ struct GNUNET_TIME_Relative frequency,
+ struct GNUNET_TIME_Relative frequency_shift,
+ uint64_t *report_id);
+
+
+ // groups
+
+ /**
+ * Lookup all of the product groups the given instance has configured.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup product groups for
+ * @param limit number of entries to return, negative for descending in execution time,
+ * positive for ascending in execution time
+ * @param offset expected_transfer_serial number of the transfer we want to offset from
+ * @param cb function to call on all groups found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_product_groups)(void *cls,
+ const char *instance_id,
+ int64_t limit,
+ uint64_t offset,
+ TALER_MERCHANTDB_ProductGroupsCallback cb,
+ void *cb_cls);
+
+ /**
+ * Delete information about a product group.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete product group of
+ * @param product_group_id serial number of the group to delete
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_product_group)(void *cls,
+ const char *instance_id,
+ uint64_t product_group_id);
+
+ /**
+ * Update details about a particular product group.
+ *
+ * @param cls closure
+ * @param instance_id instance to update product group for
+ * @param product_group_id serial number of the group to update
+ * @param name set to name of the group
+ * @param description set to description of the group
+ * @param[out] conflict set to true if @a name is already used
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_product_group)(
+ void *cls,
+ const char *instance_id,
+ uint64_t product_group_id,
+ const char *name,
+ const char *description,
+ bool *conflict);
+
+
+ /**
+ * Insert details about a particular product group.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert group for
+ * @param name set to name of the group
+ * @param description set to description of the group
+ * @param[out] product_group_id serial number of the new group
+ * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * on conflict (@a name already in use at @a instance_id).
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_product_group)(
+ void *cls,
+ const char *instance_id,
+ const char *name,
+ const char *description,
+ uint64_t *product_group_id);
+
+};
+
+#endif
diff --git a/src/lib/merchant_api_get_otp_devices.c b/src/lib/merchant_api_get_otp_devices.c
@@ -101,7 +101,7 @@ parse_otp_devices (const json_t *ia,
GNUNET_JSON_spec_string ("otp_device_id",
&ie->otp_device_id),
GNUNET_JSON_spec_string ("device_description",
- &ie->device_description),
+ &ie->otp_device_description),
GNUNET_JSON_spec_end ()
};
diff --git a/src/lib/merchant_api_post_donau_instance.c b/src/lib/merchant_api_post_donau_instance.c
@@ -131,7 +131,7 @@ struct TALER_MERCHANT_DonauInstancePostHandle *
TALER_MERCHANT_donau_instances_post (
struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const struct TALER_MERCHANT_DONAU_Charity *charity,
+ const struct TALER_MERCHANT_Charity *charity,
const char *auth_token,
TALER_MERCHANT_DonauInstancePostCallback cb,
void *cb_cls)
@@ -234,4 +234,4 @@ TALER_MERCHANT_donau_instances_post_cancel (
}
-/* end of merchant_api_post_donau_instance.c */
-\ No newline at end of file
+/* end of merchant_api_post_donau_instance.c */
diff --git a/src/lib/merchant_api_post_order_pay.c b/src/lib/merchant_api_post_order_pay.c
@@ -424,7 +424,7 @@ TALER_MERCHANT_order_pay_frontend (
unsigned int num_coins,
const struct TALER_MERCHANT_PaidCoin coins[static num_coins],
unsigned int num_tokens,
- const struct TALER_MERCHANT_UsedToken tokens[static num_tokens],
+ const struct TALER_MERCHANT_UsedToken *tokens,
json_t *j_output_tokens, // FIXME: not used, remove?
TALER_MERCHANT_OrderPayCallback pay_cb,
void *pay_cb_cls)
@@ -624,10 +624,9 @@ TALER_MERCHANT_order_pay (
unsigned int num_coins,
const struct TALER_MERCHANT_PayCoin coins[static num_coins],
unsigned int num_tokens,
- const struct TALER_MERCHANT_UseToken tokens[static num_tokens],
+ const struct TALER_MERCHANT_UseToken *tokens,
unsigned int num_output_tokens,
- const struct TALER_MERCHANT_OutputToken output_tokens[static num_output_tokens
- ],
+ const struct TALER_MERCHANT_OutputToken *output_tokens,
TALER_MERCHANT_OrderPayCallback pay_cb,
void *pay_cb_cls)
{
diff --git a/src/lib/merchant_api_post_orders.c b/src/lib/merchant_api_post_orders.c
@@ -134,7 +134,7 @@ TALER_MERCHANT_orders_post2 (
unsigned int inventory_products_length,
const struct TALER_MERCHANT_InventoryProduct inventory_products[],
unsigned int uuids_length,
- const char *uuids[static uuids_length],
+ const char *uuids[],
bool create_token,
TALER_MERCHANT_PostOrdersCallback cb,
void *cb_cls)
@@ -167,7 +167,7 @@ TALER_MERCHANT_orders_post3 (
unsigned int inventory_products_length,
const struct TALER_MERCHANT_InventoryProduct inventory_products[],
unsigned int uuids_length,
- const char *uuids[static uuids_length],
+ const char *uuids[],
bool create_token,
TALER_MERCHANT_PostOrdersCallback cb,
void *cb_cls)
diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c
@@ -346,6 +346,67 @@ prepare_donau_data (struct TALER_TESTING_Interpreter *is,
};
#endif /* HAVE_DONAU_DONAU_SERVICE_H */
+
+/**
+ * All the details about a token that are generated during issuance and
+ * that may be needed for future operations on the coin.
+ */
+struct TALER_MERCHANT_PrivateTokenDetails
+{
+
+ /**
+ * Master secret used to derive the private key from.
+ */
+ struct TALER_TokenUseMasterSecretP master;
+
+ /**
+ * Private key of the token.
+ */
+ struct TALER_TokenUsePrivateKeyP token_priv;
+
+ /**
+ * Public key of the token.
+ */
+ struct TALER_TokenUsePublicKeyP token_pub;
+
+ /**
+ * Public key of the token.
+ */
+ struct TALER_TokenUsePublicKeyHashP h_token_pub;
+
+ /**
+ * Blinded public key of the token.
+ */
+ struct TALER_TokenEnvelope envelope;
+
+ /**
+ * Value used to blind the key for the signature.
+ */
+ union GNUNET_CRYPTO_BlindingSecretP blinding_secret;
+
+ /**
+ * Inputs needed from the merchant for blind signing.
+ */
+ struct TALER_TokenUseMerchantValues blinding_inputs;
+
+ /**
+ * Token issue public key.
+ */
+ struct TALER_TokenIssuePublicKey issue_pub;
+
+ /**
+ * Unblinded token issue signature made by the merchant.
+ */
+ struct TALER_TokenIssueSignature issue_sig;
+
+ /**
+ * Blinded token issue signature made by the merchant.
+ */
+ struct TALER_BlindedTokenIssueSignature blinded_sig;
+
+};
+
+
/**
* State for a /pay CMD.
*/
diff --git a/src/testing/testing_api_cmd_post_donau_instances.c b/src/testing/testing_api_cmd_post_donau_instances.c
@@ -31,6 +31,7 @@
#include "taler/taler_merchant_donau.h"
#include <donau/donau_testing_lib.h>
+
/**
* State of a "POST /donau" CMD.
*/
@@ -54,7 +55,7 @@ struct PostDonauState
/**
* Charity details.
*/
- struct TALER_MERCHANT_DONAU_Charity charity;
+ struct TALER_MERCHANT_Charity charity;
/**
* Merchant reference to fetch public key.
@@ -138,20 +139,6 @@ post_donau_run (void *cls,
pds->is = is;
pds->charity.charity_url = TALER_TESTING_get_donau_url (is);
- if (NULL != pds->merchant_reference)
- {
- const struct TALER_TESTING_Command *mc;
- const struct TALER_MerchantPublicKeyP *merchant_pub;
-
- mc = TALER_TESTING_interpreter_lookup_command (is,
- pds->merchant_reference);
- GNUNET_assert (NULL != mc);
- GNUNET_assert (GNUNET_OK ==
- TALER_TESTING_get_trait_merchant_pub (mc,
- &merchant_pub));
- pds->charity.charity_pub.eddsa_pub = merchant_pub->eddsa_pub;
- }
-
pds->dph = TALER_MERCHANT_donau_instances_post (
TALER_TESTING_interpreter_get_context (is),
pds->merchant_url,
@@ -196,17 +183,15 @@ post_donau_cleanup (void *cls,
* Create a new testing command for POST /donau.
*/
struct TALER_TESTING_Command
-TALER_TESTING_cmd_merchant_post_donau_instance (const char *label,
- const char *url,
- const char *merchant_reference,
- unsigned int
- expected_http_status,
- ...)
+TALER_TESTING_cmd_merchant_post_donau_instance (
+ const char *label,
+ const char *url,
+ const char *merchant_reference,
+ unsigned int
+ expected_http_status,
+ ...)
{
struct PostDonauState *pds = GNUNET_new (struct PostDonauState);
- struct DONAU_CharityPublicKeyP *charity_pub = GNUNET_new (struct
- DONAU_CharityPublicKeyP);
-
struct TALER_Amount max_amount;
struct TALER_Amount date_amount;
@@ -222,16 +207,10 @@ TALER_TESTING_cmd_merchant_post_donau_instance (const char *label,
&date_amount));
{
- struct TALER_MERCHANT_DONAU_Charity charity = {
+ struct TALER_MERCHANT_Charity charity = {
.charity_url = "http://replaced.in.post_donau_run/",
- .name = "example",
- .charity_pub = *charity_pub,
.charity_id = 1,
- .max_per_year = max_amount,
- .receipts_to_date = date_amount,
- .current_year = GNUNET_TIME_get_current_year (),
};
- GNUNET_free (charity_pub);
pds->merchant_reference = merchant_reference;
pds->merchant_url = url;