summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/Makefile.am1
-rw-r--r--src/include/platform.h30
-rw-r--r--src/include/taler_merchant_bank_lib.h247
-rw-r--r--src/include/taler_merchant_service.h3019
-rw-r--r--src/include/taler_merchant_testing_lib.h1057
-rw-r--r--src/include/taler_merchantdb_lib.h10
-rw-r--r--src/include/taler_merchantdb_plugin.h1534
7 files changed, 3755 insertions, 2143 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index aeb65712..7f1b9292 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -5,6 +5,7 @@ EXTRA_DIST = \
talerincludedir = $(includedir)/taler
talerinclude_HEADERS = \
+ taler_merchant_bank_lib.h \
taler_merchantdb_lib.h \
taler_merchantdb_plugin.h \
taler_merchant_service.h \
diff --git a/src/include/platform.h b/src/include/platform.h
index 61d3e402..fcafb941 100644
--- a/src/include/platform.h
+++ b/src/include/platform.h
@@ -15,7 +15,7 @@
*/
/**
- * @file merchant/src/include/platform.h
+ * @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>
@@ -277,22 +277,42 @@ atoll (const char *nptr);
/* 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
@@ -300,6 +320,14 @@ atoll (const char *nptr);
#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_ */
diff --git a/src/include/taler_merchant_bank_lib.h b/src/include/taler_merchant_bank_lib.h
new file mode 100644
index 00000000..beaaa516
--- /dev/null
+++ b/src/include/taler_merchant_bank_lib.h
@@ -0,0 +1,247 @@
+/*
+ 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,
+};
+
+
+/**
+ * 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;
+
+};
+
+
+/* ********************* /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.
+ */
+ const char *debit_account_uri;
+
+ /**
+ * payto://-URL of the target account that
+ * received the funds.
+ */
+ const char *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_merchant_service.h b/src/include/taler_merchant_service.h
index e413a7c6..057c9eff 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2022 Taler Systems SA
+ 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
@@ -16,6 +16,8 @@
/**
* @file 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 Marcello Stanisci
* @author Priscilla HUANG
@@ -29,6 +31,11 @@
#include <gnunet/gnunet_curl_lib.h>
#include <jansson.h>
+/**
+ * Library version (in hex) for compatibility tests.
+ */
+#define TALER_MERCHANT_SERVICE_VERSION 0x00100000
+
/**
* General information about the HTTP response we obtained
@@ -211,7 +218,7 @@ struct TALER_MERCHANT_RefundUriData
* @param[out] parse_data data extracted from the URI. Must be free'd.
* @return #GNUNET_SYSERR if @e refund_uri is malformed, #GNUNET_OK otherwise.
*/
-int
+enum GNUNET_GenericReturnValue
TALER_MERCHANT_parse_refund_uri (
const char *refund_uri,
struct TALER_MERCHANT_RefundUriData *parse_data);
@@ -288,7 +295,8 @@ enum TALER_MERCHANT_VersionCompatibility
struct TALER_MERCHANT_ConfigInformation
{
/**
- * Currency used/supported by the merchant.
+ * Default currency of the merchant. See cspecs
+ * for all currencies supported by the merchant.
*/
const char *currency;
@@ -304,19 +312,96 @@ struct TALER_MERCHANT_ConfigInformation
/**
+ * Information about an exchange the merchant backend trusts.
+ */
+struct TALER_MERCHANT_ExchangeConfigInfo
+{
+ /**
+ * Base URL of the exchange REST API.
+ */
+ const char *base_url;
+
+ /**
+ * Currency for which the merchant is configured to
+ * trust the exchange.
+ */
+ const char *currency;
+
+ /**
+ * Master public key of the exchange.
+ */
+ struct TALER_MasterPublicKeyP master_pub;
+
+};
+
+/**
+ * Response to /config request.
+ */
+struct TALER_MERCHANT_ConfigResponse
+{
+ /**
+ * HTTP response.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Status-dependent details.
+ */
+ union
+ {
+ /**
+ * Information returned on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * basic information about the merchant
+ */
+ struct TALER_MERCHANT_ConfigInformation ci;
+
+ /**
+ * protocol compatibility information
+ */
+ enum TALER_MERCHANT_VersionCompatibility compat;
+
+ /**
+ * Length of the @e cspecs array.
+ */
+ unsigned int num_cspecs;
+
+ /**
+ * Array with rendering specifications for the currencies
+ * supported by this merchant backend.
+ */
+ const struct TALER_CurrencySpecification *cspecs;
+
+ /**
+ * Length of the @e exchanges array.
+ */
+ unsigned int num_exchanges;
+
+ /**
+ * Array details about exchanges trusted
+ * by this merchant backend.
+ */
+ const struct TALER_MERCHANT_ExchangeConfigInfo *exchanges;
+
+ } ok;
+ } details;
+};
+
+
+/**
* Function called with information about the merchant.
*
* @param cls closure
- * @param hr HTTP response data
- * @param ci basic information about the merchant
- * @param compat protocol compatibility information
+ * @param cr response data
*/
typedef void
(*TALER_MERCHANT_ConfigCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const struct TALER_MERCHANT_ConfigInformation *ci,
- enum TALER_MERCHANT_VersionCompatibility compat);
+ const struct TALER_MERCHANT_ConfigResponse *cr);
/**
@@ -338,17 +423,18 @@ struct TALER_MERCHANT_ConfigGetHandle;
* @return the config check handle; NULL upon 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);
+TALER_MERCHANT_config_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ TALER_MERCHANT_ConfigCallback config_cb,
+ void *config_cb_cls);
/**
* Cancel /config request. Must not be called by clients after
* the callback was invoked.
*
- * @param vgh request to cancel.
+ * @param[in] vgh request to cancel.
*/
void
TALER_MERCHANT_config_get_cancel (struct TALER_MERCHANT_ConfigGetHandle *vgh);
@@ -382,7 +468,12 @@ struct TALER_MERCHANT_InstanceInformation
* JSON array of payment targets (strings) supported by this backend
* instance.
*/
- json_t *payment_targets;
+ const json_t *payment_targets;
+
+ /**
+ * User type for the instance.
+ */
+ enum TALER_KYCLOGIC_KycUserType ut;
};
@@ -394,19 +485,47 @@ struct TALER_MERCHANT_InstancesGetHandle;
/**
+ * Response to a GET /instances request.
+ */
+struct TALER_MERCHANT_InstancesGetResponse
+{
+ /**
+ * HTTP response data
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ union
+ {
+ /**
+ * Data returned on #MHD_HTTP_OK status.
+ */
+ struct
+ {
+ /**
+ * length of the @e iis array
+ */
+ unsigned int iis_length;
+
+ /**
+ * array with instance information of length @e iis_length
+ */
+ const struct TALER_MERCHANT_InstanceInformation *iis;
+ } ok;
+ } details;
+
+};
+
+
+/**
* Function called with the result of the GET /instances operation.
*
* @param cls closure
- * @param hr HTTP response data
- * @param iis_length length of the @a iis array
- * @param iis array with instance information of length @a iis_length
+ * @param igr response data
*/
typedef void
(*TALER_MERCHANT_InstancesGetCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int iis_length,
- const struct TALER_MERCHANT_InstanceInformation iis[]);
+ const struct TALER_MERCHANT_InstancesGetResponse *igr);
/**
@@ -422,10 +541,11 @@ typedef void
* @return the instances handle; NULL upon 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);
+TALER_MERCHANT_instances_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ TALER_MERCHANT_InstancesGetCallback instances_cb,
+ void *instances_cb_cls);
/**
@@ -446,7 +566,7 @@ struct TALER_MERCHANT_InstancesPostHandle;
/**
- * Function called with the result of the GET /instances/$ID operation.
+ * Function called with the result of the POST /instances/$ID operation.
*
* @param cls closure
* @param hr HTTP response data
@@ -463,14 +583,11 @@ typedef void
* @param ctx the context
* @param backend_url HTTP base URL for the backend
* @param instance_id identity of the instance to get information about
- * @param accounts_length how many bank accounts this instance has
- * @param payto_uris URIs of the bank accounts of the merchant instance
* @param name name of the merchant instance
+ * @param ut user type of the merchant instance
* @param address physical address of the merchant instance
* @param jurisdiction jurisdiction of the merchant instance
- * @param default_max_wire_fee default maximum wire fee merchant is willing to fully pay
- * @param default_wire_fee_amortization default amortization factor for excess wire fees
- * @param default_max_deposit_fee default maximum deposit fee merchant is willing to pay
+ * @param use_stefan use STEFAN curve for acceptable fees
* @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 authentication token to use for access control, NULL for external auth; MUST follow RFC 8959
@@ -484,14 +601,11 @@ TALER_MERCHANT_instances_post (
struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const char *instance_id,
- unsigned int accounts_length,
- const char *payto_uris[],
const char *name,
+ enum TALER_KYCLOGIC_KycUserType ut,
const json_t *address,
const json_t *jurisdiction,
- const struct TALER_Amount *default_max_wire_fee,
- uint32_t default_wire_fee_amortization,
- const struct TALER_Amount *default_max_deposit_fee,
+ bool use_stefan,
struct GNUNET_TIME_Relative default_wire_transfer_delay,
struct GNUNET_TIME_Relative default_pay_delay,
const char *auth_token,
@@ -536,14 +650,11 @@ typedef void
* or base URL of an instance if @a instance_id is NULL)
* @param instance_id identity of the instance to modify information about; NULL
* if the instance is identified as part of the @a backend_url
- * @param accounts_length length of the @a accounts array
- * @param payto_uris URIs of the bank accounts of the merchant instance
* @param name name of the merchant instance
+ * @param ut user type of the merchant instance
* @param address physical address of the merchant instance
* @param jurisdiction jurisdiction of the merchant instance
- * @param default_max_wire_fee default maximum wire fee merchant is willing to fully pay
- * @param default_wire_fee_amortization default amortization factor for excess wire fees
- * @param default_max_deposit_fee default maximum deposit fee merchant is willing to pay
+ * @param use_stefan use STEFAN curve for acceptable fees
* @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 cb function to call with the
@@ -556,14 +667,11 @@ TALER_MERCHANT_instance_patch (
struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const char *instance_id,
- unsigned int accounts_length,
- const char *payto_uris[],
const char *name,
+ enum TALER_KYCLOGIC_KycUserType ut,
const json_t *address,
const json_t *jurisdiction,
- const struct TALER_Amount *default_max_wire_fee,
- uint32_t default_wire_fee_amortization,
- const struct TALER_Amount *default_max_deposit_fee,
+ bool use_stefan,
struct GNUNET_TIME_Relative default_wire_transfer_delay,
struct GNUNET_TIME_Relative default_pay_delay,
TALER_MERCHANT_InstancePatchCallback cb,
@@ -642,34 +750,6 @@ struct TALER_MERCHANT_InstanceGetHandle;
/**
- * Details about a merchant's bank account.
- */
-struct TALER_MERCHANT_Account
-{
- /**
- * salt used to compute h_wire
- */
- struct TALER_WireSaltP salt;
-
- /**
- * payto:// URI of the account.
- */
- const char *payto_uri;
-
- /**
- * Hash of @e payto_uri and @e salt.
- */
- struct TALER_MerchantWireHashP h_wire;
-
- /**
- * true if the account is active,
- * false if it is historic.
- */
- bool active;
-};
-
-
-/**
* Details about an instance.
*/
struct TALER_MERCHANT_InstanceDetails
@@ -682,7 +762,7 @@ struct TALER_MERCHANT_InstanceDetails
/**
* public key of the merchant instance
*/
- const struct TALER_MerchantPublicKeyP *merchant_pub;
+ struct TALER_MerchantPublicKeyP merchant_pub;
/**
* physical address of the merchant instance
@@ -695,29 +775,51 @@ struct TALER_MERCHANT_InstanceDetails
const json_t *jurisdiction;
/**
- * default maximum wire fee merchant is willing to fully pay
+ * Are we using STEFAN curves to determine acceptable
+ * fees?
*/
- const struct TALER_Amount *default_max_wire_fee;
+ bool use_stefan;
/**
- * default amortization factor for excess wire fees
+ * default wire transfer delay merchant will ask for
*/
- uint32_t default_wire_fee_amortization;
+ struct GNUNET_TIME_Relative default_wire_transfer_delay;
/**
- * default maximum deposit fee merchant is willing to pay
+ * default validity period for offers merchant makes
*/
- const struct TALER_Amount *default_max_deposit_fee;
+ struct GNUNET_TIME_Relative default_pay_delay;
/**
- * default wire transfer delay merchant will ask for
+ * User type for the instance.
*/
- struct GNUNET_TIME_Relative default_wire_transfer_delay;
+ enum TALER_KYCLOGIC_KycUserType ut;
+};
+
+struct TALER_MERCHANT_InstanceGetResponse
+{
/**
- * default validity period for offers merchant makes
+ * HTTP response data
*/
- struct GNUNET_TIME_Relative default_pay_delay;
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ union
+ {
+
+ /**
+ * Data returned on #MHD_HTTP_OK.
+ */
+ struct
+ {
+ /**
+ * Details about the instance.
+ */
+ struct TALER_MERCHANT_InstanceDetails details;
+
+ } ok;
+ }
+ details;
};
@@ -725,18 +827,12 @@ struct TALER_MERCHANT_InstanceDetails
* Function called with the result of the GET /instances/$ID operation.
*
* @param cls closure
- * @param hr HTTP response data
- * @param accounts_length length of the @a accounts array
- * @param accounts bank accounts of the merchant instance
- * @param details details about the instance configuration
+ * @param igr response details
*/
typedef void
(*TALER_MERCHANT_InstanceGetCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int accounts_length,
- const struct TALER_MERCHANT_Account accounts[],
- const struct TALER_MERCHANT_InstanceDetails *details);
+ const struct TALER_MERCHANT_InstanceGetResponse *igr);
/**
@@ -753,11 +849,12 @@ typedef void
* @return the instances handle; NULL upon 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);
+TALER_MERCHANT_instance_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *instance_id,
+ TALER_MERCHANT_InstanceGetCallback cb,
+ void *cb_cls);
/**
@@ -852,7 +949,422 @@ TALER_MERCHANT_instance_delete_cancel (
* @param arg request to cancel.
*/
#define TALER_MERCHANT_instance_purge_cancel(arg) \
- TALER_MERCHANT_instance_delete_cancel (arg)
+ TALER_MERCHANT_instance_delete_cancel (arg)
+
+
+/* *************** Accounts **************** */
+
+/**
+ * Handle for a POST /instances/$ID/accounts operation.
+ */
+struct TALER_MERCHANT_AccountsPostHandle;
+
+
+/**
+ * Response for a POST /instances/$ID/account operation.
+ */
+struct TALER_MERCHANT_AccountsPostResponse
+{
+ /**
+ * HTTP response data
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+
+ /**
+ * Details returned on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Hash of @e payto_uri and @e salt.
+ */
+ struct TALER_MerchantWireHashP h_wire;
+
+ /**
+ * salt used to compute h_wire
+ */
+ struct TALER_WireSaltP salt;
+ } ok;
+
+ } details;
+};
+
+
+/**
+ * Function called with the result of the POST /instances/$ID/accounts operation.
+ *
+ * @param cls closure
+ * @param par response data
+ */
+typedef void
+(*TALER_MERCHANT_AccountsPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_AccountsPostResponse *par);
+
+
+/**
+ * Setup an new account for an instance in the backend.
+ *
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param payto_uri URI of the bank account as per RFC 8905
+ * @param credit_facade_url credit facade for the account, can be NULL
+ * @param credit_facade_credentials credentials for credit facade, can be NULL
+ * @param cb function to call with the response
+ * @param cb_cls closure for @a config_cb
+ * @return the instances handle; NULL upon error
+ */
+struct TALER_MERCHANT_AccountsPostHandle *
+TALER_MERCHANT_accounts_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *payto_uri,
+ const char *credit_facade_url,
+ const json_t *credit_facade_credentials,
+ TALER_MERCHANT_AccountsPostCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel POST /accounts request. Must not be called by clients after
+ * the callback was invoked.
+ *
+ * @param pah request to cancel.
+ */
+void
+TALER_MERCHANT_accounts_post_cancel (
+ struct TALER_MERCHANT_AccountsPostHandle *pah);
+
+
+/**
+ * Handle for a GET /accounts/$ID operation.
+ */
+struct TALER_MERCHANT_AccountGetHandle;
+
+
+/**
+ * Details about a merchant's bank account.
+ */
+struct TALER_MERCHANT_AccountDetails
+{
+ /**
+ * salt used to compute h_wire
+ */
+ struct TALER_WireSaltP salt;
+
+ /**
+ * payto:// URI of the account.
+ */
+ const char *payto_uri;
+
+ /**
+ * Credit facade URL of the account.
+ */
+ const char *credit_facade_url;
+
+ /**
+ * Hash of @e payto_uri and @e salt.
+ */
+ struct TALER_MerchantWireHashP h_wire;
+
+ /**
+ * true if the account is active,
+ * false if it is historic.
+ */
+ bool active;
+};
+
+
+/**
+ * Response returned with details about an account.
+ */
+struct TALER_MERCHANT_AccountGetResponse
+{
+ /**
+ * HTTP response data
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ union
+ {
+
+ /**
+ * Data returned on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * bank accounts of the merchant instance
+ */
+ struct TALER_MERCHANT_AccountDetails ad;
+
+ } ok;
+ }
+ details;
+};
+
+
+/**
+ * Function called with the result of the GET /instances/$ID/accounts/$H_WIRE operation.
+ *
+ * @param cls closure
+ * @param igr response details
+ */
+typedef void
+(*TALER_MERCHANT_AccountGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_AccountGetResponse *igr);
+
+
+/**
+ * Get the details on one of the accounts of an instance. Will connect to the
+ * merchant backend and obtain information about the account. The respective
+ * information will be passed to the @a cb once available.
+ *
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param instance_id identity of the instance to get information about
+ * @param h_wire hash of the wire details
+ * @param cb function to call with the
+ * backend's instances information
+ * @param cb_cls closure for @a config_cb
+ * @return the instances handle; NULL upon 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 GET /accounts/$H_WIRE request. Must not be called by clients after
+ * the callback was invoked.
+ *
+ * @param igh request to cancel.
+ */
+void
+TALER_MERCHANT_account_get_cancel (
+ struct TALER_MERCHANT_AccountGetHandle *igh);
+
+
+/**
+ * Handle for a GET /accounts operation.
+ */
+struct TALER_MERCHANT_AccountsGetHandle;
+
+/**
+ * Individual account (minimal information
+ * returned via GET /accounts).
+ */
+struct TALER_MERCHANT_AccountEntry
+{
+ /**
+ * account payto URI.
+ */
+ const char *payto_uri;
+
+ /**
+ * Hash of @e payto_uri and salt.
+ */
+ struct TALER_MerchantWireHashP h_wire;
+
+};
+
+
+/**
+ * Response to a GET /accounts operation.
+ */
+struct TALER_MERCHANT_AccountsGetResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on status.
+ */
+ union
+ {
+ /**
+ * Details if status is #MHD_HTTP_OK.
+ */
+ struct
+ {
+ /**
+ * length of the @e accounts array
+ */
+ unsigned int accounts_length;
+
+ /**
+ * array of accounts the requested instance offers
+ */
+ const struct TALER_MERCHANT_AccountEntry *accounts;
+ } ok;
+ } details;
+};
+
+
+/**
+ * Function called with the result of the GET /accounts operation.
+ *
+ * @param cls closure
+ * @param tgr response details
+ */
+typedef void
+(*TALER_MERCHANT_AccountsGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_AccountsGetResponse *tgr);
+
+
+/**
+ * Make a GET /accounts request.
+ *
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param cb function to call with the backend information
+ * @param cb_cls closure for @a cb
+ * @return the request handle; NULL upon 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 GET /accounts operation.
+ *
+ * @param tgh operation to cancel
+ */
+void
+TALER_MERCHANT_accounts_get_cancel (
+ struct TALER_MERCHANT_AccountsGetHandle *tgh);
+
+
+/**
+ * Handle for a PATCH /account operation.
+ */
+struct TALER_MERCHANT_AccountPatchHandle;
+
+
+/**
+ * Function called with the result of the PATCH /account operation.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_AccountPatchCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Make a PATCH /accounts/$H_WIRE request to update account details. Cannot be used to change the payto URI or the salt.
+ *
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param h_wire identifies the account to patch
+ * @param credit_facade_url credit facade for the account, can be NULL
+ * @param credit_facade_credentials credentials for credit facade, can be NULL
+ * @param cb function to call with the backend's result
+ * @param cb_cls closure for @a cb
+ * @return the request handle; NULL upon 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 PATCH /accounts/$H_WIRE operation.
+ *
+ * @param[in] tph operation to cancel
+ */
+void
+TALER_MERCHANT_account_patch_cancel (
+ struct TALER_MERCHANT_AccountPatchHandle *tph);
+
+
+/**
+ * Handle for a DELETE /instances/$ID/account/$H_WIRE operation.
+ */
+struct TALER_MERCHANT_AccountDeleteHandle;
+
+
+/**
+ * Response for a DELETE /instances/$ID/account operation.
+ */
+struct TALER_MERCHANT_AccountDeleteResponse
+{
+ /**
+ * HTTP response data
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+};
+
+
+/**
+ * Function called with the result of the DELETE /instances/$ID/account/$H_WIRE operation.
+ *
+ * @param cls closure
+ * @param par response data
+ */
+typedef void
+(*TALER_MERCHANT_AccountDeleteCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_AccountDeleteResponse *par);
+
+
+/**
+ * Remove bank account from an instance in the backend.
+ *
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param h_wire wire hash of the bank accounts to delete
+ * @param cb function to call with the response
+ * @param cb_cls closure for @a config_cb
+ * @return the instances handle; NULL upon 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 /account request. Must not be called by clients after
+ * the callback was invoked.
+ *
+ * @param pah request to cancel.
+ */
+void
+TALER_MERCHANT_account_delete_cancel (
+ struct TALER_MERCHANT_AccountDeleteHandle *pah);
/* ********************* /products *********************** */
@@ -874,6 +1386,40 @@ struct TALER_MERCHANT_InventoryEntry
*/
const char *product_id;
+ /**
+ * Serial ID of the product.
+ */
+ uint64_t product_serial;
+};
+
+
+/**
+ * Response to a GET /products request.
+ */
+struct TALER_MERCHANT_GetProductsResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ union
+ {
+ struct
+ {
+
+ /**
+ * length of the @a products array
+ */
+ unsigned int products_length;
+
+ /**
+ * array of products the requested instance offers
+ */
+ const struct TALER_MERCHANT_InventoryEntry *products;
+ } ok;
+
+ } details;
};
@@ -881,16 +1427,12 @@ struct TALER_MERCHANT_InventoryEntry
* Function called with the result of the GET /products operation.
*
* @param cls closure
- * @param hr HTTP response details
- * @param products_length length of the @a products array
- * @param products array of products the requested instance offers
+ * @param gpr response details
*/
typedef void
(*TALER_MERCHANT_ProductsGetCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int products_length,
- const struct TALER_MERCHANT_InventoryEntry products[]);
+ const struct TALER_MERCHANT_GetProductsResponse *gpr);
/**
@@ -930,44 +1472,104 @@ struct TALER_MERCHANT_ProductGetHandle;
/**
+ * Response to GET /product/$ID operation.
+ */
+struct TALER_MERCHANT_ProductGetResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+ /**
+ * Details for #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * description of the product
+ */
+ const char *description;
+
+ /**
+ * Map from IETF BCP 47 language tags to localized descriptions
+ */
+ const json_t *description_i18n;
+
+ /**
+ * unit in which the product is measured (liters, kilograms, packages, etc.)
+ */
+ const char *unit;
+
+ /**
+ * 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.
+ */
+ struct TALER_Amount price;
+
+ /**
+ * base64-encoded product image
+ */
+ const char *image;
+
+ /**
+ * list of taxes paid by the merchant
+ */
+ const json_t *taxes;
+
+ /**
+ * total_stock in @e units, -1 to indicate "infinite" (i.e. electronic
+ * books), does NOT indicate remaining stocks, to get remaining stocks,
+ * subtract @e total_sold and @e total_lost. Note that this still does
+ * not then say how many of the remaining inventory are locked.
+ */
+ int64_t total_stock;
+
+ /**
+ * in @e units, total number of @e unit of product sold
+ */
+ uint64_t total_sold;
+
+ /**
+ * in @e units, total number of @e unit of product lost from inventory
+ */
+ uint64_t total_lost;
+
+ /**
+ * where the product is in stock
+ */
+ const json_t *location;
+
+ /**
+ * when the next restocking is expected to happen, 0 for unknown,
+ * #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
+ */
+ struct GNUNET_TIME_Timestamp next_restock;
+ } ok;
+
+ } details;
+
+};
+
+
+/**
* Function called with the result of the GET /products operation.
*
* @param cls closure
- * @param hr HTTP response details
- * @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),
- * does NOT indicate remaining stocks, to get remaining stocks,
- * subtract @a total_sold and @a total_lost. Note that this still
- * does not then say how many of the remaining inventory are locked.
- * @param total_sold in @a units, total number of @a unit of product sold
- * @param total_lost in @a units, total number of @a unit of product lost from inventory
- * @param location 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 pgr response details
*/
typedef void
(*TALER_MERCHANT_ProductGetCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- 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_sold,
- uint64_t total_lost,
- const json_t *location,
- struct GNUNET_TIME_Timestamp next_restock);
+ const struct TALER_MERCHANT_ProductGetResponse *pgr);
/**
@@ -1061,6 +1663,50 @@ TALER_MERCHANT_products_post (
/**
+ * Make a POST /products request to add a product to the
+ * inventory.
+ *
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param product_id identifier to use for the product
+ * @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 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 minimum_age minimum age the buyer must have
+ * @param cb function to call with the backend's result
+ * @param cb_cls closure for @a cb
+ * @return the request handle; NULL upon 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);
+
+
+/**
* Cancel POST /products operation.
*
* @param pph operation to cancel
@@ -1249,6 +1895,172 @@ TALER_MERCHANT_product_delete_cancel (
struct TALER_MERCHANT_ProductDeleteHandle *pdh);
+/* ********************* /tokenfamilies ************************** */
+
+/**
+ * Handle for a GET /tokenfamilies/$SLUG operation.
+ */
+struct TALER_MERCHANT_TokenFamilyGetHandle;
+
+
+/**
+ * Response to GET /tokenfamilies/$SLUG operation.
+ */
+struct TALER_MERCHANT_TokenFamilyGetResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+ /**
+ * Details for #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Identifier for the token family consisting of unreserved characters
+ * according to RFC 3986.
+ */
+ const char *slug;
+
+ /**
+ * Human-readable name for the token family.
+ */
+ const char *name;
+
+ /**
+ * description of the token family
+ */
+ const char *description;
+
+ /**
+ * Optional map from IETF BCP 47 language tags to localized descriptions.
+ */
+ const json_t *description_i18n;
+
+ /**
+ * Start time of the token family's validity period.
+ */
+ struct GNUNET_TIME_Timestamp valid_after;
+
+ /**
+ * End time of the token family's validity period.
+ */
+ struct GNUNET_TIME_Timestamp valid_before;
+
+ /**
+ * Validity duration of an issued token.
+ */
+ struct GNUNET_TIME_Relative duration;
+
+ /**
+ * Kind of token family, "subscription" or "discount".
+ */
+ const char *kind;
+
+ /**
+ * How many tokens have been issued for this family.
+ */
+ uint64_t issued;
+
+ /**
+ * How many tokens have been redeemed for this family.
+ */
+ uint64_t redeemed;
+ } ok;
+
+ } details;
+
+};
+
+/**
+ * Cancel GET /tokenfamilies/$SLUG operation.
+ *
+ * @param handle operation to cancel
+ */
+void
+TALER_MERCHANT_token_family_get_cancel (
+ struct TALER_MERCHANT_TokenFamilyGetHandle *handle);
+
+
+/**
+ * Function called with the result of the GET /tokenfamilies/$SLUG operation.
+ *
+ * @param cls closure
+ * @param pgr response details
+ */
+typedef void
+(*TALER_MERCHANT_TokenFamilyGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_TokenFamilyGetResponse *pgr);
+
+/**
+ * Handle for a POST /tokenfamilies operation.
+ */
+struct TALER_MERCHANT_TokenFamiliesPostHandle;
+
+
+/**
+ * Function called with the result of the POST /tokenfamilies operation.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_TokenFamiliesPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Make a POST /tokenfamilies request to add a token family to the
+ * merchant instance.
+ *
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param slug short, url-safe identifier for the token family
+ * @param name human-readable name for the token family
+ * @param description description of the token family
+ * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
+ * @param valid_after when the token family becomes valid
+ * @param valid_before when the token family expires
+ * @param duration how long tokens issued by this token family are valid for
+ * @param kind kind of token family, "subscription" or "discount"
+ * @param cb function to call with the backend's result
+ * @param cb_cls closure for @a cb
+ * @return the request handle; NULL upon 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,
+ struct GNUNET_TIME_Timestamp valid_after,
+ struct GNUNET_TIME_Timestamp valid_before,
+ struct GNUNET_TIME_Relative duration,
+ const char *kind,
+ TALER_MERCHANT_TokenFamiliesPostCallback cb,
+ void *cb_cls);
+
+/**
+ * Cancel POST /tokenfamilies operation.
+ *
+ * @param handle operation to cancel
+ */
+void
+TALER_MERCHANT_token_families_post_cancel (
+ struct TALER_MERCHANT_TokenFamiliesPostHandle *handle);
+
/* ********************* /orders ************************** */
@@ -1359,12 +2171,13 @@ typedef void
* @return a handle for this request, NULL on 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);
+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);
/**
* Information needed per product for constructing orders from
@@ -1414,7 +2227,44 @@ TALER_MERCHANT_orders_post2 (
unsigned int inventory_products_length,
const struct TALER_MERCHANT_InventoryProduct inventory_products[],
unsigned int uuids_length,
- const char *uuids[],
+ const char *uuids[static uuids_length],
+ bool create_token,
+ TALER_MERCHANT_PostOrdersCallback cb,
+ void *cb_cls);
+
+
+/**
+ * POST to /orders at the backend to setup an order and obtain
+ * the order ID (which may have been set by the front-end).
+ *
+ * @param ctx execution context
+ * @param backend_url URL of the backend
+ * @param order basic information about this purchase, to be extended by the backend
+ * @param session_id session ID to set for the order
+ * @param refund_delay how long can refunds happen for this order; 0 to use
+ * absolute value from contract (or not allow refunds).
+ * @param payment_target desired payment target identifier (to select merchant bank details)
+ * @param inventory_products_length length of the @a inventory_products array
+ * @param inventory_products products to add to the order from the inventory
+ * @param uuids_length length of the @a uuids array
+ * @param uuids array of UUIDs with locks on @a inventory_products
+ * @param create_token whether to create a claim token
+ * @param cb the callback to call when a reply for this request is available
+ * @param cb_cls closure for @a cb
+ * @return a handle for this request, NULL on 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[static uuids_length],
bool create_token,
TALER_MERCHANT_PostOrdersCallback cb,
void *cb_cls);
@@ -1424,7 +2274,7 @@ TALER_MERCHANT_orders_post2 (
* Cancel a POST /orders request. This function cannot be used
* on a request handle if a response is already served for it.
*
- * @param po the proposal operation request handle
+ * @param[in] po the proposal operation request handle
*/
void
TALER_MERCHANT_orders_post_cancel (
@@ -1482,19 +2332,51 @@ struct TALER_MERCHANT_OrderEntry
/**
+ * Response for a GET /private/orders request.
+ */
+struct TALER_MERCHANT_OrdersGetResponse
+{
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+ /**
+ * Details for #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * length of the @e orders array
+ */
+ unsigned int orders_length;
+
+ /**
+ * array of orders the requested instance has made
+ */
+ const struct TALER_MERCHANT_OrderEntry *orders;
+ } ok;
+ } details;
+
+};
+
+
+/**
* Function called with the result of the GET /orders operation.
*
* @param cls closure
- * @param hr HTTP response details
- * @param orders_length length of the @a orders array
- * @param orders array of orders the requested instance has made
+ * @param ogr response details
*/
typedef void
(*TALER_MERCHANT_OrdersGetCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int orders_length,
- const struct TALER_MERCHANT_OrderEntry orders[]);
+ const struct TALER_MERCHANT_OrdersGetResponse *ogr);
/**
@@ -1548,9 +2430,46 @@ TALER_MERCHANT_orders_get2 (
/**
+ * Make a GET /orders request with more filters.
+ *
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param paid filter on payment status
+ * @param refunded filter on refund status
+ * @param wired filter on wire transfer status
+ * @param session_id filter by session ID
+ * @param fulfillment_url filter by fulfillment URL
+ * @param date range limit by date
+ * @param start_row range limit by order table row
+ * @param delta range from which @a date and @a start_row apply, positive
+ * to return delta items after the given limit(s), negative to
+ * return delta items before the given limit(s)
+ * @param timeout how long to wait (long polling) of zero results match the query
+ * @param cb function to call with the backend's inventory information
+ * @param cb_cls closure for @a cb
+ * @return the request handle; NULL upon 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 GET /orders operation.
*
- * @param pgh operation to cancel
+ * @param[in] pgh operation to cancel
*/
void
TALER_MERCHANT_orders_get_cancel (
@@ -1602,7 +2521,7 @@ struct TALER_MERCHANT_OrderWalletGetResponse
*/
struct TALER_Amount refund_amount;
- } success;
+ } ok;
/**
* Response if a payment is required from the client.
@@ -1679,7 +2598,7 @@ TALER_MERCHANT_wallet_order_get (
/**
* Cancel a GET /orders/$ID request.
*
- * @param owgh handle to the request to be canceled
+ * @param[in] owgh handle to the request to be canceled
*/
void
TALER_MERCHANT_wallet_order_get_cancel (
@@ -1871,17 +2790,6 @@ struct TALER_MERCHANT_OrderStatusResponse
unsigned int wts_len;
/**
- * Array of wire reports about problems tracking wire transfers.
- * Of length @e wrs_len.
- */
- struct TALER_MERCHANT_WireReport *wrs;
-
- /**
- * Length of the @e wrs array.
- */
- unsigned int wrs_len;
-
- /**
* Details returned by the merchant backend about refunds.
* Of length @e refunds_len.
*/
@@ -1922,6 +2830,12 @@ struct TALER_MERCHANT_OrderStatusResponse
*/
bool wired;
+ /**
+ * Time of the last payment made on this order.
+ * Only available if the server supports protocol
+ * **v14** or higher, otherwise zero.
+ */
+ struct GNUNET_TIME_Timestamp last_payment;
} paid;
/**
@@ -1974,7 +2888,7 @@ struct TALER_MERCHANT_OrderStatusResponse
} details;
- } success;
+ } ok;
} details;
};
@@ -1999,10 +2913,8 @@ typedef void
* @param ctx execution context
* @param backend_url base URL of the merchant backend
* @param order_id order id to identify the payment
- * @param session_id sesion id for the payment (or NULL if the check is not
+ * @param session_id session id for the payment (or NULL if the check is not
* bound to a session)
- * @param transfer if true, obtain the wire transfer status from the exchange.
- * Otherwise, the wire transfer status MAY be returned if it is available.
* @param timeout timeout to use in long polling (how long may the server wait to reply
* before generating an unpaid response). Note that this is just provided to
* the server, we as client will block until the response comes back or until
@@ -2016,7 +2928,6 @@ TALER_MERCHANT_merchant_order_get (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const char *order_id,
const char *session_id,
- bool transfer,
struct GNUNET_TIME_Relative timeout,
TALER_MERCHANT_OrderMerchantGetCallback cb,
void *cb_cls);
@@ -2025,7 +2936,7 @@ TALER_MERCHANT_merchant_order_get (struct GNUNET_CURL_Context *ctx,
/**
* Cancel a GET /private/orders/$ID request.
*
- * @param omgh handle to the request to be canceled
+ * @param[in] omgh handle to the request to be canceled
*/
void
TALER_MERCHANT_merchant_order_get_cancel (
@@ -2075,7 +2986,7 @@ TALER_MERCHANT_order_delete (
/**
* Cancel DELETE /orders/$ID operation.
*
- * @param odh operation to cancel
+ * @param[in] odh operation to cancel
*/
void
TALER_MERCHANT_order_delete_cancel (
@@ -2089,22 +3000,54 @@ struct TALER_MERCHANT_OrderClaimHandle;
/**
+ * Response to a POST /orders/$ID/claim request.
+ */
+struct TALER_MERCHANT_OrderClaimResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+ /**
+ * Details for #MHD_HTTP_OK.
+ */
+ struct
+ {
+ /**
+ * the details of the contract
+ */
+ const json_t *contract_terms;
+
+ /**
+ * merchant's signature over @e contract_terms (already verified)
+ */
+ struct TALER_MerchantSignatureP sig;
+
+ /**
+ * hash over @e contract_terms (computed client-side to verify @e sig)
+ */
+ struct TALER_PrivateContractHashP h_contract_terms;
+ } ok;
+
+ } details;
+};
+
+/**
* Callback called to process a POST /orders/$ID/claim response.
*
* @param cls closure
- * @param hr HTTP response details
- * @param contract_terms the details of the contract
- * @param sig merchant's signature over @a contract_terms (already verified)
- * @param h_contract_terms hash over @a contract_terms (computed
- * client-side to verify @a sig)
+ * @param ocr response details
*/
typedef void
(*TALER_MERCHANT_OrderClaimCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const json_t *contract_terms,
- const struct TALER_MerchantSignatureP *sig,
- const struct TALER_PrivateContractHashP *h_contract_terms);
+ const struct TALER_MERCHANT_OrderClaimResponse *ocr);
/**
@@ -2123,19 +3066,20 @@ typedef void
* @return handle for this handle, NULL upon errors
*/
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);
+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 /order/$ID/claim request.
*
- * @param och handle to the request to be canceled
+ * @param[in] och handle to the request to be canceled
*/
void
TALER_MERCHANT_order_claim_cancel (struct TALER_MERCHANT_OrderClaimHandle *och);
@@ -2179,7 +3123,12 @@ struct TALER_MERCHANT_PayResponse
*/
struct TALER_MerchantSignatureP merchant_sig;
- } success;
+ /**
+ * Optional payment confirmation code returned by the service.
+ */
+ const char *pos_confirmation;
+
+ } ok;
// TODO: might want to return further details on errors,
// especially refund signatures on double-pay conflict.
@@ -2263,6 +3212,7 @@ struct TALER_MERCHANT_PaidCoin
* @param merchant_url base URL of the merchant
* @param order_id which order should be paid
* @param session_id session to pay for, or NULL for none
+ * @param wallet_data inputs from the wallet for the contract, NULL for none
* @param num_coins length of the @a coins array
* @param coins array of coins to pay with
* @param pay_cb the callback to call when a reply for this request is available
@@ -2275,8 +3225,9 @@ TALER_MERCHANT_order_pay_frontend (
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[],
+ const struct TALER_MERCHANT_PaidCoin coins[static num_coins],
TALER_MERCHANT_OrderPayCallback pay_cb,
void *pay_cb_cls);
@@ -2339,6 +3290,7 @@ struct TALER_MERCHANT_PayCoin
* @param merchant_url base URL of the merchant
* @param session_id session to pay for, or NULL for none
* @param h_contract hash of the contact of the merchant with the customer
+ * @param wallet_data inputs from the wallet for the contract, NULL for none
* @param amount total value of the contract to be paid to the merchant
* @param max_fee maximum fee covered by the merchant (according to the contract)
* @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
@@ -2355,23 +3307,25 @@ struct TALER_MERCHANT_PayCoin
* @return a handle for this request
*/
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,
- 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[],
- TALER_MERCHANT_OrderPayCallback pay_cb,
- void *pay_cb_cls);
+TALER_MERCHANT_order_pay (
+ struct GNUNET_CURL_Context *ctx,
+ const char *merchant_url,
+ const char *session_id,
+ const struct TALER_PrivateContractHashP *h_contract,
+ const json_t *wallet_data,
+ 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],
+ TALER_MERCHANT_OrderPayCallback pay_cb,
+ void *pay_cb_cls);
/**
@@ -2393,18 +3347,46 @@ TALER_MERCHANT_order_pay_cancel (struct TALER_MERCHANT_OrderPayHandle *oph);
*/
struct TALER_MERCHANT_OrderPaidHandle;
+/**
+ * Response to an /orders/$ID/paid request.
+ */
+struct TALER_MERCHANT_OrderPaidResponse
+{
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+ /**
+ * HTTP-status code dependent details.
+ */
+ union
+ {
+ /**
+ * Details on success.
+ */
+ struct
+ {
+ /**
+ * Set to true if the order was paid but also
+ * refunded.
+ */
+ bool refunded;
+ } ok;
+ } details;
+};
+
/**
* Callbacks of this type are used to serve the result of submitting a
* POST /orders/$ID/paid request to a merchant.
*
* @param cls closure
- * @param hr HTTP response details
+ * @param opr response details
*/
typedef void
(*TALER_MERCHANT_OrderPaidCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr);
+ const struct TALER_MERCHANT_OrderPaidResponse *opr);
/**
@@ -2418,6 +3400,7 @@ typedef void
* @param order_id which order should be paid
* @param session_id session to pay for, or NULL for none
* @param h_contract_terms hash of the contract terms
+ * @param wallet_data_hash inputs from the wallet for the contract, NULL for none
* @param merchant_sig signature from the merchant
* affirming payment, or NULL on errors
* @param paid_cb the callback to call when a reply for this request is available
@@ -2431,6 +3414,7 @@ TALER_MERCHANT_order_paid (
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);
@@ -2470,22 +3454,57 @@ struct TALER_MERCHANT_AbortedCoin
/**
+ * Response to an /orders/$ID/abort request.
+ */
+struct TALER_MERCHANT_AbortResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status code.
+ */
+ union
+ {
+ /**
+ * Details for #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * public key of the merchant
+ */
+ const struct TALER_MerchantPublicKeyP *merchant_pub;
+
+ /**
+ * size of the @e aborts array
+ */
+ unsigned int num_aborts;
+
+ /**
+ * merchant signatures refunding coins
+ */
+ const struct TALER_MERCHANT_AbortedCoin *aborts;
+ } ok;
+
+ } details;
+};
+
+
+/**
* Callbacks of this type are used to serve the result of submitting a
* /orders/$ID/abort request to a merchant.
*
* @param cls closure
- * @param hr HTTP response details
- * @param merchant_pub public key of the merchant
- * @param num_aborts size of the @a res array, 0 on errors
- * @param aborts merchant signatures refunding coins, NULL on errors
+ * @param ar response details
*/
typedef void
(*TALER_MERCHANT_AbortCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const struct TALER_MerchantPublicKeyP *merchant_pub,
- unsigned int num_aborts,
- const struct TALER_MERCHANT_AbortedCoin aborts[]);
+ const struct TALER_MERCHANT_AbortResponse *ar);
/**
@@ -2530,15 +3549,16 @@ struct TALER_MERCHANT_AbortCoin
* @return a handle for this request
*/
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[],
- TALER_MERCHANT_AbortCallback cb,
- void *cb_cls);
+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);
/**
@@ -2585,13 +3605,14 @@ typedef void
* @return a handle for this request.
*/
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[],
- TALER_MERCHANT_ForgetCallback cb,
- void *cb_cls);
+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);
/**
@@ -2599,11 +3620,11 @@ TALER_MERCHANT_order_forget (struct GNUNET_CURL_Context *ctx,
* like this, you have no assurance that the request has not yet been
* forwarded to the merchant.
*
- * @param ofh the forget request handle
+ * @param[in] ofh the forget request handle
*/
void
-TALER_MERCHANT_order_forget_cancel (struct
- TALER_MERCHANT_OrderForgetHandle *ofh);
+TALER_MERCHANT_order_forget_cancel (
+ struct TALER_MERCHANT_OrderForgetHandle *ofh);
/**
@@ -2613,20 +3634,51 @@ struct TALER_MERCHANT_OrderRefundHandle;
/**
- * Callback to process a POST /orders/ID/refund request
+ * Response to a POST /orders/$ID/refund request
+ */
+struct TALER_MERCHANT_RefundResponse
+{
+ /**
+ * HTTP response details this request
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+ /**
+ * Details if status is #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * the refund uri offered to the wallet
+ */
+ const char *taler_refund_uri;
+
+ /**
+ * Hash of the contract a wallet may need to authorize obtaining the HTTP
+ * response.
+ */
+ struct TALER_PrivateContractHashP h_contract;
+ } ok;
+ } details;
+};
+
+
+/**
+ * Callback to process a POST /orders/$ID/refund request
*
* @param cls closure
- * @param hr HTTP response details this request
- * @param taler_refund_uri the refund uri offered to the wallet
- * @param h_contract hash of the contract a Browser may need to authorize
- * obtaining the HTTP response.
+ * @param rr response details this request
*/
typedef void
(*TALER_MERCHANT_RefundCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const char *taler_refund_uri,
- const struct TALER_PrivateContractHashP *h_contract);
+ const struct TALER_MERCHANT_RefundResponse *rr);
/**
@@ -2641,13 +3693,14 @@ typedef void
* @param cb_cls closure for cb
*/
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);
+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 /refund request.
@@ -2693,17 +3746,74 @@ struct TALER_MERCHANT_RefundDetail
struct TALER_Amount refund_amount;
/**
- * Public key of the exchange affirming the refund,
- * only valid if the @e hr http_status is #MHD_HTTP_OK.
+ * Details depending on exchange HTTP status.
*/
- struct TALER_ExchangePublicKeyP exchange_pub;
+ 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 to a POST /orders/$ID/refund request
+ * for wallet API.
+ */
+struct TALER_MERCHANT_WalletRefundResponse
+{
/**
- * Signature of the exchange affirming the refund,
- * only valid if the @e hr http_status is #MHD_HTTP_OK.
+ * HTTP response details this request
*/
- struct TALER_ExchangeSignatureP exchange_sig;
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+ /**
+ * Details if status is #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Total amount of the refund that was granted
+ */
+ struct TALER_Amount refund_amount;
+
+ /**
+ * public key of the merchant signing the @e refunds
+ */
+ struct TALER_MerchantPublicKeyP merchant_pub;
+
+ /**
+ * array with details about the refunds obtained
+ */
+ const struct TALER_MERCHANT_RefundDetail *refunds;
+ /**
+ * length of the @e refunds array
+ */
+ unsigned int refunds_length;
+ } ok;
+ } details;
};
@@ -2711,20 +3821,12 @@ struct TALER_MERCHANT_RefundDetail
* Callback to process a (public) POST /orders/ID/refund request
*
* @param cls closure
- * @param hr HTTP response details
- * @param refund_amount what is the total amount of the refund that was granted
- * @param merchant_pub public key of the merchant signing the @a refunds
- * @param refunds array with details about the refunds obtained
- * @param refunds_length length of the @a refunds array
+ * @param wrr HTTP response details
*/
typedef void
(*TALER_MERCHANT_WalletRefundCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const struct TALER_Amount *refund_amount,
- const struct TALER_MerchantPublicKeyP *merchant_pub,
- struct TALER_MERCHANT_RefundDetail refunds[],
- unsigned int refunds_length);
+ const struct TALER_MERCHANT_WalletRefundResponse *wrr);
/**
@@ -2763,56 +3865,56 @@ TALER_MERCHANT_wallet_post_order_refund_cancel (
*/
struct TALER_MERCHANT_PostTransfersHandle;
+
/**
- * Information about the _total_ amount that was paid back
- * by the exchange for a given h_contract_terms, by _one_ wire
- * transfer.
+ * @brief Response to a POST /transfers operation from a merchant's backend.
*/
-struct TALER_MERCHANT_TrackTransferDetail
+struct TALER_MERCHANT_PostTransfersResponse
{
-
/**
- * Total amount paid back by the exchange.
+ * HTTP response details
*/
- struct TALER_Amount deposit_value;
+ struct TALER_MERCHANT_HttpResponse hr;
/**
- * Total amount of deposit fees.
+ * Details depending on HTTP status.
*/
- struct TALER_Amount deposit_fee;
+ union
+ {
- /**
- * Order ID associated whit this payment.
- */
- const char *order_id;
+ /**
+ * Details if we got an #MHD_HTTP_BAD_GATEWAY.
+ */
+ struct
+ {
+ /**
+ * HTTP status of the exchange (or 0 if not available).
+ */
+ unsigned int exchange_http_status;
+
+ /**
+ * Error code of the exchange (or TALER_EC_NONE if not available).
+ */
+ enum TALER_ErrorCode exchange_ec;
+
+ } bad_gateway;
+
+ } details;
};
+
/**
* Callbacks of this type are used to work the result of submitting a
* POST /transfers request to a merchant
*
* @param cls closure
- * @param hr HTTP response details
- * @param execution_time when did the transfer happen (according to the exchange),
- * #GNUNET_TIME_UNIT_FOREVER_ABS if the transfer did not yet happen or if
- * we have no data from the exchange about it
- * @param total_amount total amount of the wire transfer, or NULL if the exchange did
- * not provide any details
- * @param wire_fee how much did the exchange charge in terms of wire fees, or NULL
- * if the exchange did not provide any details
- * @param details_length length of the @a details array
- * @param details array with details about the combined transactions
+ * @param ptr response details
*/
typedef void
(*TALER_MERCHANT_PostTransfersCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- struct GNUNET_TIME_Timestamp execution_time,
- const struct TALER_Amount *total_amount,
- const struct TALER_Amount *wire_fee,
- unsigned int details_length,
- const struct TALER_MERCHANT_TrackTransferDetail details[]);
+ const struct TALER_MERCHANT_PostTransfersResponse *ptr);
/**
@@ -2964,21 +4066,54 @@ struct TALER_MERCHANT_TransferData
};
+
+/**
+ * Response from a GET /transfers request.
+ */
+struct TALER_MERCHANT_GetTransfersResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+
+ /**
+ * Details for status #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * length of the @e transfers array
+ */
+ unsigned int transfers_length;
+
+ /**
+ * array with details about the transfers we received
+ */
+ const struct TALER_MERCHANT_TransferData *transfers;
+ } ok;
+ } details;
+};
+
+
/**
* Callbacks of this type are used to work the result of submitting a
* GET /transfers request to a merchant
*
* @param cls closure
- * @param hr HTTP response details
- * @param transfers_length length of the @a transfers array
- * @param transfers array with details about the transfers we received
+ * @param gtr HTTP response details
*/
typedef void
(*TALER_MERCHANT_GetTransfersCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int transfers_length,
- const struct TALER_MERCHANT_TransferData transfers[]);
+ const struct TALER_MERCHANT_GetTransfersResponse *gtr);
/**
@@ -3033,548 +4168,353 @@ TALER_MERCHANT_transfers_get_cancel (
struct TALER_MERCHANT_GetTransfersHandle *gth);
-/* ******************* /reserves *************** */
-
-
-/**
- * @brief Handle to a POST /reserves operation at a merchant's backend.
- */
-struct TALER_MERCHANT_PostReservesHandle;
-
-
-/**
- * Callbacks of this type are used to work the result of submitting a
- * POST /reserves request to a merchant
- *
- * @param cls closure
- * @param hr HTTP response details
- * @param reserve_pub public key of the created reserve, NULL on error
- * @param payto_uri where to make the payment to for filling the reserve, NULL on error
- */
-typedef void
-(*TALER_MERCHANT_PostReservesCallback) (
- void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const char *payto_uri);
-
-
-/**
- * Request backend to create a reserve.
- *
- * @param ctx execution context
- * @param backend_url base URL of the backend
- * @param initial_balance desired initial balance for the reserve
- * @param exchange_url what is the URL of the exchange where the reserve should be set up
- * @param wire_method desired wire method, for example "iban" or "x-taler-bank"
- * @param cb the callback to call when a reply for this request is available
- * @param cb_cls closure for @a cb
- * @return a handle for this request
- */
-struct TALER_MERCHANT_PostReservesHandle *
-TALER_MERCHANT_reserves_post (
- struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct TALER_Amount *initial_balance,
- const char *exchange_url,
- const char *wire_method,
- TALER_MERCHANT_PostReservesCallback cb,
- void *cb_cls);
-
-
-/**
- * Cancel a POST /reserves request. This function cannot be used
- * on a request handle if a response is already served for it.
- *
- * @param prh the operation to cancel
- */
-void
-TALER_MERCHANT_reserves_post_cancel (
- struct TALER_MERCHANT_PostReservesHandle *prh);
-
+/* ********************* /kyc ************************** */
/**
- * Handle for a GET /reserves operation.
+ * Handle for getting the KYC status of instance(s).
*/
-struct TALER_MERCHANT_ReservesGetHandle;
+struct TALER_MERCHANT_KycGetHandle;
/**
- * Information about a reserve.
+ * Information about KYC actions the merchant still must perform.
*/
-struct TALER_MERCHANT_ReserveSummary
+struct TALER_MERCHANT_AccountKycRedirectDetail
{
- /**
- * Public key of the reserve
- */
- struct TALER_ReservePublicKeyP reserve_pub;
/**
- * Timestamp when it was established
+ * URL that the user should open in a browser to
+ * proceed with the KYC process (as returned
+ * by the exchange's /kyc-check/ endpoint). Can
+ * be NULL, specifically if KYC is satisfied but
+ * the transactions are hanging in AML.
*/
- struct GNUNET_TIME_Timestamp creation_time;
+ const char *kyc_url;
/**
- * Timestamp when it expires
+ * Base URL of the exchange this is about.
*/
- struct GNUNET_TIME_Timestamp expiration_time;
+ const char *exchange_url;
/**
- * Initial amount as per reserve creation call
+ * Our bank wire account this is about.
*/
- struct TALER_Amount merchant_initial_amount;
+ const char *payto_uri;
/**
- * Initial amount as per exchange, 0 if exchange did
- * not confirm reserve creation yet.
+ * AML state for our account.
*/
- struct TALER_Amount exchange_initial_amount;
+ enum TALER_AmlDecisionState aml_status;
+};
+
+/**
+ * Information about KYC status failures at the exchange.
+ */
+struct TALER_MERCHANT_ExchangeKycFailureDetail
+{
/**
- * Amount picked up so far.
+ * Base URL of the exchange this is about.
*/
- struct TALER_Amount pickup_amount;
+ const char *exchange_url;
/**
- * Amount approved for tips that exceeds the pickup_amount.
+ * Error code indicating errors the exchange
+ * returned, or #TALER_EC_INVALID for none.
*/
- struct TALER_Amount committed_amount;
+ enum TALER_ErrorCode exchange_code;
/**
- * Is this reserve active (false if it was deleted but not purged)
+ * HTTP status code returned by the exchange when we asked for
+ * information about the KYC status.
+ * 0 if there was no response at all.
*/
- bool active;
+ unsigned int exchange_http_status;
};
/**
- * Callback to process a GET /reserves request
- *
- * @param cls closure
- * @param hr HTTP response details
- * @param reserves_length length of the @a reserves array
- * @param reserves array with details about the reserves, NULL on error
- */
-typedef void
-(*TALER_MERCHANT_ReservesGetCallback) (
- void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int reserves_length,
- const struct TALER_MERCHANT_ReserveSummary reserves[]);
-
-
-/**
- * Issue a GET /reserves request to the backend. Informs the backend
- * that a customer wants to pick up a reserves.
- *
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param after filter for reserves created after this date, use 0 for no filtering
- * @param active filter for reserves that are active
- * @param failures filter for reserves where we disagree about the balance with
- * the exchange
- * @param cb function to call with the result(s)
- * @param cb_cls closure for @a cb
- * @return handle for this operation, NULL upon errors
- */
-struct TALER_MERCHANT_ReservesGetHandle *
-TALER_MERCHANT_reserves_get (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- struct GNUNET_TIME_Timestamp after,
- enum TALER_EXCHANGE_YesNoAll active,
- enum TALER_EXCHANGE_YesNoAll failures,
- TALER_MERCHANT_ReservesGetCallback cb,
- void *cb_cls);
-
-
-/**
- * Cancel a GET /reserves request.
- *
- * @param rgh handle to the request to be canceled
- */
-void
-TALER_MERCHANT_reserves_get_cancel (
- struct TALER_MERCHANT_ReservesGetHandle *rgh);
-
-
-/**
- * Handle for a request to obtain details on a specific
- * (tipping) reserve.
- */
-struct TALER_MERCHANT_ReserveGetHandle;
-
-
-/**
- * Details about a tip granted by the merchant.
+ * Details in a response to a GET /kyc request.
*/
-struct TALER_MERCHANT_TipDetails
+struct TALER_MERCHANT_KycResponse
{
/**
- * Identifier for the tip.
- */
- struct TALER_TipIdentifierP tip_id;
-
- /**
- * Total value of the tip (including fees).
+ * HTTP response details.
*/
- struct TALER_Amount amount;
+ struct TALER_MERCHANT_HttpResponse hr;
/**
- * Human-readable reason for why the tip was granted.
+ * Response details depending on the HTTP status.
*/
- const char *reason;
-
-};
-
-
-/**
- * Callback to process a GET /reserve/$RESERVE_PUB request
- *
- * @param cls closure
- * @param hr HTTP response details
- * @param rs reserve summary for the reserve, NULL on error
- * @param active is this reserve active (false if it was deleted but not purged)
- * @param exchange_url URL of the exchange hosting the reserve, NULL if not @a active
- * @param payto_uri URI to fill the reserve, NULL if not @a active or already filled
- * @param tips_length length of the @a reserves array
- * @param tips array with details about the tips granted, NULL on error
- */
-typedef void
-(*TALER_MERCHANT_ReserveGetCallback) (
- void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const struct TALER_MERCHANT_ReserveSummary *rs,
- bool active,
- const char *exchange_url,
- const char *payto_uri,
- unsigned int tips_length,
- const struct TALER_MERCHANT_TipDetails tips[]);
+ union
+ {
+ /**
+ * Information returned if the status was #MHD_HTTP_ACCEPTED,
+ * #MHD_HTTP_BAD_GATEWAY or #MHD_HTTP_GATEWAY_TIMEOUT.
+ */
+ struct
+ {
+ /**
+ * Array with information about KYC actions the merchant still must perform.
+ */
+ struct TALER_MERCHANT_AccountKycRedirectDetail *pending_kycs;
-/**
- * Issue a GET /reserve/$RESERVE_ID request to the backend. Queries the backend
- * about the status of a reserve.
- *
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param reserve_pub which reserve should be queried
- * @param fetch_tips should we return details about the tips issued from the reserve
- * @param cb function to call with the result(s)
- * @param cb_cls closure for @a cb
- * @return handle for this operation, NULL upon errors
- */
-struct TALER_MERCHANT_ReserveGetHandle *
-TALER_MERCHANT_reserve_get (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- bool fetch_tips,
- TALER_MERCHANT_ReserveGetCallback cb,
- void *cb_cls);
+ /**
+ * Array with information about KYC failures at the exchange.
+ */
+ struct TALER_MERCHANT_ExchangeKycFailureDetail *timeout_kycs;
+ /**
+ * Length of the @e pending_kycs array.
+ */
+ unsigned int pending_kycs_length;
-/**
- * Cancel a GET /reserve/$RESERVE_ID request.
- *
- * @param rgh handle to the request to be canceled
- */
-void
-TALER_MERCHANT_reserve_get_cancel (
- struct TALER_MERCHANT_ReserveGetHandle *rgh);
+ /**
+ * Length of the @e timeout_kycs array.
+ */
+ unsigned int timeout_kycs_length;
+ } kyc_status;
+ } details;
-/**
- * Handle for a /tip-authorize operation.
- */
-struct TALER_MERCHANT_TipAuthorizeHandle;
+};
/**
- * Callback for a /reserves/$RESERVE_PUB/tip-authorize request. Returns the result of
- * the operation.
+ * Callback to with a response from a GET [/private]/kyc request
*
* @param cls closure
- * @param hr HTTP response details
- * @param tip_id which tip ID should be used to pickup the tip
- * @param tip_uri URI for the tip
- * @param tip_expiration when does the tip expire
+ * @param kr response details
*/
typedef void
-(*TALER_MERCHANT_TipAuthorizeCallback) (
+(*TALER_MERCHANT_KycGetCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- struct TALER_TipIdentifierP *tip_id,
- const char *tip_uri,
- struct GNUNET_TIME_Timestamp tip_expiration);
+ const struct TALER_MERCHANT_KycResponse *kr);
/**
- * Issue a /tip-authorize request to the backend. Informs the backend
- * that a tip should be created.
+ * Issue a GET /private/kycs/$KYC_ID (private variant) request to the backend.
+ * Returns KYC status of bank accounts.
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
- * @param reserve_pub public key of the reserve
- * @param next_url where the browser should proceed after picking up the tip
- * @param amount amount to be handed out as a tip
- * @param justification which justification should be stored (human-readable reason for the tip)
- * @param authorize_cb callback which will work the response gotten from the backend
- * @param authorize_cb_cls closure to pass to @a authorize_cb
+ * @param h_wire which bank account to query, NULL for all
+ * @param exchange_url which exchange to query, NULL for all
+ * @param timeout how long to wait for a (positive) reply
+ * @param cb function to call with the result
+ * @param cb_cls closure for @a cb
* @return handle for this operation, NULL upon errors
*/
-struct TALER_MERCHANT_TipAuthorizeHandle *
-TALER_MERCHANT_tip_authorize2 (
+struct TALER_MERCHANT_KycGetHandle *
+TALER_MERCHANT_kyc_get (
struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const char *next_url,
- const struct TALER_Amount *amount,
- const char *justification,
- TALER_MERCHANT_TipAuthorizeCallback authorize_cb,
- void *authorize_cb_cls);
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ struct GNUNET_TIME_Relative timeout,
+ TALER_MERCHANT_KycGetCallback cb,
+ void *cb_cls);
/**
- * Issue a POST /tips request to the backend. Informs the backend that a tip
- * should be created. In contrast to #TALER_MERCHANT_tip_authorize2(), the
- * backend gets to pick the reserve with this API.
+ * Issue a GET /management/instances/$INSTANCE/kyc request to the backend.
+ * Returns KYC status of bank accounts.
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
- * @param next_url where the browser should proceed after picking up the tip
- * @param amount amount to be handed out as a tip
- * @param justification which justification should be stored (human-readable reason for the tip)
- * @param authorize_cb callback which will work the response gotten from the backend
- * @param authorize_cb_cls closure to pass to @a authorize_cb
+ * @param instance_id specific instance to query
+ * @param h_wire which bank account to query, NULL for all
+ * @param exchange_url which exchange to query, NULL for all
+ * @param timeout how long to wait for a (positive) reply
+ * @param cb function to call with the result
+ * @param cb_cls closure for @a cb
* @return handle for this operation, NULL upon errors
*/
-struct TALER_MERCHANT_TipAuthorizeHandle *
-TALER_MERCHANT_tip_authorize (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const char *next_url,
- const struct TALER_Amount *amount,
- const char *justification,
- TALER_MERCHANT_TipAuthorizeCallback authorize_cb,
- void *authorize_cb_cls);
+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,
+ struct GNUNET_TIME_Relative timeout,
+ TALER_MERCHANT_KycGetCallback cb,
+ void *cb_cls);
/**
- * Cancel a pending /tip-authorize request
+ * Cancel a GET [/private]/kyc/$KYC_ID request.
*
- * @param ta handle from the operation to cancel
+ * @param kyc handle to the request to be canceled
*/
void
-TALER_MERCHANT_tip_authorize_cancel (
- struct TALER_MERCHANT_TipAuthorizeHandle *ta);
+TALER_MERCHANT_kyc_get_cancel (
+ struct TALER_MERCHANT_KycGetHandle *kyc);
-/**
- * Handle for a request to delete or purge a specific reserve.
- */
-struct TALER_MERCHANT_ReserveDeleteHandle;
+/* ********************* /otp-devices *********************** */
/**
- * Callback to process a DELETE /reserve/$RESERVE_PUB request
- *
- * @param cls closure
- * @param hr HTTP response details
+ * Handle for a GET /otp-devices operation.
*/
-typedef void
-(*TALER_MERCHANT_ReserveDeleteCallback) (
- void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr);
-
+struct TALER_MERCHANT_OtpDevicesGetHandle;
/**
- * Issue a DELETE /reserve/$RESERVE_ID request to the backend. Only
- * deletes the private key of the reserve, preserves tipping data.
- *
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param reserve_pub which reserve should be queried
- * @param cb function to call with the result
- * @param cb_cls closure for @a cb
- * @return handle for this operation, NULL upon errors
+ * Individual OTP device (minimal information
+ * returned via GET /otp-devices).
*/
-struct TALER_MERCHANT_ReserveDeleteHandle *
-TALER_MERCHANT_reserve_delete (
- struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- TALER_MERCHANT_ReserveDeleteCallback cb,
- void *cb_cls);
+struct TALER_MERCHANT_OtpDeviceEntry
+{
+ /**
+ * OTP device identifier.
+ */
+ const char *otp_device_id;
+ /**
+ * OTP device description.
+ */
+ const char *device_description;
-/**
- * Issue a DELETE /reserve/$RESERVE_ID request to the backend.
- * Purges the reserve, deleting all associated data. DANGEROUS.
- *
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param reserve_pub which reserve should be queried
- * @param cb function to call with the result
- * @param cb_cls closure for @a cb
- * @return handle for this operation, NULL upon errors
- */
-struct TALER_MERCHANT_ReserveDeleteHandle *
-TALER_MERCHANT_reserve_purge (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- TALER_MERCHANT_ReserveDeleteCallback cb,
- void *cb_cls);
+};
/**
- * Cancel a DELETE (or purge) /reserve/$RESERVE_ID request.
- *
- * @param rdh handle to the request to be canceled
+ * Response to a GET /otp-devices operation.
*/
-void
-TALER_MERCHANT_reserve_delete_cancel (
- struct TALER_MERCHANT_ReserveDeleteHandle *rdh);
-
-
-/* ********************* /tips ************************** */
+struct TALER_MERCHANT_OtpDevicesGetResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+ /**
+ * Details depending on status.
+ */
+ union
+ {
+ /**
+ * Details if status is #MHD_HTTP_OK.
+ */
+ struct
+ {
+ /**
+ * length of the @e otp_devices array
+ */
+ unsigned int otp_devices_length;
-/**
- * Handle for a GET /tips/$TIP_ID (public variant) operation.
- */
-struct TALER_MERCHANT_TipWalletGetHandle;
+ /**
+ * array of otp_devices the requested instance offers
+ */
+ const struct TALER_MERCHANT_OtpDeviceEntry *otp_devices;
+ } ok;
+ } details;
+};
/**
- * Callback to process a GET /tips/$TIP_ID request
+ * Function called with the result of the GET /otp-devices operation.
*
* @param cls closure
- * @param hr HTTP response details
- * @param expiration when the tip will expire
- * @param exchange_url exchange from which the coins should be withdrawn
- * @param amount_remaining total amount still available for the tip
+ * @param tgr response details
*/
typedef void
-(*TALER_MERCHANT_TipWalletGetCallback) (
+(*TALER_MERCHANT_OtpDevicesGetCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- struct GNUNET_TIME_Timestamp expiration,
- const char *exchange_url,
- const struct TALER_Amount *amount_remaining);
+ const struct TALER_MERCHANT_OtpDevicesGetResponse *tgr);
/**
- * Issue a GET /tips/$TIP_ID (public variant) request to the backend. Returns
- * information needed to pick up a tip.
+ * Make a GET /otp-devices request.
*
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param tip_id which tip should we query
- * @param cb function to call with the result
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param cb function to call with the backend information
* @param cb_cls closure for @a cb
- * @return handle for this operation, NULL upon errors
+ * @return the request handle; NULL upon error
*/
-struct TALER_MERCHANT_TipWalletGetHandle *
-TALER_MERCHANT_wallet_tip_get (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct TALER_TipIdentifierP *tip_id,
- TALER_MERCHANT_TipWalletGetCallback cb,
- void *cb_cls);
+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 /tips/$TIP_ID request.
+ * Cancel GET /otp-devices operation.
*
- * @param tgh handle to the request to be canceled
+ * @param tgh operation to cancel
*/
void
-TALER_MERCHANT_wallet_tip_get_cancel (
- struct TALER_MERCHANT_TipWalletGetHandle *tgh);
+TALER_MERCHANT_otp_devices_get_cancel (
+ struct TALER_MERCHANT_OtpDevicesGetHandle *tgh);
/**
- * Handle for a GET /private/tips/$TIP_ID (private variant) operation.
+ * Handle for a GET /otp-device/$ID operation. Gets details
+ * about a single otp_device. Do not confused with a
+ * `struct TALER_MERCHANT_OtpDevicesGetHandle`, which
+ * obtains a list of all otp_devices.
*/
-struct TALER_MERCHANT_TipMerchantGetHandle;
+struct TALER_MERCHANT_OtpDeviceGetHandle;
/**
- * Summary information for a tip pickup.
+ * Details in a response to a GET /otp-devices request.
*/
-struct TALER_MERCHANT_PickupDetail
+struct TALER_MERCHANT_OtpDeviceGetResponse
{
/**
- * Identifier of the pickup.
- */
- struct TALER_PickupIdentifierP pickup_id;
-
- /**
- * Number of planchets involved.
- */
- uint64_t num_planchets;
-
- /**
- * Total amount requested for this pickup.
- */
- struct TALER_Amount requested_amount;
-};
-
-
-/**
- * Details returned about a tip by the merchant.
- */
-struct TALER_MERCHANT_TipStatusResponse
-{
- /**
- * HTTP status of the response.
+ * HTTP response details.
*/
struct TALER_MERCHANT_HttpResponse hr;
/**
- * Details depending on the HTTP status.
+ * Response details depending on the HTTP status.
*/
union
{
-
/**
- * Details on #MHD_HTTP_OK.
+ * Information returned if the status was #MHD_HTTP_OK.
*/
struct
{
/**
- * Amount that was authorized under this tip
- */
- struct TALER_Amount total_authorized;
-
- /**
- * Amount that has been picked up
+ * description of the otp_device
*/
- struct TALER_Amount total_picked_up;
+ const char *otp_device_description;
/**
- * The reason given for the tip
+ * 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 *reason;
+ const char *otp_code;
/**
- * Time when the tip will expire
+ * current counter.
*/
- struct GNUNET_TIME_Timestamp expiration;
+ uint64_t otp_ctr;
/**
- * reserve which is funding this tip
+ * OTP algorithm used.
*/
- struct TALER_ReservePublicKeyP reserve_pub;
+ enum TALER_MerchantConfirmationAlgorithm otp_alg;
/**
- * Length of the @e pickups array
+ * Timestamp in second used to compute
+ * @e otp_code.
*/
- unsigned int pickups_length;
+ uint64_t otp_timestamp_s;
- /**
- * array of pickup operations performed for this tip
- */
- struct TALER_MERCHANT_PickupDetail *pickups;
- } success;
+ } ok;
} details;
@@ -3582,577 +4522,446 @@ struct TALER_MERCHANT_TipStatusResponse
/**
- * Callback to process a GET /private/tips/$TIP_ID request
+ * Function called with the result of the GET /otp-device/$ID operation.
*
* @param cls closure
- * @param tsr response details
+ * @param tgr HTTP response details
*/
typedef void
-(*TALER_MERCHANT_TipMerchantGetCallback) (
+(*TALER_MERCHANT_OtpDeviceGetCallback)(
void *cls,
- const struct TALER_MERCHANT_TipStatusResponse *tsr);
+ const struct TALER_MERCHANT_OtpDeviceGetResponse *tgr);
/**
- * Issue a GET /private/tips/$TIP_ID (private variant) request to the backend.
- * Returns information needed to pick up a tip.
- *
- * FIXME: lp_timeout/min_pick_up not implemented in backend!
+ * Make a GET /otp-device/$ID request to get details about an
+ * individual OTP device.
*
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param tip_id which tip should we query
- * @param min_pick_up minimum amount picked up to notify about
- * @param lp_timeout how long to wait for @a min_pick_up to be exceeded
- * @param pickups whether to fetch associated pickups
- * @param cb function to call with the result
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param otp_device_id identifier of the otp_device to inquire about
+ * @param cb function to call with the backend's otp_device information
* @param cb_cls closure for @a cb
- * @return handle for this operation, NULL upon errors
+ * @return the request handle; NULL upon error
*/
-struct TALER_MERCHANT_TipMerchantGetHandle *
-TALER_MERCHANT_merchant_tip_get (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct TALER_TipIdentifierP *tip_id,
- const struct TALER_Amount *min_pick_up,
- struct GNUNET_TIME_Relative lp_timeout,
- bool pickups,
- TALER_MERCHANT_TipMerchantGetCallback cb,
- void *cb_cls);
+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/tips/$TIP_ID request.
+ * Cancel GET /otp-devices/$ID operation.
*
- * @param tgh handle to the request to be canceled
+ * @param tgh operation to cancel
*/
void
-TALER_MERCHANT_merchant_tip_get_cancel (
- struct TALER_MERCHANT_TipMerchantGetHandle *tgh);
+TALER_MERCHANT_otp_device_get_cancel (
+ struct TALER_MERCHANT_OtpDeviceGetHandle *tgh);
/**
- * Handle for a GET /private/tips request.
+ * Handle for a POST /otp-devices operation.
*/
-struct TALER_MERCHANT_TipsGetHandle;
+struct TALER_MERCHANT_OtpDevicesPostHandle;
/**
- * Database entry information of a tip.
- */
-struct TALER_MERCHANT_TipEntry
-{
- /**
- * Row number of the tip in the database.
- */
- uint64_t row_id;
-
- /**
- * Identifier for the tip.
- */
- struct TALER_TipIdentifierP tip_id;
-
- /**
- * Total value of the tip (including fees).
- */
- struct TALER_Amount tip_amount;
-
-};
-
-
-/**
- * Callback to process a GET /private/tips request.
+ * Function called with the result of the POST /otp-devices operation.
*
* @param cls closure
* @param hr HTTP response details
- * @param tips_length length of the @a tips array
- * @param tips the array of tips, NULL on error
*/
typedef void
-(*TALER_MERCHANT_TipsGetCallback) (
+(*TALER_MERCHANT_OtpDevicesPostCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int tips_length,
- const struct TALER_MERCHANT_TipEntry tips[]);
-
-
-/**
- * Issue a GET /private/tips request to the backend.
- *
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param cb function to call with the result
- * @param cb_cls closure for @a cb
- * @return handle for this operation, NULL upon errors
- */
-struct TALER_MERCHANT_TipsGetHandle *
-TALER_MERCHANT_tips_get (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- TALER_MERCHANT_TipsGetCallback cb,
- void *cb_cls);
+ const struct TALER_MERCHANT_HttpResponse *hr);
/**
- * Issue a GET /private/tips request with filters to the backend.
+ * Make a POST /otp-devices request to add an OTP device
*
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param expired yes for expired tips, no for unexpired tips, all for all tips
- * @param limit number of results to return, negative for descending row id, positive for ascending
- * @param offset row id to start returning results from
- * @param cb function to call with the result
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param otp_id identifier to use for the OTP device
+ * @param otp_device_description description of the OTP device
+ * @param otp_key key of the OTP device
+ * @param otp_alg OTP algorithm used
+ * @param otp_ctr counter for counter-based OTP
+ * @param cb function to call with the backend's result
* @param cb_cls closure for @a cb
- * @return handle for this operation, NULL upon errors
+ * @return the request handle; NULL upon error
*/
-struct TALER_MERCHANT_TipsGetHandle *
-TALER_MERCHANT_tips_get2 (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- enum TALER_EXCHANGE_YesNoAll expired,
- int64_t limit,
- uint64_t offset,
- TALER_MERCHANT_TipsGetCallback cb,
- void *cb_cls);
+struct TALER_MERCHANT_OtpDevicesPostHandle *
+TALER_MERCHANT_otp_devices_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *otp_id,
+ const char *otp_device_description,
+ const char *otp_key,
+ enum TALER_MerchantConfirmationAlgorithm otp_alg,
+ uint64_t otp_ctr,
+ TALER_MERCHANT_OtpDevicesPostCallback cb,
+ void *cb_cls);
/**
- * Cancel a GET /private/tips request.
+ * Cancel POST /otp-devices operation.
*
- * @param tgh the operation to cancel
+ * @param[in] tph operation to cancel
*/
void
-TALER_MERCHANT_tips_get_cancel (struct TALER_MERCHANT_TipsGetHandle *tgh);
+TALER_MERCHANT_otp_devices_post_cancel (
+ struct TALER_MERCHANT_OtpDevicesPostHandle *tph);
/**
- * Handle for a POST /tips/$TIP_ID/pickup operation.
+ * Handle for a PATCH /otp-device operation.
*/
-struct TALER_MERCHANT_TipPickupHandle;
-
-
-/**
- * Details about a pickup operation, as returned to the application.
- */
-struct TALER_MERCHANT_PickupDetails
-{
- /**
- * HTTP response data.
- */
- struct TALER_MERCHANT_HttpResponse hr;
-
- /**
- * Details about the response.
- */
- union
- {
- /**
- * Details if the status is #MHD_HTTP_OK.
- */
- struct
- {
-
- /**
- * Array of length @e num_sigs with details about each of the coins that
- * were picked up.
- */
- struct TALER_EXCHANGE_PrivateCoinDetails *pcds;
-
- /**
- * Length of the @e pcds array.
- */
- unsigned int num_sigs;
- } success;
-
- } details;
-
-};
+struct TALER_MERCHANT_OtpDevicePatchHandle;
/**
- * Callback for a POST /tips/$TIP_ID/pickup request. Returns the result of
- * the operation.
+ * Function called with the result of the PATCH /otp-device operation.
*
* @param cls closure
- * @param pd HTTP response details
+ * @param hr HTTP response details
*/
typedef void
-(*TALER_MERCHANT_TipPickupCallback) (
+(*TALER_MERCHANT_OtpDevicePatchCallback)(
void *cls,
- const struct TALER_MERCHANT_PickupDetails *pd);
-
-
-/**
- * Information per planchet.
- */
-struct TALER_MERCHANT_PlanchetData
-{
- /**
- * Planchet secrets.
- */
- struct TALER_PlanchetMasterSecretP ps;
+ const struct TALER_MERCHANT_HttpResponse *hr);
- /**
- * Denomination key desired.
- */
- const struct TALER_EXCHANGE_DenomPublicKey *pk;
-
-};
/**
- * Issue a POST /tips/$TIP_ID/pickup request to the backend. Informs the
- * backend that a customer wants to pick up a tip.
+ * Make a PATCH /otp-device request to update OTP device details
*
- * @param ctx execution context
- * @param exchange handle to the exchange we are picking up the tip from
- * @param backend_url base URL of the merchant backend
- * @param tip_id unique identifier for the tip
- * @param num_planchets number of planchets provided in @a pds
- * @param planchets array of planchet secrets to be signed into existence for the tip
- * @param pickup_cb callback which will work the response gotten from the backend
- * @param pickup_cb_cls closure to pass to @a pickup_cb
- * @return handle for this operation, NULL upon errors
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param otp_id identifier to use for the OTP device; the OTP device must exist,
+ * or the transaction will fail with a #MHD_HTTP_NOT_FOUND
+ * HTTP status code
+ * @param otp_device_description description of the otp_device
+ * @param otp_key key of the OTP device
+ * @param otp_alg OTP algorithm used
+ * @param otp_ctr counter for counter-based OTP
+ * @param cb function to call with the backend's result
+ * @param cb_cls closure for @a cb
+ * @return the request handle; NULL upon error
*/
-struct TALER_MERCHANT_TipPickupHandle *
-TALER_MERCHANT_tip_pickup (struct GNUNET_CURL_Context *ctx,
- struct TALER_EXCHANGE_Handle *exchange,
- const char *backend_url,
- const struct TALER_TipIdentifierP *tip_id,
- unsigned int num_planchets,
- const struct TALER_MERCHANT_PlanchetData planchets[],
- TALER_MERCHANT_TipPickupCallback pickup_cb,
- void *pickup_cb_cls);
+struct TALER_MERCHANT_OtpDevicePatchHandle *
+TALER_MERCHANT_otp_device_patch (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *otp_id,
+ const char *otp_device_description,
+ const char *otp_key,
+ enum TALER_MerchantConfirmationAlgorithm otp_alg,
+ uint64_t otp_ctr,
+ TALER_MERCHANT_OtpDevicePatchCallback cb,
+ void *cb_cls);
/**
- * Cancel a pending /tips/$TIP_ID/pickup request
+ * Cancel PATCH /otp-device operation.
*
- * @param tph handle from the operation to cancel
+ * @param[in] tph operation to cancel
*/
void
-TALER_MERCHANT_tip_pickup_cancel (struct TALER_MERCHANT_TipPickupHandle *tph);
+TALER_MERCHANT_otp_device_patch_cancel (
+ struct TALER_MERCHANT_OtpDevicePatchHandle *tph);
/**
- * Handle for a low-level /tip-pickup operation (without unblinding).
+ * Handle for a DELETE /otp-device/$ID operation.
*/
-struct TALER_MERCHANT_TipPickup2Handle;
+struct TALER_MERCHANT_OtpDeviceDeleteHandle;
/**
- * Callback for a POST /tips/$TIP_ID/pickup request. Returns the result of
- * the operation. Note that the client MUST still do the unblinding of the @a
- * blind_sigs.
+ * Function called with the result of the DELETE /otp-device/$ID operation.
*
* @param cls closure
* @param hr HTTP response details
- * @param num_blind_sigs length of the @a blind_sigs array, 0 on error
- * @param blind_sigs array of blind signatures over the planchets, NULL on error
*/
typedef void
-(*TALER_MERCHANT_TipPickup2Callback) (
+(*TALER_MERCHANT_OtpDeviceDeleteCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int num_blind_sigs,
- const struct TALER_BlindedDenominationSignature blind_sigs[]);
+ const struct TALER_MERCHANT_HttpResponse *hr);
/**
- * Issue a POST /tips/$TIP_ID/pickup request to the backend. Informs the
- * backend that a customer wants to pick up a tip.
+ * Make a DELETE /otp-device/$ID request to delete an OTP device.
*
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param tip_id unique identifier for the tip
- * @param num_planchets number of planchets provided in @a planchets
- * @param planchets array of planchets to be signed into existence for the tip
- * @param pickup_cb callback which will work the response gotten from the backend
- * @param pickup_cb_cls closure to pass to @a pickup_cb
- * @return handle for this operation, NULL upon errors
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param otp_device_id identifier of the OTP device
+ * @param cb function to call with the backend's deletion status
+ * @param cb_cls closure for @a cb
+ * @return the request handle; NULL upon error
*/
-struct TALER_MERCHANT_TipPickup2Handle *
-TALER_MERCHANT_tip_pickup2 (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct TALER_TipIdentifierP *tip_id,
- unsigned int num_planchets,
- const struct TALER_PlanchetDetail planchets[],
- TALER_MERCHANT_TipPickup2Callback pickup_cb,
- void *pickup_cb_cls);
+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 pending /tip-pickup request.
+ * Cancel DELETE /otp-device/$ID operation.
*
- * @param tp handle from the operation to cancel
+ * @param[in] tdh operation to cancel
*/
void
-TALER_MERCHANT_tip_pickup2_cancel (
- struct TALER_MERCHANT_TipPickup2Handle *tp);
+TALER_MERCHANT_otp_device_delete_cancel (
+ struct TALER_MERCHANT_OtpDeviceDeleteHandle *tdh);
-/* ********************* /kyc ************************** */
-
-/**
- * Handle for getting the KYC status of instance(s).
- */
-struct TALER_MERCHANT_KycGetHandle;
+/* ********************* /templates *********************** */
/**
- * Information about KYC actions the merchant still must perform.
+ * Handle for a GET /templates operation.
*/
-struct TALER_MERCHANT_AccountKycRedirectDetail
-{
-
- /**
- * URL that the user should open in a browser to
- * proceed with the KYC process (as returned
- * by the exchange's /kyc-check/ endpoint).
- */
- const char *kyc_url;
-
- /**
- * Base URL of the exchange this is about.
- */
- const char *exchange_url;
-
- /**
- * Our bank wire account this is about.
- */
- const char *payto_uri;
-};
-
+struct TALER_MERCHANT_TemplatesGetHandle;
/**
- * Information about KYC status failures at the exchange.
+ * Individual template (minimal information
+ * returned via GET /templates).
*/
-struct TALER_MERCHANT_ExchangeKycFailureDetail
+struct TALER_MERCHANT_TemplateEntry
{
/**
- * Base URL of the exchange this is about.
- */
- const char *exchange_url;
-
- /**
- * Error code indicating errors the exchange
- * returned, or #TALER_EC_INVALID for none.
+ * template identifier.
*/
- enum TALER_ErrorCode exchange_code;
+ const char *template_id;
- /**
- * 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;
};
/**
- * Details in a response to a GET /kyc request.
+ * Response to a GET /templates operation.
*/
-struct TALER_MERCHANT_KycResponse
+struct TALER_MERCHANT_TemplatesGetResponse
{
/**
- * HTTP response details.
+ * HTTP response details
*/
struct TALER_MERCHANT_HttpResponse hr;
/**
- * Response details depending on the HTTP status.
+ * Details depending on status.
*/
union
{
/**
- * Information returned if the status was #MHD_HTTP_ACCEPTED,
- * #MHD_HTTP_BAD_GATEWAY or #MHD_HTTP_GATEWAY_TIMEOUT.
+ * Details if status is #MHD_HTTP_OK.
*/
struct
{
-
- /**
- * Array with information about KYC actions the merchant still must perform.
- */
- struct TALER_MERCHANT_AccountKycRedirectDetail *pending_kycs;
-
- /**
- * Array with information about KYC failures at the exchange.
- */
- struct TALER_MERCHANT_ExchangeKycFailureDetail *timeout_kycs;
-
/**
- * Length of the @e pending_kycs array.
+ * length of the @e templates array
*/
- unsigned int pending_kycs_length;
+ unsigned int templates_length;
/**
- * Length of the @e timeout_kycs array.
+ * array of templates the requested instance offers
*/
- unsigned int timeout_kycs_length;
- } kyc_status;
-
+ const struct TALER_MERCHANT_TemplateEntry *templates;
+ } ok;
} details;
-
};
/**
- * Callback to with a response from a GET [/private]/kyc request
+ * Function called with the result of the GET /templates operation.
*
* @param cls closure
- * @param kr response details
+ * @param tgr response details
*/
typedef void
-(*TALER_MERCHANT_KycGetCallback) (
+(*TALER_MERCHANT_TemplatesGetCallback)(
void *cls,
- const struct TALER_MERCHANT_KycResponse *kr);
+ const struct TALER_MERCHANT_TemplatesGetResponse *tgr);
/**
- * Issue a GET /private/kycs/$KYC_ID (private variant) request to the backend.
- * Returns KYC status of bank accounts.
- *
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param h_wire which bank account to query, NULL for all
- * @param exchange_url which exchange to query, NULL for all
- * @param timeout how long to wait for a (positive) reply
- * @param cb function to call with the result
- * @param cb_cls closure for @a cb
- * @return handle for this operation, NULL upon errors
- */
-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,
- struct GNUNET_TIME_Relative timeout,
- TALER_MERCHANT_KycGetCallback cb,
- void *cb_cls);
-
-
-/**
- * Issue a GET /management/instances/$INSTANCE/kyc request to the backend.
- * Returns KYC status of bank accounts.
+ * Make a GET /templates request.
*
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param instance_id specific instance to query
- * @param h_wire which bank account to query, NULL for all
- * @param exchange_url which exchange to query, NULL for all
- * @param timeout how long to wait for a (positive) reply
- * @param cb function to call with the result
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param cb function to call with the backend information
* @param cb_cls closure for @a cb
- * @return handle for this operation, NULL upon errors
+ * @return the request handle; NULL upon 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,
- struct GNUNET_TIME_Relative timeout,
- TALER_MERCHANT_KycGetCallback cb,
- void *cb_cls);
+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]/kyc/$KYC_ID request.
+ * Cancel GET /templates operation.
*
- * @param kyc handle to the request to be canceled
+ * @param tgh operation to cancel
*/
void
-TALER_MERCHANT_kyc_get_cancel (
- struct TALER_MERCHANT_KycGetHandle *kyc);
-
-
-/* ********************* /templates *********************** */
+TALER_MERCHANT_templates_get_cancel (
+ struct TALER_MERCHANT_TemplatesGetHandle *tgh);
/**
- * Handle for a GET /templates operation.
+ * Handle for a GET /private/template/$ID operation. Gets details
+ * about a single template. Do not confused with a
+ * `struct TALER_MERCHANT_TemplatesGetHandle`, which
+ * obtains a list of all templates.
*/
-struct TALER_MERCHANT_TemplatesGetHandle;
+struct TALER_MERCHANT_TemplateGetHandle;
+
/**
- * Individual template (minimal information
- * returned via GET /templates).
+ * Details in a response to a GET /private/templates/$ID request.
*/
-struct TALER_MERCHANT_TemplateEntry
+struct TALER_MERCHANT_TemplateGetResponse
{
/**
- * template identifier.
+ * HTTP response details.
*/
- const char *template_id;
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Response details depending on the HTTP status.
+ */
+ union
+ {
+ /**
+ * Information returned if the status was #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * description of the template
+ */
+ const char *template_description;
+
+ /**
+ * OTP device ID used by the POS, NULL if none.
+ */
+ const char *otp_id;
+
+ /**
+ * Template for the contract.
+ */
+ const json_t *template_contract;
+
+ } ok;
+
+ } details;
};
/**
- * Function called with the result of the GET /templates operation.
+ * Function called with the result of the GET /private/template/$ID operation.
*
* @param cls closure
- * @param hr HTTP response details
- * @param templates_length length of the @a templates array
- * @param templates array of templates the requested instance offers
+ * @param tgr HTTP response details
*/
typedef void
-(*TALER_MERCHANT_TemplatesGetCallback)(
+(*TALER_MERCHANT_TemplateGetCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int templates_length,
- const struct TALER_MERCHANT_TemplateEntry templates[]);
+ const struct TALER_MERCHANT_TemplateGetResponse *tgr);
/**
- * Make a GET /templates request.
+ * Make a GET /private/template/$ID request to get details about an
+ * individual template.
*
* @param ctx the context
* @param backend_url HTTP base URL for the backend
- * @param cb function to call with the backend information
+ * @param template_id identifier of the template to inquire about
+ * @param cb function to call with the backend's template information
* @param cb_cls closure for @a cb
* @return the request handle; NULL upon error
*/
-struct TALER_MERCHANT_TemplatesGetHandle *
-TALER_MERCHANT_templates_get (
+struct TALER_MERCHANT_TemplateGetHandle *
+TALER_MERCHANT_template_get (
struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- TALER_MERCHANT_TemplatesGetCallback cb,
+ const char *template_id,
+ TALER_MERCHANT_TemplateGetCallback cb,
void *cb_cls);
/**
- * Cancel GET /templates operation.
+ * Cancel GET /private/templates/$ID operation.
*
* @param tgh operation to cancel
*/
void
-TALER_MERCHANT_templates_get_cancel (
- struct TALER_MERCHANT_TemplatesGetHandle *tgh);
+TALER_MERCHANT_template_get_cancel (
+ struct TALER_MERCHANT_TemplateGetHandle *tgh);
/**
- * Handle for a GET /template/$ID operation. Gets details
- * about a single template. Do not confused with a
- * `struct TALER_MERCHANT_TemplatesGetHandle`, which
- * obtains a list of all templates.
+ * Handle for a (public) GET /template/$ID operation. Gets details about a
+ * single template. Do not confused with a `struct
+ * TALER_MERCHANT_TemplateGetHandle`, which is for the private API.
*/
-struct TALER_MERCHANT_TemplateGetHandle;
+struct TALER_MERCHANT_WalletTemplateGetHandle;
/**
- * Function called with the result of the GET /templates operation.
+ * Details in a response to a GET /templates request.
+ */
+struct TALER_MERCHANT_WalletTemplateGetResponse
+{
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Response details depending on the HTTP status.
+ */
+ union
+ {
+ /**
+ * Information returned if the status was #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Template for the contract.
+ */
+ const json_t *template_contract;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Function called with the result of the GET /template/$ID operation.
*
* @param cls closure
- * @param hr HTTP response details
- * @param template_description description of the template
- * @param image base64-encoded product image
- * @param template_contract is the contract of the company
+ * @param tgr HTTP response details
*/
typedef void
-(*TALER_MERCHANT_TemplateGetCallback)(
+(*TALER_MERCHANT_WalletTemplateGetCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const char *template_description,
- const char *image,
- const json_t *template_contract);
+ const struct TALER_MERCHANT_WalletTemplateGetResponse *tgr);
/**
@@ -4166,12 +4975,12 @@ typedef void
* @param cb_cls closure for @a cb
* @return the request handle; NULL upon error
*/
-struct TALER_MERCHANT_TemplateGetHandle *
-TALER_MERCHANT_template_get (
+struct TALER_MERCHANT_WalletTemplateGetHandle *
+TALER_MERCHANT_wallet_template_get (
struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const char *template_id,
- TALER_MERCHANT_TemplateGetCallback cb,
+ TALER_MERCHANT_WalletTemplateGetCallback cb,
void *cb_cls);
@@ -4181,8 +4990,8 @@ TALER_MERCHANT_template_get (
* @param tgh operation to cancel
*/
void
-TALER_MERCHANT_template_get_cancel (
- struct TALER_MERCHANT_TemplateGetHandle *tgh);
+TALER_MERCHANT_wallet_template_get_cancel (
+ struct TALER_MERCHANT_WalletTemplateGetHandle *tgh);
/**
@@ -4210,7 +5019,7 @@ typedef void
* @param backend_url HTTP base URL for the backend
* @param template_id identifier to use for the template
* @param template_description description of the template
- * @param image base64-encoded product image
+ * @param otp_id ID of the OTP device, or NULL if OTP is not used
* @param template_contract is the contract of the company
* @param cb function to call with the backend's result
* @param cb_cls closure for @a cb
@@ -4222,7 +5031,7 @@ TALER_MERCHANT_templates_post (
const char *backend_url,
const char *template_id,
const char *template_description,
- const char *image,
+ const char *otp_id,
const json_t *template_contract,
TALER_MERCHANT_TemplatesPostCallback cb,
void *cb_cls);
@@ -4231,7 +5040,7 @@ TALER_MERCHANT_templates_post (
/**
* Cancel POST /templates operation.
*
- * @param tph operation to cancel
+ * @param[in] tph operation to cancel
*/
void
TALER_MERCHANT_templates_post_cancel (
@@ -4265,7 +5074,7 @@ typedef void
* or the transaction will fail with a #MHD_HTTP_NOT_FOUND
* HTTP status code
* @param template_description description of the template
- * @param image base64-encoded product image
+ * @param otp_id device ID of the OTP device, or NULL if OTP is not used
* @param template_contract is the contract of the company
* @param cb function to call with the backend's result
* @param cb_cls closure for @a cb
@@ -4277,7 +5086,7 @@ TALER_MERCHANT_template_patch (
const char *backend_url,
const char *template_id,
const char *template_description,
- const char *image,
+ const char *otp_id,
json_t *template_contract,
TALER_MERCHANT_TemplatePatchCallback cb,
void *cb_cls);
@@ -4286,7 +5095,7 @@ TALER_MERCHANT_template_patch (
/**
* Cancel PATCH /template operation.
*
- * @param tph operation to cancel
+ * @param[in] tph operation to cancel
*/
void
TALER_MERCHANT_template_patch_cancel (
@@ -4333,7 +5142,7 @@ TALER_MERCHANT_template_delete (
/**
* Cancel DELETE /template/$ID operation.
*
- * @param tdh operation to cancel
+ * @param[in] tdh operation to cancel
*/
void
TALER_MERCHANT_template_delete_cancel (
@@ -4366,7 +5175,7 @@ TALER_MERCHANT_using_templates_post (
/**
* Cancel POST /using-templates operation.
*
- * @param utph operation to cancel
+ * @param[in] utph operation to cancel
*/
void
TALER_MERCHANT_using_templates_post_cancel (
@@ -4396,19 +5205,51 @@ struct TALER_MERCHANT_WebhookEntry
/**
+ * Response to a GET /webhooks operation.
+ */
+struct TALER_MERCHANT_WebhooksGetResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on status.
+ */
+ union
+ {
+ /**
+ * Details if status is #MHD_HTTP_OK.
+ */
+ struct
+ {
+ /**
+ * length of the @e webhooks array
+ */
+ unsigned int webhooks_length;
+
+ /**
+ * array of templates the requested instance offers
+ */
+ const struct TALER_MERCHANT_WebhookEntry *webhooks;
+
+ } ok;
+
+ } details;
+};
+
+
+/**
* Function called with the result of the GET /webhooks operation.
*
* @param cls closure
- * @param hr HTTP response details
- * @param webhooks_length length of the @a webhooks array
- * @param webhooks array of webhooks the requested instance offers
+ * @param wgr response details
*/
typedef void
(*TALER_MERCHANT_WebhooksGetCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int webhooks_length,
- const struct TALER_MERCHANT_WebhookEntry webhooks[]);
+ const struct TALER_MERCHANT_WebhooksGetResponse *wgr);
/**
@@ -4431,7 +5272,7 @@ TALER_MERCHANT_webhooks_get (
/**
* Cancel GET /webhooks operation.
*
- * @param tgh operation to cancel
+ * @param[in] tgh operation to cancel
*/
void
TALER_MERCHANT_webhooks_get_cancel (
@@ -4492,7 +5333,7 @@ TALER_MERCHANT_webhook_get (
/**
* Cancel GET /webhooks/$ID operation.
*
- * @param tgh operation to cancel
+ * @param[in] tgh operation to cancel
*/
void
TALER_MERCHANT_webhook_get_cancel (
@@ -4549,7 +5390,7 @@ TALER_MERCHANT_webhooks_post (
/**
* Cancel POST /webhooks operation.
*
- * @param wph operation to cancel
+ * @param[in] wph operation to cancel
*/
void
TALER_MERCHANT_webhooks_post_cancel (
@@ -4608,7 +5449,7 @@ TALER_MERCHANT_webhook_patch (
/**
* Cancel PATCH /webhook operation.
*
- * @param wph operation to cancel
+ * @param[in] wph operation to cancel
*/
void
TALER_MERCHANT_webhook_patch_cancel (
@@ -4655,7 +5496,7 @@ TALER_MERCHANT_webhook_delete (
/**
* Cancel DELETE /webhook/$ID operation.
*
- * @param wdh operation to cancel
+ * @param[in] wdh operation to cancel
*/
void
TALER_MERCHANT_webhook_delete_cancel (
diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h
index c805afba..47d081fc 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2018-2022 Taler Systems SA
+ (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
@@ -27,6 +27,7 @@
#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"
@@ -36,33 +37,17 @@
#define MERCHANT_FAIL() \
do {GNUNET_break (0); return NULL; } while (0)
+
/**
- * Prepare the merchant execution. Create tables and check if
- * the port is available.
+ * Extract hostname (and port) from merchant base URL.
*
- * @param config_filename configuration filename.
- * @return the base url, or NULL upon errors. Must be freed
- * by the caller.
+ * @param merchant_url full merchant URL (e.g. "http://host:8080/foo/bar/")
+ * @return just the hostname and port ("hostname:8080")
*/
char *
-TALER_TESTING_prepare_merchant (const char *config_filename);
+TALER_MERCHANT_TESTING_extract_host (const char *merchant_url);
-/**
- * Start the merchant backend process. Assume the port
- * is available and the database is clean. Use the "prepare
- * merchant" function to do such tasks.
- *
- * @param config_filename configuration filename.
- * @param merchant_url merchant base URL, used to check
- * if the merchant was started right.
- * @return the process, or NULL if the process could not
- * be started.
- */
-struct GNUNET_OS_Process *
-TALER_TESTING_run_merchant (const char *config_filename,
- const char *merchant_url);
-
/* ************** Specific interpreter commands ************ */
@@ -107,8 +92,6 @@ TALER_TESTING_cmd_merchant_get_instances (const char *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 payto_uri payment URI to use
- * @param currency currency to use for default fees
* @param http_status expected HTTP response code.
* @return the command.
*/
@@ -116,8 +99,6 @@ struct TALER_TESTING_Command
TALER_TESTING_cmd_merchant_post_instances (const char *label,
const char *merchant_url,
const char *instance_id,
- const char *payto_uri,
- const char *currency,
unsigned int http_status);
@@ -147,14 +128,10 @@ TALER_TESTING_cmd_merchant_post_instance_auth (const char *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 accounts_length length of the @a accounts array
- * @param payto_uris URIs of the bank accounts of the merchant instance
* @param name name of the merchant instance
* @param address physical address of the merchant instance
* @param jurisdiction jurisdiction of the merchant instance
- * @param default_max_wire_fee default maximum wire fee merchant is willing to fully pay
- * @param default_wire_fee_amortization default amortization factor for excess wire fees
- * @param default_max_deposit_fee default maximum deposit fee merchant is willing to pay
+ * @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
@@ -166,14 +143,10 @@ TALER_TESTING_cmd_merchant_post_instances2 (
const char *label,
const char *merchant_url,
const char *instance_id,
- unsigned int accounts_length,
- const char *payto_uris[],
const char *name,
json_t *address,
json_t *jurisdiction,
- const char *default_max_wire_fee,
- uint32_t default_wire_fee_amortization,
- const char *default_max_deposit_fee,
+ bool use_stefan,
struct GNUNET_TIME_Relative default_wire_transfer_delay,
struct GNUNET_TIME_Relative default_pay_delay,
const char *auth_token,
@@ -181,20 +154,75 @@ TALER_TESTING_cmd_merchant_post_instances2 (
/**
+ * 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,
+ const char *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 payto_uris_length length of the @a accounts array
- * @param payto_uris URIs of the bank accounts of the merchant instance
* @param name name of the merchant instance
* @param address physical address of the merchant instance
* @param jurisdiction jurisdiction of the merchant instance
- * @param default_max_wire_fee default maximum wire fee merchant is willing to fully pay
- * @param default_wire_fee_amortization default amortization factor for excess wire fees
- * @param default_max_deposit_fee default maximum deposit fee merchant is willing to pay
+ * @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.
@@ -205,14 +233,10 @@ TALER_TESTING_cmd_merchant_patch_instance (
const char *label,
const char *merchant_url,
const char *instance_id,
- unsigned int payto_uris_length,
- const char *payto_uris[],
const char *name,
json_t *address,
json_t *jurisdiction,
- const char *default_max_wire_fee,
- uint32_t default_wire_fee_amortization,
- const char *default_max_deposit_fee,
+ bool use_stefan,
struct GNUNET_TIME_Relative default_wire_transfer_delay,
struct GNUNET_TIME_Relative default_pay_delay,
unsigned int http_status);
@@ -239,35 +263,6 @@ TALER_TESTING_cmd_merchant_get_instance (const char *label,
/**
- * Define a "GET instance" CMD that compares accounts returned.
- *
- * @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
- * @param active_accounts the accounts the merchant is actively using.
- * @param active_accounts_length length of @e active_accounts.
- * @param inactive_accounts the accounts the merchant is no longer using.
- * @param inactive_accounts_length length of @e inactive_accounts.
- * @return the command.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_merchant_get_instance2 (const char *label,
- const char *merchant_url,
- const char *instance_id,
- unsigned int http_status,
- const char *instance_reference,
- const char *active_accounts[],
- unsigned int active_accounts_length,
- const char *inactive_accounts[],
- unsigned int
- inactive_accounts_length);
-
-
-/**
* Define a "PURGE instance" CMD.
*
* @param label command label.
@@ -321,9 +316,10 @@ TALER_TESTING_cmd_merchant_delete_instance (const char *label,
* @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_ABS for 'never'.
+ * #GNUNET_TIME_UNIT_FOREVER_TS for 'never'.
* @param http_status expected HTTP response code.
* @return the command.
*/
@@ -339,6 +335,7 @@ TALER_TESTING_cmd_merchant_post_products2 (
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);
@@ -493,6 +490,7 @@ TALER_TESTING_cmd_merchant_delete_product (const char *label,
* 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.
@@ -505,6 +503,7 @@ TALER_TESTING_cmd_merchant_delete_product (const char *label,
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,
@@ -512,6 +511,7 @@ TALER_TESTING_cmd_merchant_post_orders (
struct GNUNET_TIME_Timestamp pay_deadline,
const char *amount);
+
/**
* Make the "proposal" command AVOIDING claiming the order.
*
@@ -535,10 +535,12 @@ TALER_TESTING_cmd_merchant_post_orders_no_claim (
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.
@@ -560,6 +562,7 @@ TALER_TESTING_cmd_merchant_post_orders_no_claim (
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,
@@ -574,6 +577,64 @@ TALER_TESTING_cmd_merchant_post_orders2 (
/**
+ * 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_reference label of the POST /tokenfamilies cmd.
+ * @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_reference,
+ 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.
@@ -581,7 +642,7 @@ TALER_TESTING_cmd_merchant_post_orders2 (
* GET /orders request.
* @param http_status expected HTTP response code.
* @param ... NULL-terminated list of labels (const char *) of
- * reserve (commands) we expect to be returned in the list
+ * order (commands) we expect to be returned in the list
* (assuming @a http_code is #MHD_HTTP_OK)
* @return the command.
*/
@@ -616,9 +677,10 @@ TALER_TESTING_cmd_poll_orders_start (const char *label,
* @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);
+TALER_TESTING_cmd_poll_orders_conclude (
+ const char *label,
+ unsigned int http_status,
+ const char *poll_start_reference);
/**
@@ -634,13 +696,41 @@ TALER_TESTING_cmd_poll_orders_conclude (const char *label,
* @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);
+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);
/**
@@ -737,13 +827,14 @@ TALER_TESTING_cmd_wallet_poll_order_conclude2 (
* 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,
- ...);
+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,
+ ...);
/**
@@ -770,16 +861,61 @@ TALER_TESTING_cmd_merchant_get_order (const char *label,
* @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);
+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);
/**
@@ -836,14 +972,15 @@ TALER_TESTING_cmd_merchant_claim_order (const char *label,
* @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);
+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);
/**
@@ -857,11 +994,12 @@ TALER_TESTING_cmd_merchant_pay_order (const char *label,
* @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);
+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);
/**
@@ -874,10 +1012,11 @@ TALER_TESTING_cmd_merchant_post_orders_paid (const char *label,
* @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);
+TALER_TESTING_cmd_merchant_order_abort (
+ const char *label,
+ const char *merchant_url,
+ const char *pay_reference,
+ unsigned int http_status);
/**
@@ -916,12 +1055,13 @@ TALER_TESTING_cmd_merchant_forget_order (
* @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);
+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);
/**
@@ -939,11 +1079,12 @@ TALER_TESTING_cmd_merchant_order_refund (const char *label,
* @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,
- ...);
+TALER_TESTING_cmd_wallet_order_refund (
+ const char *label,
+ const char *merchant_url,
+ const char *order_ref,
+ unsigned int http_code,
+ ...);
/**
@@ -957,10 +1098,11 @@ TALER_TESTING_cmd_wallet_order_refund (const char *label,
* @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);
+TALER_TESTING_cmd_merchant_delete_order (
+ const char *label,
+ const char *merchant_url,
+ const char *order_id,
+ unsigned int http_status);
/* ******************* /transfers *************** */
@@ -1071,421 +1213,139 @@ TALER_TESTING_cmd_merchant_delete_transfer (const char *label,
unsigned int http_status);
-/* ******************* /reserves *************** */
-
-
/**
- * Define a "POST /reserves" CMD
+ * Run a command to fetch the KYC status of a merchant.
*
- * @param label command label.
- * @param merchant_url url to the murchant.
- * @param initial_balance initial amount in the reserve.
- * @param exchange_url url to the exchange
- * @param wire_method wire transfer method to use for this reserve
- * @param http_status expected HTTP response code.
- * @return the command.
+ * @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 expected_http_status expected HTTP status
+ * @param expected_aml_state expected AML state (only effective if @e expected_http_status is #MHD_HTTP_OK)
+ * @return the command
*/
struct TALER_TESTING_Command
-TALER_TESTING_cmd_merchant_post_reserves (const char *label,
- const char *merchant_url,
- const char *initial_balance,
- const char *exchange_url,
- const char *wire_method,
- unsigned int http_status);
+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,
+ unsigned int expected_http_status,
+ enum TALER_AmlDecisionState expected_aml_state);
-/**
- * This commands does not query the backend at all,
- * but just makes up a fake reserve.
- *
- * @param label command label.
- * @return the command.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_merchant_post_reserves_fake (const char *label);
+/* ****** OTP devices ******* */
/**
- * Define a "GET reserve" CMD.
+ * Define a "POST /otp-devices" CMD.
*
* @param label command label.
- * @param merchant_url base URL of the merchant serving the request.
+ * @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.
- * @param reserve_reference reference to a "POST /reserves" that provides the
- * information we are expecting.
* @return the command.
*/
struct TALER_TESTING_Command
-TALER_TESTING_cmd_merchant_get_reserve (const char *label,
- const char *merchant_url,
- unsigned int http_status,
- const char *reserve_reference);
+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 "GET reserve" CMD.
+ * Define a "PATCH /otp-devices/$ID" CMD.
*
* @param label command label.
- * @param merchant_url base URL of the merchant serving the request.
+ * @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.
- * @param reserve_reference reference to a "POST /reserves" that provides the
- * information we are expecting.
- * @param ... NULL-terminated list of labels (const char *) of
- * tip (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_reserve_with_tips (const char *label,
- const char *merchant_url,
- unsigned int http_status,
- const char *reserve_reference,
- ...);
+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 /reserves" CMD
+ * Define a "GET /otp-devices" CMD.
*
* @param label command label.
- * @param merchant_url url to the merchant.
+ * @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
- * reserve (commands) we expect to be returned in the list
+ * 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_reserves (const char *label,
- const char *merchant_url,
- unsigned int http_status,
- ...);
+TALER_TESTING_cmd_merchant_get_otp_devices (const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ ...);
/**
- * Define a "DELETE reserve" CMD.
+ * Define a "GET otp device" CMD.
*
* @param label command label.
* @param merchant_url base URL of the merchant serving the
- * DELETE /reserves/$RESERVE_PUB request.
- * @param reserve_reference command label of a command providing a reserve
+ * 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_delete_reserve (const char *label,
+TALER_TESTING_cmd_merchant_get_otp_device (const char *label,
const char *merchant_url,
- const char *reserve_reference,
- unsigned int http_status);
+ const char *otp_id,
+ unsigned int http_status,
+ const char *otp_reference);
/**
- * Define a "PURGE reserve" CMD.
+ * Define a "DELETE otp device" CMD.
*
* @param label command label.
* @param merchant_url base URL of the merchant serving the
- * DELETE /reserves/$RESERVE_PUB request.
- * @param reserve_reference command label of a command providing a reserve
+ * 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_purge_reserve (const char *label,
- const char *merchant_url,
- const char *reserve_reference,
- unsigned int http_status);
-
-
-/**
- * Define a get tips CMD.
- *
- * @param label the command label
- * @param merchant_url base URL of the merchant which will
- * server the /tip-query request.
- * @param http_status expected HTTP response code for the
- * /tip-query request.
- * @param ... NULL-terminated list of labels (const char *) of
- * tip (commands) we expect to be returned in the list
- * (assuming @a http_code is #MHD_HTTP_OK)
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_get_tips (const char *label,
- const char *merchant_url,
- unsigned int http_status,
- ...);
-
-
-/**
- * Define a get tips CMD.
- *
- * @param label the command label
- * @param merchant_url base URL of the merchant which will
- * server the /tip-query request.
- * @param http_status expected HTTP response code for the
- * /tip-query request.
- * @param offset row to start querying the database from.
- * @param limit how many rows to return (with direction).
- * @param ... NULL-terminated list of labels (const char *) of
- * tip (commands) we expect to be returned in the list
- * (assuming @a http_code is #MHD_HTTP_OK)
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_get_tips2 (const char *label,
- const char *merchant_url,
- uint64_t offset,
- int64_t limit,
- unsigned int http_status,
- ...);
-
-
-/**
- * Define a GET /private/tips/$TIP_ID CMD.
- *
- * @param label the command label
- * @param merchant_url base URL of the merchant which will
- * serve the request.
- * @param tip_reference reference to a command that created a tip.
- * @param http_status expected HTTP response code for the request.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_merchant_get_tip (const char *label,
- const char *merchant_url,
- const char *tip_reference,
- unsigned int http_status);
-
-
-/**
- * Define a GET /private/tips/$TIP_ID CMD.
- *
- * @param label the command label
- * @param merchant_url base URL of the merchant which will
- * serve the request.
- * @param tip_reference reference to a command that created a tip.
- * @param http_status expected HTTP response code for the request.
- * @param ... NULL-terminated list of labels (const char *) of
- * pickup (commands) we expect to be returned in the list
- * (assuming @a http_code is #MHD_HTTP_OK)
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_merchant_get_tip_with_pickups (const char *label,
- const char *merchant_url,
- const char *tip_reference,
- unsigned int http_status,
- ...);
-
-/**
- * Define a GET /tips/$TIP_ID CMD.
- *
- * @param label the command label
- * @param merchant_url base URL of the merchant which will
- * serve the request.
- * @param tip_reference reference to a command that created a tip.
- * @param http_status expected HTTP response code for the request.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_wallet_get_tip (const char *label,
- const char *merchant_url,
- const char *tip_reference,
- unsigned int http_status);
-
-
-/**
- * Define a GET /tips/$TIP_ID CMD.
- *
- * @param label the command label
- * @param merchant_url base URL of the merchant which will
- * serve the request.
- * @param tip_reference reference to a command that created a tip.
- * @param amount_remaining the balance remaining after pickups.
- * @param http_status expected HTTP response code for the request.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_wallet_get_tip2 (const char *label,
- const char *merchant_url,
- const char *tip_reference,
- const char *amount_remaining,
- unsigned int http_status);
-
-
-/**
- * Create a /tip-authorize CMD.
- *
- * @param label this command label
- * @param merchant_url the base URL of the merchant that will
- * serve the /tip-authorize request.
- * @param exchange_url the base URL of the exchange that owns
- * the reserve from which the tip is going to be gotten.
- * @param http_status the HTTP response code which is expected
- * for this operation.
- * @param justification human-readable justification for this
- * tip authorization.
- * @param amount the amount to authorize for tipping.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_tip_authorize (const char *label,
- const char *merchant_url,
- const char *exchange_url,
- unsigned int http_status,
- const char *justification,
- const char *amount);
-
-
-/**
- * Create a /tip-authorize CMD.
- *
- * @param label this command label
- * @param merchant_url the base URL of the merchant that will
- * serve the /tip-authorize request.
- * @param exchange_url the base URL of the exchange that owns
- * the reserve from which the tip is going to be gotten.
- * @param reserve_reference reference to a command that created
- * a reserve.
- * @param http_status the HTTP response code which is expected
- * for this operation.
- * @param justification human-readable justification for this
- * tip authorization.
- * @param amount the amount to authorize for tipping.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_tip_authorize_from_reserve (const char *label,
+TALER_TESTING_cmd_merchant_delete_otp_device (const char *label,
const char *merchant_url,
- const char *exchange_url,
- const char *reserve_reference,
- unsigned int http_status,
- const char *justification,
- const char *amount);
-
-
-/**
- * Create a /tip-authorize CMD, specifying the Taler error code
- * that is expected to be returned by the backend.
- *
- * @param label this command label
- * @param merchant_url the base URL of the merchant that will
- * serve the /tip-authorize request.
- * @param exchange_url the base URL of the exchange that owns
- * the reserve from which the tip is going to be gotten.
- * @param http_status the HTTP response code which is expected
- * for this operation.
- * @param justification human-readable justification for this
- * tip authorization.
- * @param amount the amount to authorize for tipping.
- * @param ec expected Taler-defined error code.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_tip_authorize_with_ec (const char *label,
- const char *merchant_url,
- const char *exchange_url,
- unsigned int http_status,
- const char *justification,
- const char *amount,
- enum TALER_ErrorCode ec);
-
-
-/**
- * Create a /tip-authorize CMD, specifying the Taler error code
- * that is expected to be returned by the backend.
- *
- * @param label this command label
- * @param merchant_url the base URL of the merchant that will
- * serve the /tip-authorize request.
- * @param exchange_url the base URL of the exchange that owns
- * the reserve from which the tip is going to be gotten.
- * @param reserve_reference reference to a command that created
- * a reserve.
- * @param http_status the HTTP response code which is expected
- * for this operation.
- * @param justification human-readable justification for this
- * tip authorization.
- * @param amount the amount to authorize for tipping.
- * @param ec expected Taler-defined error code.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_tip_authorize_from_reserve_with_ec (
- const char *label,
- const char *merchant_url,
- const char *exchange_url,
- const char *reserve_reference,
- unsigned int http_status,
- const char *justification,
- const char *amount,
- enum TALER_ErrorCode ec);
-
-
-/**
- * This commands does not query the backend at all,
- * but just makes up a fake authorization id that will
- * be subsequently used by the "pick up" CMD in order
- * to test against such a case.
- *
- * @param label command label.
- * @return the command.
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_tip_authorize_fake (const char *label);
-
-
-/**
- * Define a /tip-pickup CMD, equipped with the expected error
- * code.
- *
- * @param label the command label
- * @param merchant_url base URL of the backend which will serve
- * the /tip-pickup request.
- * @param http_status expected HTTP response code.
- * @param authorize_reference reference to a /tip-autorize CMD
- * that offers a tip id to pick up.
- * @param amounts array of string-defined amounts that specifies
- * which denominations will be accepted for tipping.
- * @param ec expected Taler error code.
- * @return the command
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_tip_pickup_with_ec (const char *label,
- const char *merchant_url,
- unsigned int http_status,
- const char *authorize_reference,
- const char **amounts,
- enum TALER_ErrorCode ec);
-
-/**
- * Define a /tip-pickup CMD.
- *
- * @param label the command label
- * @param merchant_url base URL of the backend which will serve
- * the /tip-pickup request.
- * @param http_status expected HTTP response code.
- * @param authorize_reference reference to a /tip-autorize CMD
- * that offers a tip id to pick up.
- * @param amounts array of string-defined amounts that specifies
- * which denominations will be accepted for tipping.
- * @return the command
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_tip_pickup (const char *label,
- const char *merchant_url,
- unsigned int http_status,
- const char *authorize_reference,
- const char **amounts);
-
-
-/**
- * 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 expected_http_status expected HTTP status
- * @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,
- unsigned int expected_http_status);
+ const char *otp_id,
+ unsigned int http_status);
/* ****** Templates ******* */
@@ -1498,7 +1358,7 @@ TALER_TESTING_cmd_merchant_kyc_get (const char *label,
* POST /templates request.
* @param template_id the ID of the template to query
* @param template_description description of the template
- * @param image base64-encoded template image
+ * @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.
@@ -1509,7 +1369,7 @@ TALER_TESTING_cmd_merchant_post_templates2 (
const char *merchant_url,
const char *template_id,
const char *template_description,
- const char *image,
+ const char *otp_id,
json_t *template_contract,
unsigned int http_status);
@@ -1541,7 +1401,7 @@ TALER_TESTING_cmd_merchant_post_templates (const char *label,
* PATCH /template request.
* @param template_id the ID of the template to query
* @param template_description description of the template
- * @param image base64-encoded template image
+ * @param otp_id OTP device to use
* @param template_contract contract of the company
* @param http_status expected HTTP response code.
* @return the command.
@@ -1552,7 +1412,7 @@ TALER_TESTING_cmd_merchant_patch_template (
const char *merchant_url,
const char *template_id,
const char *template_description,
- const char *image,
+ const char *otp_id,
json_t *template_contract,
unsigned int http_status);
@@ -1618,21 +1478,64 @@ TALER_TESTING_cmd_merchant_delete_template (const char *label,
*
* @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 *merchant_url,
- const char *summary,
- const char *amount,
- unsigned int http_status);
+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);
+
+/* ****** 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 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,
+ const char *kind);
/* ****** Webhooks ******* */
@@ -1767,6 +1670,84 @@ TALER_TESTING_cmd_merchant_delete_webhook (const char *label,
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);
/* ****** Specific traits supported by this component ******* */
@@ -1779,28 +1760,25 @@ TALER_TESTING_cmd_merchant_delete_webhook (const char *label,
// FIXME: rename: refund_entry->refund_detail
#define TALER_MERCHANT_TESTING_SIMPLE_TRAITS(op) \
op (claim_nonce, const struct GNUNET_CRYPTO_EddsaPublicKey) \
- op (tip_id, const struct TALER_TipIdentifierP) \
op (pickup_id, const struct TALER_PickupIdentifierP) \
- op (instance_name, const char *) \
- op (instance_id, const char *) \
+ op (instance_name, const char) \
+ op (instance_id, const char) \
op (address, const json_t) \
- op (product_description, const char *) \
- op (product_image, const char *) \
+ op (product_description, const char) \
+ op (product_image, const char) \
op (product_stock, const int64_t) \
- op (product_unit, const char *) \
- op (product_id, const char *) \
- op (reason, const char *) \
- op (lock_uuid, const char *) \
- op (auth_token, const char *) \
+ op (product_unit, const char) \
+ op (product_id, const char) \
+ op (reason, const char) \
+ op (lock_uuid, const char) \
+ op (auth_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 (max_wire_fee, const struct TALER_Amount) \
- op (max_deposit_fee, const struct TALER_Amount) \
- op (wire_fee_amortization, const uint32_t) \
+ 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) \
@@ -1808,18 +1786,25 @@ TALER_TESTING_cmd_merchant_delete_webhook (const char *label,
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 (template_image, const char *) \
- op (template_id, const char *) \
+ 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 (url, const char *) \
- op (webhook_id, const char *) \
- op (http_method, const char *) \
- op (header_template, const char *) \
- op (body_template, const char *) \
- op (summary, const char *)
+ 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)
/**
@@ -1828,10 +1813,16 @@ TALER_TESTING_cmd_merchant_delete_webhook (const char *label,
* @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 char *) \
- op (amounts, const struct TALER_Amount) \
+ op (coin_reference, const char) \
+ op (paths, const char) \
+ op (payto_uris, const char) \
+ 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)
diff --git a/src/include/taler_merchantdb_lib.h b/src/include/taler_merchantdb_lib.h
index 1120b864..3a641a54 100644
--- a/src/include/taler_merchantdb_lib.h
+++ b/src/include/taler_merchantdb_lib.h
@@ -87,6 +87,16 @@ 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);
+
#endif /* MERCHANT_DB_H */
/* end of taler_merchantdb_lib.h */
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index d9fe0d24..44fdc0ab 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -23,6 +23,8 @@
#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_exchange_service.h>
@@ -96,7 +98,20 @@ struct TALER_MERCHANTDB_AccountDetails
/**
* Actual account address as a payto://-URI.
*/
- const char *payto_uri;
+ char *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;
/**
* Is the account set for active use in new contracts?
@@ -105,6 +120,19 @@ struct TALER_MERCHANTDB_AccountDetails
};
+
+/**
+ * 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.
*/
@@ -151,6 +179,7 @@ struct TALER_MERCHANTDB_InstanceSettings
* merchant's logo data uri
*/
char *logo;
+
/**
* Address of the business
*/
@@ -162,22 +191,10 @@ struct TALER_MERCHANTDB_InstanceSettings
json_t *jurisdiction;
/**
- * Default max deposit fee that the merchant is willing to
- * pay; if deposit costs more, then the customer will cover
- * the difference.
- */
- struct TALER_Amount default_max_deposit_fee;
-
- /**
- * Default maximum wire fee to assume, unless stated differently in the
- * proposal already.
+ * Use STEFAN curves to determine acceptable
+ * fees by default (otherwise: accept no fees by default).
*/
- struct TALER_Amount default_max_wire_fee;
-
- /**
- * Default factor for wire fee amortization.
- */
- uint32_t default_wire_fee_amortization;
+ bool use_stefan;
/**
* If the frontend does NOT specify an execution date, how long should
@@ -193,6 +210,10 @@ struct TALER_MERCHANTDB_InstanceSettings
*/
struct GNUNET_TIME_Relative default_pay_delay;
+ /**
+ * Type of user this merchant represents.
+ */
+ enum TALER_KYCLOGIC_KycUserType ut;
};
@@ -204,8 +225,6 @@ struct TALER_MERCHANTDB_InstanceSettings
* @param merchant_priv private key of the instance, NULL if not available
* @param is general instance settings
* @param ias instance authentication settings
- * @param accounts_length length of the @a accounts array
- * @param accounts list of accounts of the merchant
*/
typedef void
(*TALER_MERCHANTDB_InstanceCallback)(
@@ -213,18 +232,31 @@ typedef void
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_MerchantPrivateKeyP *merchant_priv,
const struct TALER_MERCHANTDB_InstanceSettings *is,
- const struct TALER_MERCHANTDB_InstanceAuthSettings *ias,
- unsigned int accounts_length,
- const struct TALER_MERCHANTDB_AccountDetails accounts[]);
+ const struct TALER_MERCHANTDB_InstanceAuthSettings *ias);
+
+
+/**
+ * Callback invoked with information about a bank account.
+ *
+ * @param cls closure
+ * @param ad details about the account
+ */
+typedef void
+(*TALER_MERCHANTDB_AccountCallback)(
+ void *cls,
+ const struct TALER_MERCHANTDB_AccountDetails *ad);
+
/**
* 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);
@@ -305,7 +337,7 @@ struct TALER_MERCHANTDB_ProductDetails
/**
* Typically called by `lookup_templates`.
*
- * @param cls a `json_t *` JSON array to build
+ * @param cls closure
* @param template_id ID of the template
* @param template_description description of the template
*/
@@ -316,6 +348,19 @@ typedef void
/**
+ * 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
@@ -326,14 +371,56 @@ struct TALER_MERCHANTDB_TemplateDetails
char *template_description;
/**
- * Base64-encoded image, or NULL.
+ * In this template contract, we can have additional information.
*/
- char *image;
+ json_t *template_contract;
/**
- * In this template contract, we can have additional information.
+ * ID of the OTP device linked to the template, or NULL.
*/
- json_t *template_contract;
+ char *otp_id;
+
+ /**
+ * Currency the payment must be in, NULL to allow any
+ * supported currency.
+ */
+ char *required_currency;
+
+ /**
+ * 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;
};
@@ -409,7 +496,7 @@ typedef void
* Typically called by `lookup_pending_webhooks`.
*
* @param cls a `json_t *` JSON array to build
- * @param webhook_serial reference to the configured webhook template.
+ * @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
@@ -419,7 +506,7 @@ typedef void
*/
typedef void
(*TALER_MERCHANTDB_PendingWebhooksCallback)(void *cls,
- uint64_t webhook_serial,
+ uint64_t webhook_pending_serial,
struct GNUNET_TIME_Absolute
next_attempt,
uint32_t retries,
@@ -434,6 +521,7 @@ typedef void
*/
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.
@@ -455,13 +543,11 @@ struct TALER_MERCHANTDB_PendingWebhookDetails
*/
char *http_method;
-
/**
* Header of the webhook.
*/
char *header;
-
/**
* Body of the webhook.
*/
@@ -476,6 +562,16 @@ struct TALER_MERCHANTDB_PendingWebhookDetails
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;
@@ -538,7 +634,6 @@ typedef void
* @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
*/
typedef void
(*TALER_MERCHANTDB_DepositsCallback)(
@@ -547,8 +642,7 @@ typedef void
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,
- const struct TALER_Amount *wire_fee);
+ const struct TALER_Amount *refund_fee);
/**
@@ -625,6 +719,7 @@ typedef void
* @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 aml_decision current AML decision state at the exchange
*/
typedef void
(*TALER_MERCHANTDB_KycCallback)(
@@ -634,7 +729,8 @@ typedef void
const char *payto_uri,
const char *exchange_url,
struct GNUNET_TIME_Timestamp last_check,
- bool kyc_ok);
+ bool kyc_ok,
+ enum TALER_AmlDecisionState aml_decision);
/**
@@ -644,6 +740,11 @@ enum TALER_MERCHANTDB_RefundStatus
{
/**
+ * 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,
@@ -688,6 +789,60 @@ typedef void
/**
+ * 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 base URL of the exchange that initiated the transfer
+ * @param payto_uri account of the merchant that received the transfer
+ * @param wtid wire transfer subject identifying the aggregation
+ * @param total total amount that was wired
+ * @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,
+ const char *payto_uri,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_Amount *total,
+ 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_backoff current value of the retry backoff
+ * @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_Relative retry_backoff,
+ 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.
*
@@ -703,6 +858,27 @@ typedef void
/**
+ * 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,
+ const char *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
@@ -732,71 +908,24 @@ typedef void
/**
- * Callback with reserve details.
- *
- * @param cls closure
- * @param reserve_pub public key of the reserve
- * @param creation_time time when the reserve was setup
- * @param expiration_time time when the reserve will be closed by the exchange
- * @param merchant_initial_amount initial amount that the merchant claims to have filled the
- * reserve with
- * @param exchange_initial_amount initial amount that the exchange claims to have received
- * @param pickup_amount total of tips that were picked up from this reserve
- * @param committed_amount total of tips that the merchant committed to, but that were not
- * picked up yet
- * @param active true if the reserve is still active (we have the private key)
- */
-typedef void
-(*TALER_MERCHANTDB_ReservesCallback)(
- void *cls,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- struct GNUNET_TIME_Timestamp creation_time,
- struct GNUNET_TIME_Timestamp expiration_time,
- const struct TALER_Amount *merchant_initial_amount,
- const struct TALER_Amount *exchange_initial_amount,
- const struct TALER_Amount *pickup_amount,
- const struct TALER_Amount *committed_amount,
- bool active);
-
-
-/**
- * Callback with details about a reserve pending exchange confirmation.
+ * If the given account is feasible, add it to the array
+ * of accounts we return.
*
* @param cls closure
- * @param instance_id for which instance is this reserve
- * @param exchange_url base URL of the exchange
- * @param reserve_pub public key of the reserve
- * @param expected_amount how much do we expect to see in the reserve
+ * @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_PendingReservesCallback)(
+(*TALER_MERCHANTDB_ExchangeAccountCallback) (
void *cls,
- const char *instance_id,
- const char *exchange_url,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_Amount *expected_amount);
-
-
-/**
- * Details about a tip.
- */
-struct TALER_MERCHANTDB_TipDetails
-{
- /**
- * ID of the tip.
- */
- struct TALER_TipIdentifierP tip_id;
-
- /**
- * Total amount of the tip.
- */
- struct TALER_Amount total_amount;
-
- /**
- * Reason given for granting the tip.
- */
- char *reason;
-};
+ const char *payto_uri,
+ const char *conversion_url,
+ const json_t *debit_restrictions,
+ const json_t *credit_restrictions,
+ const struct TALER_MasterSignatureP *master_sig);
/**
@@ -805,9 +934,10 @@ struct TALER_MERCHANTDB_TipDetails
* @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 h_wire hash of merchant's wire details
* @param coin_pub public key of the coin
*/
typedef void
@@ -816,61 +946,13 @@ typedef void
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);
/**
- * Callback with reserve details.
- *
- * @param cls closure
- * @param creation_time time when the reserve was setup
- * @param expiration_time time when the reserve will be closed by the exchange
- * @param merchant_initial_amount initial amount that the merchant claims to have filled the
- * reserve with
- * @param exchange_initial_amount initial amount that the exchange claims to have received
- * @param picked_up_amount total of tips that were picked up from this reserve
- * @param committed_amount total of tips that the merchant committed to, but that were not
- * picked up yet
- * @param active true if the reserve is still active (we have the private key)
- * @param exchange_url base URL of the exchange hosting the reserve, NULL if not @a active
- * @param payto_uri URI to use to fund the reserve, NULL if not @a active
- * @param tips_length length of the @a tips array
- * @param tips information about the tips created by this reserve
- */
-typedef void
-(*TALER_MERCHANTDB_ReserveDetailsCallback)(
- void *cls,
- struct GNUNET_TIME_Timestamp creation_time,
- struct GNUNET_TIME_Timestamp expiration_time,
- const struct TALER_Amount *merchant_initial_amount,
- const struct TALER_Amount *exchange_initial_amount,
- const struct TALER_Amount *picked_up_amount,
- const struct TALER_Amount *committed_amount,
- bool active,
- const char *exchange_url,
- const char *payto_uri,
- unsigned int tips_length,
- const struct TALER_MERCHANTDB_TipDetails *tips);
-
-
-/**
- * Typically called by `lookup_tips`.
- *
- * @param cls closure
- * @param row_id row of the tip in the database
- * @param tip_id id of the tip
- * @param amount amount of the tip
- */
-typedef void
-(*TALER_MERCHANTDB_TipsCallback)(void *cls,
- uint64_t row_id,
- struct TALER_TipIdentifierP tip_id,
- struct TALER_Amount amount);
-
-
-/**
* Function called with information about a coin that was deposited.
*
* @param cls closure
@@ -901,25 +983,151 @@ typedef void
/**
- * Details about a pickup operation executed by the merchant.
+ * Possible token family kinds.
*/
-struct TALER_MERCHANTDB_PickupDetails
+enum TALER_MERCHANTDB_TokenFamilyKind
{
+
/**
- * Identifier for the pickup operation.
+ * Token family representing a discount token
*/
- struct TALER_PickupIdentifierP pickup_id;
+ TALER_MERCHANTDB_TFK_Discount = 0,
/**
- * Total amount requested for this @e pickup_id.
+ * Token family representing a subscription token
*/
- struct TALER_Amount requested_amount;
+ TALER_MERCHANTDB_TFK_Subscription = 1,
+
+};
+
+
+/**
+ * Typically called by `lookup_token_families`.
+ *
+ * @param cls a `json_t *` JSON array to build
+ * @param slug slug of the token family
+ * @param name name of the token family
+ * @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,
+ struct GNUNET_TIME_Timestamp start_time,
+ struct GNUNET_TIME_Timestamp expiration,
+ const char *kind);
+
+
+/**
+ * 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;
+
+ /**
+ * 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.
+ */
+ struct GNUNET_TIME_Relative duration;
+
+ /**
+ * Token family kind.
+ */
+ enum TALER_MERCHANTDB_TokenFamilyKind kind;
+
+ /**
+ * Counter for each issued token of this family.
+ */
+ uint64_t issued;
+
+ /**
+ * Counter for each redeemed token of this family.
+ */
+ uint64_t redeemed;
+};
+
+
+/**
+ * Details about a token key.
+ */
+struct TALER_MERCHANTDB_TokenFamilyKeyDetails
+{
+ /**
+ * Tokens signed with this key are valid from this date on.
+ */
+ struct GNUNET_TIME_Timestamp valid_after;
+
+ /**
+ * Tokens signed with this key are valid until this date.
+ */
+ struct GNUNET_TIME_Timestamp valid_before;
/**
- * Number of planchets involved in the request.
+ * Token family public key.
*/
- unsigned int num_planchets;
+ struct TALER_TokenFamilyPublicKey *pub;
+ /**
+ * Token family private key.
+ */
+ struct TALER_TokenFamilyPrivateKey *priv;
+
+ /**
+ * Details about the token family this key belongs to.
+ */
+ struct TALER_MERCHANTDB_TokenFamilyDetails token_family;
+};
+
+/**
+ * Details about a spent token.
+*/
+struct TALER_MERCHANTDB_SpentTokenDetails
+{
+ /**
+ * Public key of the spent token.
+ */
+ struct TALER_TokenPublicKey pub;
+
+ /**
+ * Signature that this token was spent on the specified order.
+ */
+ struct TALER_TokenSignature sig;
+
+ /**
+ * Blind signature for the spent token to prove validity of it.
+ */
+ struct TALER_TokenBlindSignature blind_sig;
};
@@ -1052,7 +1260,6 @@ struct TALER_MERCHANTDB_Plugin
* Roll back the current transaction of a database connection.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
- * @return #GNUNET_OK on success
*/
void
(*rollback) (void *cls);
@@ -1061,7 +1268,7 @@ struct TALER_MERCHANTDB_Plugin
* Commit the current transaction of a database connection.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
- * @return transaction status code
+ * @return transaction status
*/
enum GNUNET_DB_QueryStatus
(*commit)(void *cls);
@@ -1139,6 +1346,132 @@ struct TALER_MERCHANTDB_Plugin
const char *id,
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
+ * @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);
+
+
+ /**
+ * 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);
+
+
+ /**
+ * 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);
+
+
+ /**
+ * 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 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 *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,
+ const char *payto_uri,
+ struct TALER_MERCHANTDB_AccountDetails *ad);
+
+
/**
* Delete private key of an instance from our database.
*
@@ -1250,6 +1583,7 @@ struct TALER_MERCHANTDB_Plugin
* @param exchange_pub public key of the exchange, or NULL for none
* @param timestamp timestamp to store
* @param kyc_ok current KYC status (true for satisfied)
+ * @param aml_decision current AML decision state at the exchange
* @return database result code
*/
enum GNUNET_DB_QueryStatus
@@ -1261,7 +1595,8 @@ struct TALER_MERCHANTDB_Plugin
const struct TALER_ExchangeSignatureP *exchange_sig,
const struct TALER_ExchangePublicKeyP *exchange_pub,
struct GNUNET_TIME_Timestamp timestamp,
- bool kyc_ok);
+ bool kyc_ok,
+ enum TALER_AmlDecisionState aml_decision);
/**
@@ -1269,6 +1604,9 @@ struct TALER_MERCHANTDB_Plugin
*
* @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 cb function to call on all products found
* @param cb_cls closure for @a cb
* @return database result code
@@ -1276,6 +1614,8 @@ struct TALER_MERCHANTDB_Plugin
enum GNUNET_DB_QueryStatus
(*lookup_products)(void *cls,
const char *instance_id,
+ uint64_t offset,
+ int64_t limit,
TALER_MERCHANTDB_ProductsCallback cb,
void *cb_cls);
@@ -1378,8 +1718,9 @@ struct TALER_MERCHANTDB_Plugin
* instances.
*
* @param cls closure
+ * @return database result code
*/
- void
+ enum GNUNET_DB_QueryStatus
(*expire_locks)(void *cls);
@@ -1465,20 +1806,26 @@ struct TALER_MERCHANTDB_Plugin
* @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 json_t *contract_terms,
+ const char *pos_key,
+ enum TALER_MerchantConfirmationAlgorithm pos_algorithm);
/**
@@ -1526,16 +1873,71 @@ struct TALER_MERCHANTDB_Plugin
* @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_terms)(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);
+ (*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
+ * @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);
+
+
+ /**
+ * 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);
/**
@@ -1555,11 +1957,12 @@ struct TALER_MERCHANTDB_Plugin
* 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);
+ (*insert_contract_terms)(
+ void *cls,
+ const char *instance_id,
+ const char *order_id,
+ json_t *contract_terms,
+ uint64_t *order_serial);
/**
@@ -1646,36 +2049,62 @@ struct TALER_MERCHANTDB_Plugin
/**
- * Insert payment confirmation from the exchange into the database.
+ * 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 coin_pub public key of the coin
* @param exchange_url URL of the exchange that issued @a coin_pub
- * @param amount_with_fee amount the exchange will deposit for this coin
- * @param deposit_fee fee the exchange will charge for this coin
+ * @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)(void *cls,
- const char *instance_id,
- struct GNUNET_TIME_Timestamp deposit_timestamp,
- const struct TALER_PrivateContractHashP *h_contract_terms,
- const struct TALER_CoinSpendPublicKeyP *coin_pub,
- 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,
- const struct TALER_ExchangeSignatureP *exchange_sig,
- const struct TALER_ExchangePublicKeyP *exchange_pub);
+ (*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
+ * @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);
/**
@@ -1778,25 +2207,6 @@ struct TALER_MERCHANTDB_Plugin
/**
- * Retrieve payment and wire status for a given @a order_serial and
- * session ID.
- *
- * @param cls closure
- * @param order_serial identifies the order
- * @param session_id session for which to check the payment status, NULL for any
- * @param[out] paid set to the payment status of the contract
- * @param[out] wired set to the wire transfer status of the exchange payment
- * @return transaction status
- */
- enum GNUNET_DB_QueryStatus
- (*lookup_payment_status)(void *cls,
- uint64_t order_serial,
- const char *session_id,
- bool *paid,
- bool *wired);
-
-
- /**
* Retrieve details about coins that were deposited for an order.
*
* @param cls closure
@@ -1831,6 +2241,47 @@ struct TALER_MERCHANTDB_Plugin
/**
+ * 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 ec current error state of checking the transfer
+ * @param failed true if validation has failed for good
+ * @param verified true if validation has succeeded for good
+ * @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,
+ enum TALER_ErrorCode ec,
+ bool failed,
+ bool verified);
+
+ /**
+ * 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
@@ -1941,6 +2392,7 @@ struct TALER_MERCHANTDB_Plugin
* @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
@@ -1950,9 +2402,42 @@ struct TALER_MERCHANTDB_Plugin
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,
+ const char *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.
*
* @param cls closure
@@ -2127,20 +2612,22 @@ struct TALER_MERCHANTDB_Plugin
/**
- * Set transfer status to verified.
+ * Set transfer status to confirmed.
*
* @param cls closure
* @param instance_id instance to lookup payments for
* @param exchange_url the exchange that made the transfer
- * @param payto_uri account that received the transfer
* @param wtid wire transfer subject
+ * @param amount confirmed amount of the wire transfer
* @return transaction status
*/
enum GNUNET_DB_QueryStatus
- (*set_transfer_status_to_verified)(
+ (*set_transfer_status_to_confirmed)(
void *cls,
+ const char *instance_id,
const char *exchange_url,
- const struct TALER_WireTransferIdentifierRawP *wtid);
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_Amount *amount);
/**
@@ -2219,402 +2706,236 @@ struct TALER_MERCHANTDB_Plugin
* including signature (so we have proof).
*
* @param cls closure
- * @param exchange_pub public key of the exchange
+ * @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 exchange_sig signature of exchange over fee structure
+ * @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 *exchange_pub,
+ 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 *exchange_sig);
-
-
- /**
- * Add @a credit to a reserve to be used for tipping. Note that
- * this function does not actually perform any wire transfers to
- * credit the reserve, it merely tells the merchant backend that
- * a reserve now exists. This has to happen before tips can be
- * authorized.
- *
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance is the reserve tied to
- * @param reserve_priv which reserve is topped up or created
- * @param reserve_pub which reserve is topped up or created
- * @param exchange_url what URL is the exchange reachable at where the reserve is located
- * @param payto_uri URI to fund the reserve
- * @param initial_balance how much money will be added to the reserve
- * @param expiration when does the reserve expire?
- * @return transaction status, usually
- * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success
- */
- enum TALER_ErrorCode
- (*insert_reserve)(void *cls,
- const char *instance_id,
- const struct TALER_ReservePrivateKeyP *reserve_priv,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const char *exchange_url,
- const char *payto_uri,
- const struct TALER_Amount *initial_balance,
- struct GNUNET_TIME_Timestamp expiration);
+ const struct TALER_MasterSignatureP *master_sig);
/**
- * Confirms @a credit as the amount the exchange claims to have received and
- * thus really 'activates' the reserve. This has to happen before tips can
- * be authorized.
+ * Delete information about wire accounts of an exchange. (Used when we got new account data.)
*
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance is the reserve tied to
- * @param reserve_pub which reserve is topped up or created
- * @param initial_exchange_balance how much money was be added to the reserve
- * according to the exchange
- * @return transaction status, usually
- * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success
+ * @param cls closure
+ * @param master_pub public key of the exchange
+ * @return transaction status code
*/
enum GNUNET_DB_QueryStatus
- (*activate_reserve)(void *cls,
- const char *instance_id,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_Amount *initial_exchange_balance);
+ (*delete_exchange_accounts)(
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub);
/**
- * Lookup reserves.
+ * Return information about wire accounts of an exchange.
*
* @param cls closure
- * @param instance_id instance to lookup payments for
- * @param created_after filter by reserves created after this date
- * @param active filter by active reserves
- * @param failures filter by reserves with a disagreement on the initial balance
- * @param cb function to call with reserve summary data
+ * @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
+ * @return transaction status code
*/
enum GNUNET_DB_QueryStatus
- (*lookup_reserves)(void *cls,
- const char *instance_id,
- struct GNUNET_TIME_Timestamp created_after,
- enum TALER_EXCHANGE_YesNoAll active,
- enum TALER_EXCHANGE_YesNoAll failures,
- TALER_MERCHANTDB_ReservesCallback cb,
- void *cb_cls);
+ (*select_accounts_by_exchange)(
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ TALER_MERCHANTDB_ExchangeAccountCallback cb,
+ void *cb_cls);
/**
- * Lookup reserves pending activation across all instances.
+ * Insert information about a wire account of an exchange.
*
* @param cls closure
- * @param cb function to call with reserve data
- * @param cb_cls closure for @a cb
- * @return transaction status
+ * @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
- (*lookup_pending_reserves)(void *cls,
- TALER_MERCHANTDB_PendingReservesCallback cb,
- void *cb_cls);
+ (*insert_exchange_account)(
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const char *payto_uri,
+ const char *conversion_url,
+ const json_t *debit_restrictions,
+ const json_t *credit_restrictions,
+ const struct TALER_MasterSignatureP *master_sig);
/**
- * Lookup reserve details.
+ * Lookup all of the templates the given instance has configured.
*
* @param cls closure
- * @param instance_id instance to lookup payments for
- * @param reserve_pub public key of the reserve to inspect
- * @param fetch_tips if true, also return information about tips
- * @param cb function to call with reserve summary data
+ * @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 transaction status
+ * @return database result code
*/
enum GNUNET_DB_QueryStatus
- (*lookup_reserve)(void *cls,
- const char *instance_id,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- bool fetch_tips,
- TALER_MERCHANTDB_ReserveDetailsCallback cb,
- void *cb_cls);
+ (*lookup_templates)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_TemplatesCallback cb,
+ void *cb_cls);
/**
- * Delete private key of a reserve.
+ * Lookup details about a particular template.
*
* @param cls closure
- * @param instance_id instance to lookup payments for
- * @param reserve_pub public key of the reserve to delete
- * @return transaction status
+ * @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
- (*delete_reserve)(void *cls,
- const char *instance_id,
- const struct TALER_ReservePublicKeyP *reserve_pub);
+ (*lookup_template)(void *cls,
+ const char *instance_id,
+ const char *template_id,
+ struct TALER_MERCHANTDB_TemplateDetails *td);
/**
- * Purge all information about a reserve (including tips from it).
+ * Delete information about a template.
*
* @param cls closure
- * @param instance_id instance to lookup payments for
- * @param reserve_pub public key of the reserve to purge
- * @return transaction status
+ * @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
- (*purge_reserve)(void *cls,
- const char *instance_id,
- const struct TALER_ReservePublicKeyP *reserve_pub);
-
-
- /**
- * Authorize a tip over @a amount from reserve @a reserve_pub. Remember
- * the authorization under @a tip_id for later, together with the
- * @a justification.
- *
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance should generate the tip
- * @param reserve_pub which reserve is debited, NULL to pick one in the DB
- * @param amount how high is the tip (with fees)
- * @param justification why was the tip approved
- * @param next_url where to send the URL post tip pickup
- * @param[out] tip_id set to the unique ID for the tip
- * @param[out] expiration set to when the tip expires
- * @return transaction status,
- * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_EXPIRED if the reserve is known but has expired
- * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_NOT_FOUND if the reserve is not known
- * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_INSUFFICIENT_FUNDS if the reserve has insufficient funds left
- * #TALER_EC_GENERIC_DB_START_FAILED on hard DB errors
- * #TALER_EC_GENERIC_DB_FETCH_FAILED on hard DB errors
- * #TALER_EC_GENERIC_DB_STORE_FAILED on hard DB errors
- * #TALER_EC_GENERIC_DB_INVARIANT_FAILURE on hard DB errors
- * #TALER_EC_GENERIC_DB_SOFT_FAILURE on soft DB errors (client should retry)
- * #TALER_EC_NONE upon success
- */
- enum TALER_ErrorCode
- (*authorize_tip)(void *cls,
- const char *instance_id,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_Amount *amount,
- const char *justification,
- const char *next_url,
- struct TALER_TipIdentifierP *tip_id,
- struct GNUNET_TIME_Timestamp *expiration);
+ (*delete_template)(void *cls,
+ const char *instance_id,
+ const char *template_id);
/**
- * Lookup pickup details for pickup @a pickup_id.
+ * Insert details about a particular template.
*
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance should we lookup tip details for
- * @param tip_id which tip should we lookup details on
- * @param pickup_id which pickup should we lookup details on
- * @param[out] exchange_url which exchange is the tip withdrawn from
- * @param[out] reserve_priv private key the tip is withdrawn from (set if still available!)
- * @param sigs_length length of the @a sigs array
- * @param[out] sigs set to the (blind) signatures we have for this @a pickup_id,
- * those that are unavailable are left at NULL
- * @return transaction status
+ * @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
- (*lookup_pickup)(void *cls,
- const char *instance_id,
- const struct TALER_TipIdentifierP *tip_id,
- const struct TALER_PickupIdentifierP *pickup_id,
- char **exchange_url,
- struct TALER_ReservePrivateKeyP *reserve_priv,
- unsigned int sigs_length,
- struct TALER_BlindedDenominationSignature sigs[]);
+ (*insert_template)(void *cls,
+ const char *instance_id,
+ const char *template_id,
+ uint64_t otp_serial_id,
+ const struct TALER_MERCHANTDB_TemplateDetails *td);
/**
- * Lookup tip details for tip @a tip_id.
+ * Delete information about an OTP device.
*
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance should we lookup tip details for
- * @param tip_id which tip should we lookup details on
- * @param[out] total_authorized amount how high is the tip (with fees)
- * @param[out] total_picked_up how much of the tip was so far picked up (with fees)
- * @param[out] expiration set to when the tip expires
- * @param[out] exchange_url set to the exchange URL where the reserve is
- * @param[out] reserve_priv set to private key of reserve to be debited
- * @return transaction status
+ * @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
- (*lookup_tip)(void *cls,
+ (*delete_otp)(void *cls,
const char *instance_id,
- const struct TALER_TipIdentifierP *tip_id,
- struct TALER_Amount *total_authorized,
- struct TALER_Amount *total_picked_up,
- struct GNUNET_TIME_Timestamp *expiration,
- char **exchange_url,
- struct TALER_ReservePrivateKeyP *reserve_priv);
-
+ const char *otp_id);
/**
- * Lookup tips
+ * Insert details about a particular OTP device.
*
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance should we lookup tips for
- * @param expired should we include expired tips?
- * @param limit maximum number of results to return, positive for
- * ascending row id, negative for descending
- * @param offset row id to start returning results from
- * @param cb function to call with tip data
- * @param cb_cls closure for @a cb
- * @return transaction status
- */
- enum GNUNET_DB_QueryStatus
- (*lookup_tips)(void *cls,
- const char *instance_id,
- enum TALER_EXCHANGE_YesNoAll expired,
- int64_t limit,
- uint64_t offset,
- TALER_MERCHANTDB_TipsCallback cb,
- void *cb_cls);
-
-
- /**
- * Lookup tip details for tip @a tip_id.
- *
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance should we lookup tip details for
- * @param tip_id which tip should we lookup details on
- * @param fpu should we fetch details about individual pickups
- * @param[out] total_authorized amount how high is the tip (with fees)
- * @param[out] total_picked_up how much of the tip was so far picked up (with fees)
- * @param[out] justification why was the tip approved
- * @param[out] expiration set to when the tip expires
- * @param[out] reserve_pub set to which reserve is debited
- * @param[out] pickups_length set to the length of @e pickups
- * @param[out] pickups if @a fpu is true, set to details about the pickup operations
- * @return transaction status
- */
- enum GNUNET_DB_QueryStatus
- (*lookup_tip_details)(void *cls,
- const char *instance_id,
- const struct TALER_TipIdentifierP *tip_id,
- bool fpu,
- struct TALER_Amount *total_authorized,
- struct TALER_Amount *total_picked_up,
- char **justification,
- struct GNUNET_TIME_Timestamp *expiration,
- struct TALER_ReservePublicKeyP *reserve_pub,
- unsigned int *pickups_length,
- struct TALER_MERCHANTDB_PickupDetails **pickups);
-
-
- /**
- * Insert details about a tip pickup operation. The @a total_picked_up
- * UPDATES the total amount under the @a tip_id, while the @a total_requested
- * is the amount to be associated with this @a pickup_id.
- * While there is usually only one pickup event that picks up the entire
- * amount, our schema allows for wallets to pick up the amount incrementally
- * over multiple pick up operations.
- *
- * @param cls closure, typically a connection to the db
- * @param tip_id the unique ID for the tip
- * @param total_picked_up how much was picked up overall at this
- * point (includes @a total_requested)
- * @param pickup_id unique ID for the operation
- * @param total_requested how much is being picked up in this operation
- * @return transaction status, usually
- * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success
- * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if @a credit_uuid already known
+ * @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_pickup)(void *cls,
- const char *instance_id,
- const struct TALER_TipIdentifierP *tip_id,
- const struct TALER_Amount *total_picked_up,
- const struct TALER_PickupIdentifierP *pickup_id,
- const struct TALER_Amount *total_requested);
+ (*insert_otp)(void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ const struct TALER_MERCHANTDB_OtpDeviceDetails *td);
/**
- * Insert blind signature obtained from the exchange during a
- * tip pickup operation.
+ * Update details about a particular OTP device.
*
- * @param cls closure, typically a connection to the db
- * @param pickup_id unique ID for the operation
- * @param offset offset of the blind signature for the pickup
- * @param blind_sig the blind signature
- * @return transaction status, usually
- * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success
- * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if @a credit_uuid already known
+ * @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
- (*insert_pickup_blind_signature)(
- void *cls,
- const struct TALER_PickupIdentifierP *pickup_id,
- uint32_t offset,
- const struct TALER_BlindedDenominationSignature *blind_sig);
-
+ (*update_otp)(void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ const struct TALER_MERCHANTDB_OtpDeviceDetails *td);
/**
- * Lookup all of the templates the given instance has configured.
+ * Lookup all of the OTP devices 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 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_templates)(void *cls,
- const char *instance_id,
- TALER_MERCHANTDB_TemplatesCallback cb,
- void *cb_cls);
+ (*lookup_otp_devices)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_OtpDeviceCallback cb,
+ void *cb_cls);
/**
- * Lookup details about a particular template.
+ * Lookup details about an OTP device.
*
* @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
+ * @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
- (*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);
+ (*select_otp)(void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ struct TALER_MERCHANTDB_OtpDeviceDetails *td);
/**
- * Insert details about a particular template.
+ * Lookup serial number of an OTP device.
*
* @param cls closure
- * @param instance_id instance to insert template for
- * @param template_id template identifier of template to insert
- * @param td the template details to insert
- * @return database result code
+ * @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
- (*insert_template)(void *cls,
- const char *instance_id,
- const char *template_id,
- const struct TALER_MERCHANTDB_TemplateDetails *td);
+ (*select_otp_serial)(void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ uint64_t *serial);
/**
@@ -2752,22 +3073,6 @@ struct TALER_MERCHANTDB_Plugin
const char *http_method,
const char *header,
const char *body);
-
- /**
- * Lookup details about a particular pending webhook.
- *
- * @param cls closure
- * @param instance_id instance to lookup webhook for
- * @param webhook_serial webhook to lookup
- * @param[out] pwb set to the pending 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_pending_webhook)(void *cls,
- const char *instance_id,
- uint64_t *webhook_serial,
- struct TALER_MERCHANTDB_PendingWebhookDetails *pwb);
/**
* Lookup the webhook that need to be send in priority. These webhooks are not successfully
* send.
@@ -2827,9 +3132,9 @@ struct TALER_MERCHANTDB_Plugin
*/
enum GNUNET_DB_QueryStatus
(*update_pending_webhook)(void *cls,
- uint64_t webhook_serial,
+ uint64_t webhook_pending_serial,
struct GNUNET_TIME_Absolute next_attempt);
- // maybe add: http status of failure?
+ // maybe add: http status of failure?
/**
@@ -2842,8 +3147,197 @@ struct TALER_MERCHANTDB_Plugin
*/
enum GNUNET_DB_QueryStatus
(*delete_pending_webhook)(void *cls,
- uint64_t webhook_serial);
+ 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] 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 TALER_EXCHANGE_Keys **keys);
+
+
+ /**
+ * Insert or update @a keys into the database.
+ *
+ * @param cls plugin closure
+ * @param keys data to store
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_exchange_keys)(void *cls,
+ const struct TALER_EXCHANGE_Keys *keys);
+
+
+ /**
+ * 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 min_valid_after lower bound of the start of the key validation period
+ * @param max_valid_after upper bound of the start of the key validation period
+ * @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 min_valid_after,
+ struct GNUNET_TIME_Timestamp max_valid_after,
+ struct TALER_MERCHANTDB_TokenFamilyKeyDetails *details);
+
+
+ /**
+ * Insert details a key pair for a token family.
+ *
+ * @param cls closure
+ * @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 valid_after start of the key validation period
+ * @param valid_before end of the key validation period
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_token_family_key)(
+ void *cls,
+ const char *token_family_slug,
+ const struct TALER_TokenFamilyPublicKey *pub,
+ const struct TALER_TokenFamilyPrivateKey *priv,
+ 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 wire_pending should we keep checking for the wire status with the exchange?
+ * @param future_retry when should we ask the exchange again
+ * @param retry_backoff current value for the retry backoff
+ * @param emsg error message to record
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_deposit_confirmation_status)(
+ void *cls,
+ uint64_t deposit_serial,
+ bool wire_pending,
+ struct GNUNET_TIME_Timestamp future_retry,
+ struct GNUNET_TIME_Relative retry_backoff,
+ const char *emsg);
};
#endif