commit f9b298b57046bc065350d99efaafbbb222d3572e parent dc3bc6d9a1d0531ac467743d7846fdc677139e4d Author: Christian Grothoff <christian@grothoff.org> Date: Tue, 10 Mar 2026 22:24:41 +0100 napi start Diffstat:
| A | src/include/taler/taler-merchant/delete-management-instances-INSTANCE-new.h | | | 181 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/delete-private-accounts-H_WIRE-new.h | | | 110 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/delete-private-donau-DONAU_SERIAL-new.h | | | 110 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/delete-private-orders-ORDER_ID-new.h | | | 180 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/delete-private-otp-devices-DEVICE_ID-new.h | | | 110 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/delete-private-products-PRODUCT_ID-new.h | | | 110 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/delete-private-templates-TEMPLATE_ID-new.h | | | 110 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/delete-private-tokens-SERIAL-new.h | | | 110 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/delete-private-transfers-TID-new.h | | | 110 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/delete-private-units-UNIT-new.h | | | 110 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/delete-private-webhooks-WEBHOOK_ID-new.h | | | 110 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-config-new.h | | | 234 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-management-instances-INSTANCE-new.h | | | 189 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-management-instances-new.h | | | 166 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-orders-ORDER_ID-new.h | | | 356 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-accounts-H_WIRE-new.h | | | 171 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-accounts-new.h | | | 156 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-donau-new.h | | | 190 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-kyc-new.h | | | 443 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-orders-ORDER_ID-new.h | | | 449 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-orders-new.h | | | 528 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-otp-devices-DEVICE_ID-new.h | | | 160 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-otp-devices-new.h | | | 157 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-products-PRODUCT_ID-new.h | | | 216 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-products-new.h | | | 156 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-statistics-amount-SLUG-new.h | | | 342 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-statistics-counter-SLUG-new.h | | | 333 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-templates-TEMPLATE_ID-new.h | | | 145 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-templates-new.h | | | 156 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG-new.h | | | 196 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-transfers-new.h | | | 423 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-units-UNIT-new.h | | | 135 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-units-new.h | | | 137 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-webhooks-WEBHOOK_ID-new.h | | | 156 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-private-webhooks-new.h | | | 156 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-products-IMAGE_HASH-image-new.h | | | 135 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/get-templates-TEMPLATE_ID-new.h | | | 135 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/patch-management-instances-INSTANCE-new.h | | | 123 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/patch-private-accounts-H_WIRE-new.h | | | 254 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/patch-private-orders-ORDER_ID-forget-new.h | | | 113 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/patch-private-otp-devices-DEVICE_ID-new.h | | | 117 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/patch-private-products-PRODUCT_ID-new.h | | | 336 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/patch-private-templates-TEMPLATE_ID-new.h | | | 115 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/patch-private-units-UNIT-new.h | | | 376 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/patch-private-webhooks-WEBHOOK_ID-new.h | | | 119 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-management-instances-INSTANCE-auth-new.h | | | 115 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-management-instances-new.h | | | 129 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-orders-ORDER_ID-abort-new.h | | | 210 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-orders-ORDER_ID-claim-new.h | | | 247 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-orders-ORDER_ID-paid-new.h | | | 225 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-orders-ORDER_ID-pay-new.h | | | 647 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-orders-ORDER_ID-refund-new.h | | | 216 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-accounts-new.h | | | 271 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-categories-new.h | | | 240 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-donau-new.h | | | 220 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-orders-ORDER_ID-refund-new.h | | | 143 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-orders-new.h | | | 472 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-otp-devices-new.h | | | 121 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-products-PRODUCT_ID-lock-new.h | | | 253 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-products-new.h | | | 459 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-templates-new.h | | | 223 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-token-new.h | | | 119 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-tokenfamilies-new.h | | | 261 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-transfers-new.h | | | 145 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-units-new.h | | | 255 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-private-webhooks-new.h | | | 123 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/include/taler/taler-merchant/post-templates-TEMPLATE_ID-new.h | | | 298 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
67 files changed, 14316 insertions(+), 0 deletions(-)
diff --git a/src/include/taler/taler-merchant/delete-management-instances-INSTANCE-new.h b/src/include/taler/taler-merchant/delete-management-instances-INSTANCE-new.h @@ -0,0 +1,181 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/delete-management-instances-INSTANCE-new.h + * @brief C interface for DELETE /management/instances/$INSTANCE + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__DELETE_MANAGEMENT_INSTANCES_INSTANCE_NEW_H +#define _TALER_MERCHANT__DELETE_MANAGEMENT_INSTANCES_INSTANCE_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a DELETE /management/instances/$INSTANCE operation. + */ +struct TALER_MERCHANT_DeleteManagementInstanceHandle; + + +/** + * Set up DELETE /management/instances/$INSTANCE operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx curl context + * @param url merchant backend base URL + * @param instance_id identifier of the instance to delete + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_DeleteManagementInstanceHandle * +TALER_MERCHANT_delete_management_instance_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *instance_id); + + +/** + * Options for DELETE /management/instances/$INSTANCE. + */ +enum TALER_MERCHANT_DeleteManagementInstanceOption +{ + /** + * Sentinel value, end of options. + */ + TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_OPTION_END = 0, + + /** + * If set, purge (hard delete) the instance, removing all data. + * Without this option, a soft delete is performed (preserves data). + * Value type: none (presence of option means purge=yes). + */ + TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_OPTION_PURGE +}; + + +/** + * Value for a DELETE /management/instances/$INSTANCE option. + */ +struct TALER_MERCHANT_DeleteManagementInstanceOptionValue +{ + /** + * Which option is being set. + */ + enum TALER_MERCHANT_DeleteManagementInstanceOption option; +}; + + +/** + * Set options for DELETE /management/instances/$INSTANCE operation. + * + * @param[in,out] handle the handle to set options for + * @param num_options length of the @a options array + * @param options array of option values (terminated with _END) + */ +void +TALER_MERCHANT_delete_management_instance_set_options_ ( + struct TALER_MERCHANT_DeleteManagementInstanceHandle *handle, + unsigned int num_options, + const struct TALER_MERCHANT_DeleteManagementInstanceOptionValue options[]); + + +/** + * Maximum number of options for set_options macro. + */ +#define TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_OPTIONS_ARRAY_MAX_SIZE 4 + +/** + * Set options for DELETE /management/instances/$INSTANCE operation. + * Variadic macro wrapper around + * #TALER_MERCHANT_delete_management_instance_set_options_(). + * + * @param handle the handle to set options for + * @param ... option values (automatically terminated with _END) + */ +#define TALER_MERCHANT_delete_management_instance_set_options(handle, ...) \ + do { \ + struct TALER_MERCHANT_DeleteManagementInstanceOptionValue __opts[] = { \ + __VA_ARGS__, \ + { .option = TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_OPTION_END } \ + }; \ + TALER_MERCHANT_delete_management_instance_set_options_ ( \ + handle, \ + sizeof (__opts) / sizeof (__opts[0]) - 1, \ + __opts); \ + } while (0) + + +/** + * Response details for a DELETE /management/instances/$INSTANCE request. + */ +struct TALER_MERCHANT_DeleteManagementInstanceResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_DeleteManagementInstanceCallback. + */ +#define TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_RESULT_CLOSURE */ + +/** + * Type of the function that receives the result of a + * DELETE /management/instances/$INSTANCE request. + * + * @param cls closure + * @param result result returned by the HTTP server + */ +typedef void +(*TALER_MERCHANT_DeleteManagementInstanceCallback)( + TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_DeleteManagementInstanceResponse *result); + + +/** + * Start DELETE /management/instances/$INSTANCE operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_delete_management_instance_start ( + struct TALER_MERCHANT_DeleteManagementInstanceHandle *handle, + TALER_MERCHANT_DeleteManagementInstanceCallback cb, + TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel DELETE /management/instances/$INSTANCE operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_delete_management_instance_cancel ( + struct TALER_MERCHANT_DeleteManagementInstanceHandle *handle); + + +#endif /* _TALER_MERCHANT__DELETE_MANAGEMENT_INSTANCES_INSTANCE_NEW_H */ diff --git a/src/include/taler/taler-merchant/delete-private-accounts-H_WIRE-new.h b/src/include/taler/taler-merchant/delete-private-accounts-H_WIRE-new.h @@ -0,0 +1,110 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/delete-private-accounts-H_WIRE-new.h + * @brief C interface for DELETE /private/accounts/$H_WIRE + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__DELETE_PRIVATE_ACCOUNTS_H_WIRE_NEW_H +#define _TALER_MERCHANT__DELETE_PRIVATE_ACCOUNTS_H_WIRE_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a DELETE /private/accounts/$H_WIRE operation. + */ +struct TALER_MERCHANT_DeletePrivateAccountHandle; + + +/** + * Set up DELETE /private/accounts/$H_WIRE operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx curl context + * @param url merchant backend base URL + * @param h_wire hash of the wire details identifying the account to delete + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_DeletePrivateAccountHandle * +TALER_MERCHANT_delete_private_account_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const struct TALER_MerchantWireHashP *h_wire); + + +/** + * Response details for a DELETE /private/accounts/$H_WIRE request. + */ +struct TALER_MERCHANT_DeletePrivateAccountResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_DELETE_PRIVATE_ACCOUNT_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_DeletePrivateAccountCallback. + */ +#define TALER_MERCHANT_DELETE_PRIVATE_ACCOUNT_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_DELETE_PRIVATE_ACCOUNT_RESULT_CLOSURE */ + +/** + * Type of the function that receives the result of a + * DELETE /private/accounts/$H_WIRE request. + * + * @param cls closure + * @param result result returned by the HTTP server + */ +typedef void +(*TALER_MERCHANT_DeletePrivateAccountCallback)( + TALER_MERCHANT_DELETE_PRIVATE_ACCOUNT_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_DeletePrivateAccountResponse *result); + + +/** + * Start DELETE /private/accounts/$H_WIRE operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_delete_private_account_start ( + struct TALER_MERCHANT_DeletePrivateAccountHandle *handle, + TALER_MERCHANT_DeletePrivateAccountCallback cb, + TALER_MERCHANT_DELETE_PRIVATE_ACCOUNT_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel DELETE /private/accounts/$H_WIRE operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_delete_private_account_cancel ( + struct TALER_MERCHANT_DeletePrivateAccountHandle *handle); + + +#endif /* _TALER_MERCHANT__DELETE_PRIVATE_ACCOUNTS_H_WIRE_NEW_H */ diff --git a/src/include/taler/taler-merchant/delete-private-donau-DONAU_SERIAL-new.h b/src/include/taler/taler-merchant/delete-private-donau-DONAU_SERIAL-new.h @@ -0,0 +1,110 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/delete-private-donau-DONAU_SERIAL-new.h + * @brief C interface for DELETE /private/donau/$DONAU_SERIAL + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__DELETE_PRIVATE_DONAU_DONAU_SERIAL_NEW_H +#define _TALER_MERCHANT__DELETE_PRIVATE_DONAU_DONAU_SERIAL_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a DELETE /private/donau/$DONAU_SERIAL operation. + */ +struct TALER_MERCHANT_DeletePrivateDonauHandle; + + +/** + * Set up DELETE /private/donau/$DONAU_SERIAL operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx curl context + * @param url merchant backend base URL + * @param charity_id charity identifier to delete + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_DeletePrivateDonauHandle * +TALER_MERCHANT_delete_private_donau_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + uint64_t charity_id); + + +/** + * Response details for a DELETE /private/donau/$DONAU_SERIAL request. + */ +struct TALER_MERCHANT_DeletePrivateDonauResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_DELETE_PRIVATE_DONAU_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_DeletePrivateDonauCallback. + */ +#define TALER_MERCHANT_DELETE_PRIVATE_DONAU_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_DELETE_PRIVATE_DONAU_RESULT_CLOSURE */ + +/** + * Type of the function that receives the result of a + * DELETE /private/donau/$DONAU_SERIAL request. + * + * @param cls closure + * @param result result returned by the HTTP server + */ +typedef void +(*TALER_MERCHANT_DeletePrivateDonauCallback)( + TALER_MERCHANT_DELETE_PRIVATE_DONAU_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_DeletePrivateDonauResponse *result); + + +/** + * Start DELETE /private/donau/$DONAU_SERIAL operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_delete_private_donau_start ( + struct TALER_MERCHANT_DeletePrivateDonauHandle *handle, + TALER_MERCHANT_DeletePrivateDonauCallback cb, + TALER_MERCHANT_DELETE_PRIVATE_DONAU_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel DELETE /private/donau/$DONAU_SERIAL operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_delete_private_donau_cancel ( + struct TALER_MERCHANT_DeletePrivateDonauHandle *handle); + + +#endif /* _TALER_MERCHANT__DELETE_PRIVATE_DONAU_DONAU_SERIAL_NEW_H */ diff --git a/src/include/taler/taler-merchant/delete-private-orders-ORDER_ID-new.h b/src/include/taler/taler-merchant/delete-private-orders-ORDER_ID-new.h @@ -0,0 +1,180 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/delete-private-orders-ORDER_ID-new.h + * @brief C interface for DELETE /private/orders/$ORDER_ID + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__DELETE_PRIVATE_ORDERS_ORDER_ID_NEW_H +#define _TALER_MERCHANT__DELETE_PRIVATE_ORDERS_ORDER_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a DELETE /private/orders/$ORDER_ID operation. + */ +struct TALER_MERCHANT_DeletePrivateOrderHandle; + + +/** + * Set up DELETE /private/orders/$ORDER_ID operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx curl context + * @param url merchant backend base URL + * @param order_id identifier of the order to delete + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_DeletePrivateOrderHandle * +TALER_MERCHANT_delete_private_order_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *order_id); + + +/** + * Options for DELETE /private/orders/$ORDER_ID. + */ +enum TALER_MERCHANT_DeletePrivateOrderOption +{ + /** + * Sentinel value, end of options. + */ + TALER_MERCHANT_DELETE_PRIVATE_ORDER_OPTION_END = 0, + + /** + * If set, force deletion even if order has payments. + * Value type: none (presence of option means force=true). + */ + TALER_MERCHANT_DELETE_PRIVATE_ORDER_OPTION_FORCE +}; + + +/** + * Value for a DELETE /private/orders/$ORDER_ID option. + */ +struct TALER_MERCHANT_DeletePrivateOrderOptionValue +{ + /** + * Which option is being set. + */ + enum TALER_MERCHANT_DeletePrivateOrderOption option; +}; + + +/** + * Set options for DELETE /private/orders/$ORDER_ID operation. + * + * @param[in,out] handle the handle to set options for + * @param num_options length of the @a options array + * @param options array of option values (terminated with _END) + */ +void +TALER_MERCHANT_delete_private_order_set_options_ ( + struct TALER_MERCHANT_DeletePrivateOrderHandle *handle, + unsigned int num_options, + const struct TALER_MERCHANT_DeletePrivateOrderOptionValue options[]); + + +/** + * Maximum number of options for set_options macro. + */ +#define TALER_MERCHANT_DELETE_PRIVATE_ORDER_OPTIONS_ARRAY_MAX_SIZE 4 + +/** + * Set options for DELETE /private/orders/$ORDER_ID operation. + * Variadic macro wrapper around + * #TALER_MERCHANT_delete_private_order_set_options_(). + * + * @param handle the handle to set options for + * @param ... option values (automatically terminated with _END) + */ +#define TALER_MERCHANT_delete_private_order_set_options(handle, ...) \ + do { \ + struct TALER_MERCHANT_DeletePrivateOrderOptionValue __opts[] = { \ + __VA_ARGS__, \ + { .option = TALER_MERCHANT_DELETE_PRIVATE_ORDER_OPTION_END } \ + }; \ + TALER_MERCHANT_delete_private_order_set_options_ ( \ + handle, \ + sizeof (__opts) / sizeof (__opts[0]) - 1, \ + __opts); \ + } while (0) + + +/** + * Response details for a DELETE /private/orders/$ORDER_ID request. + */ +struct TALER_MERCHANT_DeletePrivateOrderResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_DELETE_PRIVATE_ORDER_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_DeletePrivateOrderCallback. + */ +#define TALER_MERCHANT_DELETE_PRIVATE_ORDER_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_DELETE_PRIVATE_ORDER_RESULT_CLOSURE */ + +/** + * Type of the function that receives the result of a + * DELETE /private/orders/$ORDER_ID request. + * + * @param cls closure + * @param result result returned by the HTTP server + */ +typedef void +(*TALER_MERCHANT_DeletePrivateOrderCallback)( + TALER_MERCHANT_DELETE_PRIVATE_ORDER_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_DeletePrivateOrderResponse *result); + + +/** + * Start DELETE /private/orders/$ORDER_ID operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_delete_private_order_start ( + struct TALER_MERCHANT_DeletePrivateOrderHandle *handle, + TALER_MERCHANT_DeletePrivateOrderCallback cb, + TALER_MERCHANT_DELETE_PRIVATE_ORDER_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel DELETE /private/orders/$ORDER_ID operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_delete_private_order_cancel ( + struct TALER_MERCHANT_DeletePrivateOrderHandle *handle); + + +#endif /* _TALER_MERCHANT__DELETE_PRIVATE_ORDERS_ORDER_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/delete-private-otp-devices-DEVICE_ID-new.h b/src/include/taler/taler-merchant/delete-private-otp-devices-DEVICE_ID-new.h @@ -0,0 +1,110 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/delete-private-otp-devices-DEVICE_ID-new.h + * @brief C interface for DELETE /private/otp-devices/$DEVICE_ID + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__DELETE_PRIVATE_OTP_DEVICES_DEVICE_ID_NEW_H +#define _TALER_MERCHANT__DELETE_PRIVATE_OTP_DEVICES_DEVICE_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a DELETE /private/otp-devices/$DEVICE_ID operation. + */ +struct TALER_MERCHANT_DeletePrivateOtpDeviceHandle; + + +/** + * Set up DELETE /private/otp-devices/$DEVICE_ID operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx curl context + * @param url merchant backend base URL + * @param otp_device_id identifier of the OTP device to delete + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_DeletePrivateOtpDeviceHandle * +TALER_MERCHANT_delete_private_otp_device_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *otp_device_id); + + +/** + * Response details for a DELETE /private/otp-devices/$DEVICE_ID request. + */ +struct TALER_MERCHANT_DeletePrivateOtpDeviceResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_DELETE_PRIVATE_OTP_DEVICE_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_DeletePrivateOtpDeviceCallback. + */ +#define TALER_MERCHANT_DELETE_PRIVATE_OTP_DEVICE_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_DELETE_PRIVATE_OTP_DEVICE_RESULT_CLOSURE */ + +/** + * Type of the function that receives the result of a + * DELETE /private/otp-devices/$DEVICE_ID request. + * + * @param cls closure + * @param result result returned by the HTTP server + */ +typedef void +(*TALER_MERCHANT_DeletePrivateOtpDeviceCallback)( + TALER_MERCHANT_DELETE_PRIVATE_OTP_DEVICE_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_DeletePrivateOtpDeviceResponse *result); + + +/** + * Start DELETE /private/otp-devices/$DEVICE_ID operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_delete_private_otp_device_start ( + struct TALER_MERCHANT_DeletePrivateOtpDeviceHandle *handle, + TALER_MERCHANT_DeletePrivateOtpDeviceCallback cb, + TALER_MERCHANT_DELETE_PRIVATE_OTP_DEVICE_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel DELETE /private/otp-devices/$DEVICE_ID operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_delete_private_otp_device_cancel ( + struct TALER_MERCHANT_DeletePrivateOtpDeviceHandle *handle); + + +#endif /* _TALER_MERCHANT__DELETE_PRIVATE_OTP_DEVICES_DEVICE_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/delete-private-products-PRODUCT_ID-new.h b/src/include/taler/taler-merchant/delete-private-products-PRODUCT_ID-new.h @@ -0,0 +1,110 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/delete-private-products-PRODUCT_ID-new.h + * @brief C interface for DELETE /private/products/$PRODUCT_ID + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__DELETE_PRIVATE_PRODUCTS_PRODUCT_ID_NEW_H +#define _TALER_MERCHANT__DELETE_PRIVATE_PRODUCTS_PRODUCT_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a DELETE /private/products/$PRODUCT_ID operation. + */ +struct TALER_MERCHANT_DeletePrivateProductHandle; + + +/** + * Set up DELETE /private/products/$PRODUCT_ID operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx curl context + * @param url merchant backend base URL + * @param product_id identifier of the product to delete + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_DeletePrivateProductHandle * +TALER_MERCHANT_delete_private_product_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *product_id); + + +/** + * Response details for a DELETE /private/products/$PRODUCT_ID request. + */ +struct TALER_MERCHANT_DeletePrivateProductResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_DELETE_PRIVATE_PRODUCT_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_DeletePrivateProductCallback. + */ +#define TALER_MERCHANT_DELETE_PRIVATE_PRODUCT_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_DELETE_PRIVATE_PRODUCT_RESULT_CLOSURE */ + +/** + * Type of the function that receives the result of a + * DELETE /private/products/$PRODUCT_ID request. + * + * @param cls closure + * @param result result returned by the HTTP server + */ +typedef void +(*TALER_MERCHANT_DeletePrivateProductCallback)( + TALER_MERCHANT_DELETE_PRIVATE_PRODUCT_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_DeletePrivateProductResponse *result); + + +/** + * Start DELETE /private/products/$PRODUCT_ID operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_delete_private_product_start ( + struct TALER_MERCHANT_DeletePrivateProductHandle *handle, + TALER_MERCHANT_DeletePrivateProductCallback cb, + TALER_MERCHANT_DELETE_PRIVATE_PRODUCT_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel DELETE /private/products/$PRODUCT_ID operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_delete_private_product_cancel ( + struct TALER_MERCHANT_DeletePrivateProductHandle *handle); + + +#endif /* _TALER_MERCHANT__DELETE_PRIVATE_PRODUCTS_PRODUCT_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/delete-private-templates-TEMPLATE_ID-new.h b/src/include/taler/taler-merchant/delete-private-templates-TEMPLATE_ID-new.h @@ -0,0 +1,110 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/delete-private-templates-TEMPLATE_ID-new.h + * @brief C interface for DELETE /private/templates/$TEMPLATE_ID + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__DELETE_PRIVATE_TEMPLATES_TEMPLATE_ID_NEW_H +#define _TALER_MERCHANT__DELETE_PRIVATE_TEMPLATES_TEMPLATE_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a DELETE /private/templates/$TEMPLATE_ID operation. + */ +struct TALER_MERCHANT_DeletePrivateTemplateHandle; + + +/** + * Set up DELETE /private/templates/$TEMPLATE_ID operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx curl context + * @param url merchant backend base URL + * @param template_id identifier of the template to delete + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_DeletePrivateTemplateHandle * +TALER_MERCHANT_delete_private_template_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *template_id); + + +/** + * Response details for a DELETE /private/templates/$TEMPLATE_ID request. + */ +struct TALER_MERCHANT_DeletePrivateTemplateResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_DELETE_PRIVATE_TEMPLATE_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_DeletePrivateTemplateCallback. + */ +#define TALER_MERCHANT_DELETE_PRIVATE_TEMPLATE_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_DELETE_PRIVATE_TEMPLATE_RESULT_CLOSURE */ + +/** + * Type of the function that receives the result of a + * DELETE /private/templates/$TEMPLATE_ID request. + * + * @param cls closure + * @param result result returned by the HTTP server + */ +typedef void +(*TALER_MERCHANT_DeletePrivateTemplateCallback)( + TALER_MERCHANT_DELETE_PRIVATE_TEMPLATE_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_DeletePrivateTemplateResponse *result); + + +/** + * Start DELETE /private/templates/$TEMPLATE_ID operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_delete_private_template_start ( + struct TALER_MERCHANT_DeletePrivateTemplateHandle *handle, + TALER_MERCHANT_DeletePrivateTemplateCallback cb, + TALER_MERCHANT_DELETE_PRIVATE_TEMPLATE_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel DELETE /private/templates/$TEMPLATE_ID operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_delete_private_template_cancel ( + struct TALER_MERCHANT_DeletePrivateTemplateHandle *handle); + + +#endif /* _TALER_MERCHANT__DELETE_PRIVATE_TEMPLATES_TEMPLATE_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/delete-private-tokens-SERIAL-new.h b/src/include/taler/taler-merchant/delete-private-tokens-SERIAL-new.h @@ -0,0 +1,110 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/delete-private-tokens-SERIAL-new.h + * @brief C interface for DELETE /private/tokens/$SERIAL + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__DELETE_PRIVATE_TOKENS_SERIAL_NEW_H +#define _TALER_MERCHANT__DELETE_PRIVATE_TOKENS_SERIAL_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a DELETE /private/tokens/$SERIAL operation. + */ +struct TALER_MERCHANT_DeletePrivateTokenHandle; + + +/** + * Set up DELETE /private/tokens/$SERIAL operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx curl context + * @param url merchant backend base URL + * @param instance_id identifier of the instance + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_DeletePrivateTokenHandle * +TALER_MERCHANT_delete_private_token_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *instance_id); + + +/** + * Response details for a DELETE /private/tokens/$SERIAL request. + */ +struct TALER_MERCHANT_DeletePrivateTokenResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_DELETE_PRIVATE_TOKEN_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_DeletePrivateTokenCallback. + */ +#define TALER_MERCHANT_DELETE_PRIVATE_TOKEN_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_DELETE_PRIVATE_TOKEN_RESULT_CLOSURE */ + +/** + * Type of the function that receives the result of a + * DELETE /private/tokens/$SERIAL request. + * + * @param cls closure + * @param result result returned by the HTTP server + */ +typedef void +(*TALER_MERCHANT_DeletePrivateTokenCallback)( + TALER_MERCHANT_DELETE_PRIVATE_TOKEN_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_DeletePrivateTokenResponse *result); + + +/** + * Start DELETE /private/tokens/$SERIAL operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_delete_private_token_start ( + struct TALER_MERCHANT_DeletePrivateTokenHandle *handle, + TALER_MERCHANT_DeletePrivateTokenCallback cb, + TALER_MERCHANT_DELETE_PRIVATE_TOKEN_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel DELETE /private/tokens/$SERIAL operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_delete_private_token_cancel ( + struct TALER_MERCHANT_DeletePrivateTokenHandle *handle); + + +#endif /* _TALER_MERCHANT__DELETE_PRIVATE_TOKENS_SERIAL_NEW_H */ diff --git a/src/include/taler/taler-merchant/delete-private-transfers-TID-new.h b/src/include/taler/taler-merchant/delete-private-transfers-TID-new.h @@ -0,0 +1,110 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/delete-private-transfers-TID-new.h + * @brief C interface for DELETE /private/transfers/$TID + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__DELETE_PRIVATE_TRANSFERS_TID_NEW_H +#define _TALER_MERCHANT__DELETE_PRIVATE_TRANSFERS_TID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a DELETE /private/transfers/$TID operation. + */ +struct TALER_MERCHANT_DeletePrivateTransferHandle; + + +/** + * Set up DELETE /private/transfers/$TID operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx curl context + * @param url merchant backend base URL + * @param wire_transfer_serial serial number of the wire transfer to delete + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_DeletePrivateTransferHandle * +TALER_MERCHANT_delete_private_transfer_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + uint64_t wire_transfer_serial); + + +/** + * Response details for a DELETE /private/transfers/$TID request. + */ +struct TALER_MERCHANT_DeletePrivateTransferResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_DELETE_PRIVATE_TRANSFER_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_DeletePrivateTransferCallback. + */ +#define TALER_MERCHANT_DELETE_PRIVATE_TRANSFER_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_DELETE_PRIVATE_TRANSFER_RESULT_CLOSURE */ + +/** + * Type of the function that receives the result of a + * DELETE /private/transfers/$TID request. + * + * @param cls closure + * @param result result returned by the HTTP server + */ +typedef void +(*TALER_MERCHANT_DeletePrivateTransferCallback)( + TALER_MERCHANT_DELETE_PRIVATE_TRANSFER_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_DeletePrivateTransferResponse *result); + + +/** + * Start DELETE /private/transfers/$TID operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_delete_private_transfer_start ( + struct TALER_MERCHANT_DeletePrivateTransferHandle *handle, + TALER_MERCHANT_DeletePrivateTransferCallback cb, + TALER_MERCHANT_DELETE_PRIVATE_TRANSFER_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel DELETE /private/transfers/$TID operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_delete_private_transfer_cancel ( + struct TALER_MERCHANT_DeletePrivateTransferHandle *handle); + + +#endif /* _TALER_MERCHANT__DELETE_PRIVATE_TRANSFERS_TID_NEW_H */ diff --git a/src/include/taler/taler-merchant/delete-private-units-UNIT-new.h b/src/include/taler/taler-merchant/delete-private-units-UNIT-new.h @@ -0,0 +1,110 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/delete-private-units-UNIT-new.h + * @brief C interface for DELETE /private/units/$UNIT + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__DELETE_PRIVATE_UNITS_UNIT_NEW_H +#define _TALER_MERCHANT__DELETE_PRIVATE_UNITS_UNIT_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a DELETE /private/units/$UNIT operation. + */ +struct TALER_MERCHANT_DeletePrivateUnitHandle; + + +/** + * Set up DELETE /private/units/$UNIT operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx curl context + * @param url merchant backend base URL + * @param unit_id identifier of the unit to delete + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_DeletePrivateUnitHandle * +TALER_MERCHANT_delete_private_unit_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *unit_id); + + +/** + * Response details for a DELETE /private/units/$UNIT request. + */ +struct TALER_MERCHANT_DeletePrivateUnitResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_DELETE_PRIVATE_UNIT_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_DeletePrivateUnitCallback. + */ +#define TALER_MERCHANT_DELETE_PRIVATE_UNIT_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_DELETE_PRIVATE_UNIT_RESULT_CLOSURE */ + +/** + * Type of the function that receives the result of a + * DELETE /private/units/$UNIT request. + * + * @param cls closure + * @param result result returned by the HTTP server + */ +typedef void +(*TALER_MERCHANT_DeletePrivateUnitCallback)( + TALER_MERCHANT_DELETE_PRIVATE_UNIT_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_DeletePrivateUnitResponse *result); + + +/** + * Start DELETE /private/units/$UNIT operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_delete_private_unit_start ( + struct TALER_MERCHANT_DeletePrivateUnitHandle *handle, + TALER_MERCHANT_DeletePrivateUnitCallback cb, + TALER_MERCHANT_DELETE_PRIVATE_UNIT_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel DELETE /private/units/$UNIT operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_delete_private_unit_cancel ( + struct TALER_MERCHANT_DeletePrivateUnitHandle *handle); + + +#endif /* _TALER_MERCHANT__DELETE_PRIVATE_UNITS_UNIT_NEW_H */ diff --git a/src/include/taler/taler-merchant/delete-private-webhooks-WEBHOOK_ID-new.h b/src/include/taler/taler-merchant/delete-private-webhooks-WEBHOOK_ID-new.h @@ -0,0 +1,110 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/delete-private-webhooks-WEBHOOK_ID-new.h + * @brief C interface for DELETE /private/webhooks/$WEBHOOK_ID + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__DELETE_PRIVATE_WEBHOOKS_WEBHOOK_ID_NEW_H +#define _TALER_MERCHANT__DELETE_PRIVATE_WEBHOOKS_WEBHOOK_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a DELETE /private/webhooks/$WEBHOOK_ID operation. + */ +struct TALER_MERCHANT_DeletePrivateWebhookHandle; + + +/** + * Set up DELETE /private/webhooks/$WEBHOOK_ID operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx curl context + * @param url merchant backend base URL + * @param webhook_id identifier of the webhook to delete + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_DeletePrivateWebhookHandle * +TALER_MERCHANT_delete_private_webhook_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *webhook_id); + + +/** + * Response details for a DELETE /private/webhooks/$WEBHOOK_ID request. + */ +struct TALER_MERCHANT_DeletePrivateWebhookResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_DELETE_PRIVATE_WEBHOOK_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_DeletePrivateWebhookCallback. + */ +#define TALER_MERCHANT_DELETE_PRIVATE_WEBHOOK_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_DELETE_PRIVATE_WEBHOOK_RESULT_CLOSURE */ + +/** + * Type of the function that receives the result of a + * DELETE /private/webhooks/$WEBHOOK_ID request. + * + * @param cls closure + * @param result result returned by the HTTP server + */ +typedef void +(*TALER_MERCHANT_DeletePrivateWebhookCallback)( + TALER_MERCHANT_DELETE_PRIVATE_WEBHOOK_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_DeletePrivateWebhookResponse *result); + + +/** + * Start DELETE /private/webhooks/$WEBHOOK_ID operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_delete_private_webhook_start ( + struct TALER_MERCHANT_DeletePrivateWebhookHandle *handle, + TALER_MERCHANT_DeletePrivateWebhookCallback cb, + TALER_MERCHANT_DELETE_PRIVATE_WEBHOOK_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel DELETE /private/webhooks/$WEBHOOK_ID operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_delete_private_webhook_cancel ( + struct TALER_MERCHANT_DeletePrivateWebhookHandle *handle); + + +#endif /* _TALER_MERCHANT__DELETE_PRIVATE_WEBHOOKS_WEBHOOK_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-config-new.h b/src/include/taler/taler-merchant/get-config-new.h @@ -0,0 +1,234 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-config-new.h + * @brief C interface for the GET /config endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_CONFIG_NEW_H +#define _TALER_MERCHANT__GET_CONFIG_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Version compatibility status for the merchant backend. + */ +enum TALER_MERCHANT_GetConfigVersionCompatibility +{ + /** + * The client and server are at the same version. + */ + TALER_MERCHANT_GET_CONFIG_VC_MATCH = 0, + + /** + * The server is running a newer API version. + */ + TALER_MERCHANT_GET_CONFIG_VC_NEWER = 1, + + /** + * The server is running an older API version. + */ + TALER_MERCHANT_GET_CONFIG_VC_OLDER = 2, + + /** + * The versions are incompatible. + */ + TALER_MERCHANT_GET_CONFIG_VC_INCOMPATIBLE = 4, + + /** + * A protocol error occurred. + */ + TALER_MERCHANT_GET_CONFIG_VC_PROTOCOL_ERROR = 8 +}; + + +/** + * Information about an exchange as returned in the config response. + */ +struct TALER_MERCHANT_GetConfigExchangeInfo +{ + + /** + * Base URL of the exchange. + */ + const char *base_url; + + /** + * Currency served by this exchange. + */ + const char *currency; + + /** + * Master public key of the exchange. + */ + struct TALER_MasterPublicKeyP master_pub; + +}; + + +/** + * Handle for a GET /config request. + */ +struct TALER_MERCHANT_GetConfigHandle; + + +/** + * Response details for a GET /config request. + */ +struct TALER_MERCHANT_GetConfigResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * API version string. + */ + const char *version; + + /** + * Currency used by this merchant backend. + */ + const char *currency; + + /** + * Compatibility status with the client library. + */ + enum TALER_MERCHANT_GetConfigVersionCompatibility compat; + + /** + * Number of exchanges in @a exchanges. + */ + unsigned int num_exchanges; + + /** + * Array of exchange configurations. + */ + const struct TALER_MERCHANT_GetConfigExchangeInfo *exchanges; + + /** + * Number of currency specifications in @a cspecs. + */ + unsigned int num_cspecs; + + /** + * Array of currency specifications. + */ + const struct TALER_CurrencySpecification *cspecs; + + /** + * Currency information returned by the backend. + */ + struct + { + /** + * Currency string. + */ + const char *currency; + + /** + * Version string. + */ + const char *version; + } ci; + + } ok; + + } details; + +}; + + +/** + * Set up GET /config operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @return handle to operation + */ +struct TALER_MERCHANT_GetConfigHandle * +TALER_MERCHANT_get_config_create ( + struct GNUNET_CURL_Context *ctx, + const char *url); + + +#ifndef TALER_MERCHANT_GET_CONFIG_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetConfigCallback. + */ +#define TALER_MERCHANT_GET_CONFIG_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_CONFIG_RESULT_CLOSURE */ + +/** + * Callback for a GET /config request. + * + * @param cls closure + * @param cr response details + */ +typedef void +(*TALER_MERCHANT_GetConfigCallback)( + TALER_MERCHANT_GET_CONFIG_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetConfigResponse *cr); + + +/** + * Start GET /config operation. + * + * @param[in,out] gch operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_config_start ( + struct TALER_MERCHANT_GetConfigHandle *gch, + TALER_MERCHANT_GetConfigCallback cb, + TALER_MERCHANT_GET_CONFIG_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /config operation. This function must not be called + * by clients after the TALER_MERCHANT_GetConfigCallback has been + * invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gch operation to cancel + */ +void +TALER_MERCHANT_get_config_cancel ( + struct TALER_MERCHANT_GetConfigHandle *gch); + + +#endif /* _TALER_MERCHANT__GET_CONFIG_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-management-instances-INSTANCE-new.h b/src/include/taler/taler-merchant/get-management-instances-INSTANCE-new.h @@ -0,0 +1,189 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-management-instances-INSTANCE-new.h + * @brief C interface for GET /management/instances/$INSTANCE of the merchant backend + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_INSTANCE_NEW_H +#define _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_INSTANCE_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /management/instances/$INSTANCE request. + */ +struct TALER_MERCHANT_GetManagementInstanceHandle; + + +/** + * Detailed information about a merchant instance. + */ +struct TALER_MERCHANT_GetManagementInstanceDetails +{ + + /** + * Human-readable name of the instance. + */ + const char *name; + + /** + * Public key of the merchant instance. + */ + struct TALER_MerchantPublicKeyP merchant_pub; + + /** + * Whether to use the STEFAN curve for fee calculations. + */ + bool use_stefan; + + /** + * Default wire transfer delay. + */ + struct GNUNET_TIME_Relative default_wire_transfer_delay; + + /** + * Default payment deadline. + */ + struct GNUNET_TIME_Relative default_pay_delay; + + /** + * Default refund deadline. + */ + struct GNUNET_TIME_Relative default_refund_delay; + + /** + * Default wire transfer rounding interval. + */ + enum GNUNET_TIME_RounderInterval default_wire_transfer_rounding_interval; + + /** + * Merchant address (JSON). + */ + const json_t *address; + + /** + * Merchant jurisdiction (JSON). + */ + const json_t *jurisdiction; + +}; + + +/** + * Response details for a GET /management/instances/$INSTANCE request. + */ +struct TALER_MERCHANT_GetManagementInstanceResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Detailed information about the instance. + */ + struct TALER_MERCHANT_GetManagementInstanceDetails details; + + } ok; + + } details; + +}; + + +/** + * Set up GET /management/instances/$INSTANCE operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param instance_id identifier of the instance to retrieve + * @return handle to operation + */ +struct TALER_MERCHANT_GetManagementInstanceHandle * +TALER_MERCHANT_get_management_instance_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *instance_id); + + +#ifndef TALER_MERCHANT_GET_MANAGEMENT_INSTANCE_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetManagementInstanceCallback. + */ +#define TALER_MERCHANT_GET_MANAGEMENT_INSTANCE_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_MANAGEMENT_INSTANCE_RESULT_CLOSURE */ + +/** + * Callback for a GET /management/instances/$INSTANCE request. + * + * @param cls closure + * @param igr response details + */ +typedef void +(*TALER_MERCHANT_GetManagementInstanceCallback)( + TALER_MERCHANT_GET_MANAGEMENT_INSTANCE_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetManagementInstanceResponse *igr); + + +/** + * Start GET /management/instances/$INSTANCE operation. + * + * @param[in,out] gmi operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_management_instance_start ( + struct TALER_MERCHANT_GetManagementInstanceHandle *gmi, + TALER_MERCHANT_GetManagementInstanceCallback cb, + TALER_MERCHANT_GET_MANAGEMENT_INSTANCE_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /management/instances/$INSTANCE operation. This function + * must not be called by clients after the + * TALER_MERCHANT_GetManagementInstanceCallback has been invoked + * (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gmi operation to cancel + */ +void +TALER_MERCHANT_get_management_instance_cancel ( + struct TALER_MERCHANT_GetManagementInstanceHandle *gmi); + + +#endif /* _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_INSTANCE_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-management-instances-new.h b/src/include/taler/taler-merchant/get-management-instances-new.h @@ -0,0 +1,166 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-management-instances-new.h + * @brief C interface for the GET /management/instances endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_NEW_H +#define _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /management/instances request. + */ +struct TALER_MERCHANT_GetManagementInstancesHandle; + + +/** + * Information about one merchant instance. + */ +struct TALER_MERCHANT_GetManagementInstancesInstanceInfo +{ + + /** + * Instance identifier string. + */ + const char *id; + + /** + * Human-readable name of the instance. + */ + const char *name; + + /** + * Public key of the instance. + */ + struct TALER_MerchantPublicKeyP merchant_pub; + + /** + * JSON array of supported payment targets. + */ + const json_t *payment_targets; + +}; + + +/** + * Response details for a GET /management/instances request. + */ +struct TALER_MERCHANT_GetManagementInstancesResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of instances in @a iis. + */ + unsigned int iis_length; + + /** + * Array of instance information. + */ + const struct TALER_MERCHANT_GetManagementInstancesInstanceInfo *iis; + + } ok; + + } details; + +}; + + +/** + * Set up GET /management/instances operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @return handle to operation + */ +struct TALER_MERCHANT_GetManagementInstancesHandle * +TALER_MERCHANT_get_management_instances_create ( + struct GNUNET_CURL_Context *ctx, + const char *url); + + +#ifndef TALER_MERCHANT_GET_MANAGEMENT_INSTANCES_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetManagementInstancesCallback. + */ +#define TALER_MERCHANT_GET_MANAGEMENT_INSTANCES_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_MANAGEMENT_INSTANCES_RESULT_CLOSURE */ + +/** + * Callback for a GET /management/instances request. + * + * @param cls closure + * @param igr response details + */ +typedef void +(*TALER_MERCHANT_GetManagementInstancesCallback)( + TALER_MERCHANT_GET_MANAGEMENT_INSTANCES_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetManagementInstancesResponse *igr); + + +/** + * Start GET /management/instances operation. + * + * @param[in,out] gimh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_management_instances_start ( + struct TALER_MERCHANT_GetManagementInstancesHandle *gimh, + TALER_MERCHANT_GetManagementInstancesCallback cb, + TALER_MERCHANT_GET_MANAGEMENT_INSTANCES_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /management/instances operation. This function must not be + * called by clients after the TALER_MERCHANT_GetManagementInstancesCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gimh operation to cancel + */ +void +TALER_MERCHANT_get_management_instances_cancel ( + struct TALER_MERCHANT_GetManagementInstancesHandle *gimh); + + +#endif /* _TALER_MERCHANT__GET_MANAGEMENT_INSTANCES_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-orders-ORDER_ID-new.h b/src/include/taler/taler-merchant/get-orders-ORDER_ID-new.h @@ -0,0 +1,356 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-orders-ORDER_ID-new.h + * @brief C interface for the GET /orders/$ORDER_ID endpoint (wallet-facing) + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_ORDERS_ORDER_ID_NEW_H +#define _TALER_MERCHANT__GET_ORDERS_ORDER_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options we can set for the GET /orders/$ORDER_ID request. + */ +enum TALER_MERCHANT_GetOrdersOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_GET_ORDERS_OPTION_END = 0, + + /** + * Long polling timeout. + */ + TALER_MERCHANT_GET_ORDERS_OPTION_TIMEOUT, + + /** + * Session ID for repurchase detection. + */ + TALER_MERCHANT_GET_ORDERS_OPTION_SESSION_ID, + + /** + * Minimum refund amount to wait for. + */ + TALER_MERCHANT_GET_ORDERS_OPTION_MIN_REFUND, + + /** + * If true, wait until refund is confirmed obtained. + */ + TALER_MERCHANT_GET_ORDERS_OPTION_AWAIT_REFUND_OBTAINED + +}; + + +/** + * Value for an option for the GET /orders/$ORDER_ID request. + */ +struct TALER_MERCHANT_GetOrdersOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_GetOrdersOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_ORDERS_OPTION_TIMEOUT. + */ + struct GNUNET_TIME_Relative timeout; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_ORDERS_OPTION_SESSION_ID. + */ + const char *session_id; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_ORDERS_OPTION_MIN_REFUND. + */ + struct TALER_Amount min_refund; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_ORDERS_OPTION_AWAIT_REFUND_OBTAINED. + */ + bool await_refund_obtained; + + } details; + +}; + + +/** + * Handle for a GET /orders/$ORDER_ID request (wallet-facing). + */ +struct TALER_MERCHANT_GetOrdersHandle; + + +/** + * Set up GET /orders/$ORDER_ID operation (wallet-facing). + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param order_id identifier of the order to check + * @param h_contract hash of the contract terms (for authentication) + * @return handle to operation + */ +struct TALER_MERCHANT_GetOrdersHandle * +TALER_MERCHANT_get_orders_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *order_id, + const struct TALER_PrivateContractHashP *h_contract); + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_GetOrdersOptionValue + */ +#define TALER_MERCHANT_get_orders_option_end_() \ + (const struct TALER_MERCHANT_GetOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_ORDERS_OPTION_END \ + } + +/** + * Set long polling timeout. + * + * @param t timeout to use + * @return representation of the option as a struct TALER_MERCHANT_GetOrdersOptionValue + */ +#define TALER_MERCHANT_get_orders_option_timeout(t) \ + (const struct TALER_MERCHANT_GetOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_ORDERS_OPTION_TIMEOUT, \ + .details.timeout = (t) \ + } + +/** + * Set session ID for repurchase detection. + * + * @param s session ID to use + * @return representation of the option as a struct TALER_MERCHANT_GetOrdersOptionValue + */ +#define TALER_MERCHANT_get_orders_option_session_id(s) \ + (const struct TALER_MERCHANT_GetOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_ORDERS_OPTION_SESSION_ID, \ + .details.session_id = (s) \ + } + +/** + * Set minimum refund amount to wait for. + * + * @param a minimum refund amount + * @return representation of the option as a struct TALER_MERCHANT_GetOrdersOptionValue + */ +#define TALER_MERCHANT_get_orders_option_min_refund(a) \ + (const struct TALER_MERCHANT_GetOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_ORDERS_OPTION_MIN_REFUND, \ + .details.min_refund = (a) \ + } + +/** + * Set await refund obtained flag. + * + * @param b true to wait until refund is confirmed obtained + * @return representation of the option as a struct TALER_MERCHANT_GetOrdersOptionValue + */ +#define TALER_MERCHANT_get_orders_option_await_refund_obtained(b) \ + (const struct TALER_MERCHANT_GetOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_ORDERS_OPTION_AWAIT_REFUND_OBTAINED, \ + .details.await_refund_obtained = (b) \ + } + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * @param oph the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_get_orders_set_options_ ( + struct TALER_MERCHANT_GetOrdersHandle *oph, + unsigned int num_options, + const struct TALER_MERCHANT_GetOrdersOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * It should be used with helpers that create required options, for example: + * + * TALER_MERCHANT_get_orders_set_options ( + * oph, + * TALER_MERCHANT_get_orders_option_timeout ( + * GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)), + * TALER_MERCHANT_get_orders_option_session_id ("mysession")); + * + * @param oph the request to set the options for + * @param ... the list of the options, each option must be created + * by helpers TALER_MERCHANT_get_orders_option_NAME(VALUE) + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_get_orders_set_options(oph,...) \ + TALER_MERCHANT_get_orders_set_options_ ( \ + oph, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_GetOrdersOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_get_orders_option_end_ () } \ + )) + + +/** + * Response details for a GET /orders/$ORDER_ID request (wallet-facing). + */ +struct TALER_MERCHANT_GetOrdersResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK (order is paid, refund info available). + */ + struct + { + + /** + * True if a refund has been granted. + */ + bool refunded; + + /** + * True if a refund is still pending. + */ + bool refund_pending; + + /** + * Total amount refunded. + */ + struct TALER_Amount refund_amount; + + } ok; + + /** + * Details on #MHD_HTTP_PAYMENT_REQUIRED (order not yet paid). + */ + struct + { + + /** + * Taler pay URI for this order. + */ + const char *taler_pay_uri; + + /** + * Order ID of a previously paid order that covers this one, + * or NULL if none. + */ + const char *already_paid_order_id; + + } payment_required; + + } details; + +}; + + +#ifndef TALER_MERCHANT_GET_ORDERS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetOrdersCallback. + */ +#define TALER_MERCHANT_GET_ORDERS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_ORDERS_RESULT_CLOSURE */ + +/** + * Callback for a GET /orders/$ORDER_ID request (wallet-facing). + * + * @param cls closure + * @param owgr response details + */ +typedef void +(*TALER_MERCHANT_GetOrdersCallback)( + TALER_MERCHANT_GET_ORDERS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetOrdersResponse *owgr); + + +/** + * Start GET /orders/$ORDER_ID operation (wallet-facing). + * + * @param[in,out] oph operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_orders_start ( + struct TALER_MERCHANT_GetOrdersHandle *oph, + TALER_MERCHANT_GetOrdersCallback cb, + TALER_MERCHANT_GET_ORDERS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /orders/$ORDER_ID operation (wallet-facing). This function + * must not be called by clients after the TALER_MERCHANT_GetOrdersCallback + * has been invoked (as in those cases it'll be called internally by + * the implementation already). + * + * @param[in] oph operation to cancel + */ +void +TALER_MERCHANT_get_orders_cancel ( + struct TALER_MERCHANT_GetOrdersHandle *oph); + + +#endif /* _TALER_MERCHANT__GET_ORDERS_ORDER_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-accounts-H_WIRE-new.h b/src/include/taler/taler-merchant/get-private-accounts-H_WIRE-new.h @@ -0,0 +1,171 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-accounts-H_WIRE-new.h + * @brief C interface for GET /private/accounts/$H_WIRE of the merchant backend + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_ACCOUNTS_H_WIRE_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_ACCOUNTS_H_WIRE_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/accounts/$H_WIRE request. + */ +struct TALER_MERCHANT_GetPrivateAccountHandle; + + +/** + * Account details for a merchant wire account. + */ +struct TALER_MERCHANT_GetPrivateAccountDetails +{ + + /** + * Hash of the wire details. + */ + struct TALER_MerchantWireHashP h_wire; + + /** + * Salt used in the wire hash computation. + */ + struct TALER_WireSaltP salt; + + /** + * Full payto URI of the account. + */ + struct TALER_FullPayto payto_uri; + + /** + * URL of the credit facade, or NULL if none. + */ + const char *credit_facade_url; + + /** + * True if the account is currently active. + */ + bool active; + +}; + + +/** + * Response details for a GET /private/accounts/$H_WIRE request. + */ +struct TALER_MERCHANT_GetPrivateAccountResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Detailed account information. + */ + struct TALER_MERCHANT_GetPrivateAccountDetails ad; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/accounts/$H_WIRE operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param instance_id identifier of the merchant instance + * @param h_wire hash of the wire details identifying the account + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateAccountHandle * +TALER_MERCHANT_get_private_account_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *instance_id, + const struct TALER_MerchantWireHashP *h_wire); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_ACCOUNT_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateAccountCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_ACCOUNT_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_ACCOUNT_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/accounts/$H_WIRE request. + * + * @param cls closure + * @param agr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateAccountCallback)( + TALER_MERCHANT_GET_PRIVATE_ACCOUNT_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateAccountResponse *agr); + + +/** + * Start GET /private/accounts/$H_WIRE operation. + * + * @param[in,out] gpa operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_account_start ( + struct TALER_MERCHANT_GetPrivateAccountHandle *gpa, + TALER_MERCHANT_GetPrivateAccountCallback cb, + TALER_MERCHANT_GET_PRIVATE_ACCOUNT_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/accounts/$H_WIRE operation. This function + * must not be called by clients after the + * TALER_MERCHANT_GetPrivateAccountCallback has been invoked + * (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpa operation to cancel + */ +void +TALER_MERCHANT_get_private_account_cancel ( + struct TALER_MERCHANT_GetPrivateAccountHandle *gpa); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_ACCOUNTS_H_WIRE_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-accounts-new.h b/src/include/taler/taler-merchant/get-private-accounts-new.h @@ -0,0 +1,156 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-accounts-new.h + * @brief C interface for the GET /private/accounts endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_ACCOUNTS_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_ACCOUNTS_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/accounts request. + */ +struct TALER_MERCHANT_GetPrivateAccountsHandle; + + +/** + * Account details for a merchant wire account. + */ +struct TALER_MERCHANT_GetPrivateAccountsAccountEntry +{ + + /** + * Hash of the wire details. + */ + struct TALER_MerchantWireHashP h_wire; + + /** + * Full payto URI of the account. + */ + struct TALER_FullPayto payto_uri; + +}; + + +/** + * Response details for a GET /private/accounts request. + */ +struct TALER_MERCHANT_GetPrivateAccountsResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of accounts in @a accounts. + */ + unsigned int accounts_length; + + /** + * Array of account entries. + */ + const struct TALER_MERCHANT_GetPrivateAccountsAccountEntry *accounts; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/accounts operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateAccountsHandle * +TALER_MERCHANT_get_private_accounts_create ( + struct GNUNET_CURL_Context *ctx, + const char *url); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_ACCOUNTS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateAccountsCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_ACCOUNTS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_ACCOUNTS_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/accounts request. + * + * @param cls closure + * @param agr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateAccountsCallback)( + TALER_MERCHANT_GET_PRIVATE_ACCOUNTS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateAccountsResponse *agr); + + +/** + * Start GET /private/accounts operation. + * + * @param[in,out] gpah operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_accounts_start ( + struct TALER_MERCHANT_GetPrivateAccountsHandle *gpah, + TALER_MERCHANT_GetPrivateAccountsCallback cb, + TALER_MERCHANT_GET_PRIVATE_ACCOUNTS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/accounts operation. This function must not be + * called by clients after the TALER_MERCHANT_GetPrivateAccountsCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpah operation to cancel + */ +void +TALER_MERCHANT_get_private_accounts_cancel ( + struct TALER_MERCHANT_GetPrivateAccountsHandle *gpah); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_ACCOUNTS_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-donau-new.h b/src/include/taler/taler-merchant/get-private-donau-new.h @@ -0,0 +1,190 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-donau-new.h + * @brief C interface for the GET /private/donau endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_DONAU_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_DONAU_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/donau request. + */ +struct TALER_MERCHANT_GetPrivateDonauHandle; + + +/** + * Individual Donau instance details. + */ +struct TALER_MERCHANT_GetPrivateDonauDonauInstanceEntry +{ + /** + * Serial number of the Donau instance in merchant database. + */ + uint64_t donau_instance_serial; + + /** + * The URL of the Donau service. + */ + const char *donau_url; + + /** + * Name of the charity associated with the Donau instance. + */ + const char *charity_name; + + /** + * Public key of the charity. + */ + struct DONAU_CharityPublicKeyP charity_pub_key; + + /** + * ID of the charity on Donau. + */ + uint64_t charity_id; + + /** + * Maximum donation amount per year allowed for the charity. + */ + struct TALER_Amount charity_max_per_year; + + /** + * Total donations received by the charity in the current year. + */ + struct TALER_Amount charity_receipts_to_date; + + /** + * The current year being tracked for donations. + */ + int64_t current_year; + + /** + * Additional key information related to the Donau instance. + */ + const struct DONAU_Keys *donau_keys; +}; + + +/** + * Response details for a GET /private/donau request. + */ +struct TALER_MERCHANT_GetPrivateDonauResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of Donau instances in @a donau_instances. + */ + unsigned int donau_instances_length; + + /** + * Array of Donau instance entries. + */ + const struct TALER_MERCHANT_GetPrivateDonauDonauInstanceEntry * + donau_instances; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/donau operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateDonauHandle * +TALER_MERCHANT_get_private_donau_create ( + struct GNUNET_CURL_Context *ctx, + const char *url); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_DONAU_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateDonauCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_DONAU_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_DONAU_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/donau request. + * + * @param cls closure + * @param dgr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateDonauCallback)( + TALER_MERCHANT_GET_PRIVATE_DONAU_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateDonauResponse *dgr); + + +/** + * Start GET /private/donau operation. + * + * @param[in,out] gpdh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_donau_start ( + struct TALER_MERCHANT_GetPrivateDonauHandle *gpdh, + TALER_MERCHANT_GetPrivateDonauCallback cb, + TALER_MERCHANT_GET_PRIVATE_DONAU_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/donau operation. This function must not be + * called by clients after the TALER_MERCHANT_GetPrivateDonauCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpdh operation to cancel + */ +void +TALER_MERCHANT_get_private_donau_cancel ( + struct TALER_MERCHANT_GetPrivateDonauHandle *gpdh); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_DONAU_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-kyc-new.h b/src/include/taler/taler-merchant/get-private-kyc-new.h @@ -0,0 +1,443 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-kyc-new.h + * @brief C interface for the GET /private/kyc (and /management/instances/$INSTANCE/kyc) endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_KYC_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_KYC_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options we can set for the GET /private/kyc request. + */ +enum TALER_MERCHANT_GetPrivateKycOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_END = 0, + + /** + * Hash of the wire account to check, or NULL for all. + */ + TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_H_WIRE, + + /** + * URL of the exchange to check with, or NULL for any. + */ + TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_EXCHANGE_URL, + + /** + * Long-poll target (what status to wait for). + */ + TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_LPT, + + /** + * Long polling timeout. + */ + TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_TIMEOUT, + + /** + * Instance ID for management mode (GET /management/instances/$INSTANCE/kyc). + * If not set, uses the private endpoint (GET /private/kyc). + */ + TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_INSTANCE_ID + +}; + + +/** + * Value for an option for the GET /private/kyc request. + */ +struct TALER_MERCHANT_GetPrivateKycOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_GetPrivateKycOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_H_WIRE. + */ + const struct TALER_MerchantWireHashP *h_wire; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_EXCHANGE_URL. + */ + const char *exchange_url; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_LPT. + */ + enum TALER_EXCHANGE_KycLongPollTarget lpt; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_TIMEOUT. + */ + struct GNUNET_TIME_Relative timeout; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_INSTANCE_ID. + * If set, the management endpoint + * /management/instances/$INSTANCE/kyc is used instead of + * /private/kyc. + */ + const char *instance_id; + + } details; + +}; + + +/** + * Handle for a GET /private/kyc (or /management/instances/$INSTANCE/kyc) request. + */ +struct TALER_MERCHANT_GetPrivateKycHandle; + + +/** + * Set up GET /private/kyc operation. + * Note that you must explicitly start the operation after + * possibly setting options. By default, uses the /private/kyc + * endpoint; set the INSTANCE_ID option to use the management + * endpoint instead. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateKycHandle * +TALER_MERCHANT_get_private_kyc_create ( + struct GNUNET_CURL_Context *ctx, + const char *url); + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_GetPrivateKycOptionValue + */ +#define TALER_MERCHANT_get_private_kyc_option_end_() \ + (const struct TALER_MERCHANT_GetPrivateKycOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_END \ + } + +/** + * Set hash of the wire account to check. + * + * @param h pointer to the wire hash to filter by + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateKycOptionValue + */ +#define TALER_MERCHANT_get_private_kyc_option_h_wire(h) \ + (const struct TALER_MERCHANT_GetPrivateKycOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_H_WIRE, \ + .details.h_wire = (h) \ + } + +/** + * Set exchange URL to check with. + * + * @param u exchange URL to filter by + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateKycOptionValue + */ +#define TALER_MERCHANT_get_private_kyc_option_exchange_url(u) \ + (const struct TALER_MERCHANT_GetPrivateKycOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_EXCHANGE_URL, \ + .details.exchange_url = (u) \ + } + +/** + * Set long-poll target. + * + * @param t long-poll target to wait for + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateKycOptionValue + */ +#define TALER_MERCHANT_get_private_kyc_option_lpt(t) \ + (const struct TALER_MERCHANT_GetPrivateKycOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_LPT, \ + .details.lpt = (t) \ + } + +/** + * Set long polling timeout. + * + * @param t timeout to use + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateKycOptionValue + */ +#define TALER_MERCHANT_get_private_kyc_option_timeout(t) \ + (const struct TALER_MERCHANT_GetPrivateKycOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_TIMEOUT, \ + .details.timeout = (t) \ + } + +/** + * Set instance ID for management mode. When set, the request uses + * the /management/instances/$INSTANCE/kyc endpoint instead of + * /private/kyc. + * + * @param id instance identifier + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateKycOptionValue + */ +#define TALER_MERCHANT_get_private_kyc_option_instance_id(id) \ + (const struct TALER_MERCHANT_GetPrivateKycOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_KYC_OPTION_INSTANCE_ID, \ + .details.instance_id = (id) \ + } + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * @param kyc the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_get_private_kyc_set_options_ ( + struct TALER_MERCHANT_GetPrivateKycHandle *kyc, + unsigned int num_options, + const struct TALER_MERCHANT_GetPrivateKycOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * It should be used with helpers that create required options, for example: + * + * TALER_MERCHANT_get_private_kyc_set_options ( + * kyc, + * TALER_MERCHANT_get_private_kyc_option_exchange_url ( + * "https://exchange.example.com/"), + * TALER_MERCHANT_get_private_kyc_option_timeout ( + * GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30))); + * + * @param kyc the request to set the options for + * @param ... the list of the options, each option must be created + * by helpers TALER_MERCHANT_get_private_kyc_option_NAME(VALUE) + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_get_private_kyc_set_options(kyc,...) \ + TALER_MERCHANT_get_private_kyc_set_options_ ( \ + kyc, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_GetPrivateKycOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_get_private_kyc_option_end_ () } \ + )) + + +/** + * Information about KYC actions the merchant still must perform. + */ +struct TALER_MERCHANT_GetPrivateKycRedirectDetail +{ + + /** + * Access token the user needs to start a KYC process, + * all zero if a KYC auth transfer must be made first. + */ + struct TALER_AccountAccessTokenP access_token; + + /** + * Base URL of the exchange this is about. + */ + const char *exchange_url; + + /** + * Our bank wire account this is about. + */ + struct TALER_FullPayto payto_uri; + + /** + * Array of length @e limits_length with (exposed) limits that apply to the + * account. + */ + const struct TALER_EXCHANGE_AccountLimit *limits; + + /** + * Array of payto://-URIs with instructions for wire + * transfers to perform a KYC auth wire transfer for + * the given account. Needed if @e access_token is zero + * and @e limits are to be passed. + */ + struct TALER_FullPayto *payto_kycauths; + + /** + * Length of the @e limits array. + */ + unsigned int limits_length; + + /** + * Length of the @e payto_kycauths array. + */ + unsigned int pkycauth_length; + + /** + * HTTP status code returned by the exchange when we asked for + * information about the KYC status. + * 0 if there was no response at all. + */ + unsigned int exchange_http_status; + + /** + * Error code indicating errors the exchange + * returned, or #TALER_EC_NONE for none. + */ + enum TALER_ErrorCode exchange_code; + + /** + * Set to true if @e access_token was not given. + */ + bool no_access_token; + + /** + * Set to true if the merchant backend could not + * get the exchanges ``/keys`` and thus could not + * determine default limits or determine an + * @e auth_conflict. + */ + bool no_keys; + + /** + * Set to true if the given account cannot do KYC at the given exchange + * because no wire method exists that could be used to do the KYC auth wire + * transfer. + */ + bool auth_conflict; + +}; + + +/** + * Response details for a KYC status request. + */ +struct TALER_MERCHANT_GetPrivateKycResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of KYC redirect details in @a kycs. + */ + unsigned int kycs_length; + + /** + * Array of KYC redirect details for accounts requiring KYC. + */ + const struct TALER_MERCHANT_GetPrivateKycRedirectDetail *kycs; + + } ok; + + } details; + +}; + + +#ifndef TALER_MERCHANT_GET_PRIVATE_KYC_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateKycCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_KYC_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_KYC_RESULT_CLOSURE */ + +/** + * Callback for a KYC status request. + * + * @param cls closure + * @param kr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateKycCallback)( + TALER_MERCHANT_GET_PRIVATE_KYC_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateKycResponse *kr); + + +/** + * Start GET /private/kyc (or /management/instances/$INSTANCE/kyc) operation. + * + * @param[in,out] kyc operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_kyc_start ( + struct TALER_MERCHANT_GetPrivateKycHandle *kyc, + TALER_MERCHANT_GetPrivateKycCallback cb, + TALER_MERCHANT_GET_PRIVATE_KYC_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/kyc operation. This function must not be + * called by clients after the TALER_MERCHANT_GetPrivateKycCallback + * has been invoked (as in those cases it'll be called internally by + * the implementation already). + * + * @param[in] kyc operation to cancel + */ +void +TALER_MERCHANT_get_private_kyc_cancel ( + struct TALER_MERCHANT_GetPrivateKycHandle *kyc); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_KYC_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-orders-ORDER_ID-new.h b/src/include/taler/taler-merchant/get-private-orders-ORDER_ID-new.h @@ -0,0 +1,449 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-orders-ORDER_ID-new.h + * @brief C interface for the GET /private/orders/$ORDER_ID endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_ORDERS_ORDER_ID_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_ORDERS_ORDER_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options we can set for the GET /private/orders/$ORDER_ID request. + */ +enum TALER_MERCHANT_GetPrivateOrderOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_GET_PRIVATE_ORDER_OPTION_END = 0, + + /** + * Session ID for repurchase detection. + */ + TALER_MERCHANT_GET_PRIVATE_ORDER_OPTION_SESSION_ID, + + /** + * Long polling timeout. + */ + TALER_MERCHANT_GET_PRIVATE_ORDER_OPTION_TIMEOUT + +}; + + +/** + * Value for an option for the GET /private/orders/$ORDER_ID request. + */ +struct TALER_MERCHANT_GetPrivateOrderOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_GetPrivateOrderOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_ORDER_OPTION_SESSION_ID. + */ + const char *session_id; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_ORDER_OPTION_TIMEOUT. + */ + struct GNUNET_TIME_Relative timeout; + + } details; + +}; + + +/** + * Handle for a GET /private/orders/$ORDER_ID request. + */ +struct TALER_MERCHANT_GetPrivateOrderHandle; + + +/** + * Set up GET /private/orders/$ORDER_ID operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param order_id identifier of the order to retrieve + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateOrderHandle * +TALER_MERCHANT_get_private_order_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *order_id); + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_GetPrivateOrderOptionValue + */ +#define TALER_MERCHANT_get_private_order_option_end_() \ + (const struct TALER_MERCHANT_GetPrivateOrderOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDER_OPTION_END \ + } + +/** + * Set session ID for repurchase detection. + * + * @param s session ID to use + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateOrderOptionValue + */ +#define TALER_MERCHANT_get_private_order_option_session_id(s) \ + (const struct TALER_MERCHANT_GetPrivateOrderOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDER_OPTION_SESSION_ID, \ + .details.session_id = (s) \ + } + +/** + * Set long polling timeout. + * + * @param t timeout to use + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateOrderOptionValue + */ +#define TALER_MERCHANT_get_private_order_option_timeout(t) \ + (const struct TALER_MERCHANT_GetPrivateOrderOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDER_OPTION_TIMEOUT, \ + .details.timeout = (t) \ + } + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * @param oph the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_get_private_order_set_options_ ( + struct TALER_MERCHANT_GetPrivateOrderHandle *oph, + unsigned int num_options, + const struct TALER_MERCHANT_GetPrivateOrderOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * It should be used with helpers that create required options, for example: + * + * TALER_MERCHANT_get_private_order_set_options ( + * oph, + * TALER_MERCHANT_get_private_order_option_session_id ("mysession")); + * + * @param oph the request to set the options for + * @param ... the list of the options, each option must be created + * by helpers TALER_MERCHANT_get_private_order_option_NAME(VALUE) + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_get_private_order_set_options(oph,...) \ + TALER_MERCHANT_get_private_order_set_options_ ( \ + oph, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_GetPrivateOrderOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_get_private_order_option_end_ () } \ + )) + + +/** + * Order status code. + */ +enum TALER_MERCHANT_OrderStatusCode +{ + /** + * The order is unpaid. + */ + TALER_MERCHANT_OSC_UNPAID = 0, + + /** + * The order has been claimed by a wallet. + */ + TALER_MERCHANT_OSC_CLAIMED = 1, + + /** + * The order has been paid. + */ + TALER_MERCHANT_OSC_PAID = 2 +}; + + +/** + * Refund detail in a paid order (merchant view). + */ +struct TALER_MERCHANT_GetPrivateOrderRefundDetail +{ + + /** + * Human-readable reason given for the refund. + */ + const char *reason; + + /** + * Time when the refund was granted. + */ + struct GNUNET_TIME_Timestamp refund_time; + + /** + * Total amount that was refunded. + */ + struct TALER_Amount refund_amount; + +}; + + +/** + * Response details for a GET /private/orders/$ORDER_ID request. + */ +struct TALER_MERCHANT_GetPrivateOrderResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Current status of the order. + */ + enum TALER_MERCHANT_OrderStatusCode status; + + /** + * Details depending on @a status. + */ + union + { + + /** + * Details when @a status is #TALER_MERCHANT_OSC_UNPAID. + */ + struct + { + + /** + * Total amount of the order. + */ + struct TALER_Amount contract_amount; + + /** + * Order ID of a previously paid order that covers this one, + * or NULL if none. + */ + const char *already_paid_order_id; + + /** + * Taler pay URI for this order. + */ + const char *taler_pay_uri; + + /** + * Short summary of the order. + */ + const char *summary; + + /** + * Timestamp when the order was created. + */ + struct GNUNET_TIME_Timestamp creation_time; + + } unpaid; + + /** + * Details when @a status is #TALER_MERCHANT_OSC_CLAIMED. + */ + struct + { + + /** + * Contract terms (JSON). + */ + const json_t *contract_terms; + + } claimed; + + /** + * Details when @a status is #TALER_MERCHANT_OSC_PAID. + */ + struct + { + + /** + * True if a refund has been granted. + */ + bool refunded; + + /** + * True if a refund is still pending at the exchange. + */ + bool refund_pending; + + /** + * True if the payment has been wired to the merchant. + */ + bool wired; + + /** + * Total amount deposited. + */ + struct TALER_Amount deposit_total; + + /** + * Error code from the exchange, or TALER_EC_NONE. + */ + enum TALER_ErrorCode exchange_ec; + + /** + * HTTP status returned by the exchange. + */ + unsigned int exchange_hc; + + /** + * Total amount refunded. + */ + struct TALER_Amount refund_amount; + + /** + * Contract terms (JSON). + */ + const json_t *contract_terms; + + /** + * Number of wire transfers in @a wts. + */ + unsigned int wts_len; + + /** + * Array of wire transfer details. + */ + struct TALER_MERCHANT_WireTransfer *wts; + + /** + * Number of refund details in @a refunds. + */ + unsigned int refunds_len; + + /** + * Array of per-coin refund details. + */ + struct TALER_MERCHANT_GetPrivateOrderRefundDetail *refunds; + + /** + * Timestamp of the last payment. + */ + struct GNUNET_TIME_Timestamp last_payment; + + } paid; + + } details; + + } ok; + + } details; + +}; + + +#ifndef TALER_MERCHANT_GET_PRIVATE_ORDER_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateOrderCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_ORDER_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_ORDER_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/orders/$ORDER_ID request. + * + * @param cls closure + * @param osr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateOrderCallback)( + TALER_MERCHANT_GET_PRIVATE_ORDER_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateOrderResponse *osr); + + +/** + * Start GET /private/orders/$ORDER_ID operation. + * + * @param[in,out] oph operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_order_start ( + struct TALER_MERCHANT_GetPrivateOrderHandle *oph, + TALER_MERCHANT_GetPrivateOrderCallback cb, + TALER_MERCHANT_GET_PRIVATE_ORDER_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/orders/$ORDER_ID operation. This function must not be + * called by clients after the TALER_MERCHANT_GetPrivateOrderCallback + * has been invoked (as in those cases it'll be called internally by + * the implementation already). + * + * @param[in] oph operation to cancel + */ +void +TALER_MERCHANT_get_private_order_cancel ( + struct TALER_MERCHANT_GetPrivateOrderHandle *oph); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_ORDERS_ORDER_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-orders-new.h b/src/include/taler/taler-merchant/get-private-orders-new.h @@ -0,0 +1,528 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-orders-new.h + * @brief C interface for the GET /private/orders endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_ORDERS_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_ORDERS_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options we can set for the GET /private/orders request. + */ +enum TALER_MERCHANT_GetPrivateOrdersOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_END = 0, + + /** + * Filter by paid status. + */ + TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_PAID, + + /** + * Filter by refunded status. + */ + TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_REFUNDED, + + /** + * Filter by wired status. + */ + TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_WIRED, + + /** + * Return at most N values. Negative values + * to return before offset, positive to return after offset. + * Default is -20. + */ + TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_LIMIT, + + /** + * Starting row_id for pagination. + */ + TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_OFFSET, + + /** + * Date threshold for filtering. + */ + TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_DATE, + + /** + * Long polling timeout. + */ + TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_TIMEOUT, + + /** + * Filter by session ID. + */ + TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_SESSION_ID, + + /** + * Filter by fulfillment URL. + */ + TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_FULFILLMENT_URL, + + /** + * Filter by summary text (case-insensitive substring match). + */ + TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_SUMMARY_FILTER + +}; + + +/** + * Value for an option for the GET /private/orders request. + */ +struct TALER_MERCHANT_GetPrivateOrdersOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_GetPrivateOrdersOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_PAID. + */ + enum TALER_EXCHANGE_YesNoAll paid; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_REFUNDED. + */ + enum TALER_EXCHANGE_YesNoAll refunded; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_WIRED. + */ + enum TALER_EXCHANGE_YesNoAll wired; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_LIMIT. + */ + int64_t limit; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_OFFSET. + */ + uint64_t offset; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_DATE. + */ + struct GNUNET_TIME_Timestamp date; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_TIMEOUT. + */ + struct GNUNET_TIME_Relative timeout; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_SESSION_ID. + */ + const char *session_id; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_FULFILLMENT_URL. + */ + const char *fulfillment_url; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_SUMMARY_FILTER. + */ + const char *summary_filter; + + } details; + +}; + + +/** + * Handle for a GET /private/orders request. + */ +struct TALER_MERCHANT_GetPrivateOrdersHandle; + + +/** + * Set up GET /private/orders operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateOrdersHandle * +TALER_MERCHANT_get_private_orders_create ( + struct GNUNET_CURL_Context *ctx, + const char *url); + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_GetPrivateOrdersOptionValue + */ +#define TALER_MERCHANT_get_private_orders_option_end_() \ + (const struct TALER_MERCHANT_GetPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_END \ + } + +/** + * Set filter on paid status. + * + * @param p paid filter to use + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateOrdersOptionValue + */ +#define TALER_MERCHANT_get_private_orders_option_paid(p) \ + (const struct TALER_MERCHANT_GetPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_PAID, \ + .details.paid = (p) \ + } + +/** + * Set filter on refunded status. + * + * @param r refunded filter to use + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateOrdersOptionValue + */ +#define TALER_MERCHANT_get_private_orders_option_refunded(r) \ + (const struct TALER_MERCHANT_GetPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_REFUNDED, \ + .details.refunded = (r) \ + } + +/** + * Set filter on wired status. + * + * @param w wired filter to use + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateOrdersOptionValue + */ +#define TALER_MERCHANT_get_private_orders_option_wired(w) \ + (const struct TALER_MERCHANT_GetPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_WIRED, \ + .details.wired = (w) \ + } + +/** + * Set limit on the number of results to return. + * + * @param l limit on the number of results to return + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateOrdersOptionValue + */ +#define TALER_MERCHANT_get_private_orders_option_limit(l) \ + (const struct TALER_MERCHANT_GetPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_LIMIT, \ + .details.limit = (l) \ + } + +/** + * Set row offset from which to return results. + * + * @param o offset to use + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateOrdersOptionValue + */ +#define TALER_MERCHANT_get_private_orders_option_offset(o) \ + (const struct TALER_MERCHANT_GetPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_OFFSET, \ + .details.offset = (o) \ + } + +/** + * Set date threshold for filtering. + * + * @param d date threshold to use + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateOrdersOptionValue + */ +#define TALER_MERCHANT_get_private_orders_option_date(d) \ + (const struct TALER_MERCHANT_GetPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_DATE, \ + .details.date = (d) \ + } + +/** + * Set long polling timeout. + * + * @param t timeout to use + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateOrdersOptionValue + */ +#define TALER_MERCHANT_get_private_orders_option_timeout(t) \ + (const struct TALER_MERCHANT_GetPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_TIMEOUT, \ + .details.timeout = (t) \ + } + +/** + * Set session ID filter. + * + * @param s session ID to filter by + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateOrdersOptionValue + */ +#define TALER_MERCHANT_get_private_orders_option_session_id(s) \ + (const struct TALER_MERCHANT_GetPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_SESSION_ID, \ + .details.session_id = (s) \ + } + +/** + * Set fulfillment URL filter. + * + * @param u fulfillment URL to filter by + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateOrdersOptionValue + */ +#define TALER_MERCHANT_get_private_orders_option_fulfillment_url(u) \ + (const struct TALER_MERCHANT_GetPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_FULFILLMENT_URL, \ + .details.fulfillment_url = (u) \ + } + +/** + * Set summary text filter. + * + * @param f summary filter string (case-insensitive substring match) + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateOrdersOptionValue + */ +#define TALER_MERCHANT_get_private_orders_option_summary_filter(f) \ + (const struct TALER_MERCHANT_GetPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_ORDERS_OPTION_SUMMARY_FILTER, \ + .details.summary_filter = (f) \ + } + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * @param oph the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_get_private_orders_set_options_ ( + struct TALER_MERCHANT_GetPrivateOrdersHandle *oph, + unsigned int num_options, + const struct TALER_MERCHANT_GetPrivateOrdersOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * It should be used with helpers that create required options, for example: + * + * TALER_MERCHANT_get_private_orders_set_options ( + * oph, + * TALER_MERCHANT_get_private_orders_option_paid ( + * TALER_EXCHANGE_YNA_YES), + * TALER_MERCHANT_get_private_orders_option_limit (-20)); + * + * @param oph the request to set the options for + * @param ... the list of the options, each option must be created + * by helpers TALER_MERCHANT_get_private_orders_option_NAME(VALUE) + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_get_private_orders_set_options(oph,...) \ + TALER_MERCHANT_get_private_orders_set_options_ ( \ + oph, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_GetPrivateOrdersOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_get_private_orders_option_end_ () } \ + )) + + +/** + * Entry for one order in the GET /private/orders response. + */ +struct TALER_MERCHANT_GetPrivateOrdersOrderEntry +{ + + /** + * The order identifier string. + */ + const char *order_id; + + /** + * Timestamp when the order was created. + */ + struct GNUNET_TIME_Timestamp timestamp; + + /** + * Serial number of the order in the database. + */ + uint64_t order_serial; + + /** + * Total amount of the order. + */ + struct TALER_Amount amount; + + /** + * Amount refunded so far. + */ + struct TALER_Amount refund_amount; + + /** + * Amount still pending refund. + */ + struct TALER_Amount pending_refund_amount; + + /** + * Short summary of the order. + */ + const char *summary; + + /** + * True if refund is possible. + */ + bool refundable; + + /** + * True if the order has been paid. + */ + bool paid; + +}; + + +/** + * Response details for a GET /private/orders request. + */ +struct TALER_MERCHANT_GetPrivateOrdersResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of orders in @a orders. + */ + unsigned int orders_length; + + /** + * Array of order entries. + */ + const struct TALER_MERCHANT_GetPrivateOrdersOrderEntry *orders; + + } ok; + + } details; + +}; + + +#ifndef TALER_MERCHANT_GET_PRIVATE_ORDERS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateOrdersCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_ORDERS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_ORDERS_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/orders request. + * + * @param cls closure + * @param ogr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateOrdersCallback)( + TALER_MERCHANT_GET_PRIVATE_ORDERS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateOrdersResponse *ogr); + + +/** + * Start GET /private/orders operation. + * + * @param[in,out] oph operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_orders_start ( + struct TALER_MERCHANT_GetPrivateOrdersHandle *oph, + TALER_MERCHANT_GetPrivateOrdersCallback cb, + TALER_MERCHANT_GET_PRIVATE_ORDERS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/orders operation. This function must not be + * called by clients after the TALER_MERCHANT_GetPrivateOrdersCallback + * has been invoked (as in those cases it'll be called internally by + * the implementation already). + * + * @param[in] oph operation to cancel + */ +void +TALER_MERCHANT_get_private_orders_cancel ( + struct TALER_MERCHANT_GetPrivateOrdersHandle *oph); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_ORDERS_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-otp-devices-DEVICE_ID-new.h b/src/include/taler/taler-merchant/get-private-otp-devices-DEVICE_ID-new.h @@ -0,0 +1,160 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-otp-devices-DEVICE_ID-new.h + * @brief C interface for GET /private/otp-devices/$DEVICE_ID of the merchant backend + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_DEVICE_ID_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_DEVICE_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/otp-devices/$DEVICE_ID request. + */ +struct TALER_MERCHANT_GetPrivateOtpDeviceHandle; + + +/** + * Response details for a GET /private/otp-devices/$DEVICE_ID request. + */ +struct TALER_MERCHANT_GetPrivateOtpDeviceResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Human-readable description of the OTP device. + */ + const char *otp_device_description; + + /** + * Current counter value of the OTP device (for HOTP). + */ + uint64_t otp_ctr; + + /** + * Current timestamp in seconds (for TOTP). + */ + uint64_t otp_timestamp_s; + + /** + * POS confirmation text with OTP codes that + * would be returned for a purchase over the + * amount given in the query for the respective + * time and algorithm. NULL if the confirmation + * could not be computed based on the query and + * OTP algorithm. + */ + const char *otp_code; + + /** + * OTP algorithm used. + */ + enum TALER_MerchantConfirmationAlgorithm otp_alg; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/otp-devices/$DEVICE_ID operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param otp_device_id identifier of the OTP device to retrieve + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateOtpDeviceHandle * +TALER_MERCHANT_get_private_otp_device_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *otp_device_id); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_OTP_DEVICE_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateOtpDeviceCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_OTP_DEVICE_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_OTP_DEVICE_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/otp-devices/$DEVICE_ID request. + * + * @param cls closure + * @param ogr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateOtpDeviceCallback)( + TALER_MERCHANT_GET_PRIVATE_OTP_DEVICE_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateOtpDeviceResponse *ogr); + + +/** + * Start GET /private/otp-devices/$DEVICE_ID operation. + * + * @param[in,out] god operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_otp_device_start ( + struct TALER_MERCHANT_GetPrivateOtpDeviceHandle *god, + TALER_MERCHANT_GetPrivateOtpDeviceCallback cb, + TALER_MERCHANT_GET_PRIVATE_OTP_DEVICE_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/otp-devices/$DEVICE_ID operation. This function + * must not be called by clients after the + * TALER_MERCHANT_GetPrivateOtpDeviceCallback has been invoked + * (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] god operation to cancel + */ +void +TALER_MERCHANT_get_private_otp_device_cancel ( + struct TALER_MERCHANT_GetPrivateOtpDeviceHandle *god); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_DEVICE_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-otp-devices-new.h b/src/include/taler/taler-merchant/get-private-otp-devices-new.h @@ -0,0 +1,157 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-otp-devices-new.h + * @brief C interface for the GET /private/otp-devices endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/otp-devices request. + */ +struct TALER_MERCHANT_GetPrivateOtpDevicesHandle; + + +/** + * Entry for one OTP device. + */ +struct TALER_MERCHANT_GetPrivateOtpDevicesOtpDeviceEntry +{ + + /** + * Identifier of the OTP device. + */ + const char *otp_device_id; + + /** + * Human-readable description of the OTP device. + */ + const char *otp_device_description; + +}; + + +/** + * Response details for a GET /private/otp-devices request. + */ +struct TALER_MERCHANT_GetPrivateOtpDevicesResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of OTP devices in @a otp_devices. + */ + unsigned int otp_devices_length; + + /** + * Array of OTP device entries. + */ + const struct TALER_MERCHANT_GetPrivateOtpDevicesOtpDeviceEntry * + otp_devices; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/otp-devices operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateOtpDevicesHandle * +TALER_MERCHANT_get_private_otp_devices_create ( + struct GNUNET_CURL_Context *ctx, + const char *url); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_OTP_DEVICES_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateOtpDevicesCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_OTP_DEVICES_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_OTP_DEVICES_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/otp-devices request. + * + * @param cls closure + * @param ogr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateOtpDevicesCallback)( + TALER_MERCHANT_GET_PRIVATE_OTP_DEVICES_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateOtpDevicesResponse *ogr); + + +/** + * Start GET /private/otp-devices operation. + * + * @param[in,out] gpoh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_otp_devices_start ( + struct TALER_MERCHANT_GetPrivateOtpDevicesHandle *gpoh, + TALER_MERCHANT_GetPrivateOtpDevicesCallback cb, + TALER_MERCHANT_GET_PRIVATE_OTP_DEVICES_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/otp-devices operation. This function must not be + * called by clients after the TALER_MERCHANT_GetPrivateOtpDevicesCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpoh operation to cancel + */ +void +TALER_MERCHANT_get_private_otp_devices_cancel ( + struct TALER_MERCHANT_GetPrivateOtpDevicesHandle *gpoh); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-products-PRODUCT_ID-new.h b/src/include/taler/taler-merchant/get-private-products-PRODUCT_ID-new.h @@ -0,0 +1,216 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-products-PRODUCT_ID-new.h + * @brief C interface for GET /private/products/$PRODUCT_ID of the merchant backend + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_PRODUCTS_PRODUCT_ID_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_PRODUCTS_PRODUCT_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/products/$PRODUCT_ID request. + */ +struct TALER_MERCHANT_GetPrivateProductHandle; + + +/** + * Response details for a GET /private/products/$PRODUCT_ID request. + */ +struct TALER_MERCHANT_GetPrivateProductResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Human-readable product name. + */ + const char *product_name; + + /** + * Human-readable product description. + */ + const char *description; + + /** + * Internationalized descriptions (JSON object), or NULL. + */ + const json_t *description_i18n; + + /** + * Unit of measurement for this product. + */ + const char *unit; + + /** + * Number of prices in @a unit_price. + */ + size_t unit_price_len; + + /** + * Array of unit prices (for different payment options). + */ + const struct TALER_Amount *unit_price; + + /** + * Single unit price (first element of @a unit_price, for backwards compatibility). + */ + struct TALER_Amount price; + + /** + * Base64-encoded product image, or empty string. + */ + const char *image; + + /** + * Tax information (JSON array), or NULL. + */ + const json_t *taxes; + + /** + * Total available stock (-1 for unlimited). + */ + int64_t total_stock; + + /** + * Total stock in fractional unit representation. + * Stock level encoded as a decimal string. Preferred source of truth for fractional stock. + */ + const char *unit_total_stock; + + /** + * Whether fractional quantities are allowed. + */ + bool unit_allow_fraction; + + /** + * Precision level for fractional quantities. + */ + uint32_t unit_precision_level; + + /** + * Total number of units sold. + */ + uint64_t total_sold; + + /** + * Total number of units lost/expired. + */ + uint64_t total_lost; + + /** + * Storage location (JSON), or NULL. + */ + const json_t *location; + + /** + * Expected time of next restock (may be zero if unknown). + */ + struct GNUNET_TIME_Timestamp next_restock; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/products/$PRODUCT_ID operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param product_id identifier of the product to retrieve + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateProductHandle * +TALER_MERCHANT_get_private_product_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *product_id); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_PRODUCT_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateProductCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_PRODUCT_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_PRODUCT_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/products/$PRODUCT_ID request. + * + * @param cls closure + * @param pgr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateProductCallback)( + TALER_MERCHANT_GET_PRIVATE_PRODUCT_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateProductResponse *pgr); + + +/** + * Start GET /private/products/$PRODUCT_ID operation. + * + * @param[in,out] gpp operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_product_start ( + struct TALER_MERCHANT_GetPrivateProductHandle *gpp, + TALER_MERCHANT_GetPrivateProductCallback cb, + TALER_MERCHANT_GET_PRIVATE_PRODUCT_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/products/$PRODUCT_ID operation. This function + * must not be called by clients after the + * TALER_MERCHANT_GetPrivateProductCallback has been invoked + * (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpp operation to cancel + */ +void +TALER_MERCHANT_get_private_product_cancel ( + struct TALER_MERCHANT_GetPrivateProductHandle *gpp); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_PRODUCTS_PRODUCT_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-products-new.h b/src/include/taler/taler-merchant/get-private-products-new.h @@ -0,0 +1,156 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-products-new.h + * @brief C interface for the GET /private/products endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_PRODUCTS_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_PRODUCTS_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/products request. + */ +struct TALER_MERCHANT_GetPrivateProductsHandle; + + +/** + * Inventory entry for the GET /private/products response. + */ +struct TALER_MERCHANT_GetPrivateProductsInventoryEntry +{ + + /** + * Identifier of the product. + */ + const char *product_id; + + /** + * Serial ID of the product. + */ + uint64_t product_serial; + +}; + + +/** + * Response details for a GET /private/products request. + */ +struct TALER_MERCHANT_GetPrivateProductsResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of products in @a products. + */ + unsigned int products_length; + + /** + * Array of product entries. + */ + const struct TALER_MERCHANT_GetPrivateProductsInventoryEntry *products; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/products operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateProductsHandle * +TALER_MERCHANT_get_private_products_create ( + struct GNUNET_CURL_Context *ctx, + const char *url); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_PRODUCTS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateProductsCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_PRODUCTS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_PRODUCTS_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/products request. + * + * @param cls closure + * @param pgr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateProductsCallback)( + TALER_MERCHANT_GET_PRIVATE_PRODUCTS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateProductsResponse *pgr); + + +/** + * Start GET /private/products operation. + * + * @param[in,out] gpph operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_products_start ( + struct TALER_MERCHANT_GetPrivateProductsHandle *gpph, + TALER_MERCHANT_GetPrivateProductsCallback cb, + TALER_MERCHANT_GET_PRIVATE_PRODUCTS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/products operation. This function must not be + * called by clients after the TALER_MERCHANT_GetPrivateProductsCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpph operation to cancel + */ +void +TALER_MERCHANT_get_private_products_cancel ( + struct TALER_MERCHANT_GetPrivateProductsHandle *gpph); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_PRODUCTS_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-statistics-amount-SLUG-new.h b/src/include/taler/taler-merchant/get-private-statistics-amount-SLUG-new.h @@ -0,0 +1,342 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-statistics-amount-SLUG-new.h + * @brief C interface for the GET /private/statistics-amount/$SLUG endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_STATISTICS_AMOUNT_SLUG_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_STATISTICS_AMOUNT_SLUG_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options we can set for the GET /private/statistics-amount/$SLUG request. + */ +enum TALER_MERCHANT_GetPrivateStatisticsAmountOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_GET_PRIVATE_STATISTICS_AMOUNT_OPTION_END = 0, + + /** + * Aggregation mode to request (BUCKET, INTERVAL, or ANY). + */ + TALER_MERCHANT_GET_PRIVATE_STATISTICS_AMOUNT_OPTION_TYPE + +}; + + +/** + * Value for an option for the GET /private/statistics-amount/$SLUG request. + */ +struct TALER_MERCHANT_GetPrivateStatisticsAmountOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_GetPrivateStatisticsAmountOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_STATISTICS_AMOUNT_OPTION_TYPE. + */ + enum TALER_MERCHANT_StatisticsType type; + + } details; + +}; + + +/** + * Handle for a GET /private/statistics-amount/$SLUG request. + */ +struct TALER_MERCHANT_GetPrivateStatisticsAmountHandle; + + +/** + * Set up GET /private/statistics-amount/$SLUG operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param slug statistics slug to retrieve + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateStatisticsAmountHandle * +TALER_MERCHANT_get_private_statistics_amount_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *slug); + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_GetPrivateStatisticsAmountOptionValue + */ +#define TALER_MERCHANT_get_private_statistics_amount_option_end_() \ + (const struct TALER_MERCHANT_GetPrivateStatisticsAmountOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_STATISTICS_AMOUNT_OPTION_END \ + } + +/** + * Set aggregation mode type. + * + * @param t aggregation mode to request + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateStatisticsAmountOptionValue + */ +#define TALER_MERCHANT_get_private_statistics_amount_option_type(t) \ + (const struct TALER_MERCHANT_GetPrivateStatisticsAmountOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_STATISTICS_AMOUNT_OPTION_TYPE, \ + .details.type = (t) \ + } + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * @param sah the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_get_private_statistics_amount_set_options_ ( + struct TALER_MERCHANT_GetPrivateStatisticsAmountHandle *sah, + unsigned int num_options, + const struct TALER_MERCHANT_GetPrivateStatisticsAmountOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * It should be used with helpers that create required options, for example: + * + * TALER_MERCHANT_get_private_statistics_amount_set_options ( + * sah, + * TALER_MERCHANT_get_private_statistics_amount_option_type ( + * TALER_MERCHANT_STATISTICS_TYPE_BUCKET)); + * + * @param sah the request to set the options for + * @param ... the list of the options, each option must be created + * by helpers TALER_MERCHANT_get_private_statistics_amount_option_NAME(VALUE) + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_get_private_statistics_amount_set_options(sah,...) \ + TALER_MERCHANT_get_private_statistics_amount_set_options_ ( \ + sah, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_GetPrivateStatisticsAmountOptionValue[]) \ + {__VA_ARGS__, \ + TALER_MERCHANT_get_private_statistics_amount_option_end_ () } \ + )) + + +/** + * Statistic amount aggregated by bucket. + */ +struct TALER_MERCHANT_GetPrivateStatisticsAmountByBucket +{ + + /** + * Start time of the bucket (inclusive). + */ + struct GNUNET_TIME_Timestamp start_time; + + /** + * End time of the bucket (exclusive). + */ + struct GNUNET_TIME_Timestamp end_time; + + /** + * Range of the bucket. + */ + const char *range; + + /** + * Sum of all amounts falling under the given + * SLUG within this timeframe. + */ + struct TALER_Amount *cumulative_amounts; + + /** + * Length of array @a cumulative_amounts. + */ + unsigned int cumulative_amount_len; + +}; + + +/** + * Statistic amount aggregated by interval. + */ +struct TALER_MERCHANT_GetPrivateStatisticsAmountByInterval +{ + + /** + * Start time of the interval (inclusive). + * The interval always ends at the response + * generation time. + */ + struct GNUNET_TIME_Timestamp start_time; + + /** + * Sum of all amounts falling under the given + * SLUG within this timeframe. + */ + struct TALER_Amount *cumulative_amounts; + + /** + * Length of array @a cumulative_amounts. + */ + unsigned int cumulative_amount_len; + +}; + + +/** + * Response details for a GET /private/statistics-amount/$SLUG request. + */ +struct TALER_MERCHANT_GetPrivateStatisticsAmountResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of bucket entries in @a buckets. + */ + unsigned int buckets_length; + + /** + * Array of amount statistics per bucket. + */ + const struct TALER_MERCHANT_GetPrivateStatisticsAmountByBucket *buckets; + + /** + * Description of the bucket aggregation scheme, or NULL. + */ + const char *buckets_description; + + /** + * Number of interval entries in @a intervals. + */ + unsigned int intervals_length; + + /** + * Array of amount statistics per time interval. + */ + const struct TALER_MERCHANT_GetPrivateStatisticsAmountByInterval * + intervals; + + /** + * Description of the interval aggregation scheme, or NULL. + */ + const char *intervals_description; + + } ok; + + } details; + +}; + + +#ifndef TALER_MERCHANT_GET_PRIVATE_STATISTICS_AMOUNT_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateStatisticsAmountCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_STATISTICS_AMOUNT_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_STATISTICS_AMOUNT_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/statistics-amount/$SLUG request. + * + * @param cls closure + * @param sagr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateStatisticsAmountCallback)( + TALER_MERCHANT_GET_PRIVATE_STATISTICS_AMOUNT_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateStatisticsAmountResponse *sagr); + + +/** + * Start GET /private/statistics-amount/$SLUG operation. + * + * @param[in,out] sah operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_statistics_amount_start ( + struct TALER_MERCHANT_GetPrivateStatisticsAmountHandle *sah, + TALER_MERCHANT_GetPrivateStatisticsAmountCallback cb, + TALER_MERCHANT_GET_PRIVATE_STATISTICS_AMOUNT_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/statistics-amount/$SLUG operation. This function + * must not be called by clients after the + * TALER_MERCHANT_GetPrivateStatisticsAmountCallback has been invoked + * (as in those cases it'll be called internally by the implementation + * already). + * + * @param[in] sah operation to cancel + */ +void +TALER_MERCHANT_get_private_statistics_amount_cancel ( + struct TALER_MERCHANT_GetPrivateStatisticsAmountHandle *sah); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_STATISTICS_AMOUNT_SLUG_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-statistics-counter-SLUG-new.h b/src/include/taler/taler-merchant/get-private-statistics-counter-SLUG-new.h @@ -0,0 +1,333 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-statistics-counter-SLUG-new.h + * @brief C interface for the GET /private/statistics-counter/$SLUG endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_STATISTICS_COUNTER_SLUG_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_STATISTICS_COUNTER_SLUG_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options we can set for the GET /private/statistics-counter/$SLUG request. + */ +enum TALER_MERCHANT_GetPrivateStatisticsCounterOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_GET_PRIVATE_STATISTICS_COUNTER_OPTION_END = 0, + + /** + * Aggregation mode to request (BUCKET, INTERVAL, or ANY). + */ + TALER_MERCHANT_GET_PRIVATE_STATISTICS_COUNTER_OPTION_TYPE + +}; + + +/** + * Value for an option for the GET /private/statistics-counter/$SLUG request. + */ +struct TALER_MERCHANT_GetPrivateStatisticsCounterOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_GetPrivateStatisticsCounterOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_STATISTICS_COUNTER_OPTION_TYPE. + */ + enum TALER_MERCHANT_StatisticsType type; + + } details; + +}; + + +/** + * Handle for a GET /private/statistics-counter/$SLUG request. + */ +struct TALER_MERCHANT_GetPrivateStatisticsCounterHandle; + + +/** + * Set up GET /private/statistics-counter/$SLUG operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param slug statistics slug to retrieve + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateStatisticsCounterHandle * +TALER_MERCHANT_get_private_statistics_counter_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *slug); + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_GetPrivateStatisticsCounterOptionValue + */ +#define TALER_MERCHANT_get_private_statistics_counter_option_end_() \ + (const struct TALER_MERCHANT_GetPrivateStatisticsCounterOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_STATISTICS_COUNTER_OPTION_END \ + } + +/** + * Set aggregation mode type. + * + * @param t aggregation mode to request + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateStatisticsCounterOptionValue + */ +#define TALER_MERCHANT_get_private_statistics_counter_option_type(t) \ + (const struct TALER_MERCHANT_GetPrivateStatisticsCounterOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_STATISTICS_COUNTER_OPTION_TYPE, \ + .details.type = (t) \ + } + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * @param sch the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_get_private_statistics_counter_set_options_ ( + struct TALER_MERCHANT_GetPrivateStatisticsCounterHandle *sch, + unsigned int num_options, + const struct TALER_MERCHANT_GetPrivateStatisticsCounterOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * It should be used with helpers that create required options, for example: + * + * TALER_MERCHANT_get_private_statistics_counter_set_options ( + * sch, + * TALER_MERCHANT_get_private_statistics_counter_option_type ( + * TALER_MERCHANT_STATISTICS_TYPE_INTERVAL)); + * + * @param sch the request to set the options for + * @param ... the list of the options, each option must be created + * by helpers TALER_MERCHANT_get_private_statistics_counter_option_NAME(VALUE) + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_get_private_statistics_counter_set_options(sch,...) \ + TALER_MERCHANT_get_private_statistics_counter_set_options_ ( \ + sch, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_GetPrivateStatisticsCounterOptionValue[] \ + ) \ + {__VA_ARGS__, \ + TALER_MERCHANT_get_private_statistics_counter_option_end_ () } \ + )) + + +/** + * Statistic counter aggregated by bucket. + */ +struct TALER_MERCHANT_GetPrivateStatisticsCounterByBucket +{ + + /** + * Start time of the bucket (inclusive). + */ + struct GNUNET_TIME_Timestamp start_time; + + /** + * End time of the bucket (exclusive). + */ + struct GNUNET_TIME_Timestamp end_time; + + /** + * Range of the bucket. + */ + const char *range; + + /** + * Sum of all counters falling under the given + * SLUG within this timeframe. + */ + uint64_t cumulative_counter; + +}; + + +/** + * Statistic counter aggregated by interval. + */ +struct TALER_MERCHANT_GetPrivateStatisticsCounterByInterval +{ + + /** + * Start time of the interval (inclusive). + * The interval always ends at the response + * generation time. + */ + struct GNUNET_TIME_Timestamp start_time; + + /** + * Sum of all counters falling under the given + * SLUG within this timeframe. + */ + uint64_t cumulative_counter; + +}; + + +/** + * Response details for a GET /private/statistics-counter/$SLUG request. + */ +struct TALER_MERCHANT_GetPrivateStatisticsCounterResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of bucket entries in @a buckets. + */ + unsigned int buckets_length; + + /** + * Array of counter statistics per bucket. + */ + const struct TALER_MERCHANT_GetPrivateStatisticsCounterByBucket *buckets; + + /** + * Description of the bucket aggregation scheme, or NULL. + */ + const char *buckets_description; + + /** + * Number of interval entries in @a intervals. + */ + unsigned int intervals_length; + + /** + * Array of counter statistics per time interval. + */ + const struct TALER_MERCHANT_GetPrivateStatisticsCounterByInterval * + intervals; + + /** + * Description of the interval aggregation scheme, or NULL. + */ + const char *intervals_description; + + } ok; + + } details; + +}; + + +#ifndef TALER_MERCHANT_GET_PRIVATE_STATISTICS_COUNTER_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateStatisticsCounterCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_STATISTICS_COUNTER_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_STATISTICS_COUNTER_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/statistics-counter/$SLUG request. + * + * @param cls closure + * @param scgr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateStatisticsCounterCallback)( + TALER_MERCHANT_GET_PRIVATE_STATISTICS_COUNTER_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateStatisticsCounterResponse *scgr); + + +/** + * Start GET /private/statistics-counter/$SLUG operation. + * + * @param[in,out] sch operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_statistics_counter_start ( + struct TALER_MERCHANT_GetPrivateStatisticsCounterHandle *sch, + TALER_MERCHANT_GetPrivateStatisticsCounterCallback cb, + TALER_MERCHANT_GET_PRIVATE_STATISTICS_COUNTER_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/statistics-counter/$SLUG operation. This function + * must not be called by clients after the + * TALER_MERCHANT_GetPrivateStatisticsCounterCallback has been invoked + * (as in those cases it'll be called internally by the implementation + * already). + * + * @param[in] sch operation to cancel + */ +void +TALER_MERCHANT_get_private_statistics_counter_cancel ( + struct TALER_MERCHANT_GetPrivateStatisticsCounterHandle *sch); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_STATISTICS_COUNTER_SLUG_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-templates-TEMPLATE_ID-new.h b/src/include/taler/taler-merchant/get-private-templates-TEMPLATE_ID-new.h @@ -0,0 +1,145 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-templates-TEMPLATE_ID-new.h + * @brief C interface for GET /private/templates/$TEMPLATE_ID of the merchant backend + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_TEMPLATE_ID_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_TEMPLATE_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/templates/$TEMPLATE_ID request. + */ +struct TALER_MERCHANT_GetPrivateTemplateHandle; + + +/** + * Response details for a GET /private/templates/$TEMPLATE_ID request. + */ +struct TALER_MERCHANT_GetPrivateTemplateResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Human-readable description of the template. + */ + const char *template_description; + + /** + * OTP device ID associated with this template, or NULL. + */ + const char *otp_id; + + /** + * Template contract (JSON). + */ + const json_t *template_contract; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/templates/$TEMPLATE_ID operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param template_id identifier of the template to retrieve + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateTemplateHandle * +TALER_MERCHANT_get_private_template_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *template_id); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_TEMPLATE_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateTemplateCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_TEMPLATE_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_TEMPLATE_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/templates/$TEMPLATE_ID request. + * + * @param cls closure + * @param tgr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateTemplateCallback)( + TALER_MERCHANT_GET_PRIVATE_TEMPLATE_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateTemplateResponse *tgr); + + +/** + * Start GET /private/templates/$TEMPLATE_ID operation. + * + * @param[in,out] gpt operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_template_start ( + struct TALER_MERCHANT_GetPrivateTemplateHandle *gpt, + TALER_MERCHANT_GetPrivateTemplateCallback cb, + TALER_MERCHANT_GET_PRIVATE_TEMPLATE_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/templates/$TEMPLATE_ID operation. This function + * must not be called by clients after the + * TALER_MERCHANT_GetPrivateTemplateCallback has been invoked + * (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpt operation to cancel + */ +void +TALER_MERCHANT_get_private_template_cancel ( + struct TALER_MERCHANT_GetPrivateTemplateHandle *gpt); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_TEMPLATE_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-templates-new.h b/src/include/taler/taler-merchant/get-private-templates-new.h @@ -0,0 +1,156 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-templates-new.h + * @brief C interface for the GET /private/templates endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/templates request. + */ +struct TALER_MERCHANT_GetPrivateTemplatesHandle; + + +/** + * Entry for one order template. + */ +struct TALER_MERCHANT_GetPrivateTemplatesTemplateEntry +{ + + /** + * Identifier of the template. + */ + const char *template_id; + + /** + * Human-readable description of the template. + */ + const char *template_description; + +}; + + +/** + * Response details for a GET /private/templates request. + */ +struct TALER_MERCHANT_GetPrivateTemplatesResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of templates in @a templates. + */ + unsigned int templates_length; + + /** + * Array of template entries. + */ + const struct TALER_MERCHANT_GetPrivateTemplatesTemplateEntry *templates; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/templates operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateTemplatesHandle * +TALER_MERCHANT_get_private_templates_create ( + struct GNUNET_CURL_Context *ctx, + const char *url); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_TEMPLATES_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateTemplatesCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_TEMPLATES_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_TEMPLATES_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/templates request. + * + * @param cls closure + * @param tgr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateTemplatesCallback)( + TALER_MERCHANT_GET_PRIVATE_TEMPLATES_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateTemplatesResponse *tgr); + + +/** + * Start GET /private/templates operation. + * + * @param[in,out] gpth operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_templates_start ( + struct TALER_MERCHANT_GetPrivateTemplatesHandle *gpth, + TALER_MERCHANT_GetPrivateTemplatesCallback cb, + TALER_MERCHANT_GET_PRIVATE_TEMPLATES_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/templates operation. This function must not be + * called by clients after the TALER_MERCHANT_GetPrivateTemplatesCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpth operation to cancel + */ +void +TALER_MERCHANT_get_private_templates_cancel ( + struct TALER_MERCHANT_GetPrivateTemplatesHandle *gpth); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG-new.h b/src/include/taler/taler-merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG-new.h @@ -0,0 +1,196 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG-new.h + * @brief C interface for GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG + * of the merchant backend + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_TOKENFAMILIES_TOKEN_FAMILY_SLUG_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_TOKENFAMILIES_TOKEN_FAMILY_SLUG_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG request. + */ +struct TALER_MERCHANT_GetPrivateTokenfamiliesHandle; + + +/** + * Response details for a GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG request. + */ +struct TALER_MERCHANT_GetPrivateTokenfamiliesResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * URL-safe slug identifier of the token family. + */ + const char *slug; + + /** + * Human-readable name. + */ + const char *name; + + /** + * Human-readable description. + */ + const char *description; + + /** + * Internationalized descriptions (JSON), or NULL. + */ + const json_t *description_i18n; + + /** + * Extra data associated with this token family (JSON), or NULL. + */ + const json_t *extra_data; + + /** + * Start of validity period. + */ + struct GNUNET_TIME_Timestamp valid_after; + + /** + * End of validity period. + */ + struct GNUNET_TIME_Timestamp valid_before; + + /** + * Duration of individual token validity. + */ + struct GNUNET_TIME_Relative duration; + + /** + * Granularity for validity period alignment. + */ + struct GNUNET_TIME_Relative validity_granularity; + + /** + * Offset from purchase time to start of validity. + */ + struct GNUNET_TIME_Relative start_offset; + + /** + * Kind of token family ("subscription" or "discount"). + */ + const char *kind; + + /** + * Total number of tokens issued. + */ + uint64_t issued; + + /** + * Total number of tokens used. + */ + uint64_t used; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param token_family_slug slug of the token family to retrieve + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateTokenfamiliesHandle * +TALER_MERCHANT_get_private_tokenfamilies_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *token_family_slug); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateTokenfamiliesCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG request. + * + * @param cls closure + * @param tfgr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateTokenfamiliesCallback)( + TALER_MERCHANT_GET_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateTokenfamiliesResponse *tfgr); + + +/** + * Start GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG operation. + * + * @param[in,out] gptf operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_tokenfamilies_start ( + struct TALER_MERCHANT_GetPrivateTokenfamiliesHandle *gptf, + TALER_MERCHANT_GetPrivateTokenfamiliesCallback cb, + TALER_MERCHANT_GET_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG operation. + * This function must not be called by clients after the + * TALER_MERCHANT_GetPrivateTokenfamiliesCallback has been invoked + * (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gptf operation to cancel + */ +void +TALER_MERCHANT_get_private_tokenfamilies_cancel ( + struct TALER_MERCHANT_GetPrivateTokenfamiliesHandle *gptf); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_TOKENFAMILIES_TOKEN_FAMILY_SLUG_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-transfers-new.h b/src/include/taler/taler-merchant/get-private-transfers-new.h @@ -0,0 +1,423 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-transfers-new.h + * @brief C interface for the GET /private/transfers endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_TRANSFERS_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_TRANSFERS_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options we can set for the GET /private/transfers request. + */ +enum TALER_MERCHANT_GetPrivateTransfersOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_END = 0, + + /** + * Filter by payto URI. + */ + TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_PAYTO_URI, + + /** + * Filter for transfers before this time. + */ + TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_BEFORE, + + /** + * Filter for transfers after this time. + */ + TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_AFTER, + + /** + * Return at most N values. Negative values + * to return in descending order, positive for ascending. + * Default is -20. + */ + TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_LIMIT, + + /** + * Starting transfer_serial_id for pagination. + */ + TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_OFFSET, + + /** + * Filter by verification/expected status. + */ + TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_EXPECTED + +}; + + +/** + * Value for an option for the GET /private/transfers request. + */ +struct TALER_MERCHANT_GetPrivateTransfersOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_GetPrivateTransfersOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_PAYTO_URI. + */ + struct TALER_FullPayto payto_uri; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_BEFORE. + */ + struct GNUNET_TIME_Timestamp before; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_AFTER. + */ + struct GNUNET_TIME_Timestamp after; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_LIMIT. + */ + int64_t limit; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_OFFSET. + */ + uint64_t offset; + + /** + * Value if @e option is + * #TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_EXPECTED. + */ + enum TALER_EXCHANGE_YesNoAll expected; + + } details; + +}; + + +/** + * Handle for a GET /private/transfers request. + */ +struct TALER_MERCHANT_GetPrivateTransfersHandle; + + +/** + * Set up GET /private/transfers operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateTransfersHandle * +TALER_MERCHANT_get_private_transfers_create ( + struct GNUNET_CURL_Context *ctx, + const char *url); + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_GetPrivateTransfersOptionValue + */ +#define TALER_MERCHANT_get_private_transfers_option_end_() \ + (const struct TALER_MERCHANT_GetPrivateTransfersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_END \ + } + +/** + * Set payto URI filter. + * + * @param p payto URI to filter by + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateTransfersOptionValue + */ +#define TALER_MERCHANT_get_private_transfers_option_payto_uri(p) \ + (const struct TALER_MERCHANT_GetPrivateTransfersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_PAYTO_URI, \ + .details.payto_uri = (p) \ + } + +/** + * Set filter for transfers before the given timestamp. + * + * @param t timestamp threshold + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateTransfersOptionValue + */ +#define TALER_MERCHANT_get_private_transfers_option_before(t) \ + (const struct TALER_MERCHANT_GetPrivateTransfersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_BEFORE, \ + .details.before = (t) \ + } + +/** + * Set filter for transfers after the given timestamp. + * + * @param t timestamp threshold + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateTransfersOptionValue + */ +#define TALER_MERCHANT_get_private_transfers_option_after(t) \ + (const struct TALER_MERCHANT_GetPrivateTransfersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_AFTER, \ + .details.after = (t) \ + } + +/** + * Set limit on the number of results to return. + * + * @param l limit on the number of results to return + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateTransfersOptionValue + */ +#define TALER_MERCHANT_get_private_transfers_option_limit(l) \ + (const struct TALER_MERCHANT_GetPrivateTransfersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_LIMIT, \ + .details.limit = (l) \ + } + +/** + * Set row offset from which to return results. + * + * @param o offset to use + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateTransfersOptionValue + */ +#define TALER_MERCHANT_get_private_transfers_option_offset(o) \ + (const struct TALER_MERCHANT_GetPrivateTransfersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_OFFSET, \ + .details.offset = (o) \ + } + +/** + * Set filter on expected/verified status. + * + * @param e expected filter to use + * @return representation of the option as a struct TALER_MERCHANT_GetPrivateTransfersOptionValue + */ +#define TALER_MERCHANT_get_private_transfers_option_expected(e) \ + (const struct TALER_MERCHANT_GetPrivateTransfersOptionValue) \ + { \ + .option = TALER_MERCHANT_GET_PRIVATE_TRANSFERS_OPTION_EXPECTED, \ + .details.expected = (e) \ + } + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * @param gth the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_get_private_transfers_set_options_ ( + struct TALER_MERCHANT_GetPrivateTransfersHandle *gth, + unsigned int num_options, + const struct TALER_MERCHANT_GetPrivateTransfersOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * It should be used with helpers that create required options, for example: + * + * TALER_MERCHANT_get_private_transfers_set_options ( + * gth, + * TALER_MERCHANT_get_private_transfers_option_limit (-20), + * TALER_MERCHANT_get_private_transfers_option_expected ( + * TALER_EXCHANGE_YNA_YES)); + * + * @param gth the request to set the options for + * @param ... the list of the options, each option must be created + * by helpers TALER_MERCHANT_get_private_transfers_option_NAME(VALUE) + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_get_private_transfers_set_options(gth,...) \ + TALER_MERCHANT_get_private_transfers_set_options_ ( \ + gth, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_GetPrivateTransfersOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_get_private_transfers_option_end_ () } \ + )) + + +/** + * Transfer data entry. + */ +struct TALER_MERCHANT_GetPrivateTransfersTransferData +{ + + /** + * Total amount wired by the exchange (without wire fee). + */ + struct TALER_Amount credit_amount; + + /** + * Wire transfer identifier used. + */ + struct TALER_WireTransferIdentifierRawP wtid; + + /** + * URI of the target account. + */ + struct TALER_FullPayto payto_uri; + + /** + * URL of the exchange that made the transfer. + */ + const char *exchange_url; + + /** + * Serial number of the credit operation in the merchant backend. + */ + uint64_t credit_serial; + + /** + * Time of the wire transfer, based on when we received + * a confirmation for the wire transfer. + */ + struct GNUNET_TIME_Timestamp execution_time; + + /** + * True if this wire transfer was expected. + */ + bool expected; + +}; + + +/** + * Response details for a GET /private/transfers request. + */ +struct TALER_MERCHANT_GetPrivateTransfersResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of transfers in @a transfers. + */ + unsigned int transfers_length; + + /** + * Array of transfer data entries. + */ + const struct TALER_MERCHANT_GetPrivateTransfersTransferData *transfers; + + } ok; + + } details; + +}; + + +#ifndef TALER_MERCHANT_GET_PRIVATE_TRANSFERS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateTransfersCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_TRANSFERS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_TRANSFERS_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/transfers request. + * + * @param cls closure + * @param gtr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateTransfersCallback)( + TALER_MERCHANT_GET_PRIVATE_TRANSFERS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateTransfersResponse *gtr); + + +/** + * Start GET /private/transfers operation. + * + * @param[in,out] gth operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_transfers_start ( + struct TALER_MERCHANT_GetPrivateTransfersHandle *gth, + TALER_MERCHANT_GetPrivateTransfersCallback cb, + TALER_MERCHANT_GET_PRIVATE_TRANSFERS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/transfers operation. This function must not be + * called by clients after the TALER_MERCHANT_GetPrivateTransfersCallback + * has been invoked (as in those cases it'll be called internally by + * the implementation already). + * + * @param[in] gth operation to cancel + */ +void +TALER_MERCHANT_get_private_transfers_cancel ( + struct TALER_MERCHANT_GetPrivateTransfersHandle *gth); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_TRANSFERS_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-units-UNIT-new.h b/src/include/taler/taler-merchant/get-private-units-UNIT-new.h @@ -0,0 +1,135 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-units-UNIT-new.h + * @brief C interface for GET /private/units/$UNIT of the merchant backend + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_UNITS_UNIT_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_UNITS_UNIT_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/units/$UNIT request. + */ +struct TALER_MERCHANT_GetPrivateUnitHandle; + + +/** + * Response details for a GET /private/units/$UNIT request. + */ +struct TALER_MERCHANT_GetPrivateUnitResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Detailed unit information. + */ + struct TALER_MERCHANT_UnitEntry unit; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/units/$UNIT operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param unit_id identifier of the unit to retrieve + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateUnitHandle * +TALER_MERCHANT_get_private_unit_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *unit_id); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_UNIT_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateUnitCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_UNIT_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_UNIT_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/units/$UNIT request. + * + * @param cls closure + * @param ugr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateUnitCallback)( + TALER_MERCHANT_GET_PRIVATE_UNIT_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateUnitResponse *ugr); + + +/** + * Start GET /private/units/$UNIT operation. + * + * @param[in,out] gpu operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_unit_start ( + struct TALER_MERCHANT_GetPrivateUnitHandle *gpu, + TALER_MERCHANT_GetPrivateUnitCallback cb, + TALER_MERCHANT_GET_PRIVATE_UNIT_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/units/$UNIT operation. This function + * must not be called by clients after the + * TALER_MERCHANT_GetPrivateUnitCallback has been invoked + * (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpu operation to cancel + */ +void +TALER_MERCHANT_get_private_unit_cancel ( + struct TALER_MERCHANT_GetPrivateUnitHandle *gpu); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_UNITS_UNIT_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-units-new.h b/src/include/taler/taler-merchant/get-private-units-new.h @@ -0,0 +1,137 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-units-new.h + * @brief C interface for the GET /private/units endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_UNITS_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_UNITS_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/units request. + */ +struct TALER_MERCHANT_GetPrivateUnitsHandle; + + +/** + * Response details for a GET /private/units request. + */ +struct TALER_MERCHANT_GetPrivateUnitsResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of units in @a units. + */ + unsigned int units_length; + + /** + * Array of unit entries. + */ + const struct TALER_MERCHANT_UnitEntry *units; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/units operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateUnitsHandle * +TALER_MERCHANT_get_private_units_create ( + struct GNUNET_CURL_Context *ctx, + const char *url); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_UNITS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateUnitsCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_UNITS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_UNITS_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/units request. + * + * @param cls closure + * @param ugr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateUnitsCallback)( + TALER_MERCHANT_GET_PRIVATE_UNITS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateUnitsResponse *ugr); + + +/** + * Start GET /private/units operation. + * + * @param[in,out] gpuh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_units_start ( + struct TALER_MERCHANT_GetPrivateUnitsHandle *gpuh, + TALER_MERCHANT_GetPrivateUnitsCallback cb, + TALER_MERCHANT_GET_PRIVATE_UNITS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/units operation. This function must not be + * called by clients after the TALER_MERCHANT_GetPrivateUnitsCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpuh operation to cancel + */ +void +TALER_MERCHANT_get_private_units_cancel ( + struct TALER_MERCHANT_GetPrivateUnitsHandle *gpuh); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_UNITS_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-webhooks-WEBHOOK_ID-new.h b/src/include/taler/taler-merchant/get-private-webhooks-WEBHOOK_ID-new.h @@ -0,0 +1,156 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-webhooks-WEBHOOK_ID-new.h + * @brief C interface for GET /private/webhooks/$WEBHOOK_ID of the merchant backend + * @author Priscilla Huang + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_WEBHOOK_ID_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_WEBHOOK_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/webhooks/$WEBHOOK_ID request. + */ +struct TALER_MERCHANT_GetPrivateWebhookHandle; + + +/** + * Response details for a GET /private/webhooks/$WEBHOOK_ID request. + */ +struct TALER_MERCHANT_GetPrivateWebhookResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Event type that triggers this webhook. + */ + const char *event_type; + + /** + * URL to send the webhook notification to. + */ + const char *url; + + /** + * HTTP method to use. + */ + const char *http_method; + + /** + * Template for HTTP headers, or NULL. + */ + const char *header_template; + + /** + * Template for the HTTP body, or NULL. + */ + const char *body_template; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/webhooks/$WEBHOOK_ID operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param webhook_id identifier of the webhook to retrieve + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateWebhookHandle * +TALER_MERCHANT_get_private_webhook_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *webhook_id); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_WEBHOOK_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateWebhookCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_WEBHOOK_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_WEBHOOK_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/webhooks/$WEBHOOK_ID request. + * + * @param cls closure + * @param wgr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateWebhookCallback)( + TALER_MERCHANT_GET_PRIVATE_WEBHOOK_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateWebhookResponse *wgr); + + +/** + * Start GET /private/webhooks/$WEBHOOK_ID operation. + * + * @param[in,out] gpw operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_webhook_start ( + struct TALER_MERCHANT_GetPrivateWebhookHandle *gpw, + TALER_MERCHANT_GetPrivateWebhookCallback cb, + TALER_MERCHANT_GET_PRIVATE_WEBHOOK_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/webhooks/$WEBHOOK_ID operation. This function + * must not be called by clients after the + * TALER_MERCHANT_GetPrivateWebhookCallback has been invoked + * (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpw operation to cancel + */ +void +TALER_MERCHANT_get_private_webhook_cancel ( + struct TALER_MERCHANT_GetPrivateWebhookHandle *gpw); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_WEBHOOK_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-private-webhooks-new.h b/src/include/taler/taler-merchant/get-private-webhooks-new.h @@ -0,0 +1,156 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-private-webhooks-new.h + * @brief C interface for the GET /private/webhooks endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_NEW_H +#define _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /private/webhooks request. + */ +struct TALER_MERCHANT_GetPrivateWebhooksHandle; + + +/** + * Entry for one webhook. + */ +struct TALER_MERCHANT_GetPrivateWebhooksWebhookEntry +{ + + /** + * Identifier of the webhook. + */ + const char *webhook_id; + + /** + * Event type that triggers this webhook. + */ + const char *event_type; + +}; + + +/** + * Response details for a GET /private/webhooks request. + */ +struct TALER_MERCHANT_GetPrivateWebhooksResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of webhooks in @a webhooks. + */ + unsigned int webhooks_length; + + /** + * Array of webhook entries. + */ + const struct TALER_MERCHANT_GetPrivateWebhooksWebhookEntry *webhooks; + + } ok; + + } details; + +}; + + +/** + * Set up GET /private/webhooks operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @return handle to operation + */ +struct TALER_MERCHANT_GetPrivateWebhooksHandle * +TALER_MERCHANT_get_private_webhooks_create ( + struct GNUNET_CURL_Context *ctx, + const char *url); + + +#ifndef TALER_MERCHANT_GET_PRIVATE_WEBHOOKS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetPrivateWebhooksCallback. + */ +#define TALER_MERCHANT_GET_PRIVATE_WEBHOOKS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRIVATE_WEBHOOKS_RESULT_CLOSURE */ + +/** + * Callback for a GET /private/webhooks request. + * + * @param cls closure + * @param wgr response details + */ +typedef void +(*TALER_MERCHANT_GetPrivateWebhooksCallback)( + TALER_MERCHANT_GET_PRIVATE_WEBHOOKS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetPrivateWebhooksResponse *wgr); + + +/** + * Start GET /private/webhooks operation. + * + * @param[in,out] gpwh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_private_webhooks_start ( + struct TALER_MERCHANT_GetPrivateWebhooksHandle *gpwh, + TALER_MERCHANT_GetPrivateWebhooksCallback cb, + TALER_MERCHANT_GET_PRIVATE_WEBHOOKS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /private/webhooks operation. This function must not be + * called by clients after the TALER_MERCHANT_GetPrivateWebhooksCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpwh operation to cancel + */ +void +TALER_MERCHANT_get_private_webhooks_cancel ( + struct TALER_MERCHANT_GetPrivateWebhooksHandle *gpwh); + + +#endif /* _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-products-IMAGE_HASH-image-new.h b/src/include/taler/taler-merchant/get-products-IMAGE_HASH-image-new.h @@ -0,0 +1,135 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-products-IMAGE_HASH-image-new.h + * @brief C interface for GET /products/$IMAGE_HASH/image of the merchant backend + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_PRODUCTS_IMAGE_HASH_IMAGE_NEW_H +#define _TALER_MERCHANT__GET_PRODUCTS_IMAGE_HASH_IMAGE_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /products/$IMAGE_HASH/image request. + */ +struct TALER_MERCHANT_GetProductsImageHandle; + + +/** + * Response details for a GET /products/$IMAGE_HASH/image request. + */ +struct TALER_MERCHANT_GetProductsImageResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Image data (a data URI). + */ + const char *image; + + } ok; + + } details; + +}; + + +/** + * Set up GET /products/$IMAGE_HASH/image operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param image_hash hash identifying the image to retrieve + * @return handle to operation + */ +struct TALER_MERCHANT_GetProductsImageHandle * +TALER_MERCHANT_get_products_image_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *image_hash); + + +#ifndef TALER_MERCHANT_GET_PRODUCTS_IMAGE_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetProductsImageCallback. + */ +#define TALER_MERCHANT_GET_PRODUCTS_IMAGE_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_PRODUCTS_IMAGE_RESULT_CLOSURE */ + +/** + * Callback for a GET /products/$IMAGE_HASH/image request. + * + * @param cls closure + * @param pgr response details + */ +typedef void +(*TALER_MERCHANT_GetProductsImageCallback)( + TALER_MERCHANT_GET_PRODUCTS_IMAGE_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetProductsImageResponse *pgr); + + +/** + * Start GET /products/$IMAGE_HASH/image operation. + * + * @param[in,out] gpi operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_products_image_start ( + struct TALER_MERCHANT_GetProductsImageHandle *gpi, + TALER_MERCHANT_GetProductsImageCallback cb, + TALER_MERCHANT_GET_PRODUCTS_IMAGE_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /products/$IMAGE_HASH/image operation. This function + * must not be called by clients after the + * TALER_MERCHANT_GetProductsImageCallback has been invoked + * (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gpi operation to cancel + */ +void +TALER_MERCHANT_get_products_image_cancel ( + struct TALER_MERCHANT_GetProductsImageHandle *gpi); + + +#endif /* _TALER_MERCHANT__GET_PRODUCTS_IMAGE_HASH_IMAGE_NEW_H */ diff --git a/src/include/taler/taler-merchant/get-templates-TEMPLATE_ID-new.h b/src/include/taler/taler-merchant/get-templates-TEMPLATE_ID-new.h @@ -0,0 +1,135 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/get-templates-TEMPLATE_ID-new.h + * @brief C interface for GET /templates/$TEMPLATE_ID (wallet-facing) of the merchant backend + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__GET_TEMPLATES_TEMPLATE_ID_NEW_H +#define _TALER_MERCHANT__GET_TEMPLATES_TEMPLATE_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a GET /templates/$TEMPLATE_ID request (wallet-facing). + */ +struct TALER_MERCHANT_GetTemplatesHandle; + + +/** + * Response details for a GET /templates/$TEMPLATE_ID request (wallet-facing). + */ +struct TALER_MERCHANT_GetTemplatesResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Template contract (JSON). + */ + const json_t *template_contract; + + } ok; + + } details; + +}; + + +/** + * Set up GET /templates/$TEMPLATE_ID operation (wallet-facing). + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param template_id identifier of the template to retrieve + * @return handle to operation + */ +struct TALER_MERCHANT_GetTemplatesHandle * +TALER_MERCHANT_get_templates_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *template_id); + + +#ifndef TALER_MERCHANT_GET_TEMPLATES_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_GetTemplatesCallback. + */ +#define TALER_MERCHANT_GET_TEMPLATES_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_GET_TEMPLATES_RESULT_CLOSURE */ + +/** + * Callback for a GET /templates/$TEMPLATE_ID request (wallet-facing). + * + * @param cls closure + * @param wtgr response details + */ +typedef void +(*TALER_MERCHANT_GetTemplatesCallback)( + TALER_MERCHANT_GET_TEMPLATES_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_GetTemplatesResponse *wtgr); + + +/** + * Start GET /templates/$TEMPLATE_ID operation (wallet-facing). + * + * @param[in,out] gth operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_get_templates_start ( + struct TALER_MERCHANT_GetTemplatesHandle *gth, + TALER_MERCHANT_GetTemplatesCallback cb, + TALER_MERCHANT_GET_TEMPLATES_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel GET /templates/$TEMPLATE_ID operation (wallet-facing). + * This function must not be called by clients after the + * TALER_MERCHANT_GetTemplatesCallback has been invoked + * (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] gth operation to cancel + */ +void +TALER_MERCHANT_get_templates_cancel ( + struct TALER_MERCHANT_GetTemplatesHandle *gth); + + +#endif /* _TALER_MERCHANT__GET_TEMPLATES_TEMPLATE_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/patch-management-instances-INSTANCE-new.h b/src/include/taler/taler-merchant/patch-management-instances-INSTANCE-new.h @@ -0,0 +1,123 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/patch-management-instances-INSTANCE-new.h + * @brief C interface for PATCH /management/instances/$INSTANCE + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__PATCH_MANAGEMENT_INSTANCES_INSTANCE_NEW_H +#define _TALER_MERCHANT__PATCH_MANAGEMENT_INSTANCES_INSTANCE_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a PATCH /management/instances/$INSTANCE operation. + */ +struct TALER_MERCHANT_PatchManagementInstancesHandle; + + +/** + * Set up PATCH /management/instances/$INSTANCE operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param instance_id identifier of the instance to patch + * @param name new human-readable name + * @param address new address (JSON) + * @param jurisdiction new jurisdiction (JSON) + * @param use_stefan whether to use the STEFAN curve for fee calculations + * @param default_wire_transfer_delay default delay for wire transfers + * @param default_pay_delay default payment deadline + * @param default_refund_delay default refund deadline + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_PatchManagementInstancesHandle * +TALER_MERCHANT_patch_management_instances_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *instance_id, + const char *name, + const json_t *address, + const json_t *jurisdiction, + bool use_stefan, + struct GNUNET_TIME_Relative default_wire_transfer_delay, + struct GNUNET_TIME_Relative default_pay_delay, + struct GNUNET_TIME_Relative default_refund_delay); + + +/** + * Response details for a PATCH /management/instances/$INSTANCE request. + */ +struct TALER_MERCHANT_PatchManagementInstancesResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_PATCH_MANAGEMENT_INSTANCES_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PatchManagementInstancesCallback. + */ +#define TALER_MERCHANT_PATCH_MANAGEMENT_INSTANCES_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_PATCH_MANAGEMENT_INSTANCES_RESULT_CLOSURE */ + +/** + * Callback for a PATCH /management/instances/$INSTANCE request. + * + * @param cls closure + * @param result response details + */ +typedef void +(*TALER_MERCHANT_PatchManagementInstancesCallback)( + TALER_MERCHANT_PATCH_MANAGEMENT_INSTANCES_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PatchManagementInstancesResponse *result); + + +/** + * Start PATCH /management/instances/$INSTANCE operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_patch_management_instances_start ( + struct TALER_MERCHANT_PatchManagementInstancesHandle *handle, + TALER_MERCHANT_PatchManagementInstancesCallback cb, + TALER_MERCHANT_PATCH_MANAGEMENT_INSTANCES_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel PATCH /management/instances/$INSTANCE operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_patch_management_instances_cancel ( + struct TALER_MERCHANT_PatchManagementInstancesHandle *handle); + + +#endif /* _TALER_MERCHANT__PATCH_MANAGEMENT_INSTANCES_INSTANCE_NEW_H */ diff --git a/src/include/taler/taler-merchant/patch-private-accounts-H_WIRE-new.h b/src/include/taler/taler-merchant/patch-private-accounts-H_WIRE-new.h @@ -0,0 +1,254 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/patch-private-accounts-H_WIRE-new.h + * @brief C interface for PATCH /private/accounts/$H_WIRE + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__PATCH_PRIVATE_ACCOUNTS_H_WIRE_NEW_H +#define _TALER_MERCHANT__PATCH_PRIVATE_ACCOUNTS_H_WIRE_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options we can set for the PATCH /private/accounts/$H_WIRE request. + */ +enum TALER_MERCHANT_PatchPrivateAccountOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_OPTION_END = 0, + + /** + * Set the credit facade URL. + */ + TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_OPTION_CREDIT_FACADE_URL, + + /** + * Set the credit facade credentials (JSON). + */ + TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_OPTION_CREDIT_FACADE_CREDENTIALS + +}; + + +/** + * Value for an option for the PATCH /private/accounts/$H_WIRE request. + */ +struct TALER_MERCHANT_PatchPrivateAccountOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PatchPrivateAccountOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_OPTION_CREDIT_FACADE_URL. + */ + const char *credit_facade_url; + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_OPTION_CREDIT_FACADE_CREDENTIALS. + */ + const json_t *credit_facade_credentials; + + } details; + +}; + + +/** + * Handle for a PATCH /private/accounts/$H_WIRE operation. + */ +struct TALER_MERCHANT_PatchPrivateAccountHandle; + + +/** + * Set up PATCH /private/accounts/$H_WIRE operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param h_wire hash of the wire details identifying the account + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_PatchPrivateAccountHandle * +TALER_MERCHANT_patch_private_account_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const struct TALER_MerchantWireHashP *h_wire); + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_PatchPrivateAccountOptionValue + */ +#define TALER_MERCHANT_patch_private_account_option_end_() \ + (const struct TALER_MERCHANT_PatchPrivateAccountOptionValue) \ + { \ + .option = TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_OPTION_END \ + } + +/** + * Set credit facade URL. + * + * @param u credit facade URL to set + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateAccountOptionValue + */ +#define TALER_MERCHANT_patch_private_account_option_credit_facade_url(u) \ + (const struct TALER_MERCHANT_PatchPrivateAccountOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_OPTION_CREDIT_FACADE_URL, \ + .details.credit_facade_url = (u) \ + } + +/** + * Set credit facade credentials. + * + * @param c credit facade credentials (JSON) to set + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateAccountOptionValue + */ +#define TALER_MERCHANT_patch_private_account_option_credit_facade_credentials(c) \ + (const struct TALER_MERCHANT_PatchPrivateAccountOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_OPTION_CREDIT_FACADE_CREDENTIALS, \ + .details.credit_facade_credentials = (c) \ + } + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * @param pah the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_patch_private_account_set_options_ ( + struct TALER_MERCHANT_PatchPrivateAccountHandle *pah, + unsigned int num_options, + const struct TALER_MERCHANT_PatchPrivateAccountOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * It should be used with helpers that create required options, for example: + * + * TALER_MERCHANT_patch_private_account_set_options ( + * pah, + * TALER_MERCHANT_patch_private_account_option_credit_facade_url ( + * "https://example.com/facade")); + * + * @param pah the request to set the options for + * @param ... the list of the options, each option must be created + * by helpers TALER_MERCHANT_patch_private_account_option_NAME(VALUE) + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_patch_private_account_set_options(pah,...) \ + TALER_MERCHANT_patch_private_account_set_options_ ( \ + pah, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PatchPrivateAccountOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_patch_private_account_option_end_ () } \ + )) + + +/** + * Response details for a PATCH /private/accounts/$H_WIRE request. + */ +struct TALER_MERCHANT_PatchPrivateAccountResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PatchPrivateAccountCallback. + */ +#define TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_RESULT_CLOSURE */ + +/** + * Callback for a PATCH /private/accounts/$H_WIRE request. + * + * @param cls closure + * @param result response details + */ +typedef void +(*TALER_MERCHANT_PatchPrivateAccountCallback)( + TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PatchPrivateAccountResponse *result); + + +/** + * Start PATCH /private/accounts/$H_WIRE operation. + * + * @param[in,out] pah operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_patch_private_account_start ( + struct TALER_MERCHANT_PatchPrivateAccountHandle *pah, + TALER_MERCHANT_PatchPrivateAccountCallback cb, + TALER_MERCHANT_PATCH_PRIVATE_ACCOUNT_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel PATCH /private/accounts/$H_WIRE operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] pah operation to cancel + */ +void +TALER_MERCHANT_patch_private_account_cancel ( + struct TALER_MERCHANT_PatchPrivateAccountHandle *pah); + + +#endif /* _TALER_MERCHANT__PATCH_PRIVATE_ACCOUNTS_H_WIRE_NEW_H */ diff --git a/src/include/taler/taler-merchant/patch-private-orders-ORDER_ID-forget-new.h b/src/include/taler/taler-merchant/patch-private-orders-ORDER_ID-forget-new.h @@ -0,0 +1,113 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/patch-private-orders-ORDER_ID-forget-new.h + * @brief C interface for PATCH /private/orders/$ORDER_ID/forget + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__PATCH_PRIVATE_ORDERS_ORDER_ID_FORGET_NEW_H +#define _TALER_MERCHANT__PATCH_PRIVATE_ORDERS_ORDER_ID_FORGET_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a PATCH /private/orders/$ORDER_ID/forget operation. + */ +struct TALER_MERCHANT_PatchPrivateOrdersForgetHandle; + + +/** + * Set up PATCH /private/orders/$ORDER_ID/forget operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param order_id identifier of the order + * @param fields_length number of field paths in @a fields + * @param fields array of JSON pointer paths to redact + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_PatchPrivateOrdersForgetHandle * +TALER_MERCHANT_patch_private_orders_forget_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *order_id, + unsigned int fields_length, + const char *fields[static fields_length]); + + +/** + * Response details for a PATCH /private/orders/$ORDER_ID/forget request. + */ +struct TALER_MERCHANT_PatchPrivateOrdersForgetResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_PATCH_PRIVATE_ORDERS_FORGET_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PatchPrivateOrdersForgetCallback. + */ +#define TALER_MERCHANT_PATCH_PRIVATE_ORDERS_FORGET_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_PATCH_PRIVATE_ORDERS_FORGET_RESULT_CLOSURE */ + +/** + * Callback for a PATCH /private/orders/$ORDER_ID/forget request. + * + * @param cls closure + * @param result response details + */ +typedef void +(*TALER_MERCHANT_PatchPrivateOrdersForgetCallback)( + TALER_MERCHANT_PATCH_PRIVATE_ORDERS_FORGET_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PatchPrivateOrdersForgetResponse *result); + + +/** + * Start PATCH /private/orders/$ORDER_ID/forget operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_patch_private_orders_forget_start ( + struct TALER_MERCHANT_PatchPrivateOrdersForgetHandle *handle, + TALER_MERCHANT_PatchPrivateOrdersForgetCallback cb, + TALER_MERCHANT_PATCH_PRIVATE_ORDERS_FORGET_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel PATCH /private/orders/$ORDER_ID/forget operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_patch_private_orders_forget_cancel ( + struct TALER_MERCHANT_PatchPrivateOrdersForgetHandle *handle); + + +#endif /* _TALER_MERCHANT__PATCH_PRIVATE_ORDERS_ORDER_ID_FORGET_NEW_H */ diff --git a/src/include/taler/taler-merchant/patch-private-otp-devices-DEVICE_ID-new.h b/src/include/taler/taler-merchant/patch-private-otp-devices-DEVICE_ID-new.h @@ -0,0 +1,117 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/patch-private-otp-devices-DEVICE_ID-new.h + * @brief C interface for PATCH /private/otp-devices/$DEVICE_ID + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__PATCH_PRIVATE_OTP_DEVICES_DEVICE_ID_NEW_H +#define _TALER_MERCHANT__PATCH_PRIVATE_OTP_DEVICES_DEVICE_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a PATCH /private/otp-devices/$DEVICE_ID operation. + */ +struct TALER_MERCHANT_PatchPrivateOtpDeviceHandle; + + +/** + * Set up PATCH /private/otp-devices/$DEVICE_ID operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param otp_device_id identifier of the OTP device to update + * @param otp_device_description new human-readable description + * @param otp_key new base32-encoded OTP secret key, or NULL to keep unchanged + * @param mca new OTP algorithm + * @param otp_ctr new counter value (for HOTP) + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_PatchPrivateOtpDeviceHandle * +TALER_MERCHANT_patch_private_otp_device_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *otp_device_id, + const char *otp_device_description, + const char *otp_key, + enum TALER_MerchantConfirmationAlgorithm mca, + uint64_t otp_ctr); + + +/** + * Response details for a PATCH /private/otp-devices/$DEVICE_ID request. + */ +struct TALER_MERCHANT_PatchPrivateOtpDeviceResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_PATCH_PRIVATE_OTP_DEVICE_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PatchPrivateOtpDeviceCallback. + */ +#define TALER_MERCHANT_PATCH_PRIVATE_OTP_DEVICE_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_PATCH_PRIVATE_OTP_DEVICE_RESULT_CLOSURE */ + +/** + * Callback for a PATCH /private/otp-devices/$DEVICE_ID request. + * + * @param cls closure + * @param result response details + */ +typedef void +(*TALER_MERCHANT_PatchPrivateOtpDeviceCallback)( + TALER_MERCHANT_PATCH_PRIVATE_OTP_DEVICE_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PatchPrivateOtpDeviceResponse *result); + + +/** + * Start PATCH /private/otp-devices/$DEVICE_ID operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_patch_private_otp_device_start ( + struct TALER_MERCHANT_PatchPrivateOtpDeviceHandle *handle, + TALER_MERCHANT_PatchPrivateOtpDeviceCallback cb, + TALER_MERCHANT_PATCH_PRIVATE_OTP_DEVICE_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel PATCH /private/otp-devices/$DEVICE_ID operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_patch_private_otp_device_cancel ( + struct TALER_MERCHANT_PatchPrivateOtpDeviceHandle *handle); + + +#endif /* _TALER_MERCHANT__PATCH_PRIVATE_OTP_DEVICES_DEVICE_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/patch-private-products-PRODUCT_ID-new.h b/src/include/taler/taler-merchant/patch-private-products-PRODUCT_ID-new.h @@ -0,0 +1,336 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/patch-private-products-PRODUCT_ID-new.h + * @brief C interface for PATCH /private/products/$PRODUCT_ID + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__PATCH_PRIVATE_PRODUCTS_PRODUCT_ID_NEW_H +#define _TALER_MERCHANT__PATCH_PRIVATE_PRODUCTS_PRODUCT_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options we can set for the PATCH /private/products/$PRODUCT_ID request. + */ +enum TALER_MERCHANT_PatchPrivateProductOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_END = 0, + + /** + * Set unit prices array (for patch2 variant with full unit/fraction support). + */ + TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_UNIT_PRICES, + + /** + * Set fractional part of total stock. + */ + TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_TOTAL_STOCK_FRAC, + + /** + * Set whether fractional quantities are allowed. + */ + TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_UNIT_ALLOW_FRACTION, + + /** + * Set precision level for fractions. + */ + TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_UNIT_PRECISION_LEVEL + +}; + + +/** + * Value for an option for the PATCH /private/products/$PRODUCT_ID request. + */ +struct TALER_MERCHANT_PatchPrivateProductOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PatchPrivateProductOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_UNIT_PRICES. + */ + struct + { + /** + * Array of unit prices. + */ + const struct TALER_Amount *unit_prices; + + /** + * Number of prices in @e unit_prices. + */ + size_t unit_price_len; + + } unit_prices; + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_TOTAL_STOCK_FRAC. + */ + uint32_t total_stock_frac; + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_UNIT_ALLOW_FRACTION. + */ + bool unit_allow_fraction; + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_UNIT_PRECISION_LEVEL. + */ + uint32_t unit_precision_level; + + } details; + +}; + + +/** + * Handle for a PATCH /private/products/$PRODUCT_ID operation. + */ +struct TALER_MERCHANT_PatchPrivateProductHandle; + + +/** + * Set up PATCH /private/products/$PRODUCT_ID operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param product_id identifier of the product to update + * @param description new human-readable description + * @param description_i18n internationalized descriptions (JSON) + * @param unit unit of measurement + * @param price new unit price + * @param image new base64-encoded image + * @param taxes new tax information (JSON array) + * @param total_stock new total stock (-1 for unlimited) + * @param total_lost total units lost/expired + * @param address storage location (JSON) + * @param next_restock expected restock time + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_PatchPrivateProductHandle * +TALER_MERCHANT_patch_private_product_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *product_id, + const char *description, + const json_t *description_i18n, + const char *unit, + const struct TALER_Amount *price, + const char *image, + const json_t *taxes, + int64_t total_stock, + uint64_t total_lost, + const json_t *address, + struct GNUNET_TIME_Timestamp next_restock); + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_PatchPrivateProductOptionValue + */ +#define TALER_MERCHANT_patch_private_product_option_end_() \ + (const struct TALER_MERCHANT_PatchPrivateProductOptionValue) \ + { \ + .option = TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_END \ + } + +/** + * Set unit prices array. + * + * @param p pointer to array of unit prices + * @param l number of prices in the array + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateProductOptionValue + */ +#define TALER_MERCHANT_patch_private_product_option_unit_prices(p,l) \ + (const struct TALER_MERCHANT_PatchPrivateProductOptionValue) \ + { \ + .option = TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_UNIT_PRICES, \ + .details.unit_prices = { .unit_prices = (p), .unit_price_len = (l) } \ + } + +/** + * Set fractional part of total stock. + * + * @param f fractional stock value + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateProductOptionValue + */ +#define TALER_MERCHANT_patch_private_product_option_total_stock_frac(f) \ + (const struct TALER_MERCHANT_PatchPrivateProductOptionValue) \ + { \ + .option = TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_TOTAL_STOCK_FRAC \ + , \ + .details.total_stock_frac = (f) \ + } + +/** + * Set whether fractional quantities are allowed. + * + * @param a true if fractional quantities are allowed + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateProductOptionValue + */ +#define TALER_MERCHANT_patch_private_product_option_unit_allow_fraction(a) \ + (const struct TALER_MERCHANT_PatchPrivateProductOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_UNIT_ALLOW_FRACTION, \ + .details.unit_allow_fraction = (a) \ + } + +/** + * Set precision level for fractions. + * + * @param p precision level value + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateProductOptionValue + */ +#define TALER_MERCHANT_patch_private_product_option_unit_precision_level(p) \ + (const struct TALER_MERCHANT_PatchPrivateProductOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_OPTION_UNIT_PRECISION_LEVEL, \ + .details.unit_precision_level = (p) \ + } + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * @param pph the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_patch_private_product_set_options_ ( + struct TALER_MERCHANT_PatchPrivateProductHandle *pph, + unsigned int num_options, + const struct TALER_MERCHANT_PatchPrivateProductOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * It should be used with helpers that create required options, for example: + * + * TALER_MERCHANT_patch_private_product_set_options ( + * pph, + * TALER_MERCHANT_patch_private_product_option_total_stock_frac (500), + * TALER_MERCHANT_patch_private_product_option_unit_allow_fraction (true)); + * + * @param pph the request to set the options for + * @param ... the list of the options, each option must be created + * by helpers TALER_MERCHANT_patch_private_product_option_NAME(VALUE) + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_patch_private_product_set_options(pph,...) \ + TALER_MERCHANT_patch_private_product_set_options_ ( \ + pph, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PatchPrivateProductOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_patch_private_product_option_end_ () } \ + )) + + +/** + * Response details for a PATCH /private/products/$PRODUCT_ID request. + */ +struct TALER_MERCHANT_PatchPrivateProductResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PatchPrivateProductCallback. + */ +#define TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_RESULT_CLOSURE */ + +/** + * Callback for a PATCH /private/products/$PRODUCT_ID request. + * + * @param cls closure + * @param result response details + */ +typedef void +(*TALER_MERCHANT_PatchPrivateProductCallback)( + TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PatchPrivateProductResponse *result); + + +/** + * Start PATCH /private/products/$PRODUCT_ID operation. + * + * @param[in,out] pph operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_patch_private_product_start ( + struct TALER_MERCHANT_PatchPrivateProductHandle *pph, + TALER_MERCHANT_PatchPrivateProductCallback cb, + TALER_MERCHANT_PATCH_PRIVATE_PRODUCT_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel PATCH /private/products/$PRODUCT_ID operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] pph operation to cancel + */ +void +TALER_MERCHANT_patch_private_product_cancel ( + struct TALER_MERCHANT_PatchPrivateProductHandle *pph); + + +#endif /* _TALER_MERCHANT__PATCH_PRIVATE_PRODUCTS_PRODUCT_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/patch-private-templates-TEMPLATE_ID-new.h b/src/include/taler/taler-merchant/patch-private-templates-TEMPLATE_ID-new.h @@ -0,0 +1,115 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/patch-private-templates-TEMPLATE_ID-new.h + * @brief C interface for PATCH /private/templates/$TEMPLATE_ID + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__PATCH_PRIVATE_TEMPLATES_TEMPLATE_ID_NEW_H +#define _TALER_MERCHANT__PATCH_PRIVATE_TEMPLATES_TEMPLATE_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a PATCH /private/templates/$TEMPLATE_ID operation. + */ +struct TALER_MERCHANT_PatchPrivateTemplateHandle; + + +/** + * Set up PATCH /private/templates/$TEMPLATE_ID operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param template_id identifier of the template to update + * @param template_description new human-readable description + * @param otp_id new OTP device ID, or NULL to remove association + * @param template_contract new template contract (JSON) + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_PatchPrivateTemplateHandle * +TALER_MERCHANT_patch_private_template_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *template_id, + const char *template_description, + const char *otp_id, + json_t *template_contract); + + +/** + * Response details for a PATCH /private/templates/$TEMPLATE_ID request. + */ +struct TALER_MERCHANT_PatchPrivateTemplateResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_PATCH_PRIVATE_TEMPLATE_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PatchPrivateTemplateCallback. + */ +#define TALER_MERCHANT_PATCH_PRIVATE_TEMPLATE_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_PATCH_PRIVATE_TEMPLATE_RESULT_CLOSURE */ + +/** + * Callback for a PATCH /private/templates/$TEMPLATE_ID request. + * + * @param cls closure + * @param result response details + */ +typedef void +(*TALER_MERCHANT_PatchPrivateTemplateCallback)( + TALER_MERCHANT_PATCH_PRIVATE_TEMPLATE_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PatchPrivateTemplateResponse *result); + + +/** + * Start PATCH /private/templates/$TEMPLATE_ID operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_patch_private_template_start ( + struct TALER_MERCHANT_PatchPrivateTemplateHandle *handle, + TALER_MERCHANT_PatchPrivateTemplateCallback cb, + TALER_MERCHANT_PATCH_PRIVATE_TEMPLATE_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel PATCH /private/templates/$TEMPLATE_ID operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_patch_private_template_cancel ( + struct TALER_MERCHANT_PatchPrivateTemplateHandle *handle); + + +#endif /* _TALER_MERCHANT__PATCH_PRIVATE_TEMPLATES_TEMPLATE_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/patch-private-units-UNIT-new.h b/src/include/taler/taler-merchant/patch-private-units-UNIT-new.h @@ -0,0 +1,376 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/patch-private-units-UNIT-new.h + * @brief C interface for PATCH /private/units/$UNIT + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__PATCH_PRIVATE_UNITS_UNIT_NEW_H +#define _TALER_MERCHANT__PATCH_PRIVATE_UNITS_UNIT_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options we can set for the PATCH /private/units/$UNIT request. + */ +enum TALER_MERCHANT_PatchPrivateUnitOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_END = 0, + + /** + * Set the long name of the unit. + */ + TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_NAME_LONG, + + /** + * Set the short name (symbol) of the unit. + */ + TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_NAME_SHORT, + + /** + * Set internationalized long names (JSON). + */ + TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_NAME_LONG_I18N, + + /** + * Set internationalized short names (JSON). + */ + TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_NAME_SHORT_I18N, + + /** + * Set whether fractional quantities are allowed. + */ + TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_ALLOW_FRACTION, + + /** + * Set precision level for fractions. + */ + TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_PRECISION_LEVEL, + + /** + * Set active status of the unit. + */ + TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_ACTIVE + +}; + + +/** + * Value for an option for the PATCH /private/units/$UNIT request. + */ +struct TALER_MERCHANT_PatchPrivateUnitOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PatchPrivateUnitOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_NAME_LONG. + */ + const char *unit_name_long; + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_NAME_SHORT. + */ + const char *unit_name_short; + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_NAME_LONG_I18N. + */ + const json_t *unit_name_long_i18n; + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_NAME_SHORT_I18N. + */ + const json_t *unit_name_short_i18n; + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_ALLOW_FRACTION. + */ + bool unit_allow_fraction; + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_PRECISION_LEVEL. + */ + uint32_t unit_precision_level; + + /** + * Value if @e option is + * #TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_ACTIVE. + */ + bool unit_active; + + } details; + +}; + + +/** + * Handle for a PATCH /private/units/$UNIT operation. + */ +struct TALER_MERCHANT_PatchPrivateUnitHandle; + + +/** + * Set up PATCH /private/units/$UNIT operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param unit_id identifier of the unit to update + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_PatchPrivateUnitHandle * +TALER_MERCHANT_patch_private_unit_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *unit_id); + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_PatchPrivateUnitOptionValue + */ +#define TALER_MERCHANT_patch_private_unit_option_end_() \ + (const struct TALER_MERCHANT_PatchPrivateUnitOptionValue) \ + { \ + .option = TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_END \ + } + +/** + * Set the long name of the unit. + * + * @param n long name to set + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateUnitOptionValue + */ +#define TALER_MERCHANT_patch_private_unit_option_unit_name_long(n) \ + (const struct TALER_MERCHANT_PatchPrivateUnitOptionValue) \ + { \ + .option = TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_NAME_LONG, \ + .details.unit_name_long = (n) \ + } + +/** + * Set the short name (symbol) of the unit. + * + * @param n short name to set + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateUnitOptionValue + */ +#define TALER_MERCHANT_patch_private_unit_option_unit_name_short(n) \ + (const struct TALER_MERCHANT_PatchPrivateUnitOptionValue) \ + { \ + .option = TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_NAME_SHORT, \ + .details.unit_name_short = (n) \ + } + +/** + * Set internationalized long names. + * + * @param j JSON object with internationalized long names + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateUnitOptionValue + */ +#define TALER_MERCHANT_patch_private_unit_option_unit_name_long_i18n(j) \ + (const struct TALER_MERCHANT_PatchPrivateUnitOptionValue) \ + { \ + .option = TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_NAME_LONG_I18N \ + , \ + .details.unit_name_long_i18n = (j) \ + } + +/** + * Set internationalized short names. + * + * @param j JSON object with internationalized short names + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateUnitOptionValue + */ +#define TALER_MERCHANT_patch_private_unit_option_unit_name_short_i18n(j) \ + (const struct TALER_MERCHANT_PatchPrivateUnitOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_NAME_SHORT_I18N, \ + .details.unit_name_short_i18n = (j) \ + } + +/** + * Set whether fractional quantities are allowed. + * + * @param a true if fractional quantities are allowed + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateUnitOptionValue + */ +#define TALER_MERCHANT_patch_private_unit_option_unit_allow_fraction(a) \ + (const struct TALER_MERCHANT_PatchPrivateUnitOptionValue) \ + { \ + .option = TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_ALLOW_FRACTION \ + , \ + .details.unit_allow_fraction = (a) \ + } + +/** + * Set precision level for fractions. + * + * @param p precision level value + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateUnitOptionValue + */ +#define TALER_MERCHANT_patch_private_unit_option_unit_precision_level(p) \ + (const struct TALER_MERCHANT_PatchPrivateUnitOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_PRECISION_LEVEL, \ + .details.unit_precision_level = (p) \ + } + +/** + * Set active status of the unit. + * + * @param a true if the unit should be active + * @return representation of the option as a struct TALER_MERCHANT_PatchPrivateUnitOptionValue + */ +#define TALER_MERCHANT_patch_private_unit_option_unit_active(a) \ + (const struct TALER_MERCHANT_PatchPrivateUnitOptionValue) \ + { \ + .option = TALER_MERCHANT_PATCH_PRIVATE_UNIT_OPTION_UNIT_ACTIVE, \ + .details.unit_active = (a) \ + } + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * @param uph the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_patch_private_unit_set_options_ ( + struct TALER_MERCHANT_PatchPrivateUnitHandle *uph, + unsigned int num_options, + const struct TALER_MERCHANT_PatchPrivateUnitOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * If any option fail other options may be or may be not applied. + * + * It should be used with helpers that create required options, for example: + * + * TALER_MERCHANT_patch_private_unit_set_options ( + * uph, + * TALER_MERCHANT_patch_private_unit_option_unit_name_long ("Kilogram"), + * TALER_MERCHANT_patch_private_unit_option_unit_active (true)); + * + * @param uph the request to set the options for + * @param ... the list of the options, each option must be created + * by helpers TALER_MERCHANT_patch_private_unit_option_NAME(VALUE) + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_patch_private_unit_set_options(uph,...) \ + TALER_MERCHANT_patch_private_unit_set_options_ ( \ + uph, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PatchPrivateUnitOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_patch_private_unit_option_end_ () } \ + )) + + +/** + * Response details for a PATCH /private/units/$UNIT request. + */ +struct TALER_MERCHANT_PatchPrivateUnitResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_PATCH_PRIVATE_UNIT_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PatchPrivateUnitCallback. + */ +#define TALER_MERCHANT_PATCH_PRIVATE_UNIT_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_PATCH_PRIVATE_UNIT_RESULT_CLOSURE */ + +/** + * Callback for a PATCH /private/units/$UNIT request. + * + * @param cls closure + * @param result response details + */ +typedef void +(*TALER_MERCHANT_PatchPrivateUnitCallback)( + TALER_MERCHANT_PATCH_PRIVATE_UNIT_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PatchPrivateUnitResponse *result); + + +/** + * Start PATCH /private/units/$UNIT operation. + * + * @param[in,out] uph operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_patch_private_unit_start ( + struct TALER_MERCHANT_PatchPrivateUnitHandle *uph, + TALER_MERCHANT_PatchPrivateUnitCallback cb, + TALER_MERCHANT_PATCH_PRIVATE_UNIT_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel PATCH /private/units/$UNIT operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] uph operation to cancel + */ +void +TALER_MERCHANT_patch_private_unit_cancel ( + struct TALER_MERCHANT_PatchPrivateUnitHandle *uph); + + +#endif /* _TALER_MERCHANT__PATCH_PRIVATE_UNITS_UNIT_NEW_H */ diff --git a/src/include/taler/taler-merchant/patch-private-webhooks-WEBHOOK_ID-new.h b/src/include/taler/taler-merchant/patch-private-webhooks-WEBHOOK_ID-new.h @@ -0,0 +1,119 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/patch-private-webhooks-WEBHOOK_ID-new.h + * @brief C interface for PATCH /private/webhooks/$WEBHOOK_ID + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__PATCH_PRIVATE_WEBHOOKS_WEBHOOK_ID_NEW_H +#define _TALER_MERCHANT__PATCH_PRIVATE_WEBHOOKS_WEBHOOK_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a PATCH /private/webhooks/$WEBHOOK_ID operation. + */ +struct TALER_MERCHANT_PatchPrivateWebhookHandle; + + +/** + * Set up PATCH /private/webhooks/$WEBHOOK_ID operation. + * Note that you must explicitly start the operation after setup. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param webhook_id identifier of the webhook to update + * @param event_type new event type + * @param url_template new notification URL template + * @param http_method new HTTP method + * @param header_template new header template + * @param body_template new body template + * @return handle to operation, NULL on error + */ +struct TALER_MERCHANT_PatchPrivateWebhookHandle * +TALER_MERCHANT_patch_private_webhook_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *webhook_id, + const char *event_type, + const char *url_template, + const char *http_method, + const char *header_template, + const char *body_template); + + +/** + * Response details for a PATCH /private/webhooks/$WEBHOOK_ID request. + */ +struct TALER_MERCHANT_PatchPrivateWebhookResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; +}; + + +#ifndef TALER_MERCHANT_PATCH_PRIVATE_WEBHOOK_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PatchPrivateWebhookCallback. + */ +#define TALER_MERCHANT_PATCH_PRIVATE_WEBHOOK_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_PATCH_PRIVATE_WEBHOOK_RESULT_CLOSURE */ + +/** + * Callback for a PATCH /private/webhooks/$WEBHOOK_ID request. + * + * @param cls closure + * @param result response details + */ +typedef void +(*TALER_MERCHANT_PatchPrivateWebhookCallback)( + TALER_MERCHANT_PATCH_PRIVATE_WEBHOOK_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PatchPrivateWebhookResponse *result); + + +/** + * Start PATCH /private/webhooks/$WEBHOOK_ID operation. + * + * @param[in,out] handle operation to start + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_patch_private_webhook_start ( + struct TALER_MERCHANT_PatchPrivateWebhookHandle *handle, + TALER_MERCHANT_PatchPrivateWebhookCallback cb, + TALER_MERCHANT_PATCH_PRIVATE_WEBHOOK_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel PATCH /private/webhooks/$WEBHOOK_ID operation. + * This function must not be called by clients after the + * callback has been invoked. + * + * @param[in] handle operation to cancel + */ +void +TALER_MERCHANT_patch_private_webhook_cancel ( + struct TALER_MERCHANT_PatchPrivateWebhookHandle *handle); + + +#endif /* _TALER_MERCHANT__PATCH_PRIVATE_WEBHOOKS_WEBHOOK_ID_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-management-instances-INSTANCE-auth-new.h b/src/include/taler/taler-merchant/post-management-instances-INSTANCE-auth-new.h @@ -0,0 +1,115 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-management-instances-INSTANCE-auth-new.h + * @brief C interface for the POST /management/instances/$INSTANCE/auth endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_MANAGEMENT_INSTANCES_INSTANCE_AUTH_NEW_H +#define _TALER_MERCHANT__POST_MANAGEMENT_INSTANCES_INSTANCE_AUTH_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a POST /management/instances/$INSTANCE/auth request. + */ +struct TALER_MERCHANT_PostManagementInstancesAuthHandle; + + +/** + * Response details for a POST /management/instances/$INSTANCE/auth request. + */ +struct TALER_MERCHANT_PostManagementInstancesAuthResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Set up POST /management/instances/$INSTANCE/auth operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param instance_id identifier of the instance + * @param auth_password new authentication password + * @return handle to operation + */ +struct TALER_MERCHANT_PostManagementInstancesAuthHandle * +TALER_MERCHANT_post_management_instances_auth_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *instance_id, + const char *auth_password); + + +#ifndef TALER_MERCHANT_POST_MANAGEMENT_INSTANCES_AUTH_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostManagementInstancesAuthCallback. + */ +#define TALER_MERCHANT_POST_MANAGEMENT_INSTANCES_AUTH_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_MANAGEMENT_INSTANCES_AUTH_RESULT_CLOSURE */ + +/** + * Callback for a POST /management/instances/$INSTANCE/auth request. + * + * @param cls closure + * @param iar response details + */ +typedef void +(*TALER_MERCHANT_PostManagementInstancesAuthCallback)( + TALER_MERCHANT_POST_MANAGEMENT_INSTANCES_AUTH_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostManagementInstancesAuthResponse *iar); + + +/** + * Start POST /management/instances/$INSTANCE/auth operation. + * + * @param[in,out] piah operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_management_instances_auth_start ( + struct TALER_MERCHANT_PostManagementInstancesAuthHandle *piah, + TALER_MERCHANT_PostManagementInstancesAuthCallback cb, + TALER_MERCHANT_POST_MANAGEMENT_INSTANCES_AUTH_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /management/instances/$INSTANCE/auth operation. This function + * must not be called by clients after the + * TALER_MERCHANT_PostManagementInstancesAuthCallback has been invoked (as in + * those cases it'll be called internally by the implementation already). + * + * @param[in] piah operation to cancel + */ +void +TALER_MERCHANT_post_management_instances_auth_cancel ( + struct TALER_MERCHANT_PostManagementInstancesAuthHandle *piah); + + +#endif /* _TALER_MERCHANT__POST_MANAGEMENT_INSTANCES_INSTANCE_AUTH_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-management-instances-new.h b/src/include/taler/taler-merchant/post-management-instances-new.h @@ -0,0 +1,129 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-management-instances-new.h + * @brief C interface for the POST /management/instances endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_MANAGEMENT_INSTANCES_NEW_H +#define _TALER_MERCHANT__POST_MANAGEMENT_INSTANCES_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a POST /management/instances request. + */ +struct TALER_MERCHANT_PostManagementInstancesHandle; + + +/** + * Response details for a POST /management/instances request. + */ +struct TALER_MERCHANT_PostManagementInstancesResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Set up POST /management/instances operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param instance_id identifier for the new instance + * @param name human-readable name + * @param address address (JSON) + * @param jurisdiction jurisdiction (JSON) + * @param use_stefan whether to use the STEFAN curve for fee calculations + * @param default_wire_transfer_delay default delay for wire transfers + * @param default_pay_delay default payment deadline + * @param default_refund_delay default refund deadline + * @param auth_password authentication password for the new instance, or NULL + * @return handle to operation + */ +struct TALER_MERCHANT_PostManagementInstancesHandle * +TALER_MERCHANT_post_management_instances_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *instance_id, + const char *name, + const json_t *address, + const json_t *jurisdiction, + bool use_stefan, + struct GNUNET_TIME_Relative default_wire_transfer_delay, + struct GNUNET_TIME_Relative default_pay_delay, + struct GNUNET_TIME_Relative default_refund_delay, + const char *auth_password); + + +#ifndef TALER_MERCHANT_POST_MANAGEMENT_INSTANCES_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostManagementInstancesCallback. + */ +#define TALER_MERCHANT_POST_MANAGEMENT_INSTANCES_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_MANAGEMENT_INSTANCES_RESULT_CLOSURE */ + +/** + * Callback for a POST /management/instances request. + * + * @param cls closure + * @param mir response details + */ +typedef void +(*TALER_MERCHANT_PostManagementInstancesCallback)( + TALER_MERCHANT_POST_MANAGEMENT_INSTANCES_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostManagementInstancesResponse *mir); + + +/** + * Start POST /management/instances operation. + * + * @param[in,out] pmih operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_management_instances_start ( + struct TALER_MERCHANT_PostManagementInstancesHandle *pmih, + TALER_MERCHANT_PostManagementInstancesCallback cb, + TALER_MERCHANT_POST_MANAGEMENT_INSTANCES_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /management/instances operation. This function must not be + * called by clients after the TALER_MERCHANT_PostManagementInstancesCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] pmih operation to cancel + */ +void +TALER_MERCHANT_post_management_instances_cancel ( + struct TALER_MERCHANT_PostManagementInstancesHandle *pmih); + + +#endif /* _TALER_MERCHANT__POST_MANAGEMENT_INSTANCES_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-orders-ORDER_ID-abort-new.h b/src/include/taler/taler-merchant/post-orders-ORDER_ID-abort-new.h @@ -0,0 +1,210 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-orders-ORDER_ID-abort-new.h + * @brief C interface for the POST /orders/$ORDER_ID/abort endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_ORDERS_ORDER_ID_ABORT_NEW_H +#define _TALER_MERCHANT__POST_ORDERS_ORDER_ID_ABORT_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a POST /orders/$ORDER_ID/abort request. + */ +struct TALER_MERCHANT_PostOrdersAbortHandle; + + +/** + * One coin used in an abort request. + */ +struct TALER_MERCHANT_PostOrdersAbortCoin +{ + + /** + * Base URL of the exchange this coin was issued by. + */ + const char *exchange_url; + + /** + * Public key of the coin. + */ + struct TALER_CoinSpendPublicKeyP coin_pub; + + /** + * Total amount contributed including deposit fee. + */ + struct TALER_Amount amount_with_fee; + + /** + * Hash of the denomination public key. + */ + struct TALER_DenominationHashP denom_pub_hash; + + /** + * Denomination signature over the coin. + */ + struct TALER_DenominationSignature denom_sig; + + /** + * Amount contributed without the deposit fee. + */ + struct TALER_Amount contribution; + +}; + + +/** + * Result for one coin from an abort operation. + */ +struct TALER_MERCHANT_PostOrdersAbortedCoin +{ + + /** + * Exchange signature confirming the refund. + */ + struct TALER_ExchangeSignatureP exchange_sig; + + /** + * Exchange public key used for @e exchange_sig. + */ + struct TALER_ExchangePublicKeyP exchange_pub; + + /** + * Public key of the coin. + */ + struct TALER_CoinSpendPublicKeyP coin_pub; + +}; + + +/** + * Response details for a POST /orders/$ORDER_ID/abort request. + */ +struct TALER_MERCHANT_PostOrdersAbortResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of aborted coins in @a aborts. + */ + unsigned int num_aborts; + + /** + * Array of aborted coin results. + */ + const struct TALER_MERCHANT_PostOrdersAbortedCoin *aborts; + + } ok; + + } details; + +}; + + +/** + * Set up POST /orders/$ORDER_ID/abort operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param order_id identifier of the order to abort + * @param merchant_pub merchant public key + * @param h_contract hash of the contract terms + * @param num_coins number of coins in @a coins + * @param coins array of coins used in the aborted payment + * @return handle to operation + */ +struct TALER_MERCHANT_PostOrdersAbortHandle * +TALER_MERCHANT_post_orders_abort_create ( + struct GNUNET_CURL_Context *ctx, + const char *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_PostOrdersAbortCoin coins[static num_coins]); + + +#ifndef TALER_MERCHANT_POST_ORDERS_ABORT_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostOrdersAbortCallback. + */ +#define TALER_MERCHANT_POST_ORDERS_ABORT_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_ORDERS_ABORT_RESULT_CLOSURE */ + +/** + * Callback for a POST /orders/$ORDER_ID/abort request. + * + * @param cls closure + * @param oar response details + */ +typedef void +(*TALER_MERCHANT_PostOrdersAbortCallback)( + TALER_MERCHANT_POST_ORDERS_ABORT_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostOrdersAbortResponse *oar); + + +/** + * Start POST /orders/$ORDER_ID/abort operation. + * + * @param[in,out] poah operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_orders_abort_start ( + struct TALER_MERCHANT_PostOrdersAbortHandle *poah, + TALER_MERCHANT_PostOrdersAbortCallback cb, + TALER_MERCHANT_POST_ORDERS_ABORT_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /orders/$ORDER_ID/abort operation. This function must not be + * called by clients after the TALER_MERCHANT_PostOrdersAbortCallback has + * been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] poah operation to cancel + */ +void +TALER_MERCHANT_post_orders_abort_cancel ( + struct TALER_MERCHANT_PostOrdersAbortHandle *poah); + + +#endif /* _TALER_MERCHANT__POST_ORDERS_ORDER_ID_ABORT_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-orders-ORDER_ID-claim-new.h b/src/include/taler/taler-merchant/post-orders-ORDER_ID-claim-new.h @@ -0,0 +1,247 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-orders-ORDER_ID-claim-new.h + * @brief C interface for the POST /orders/$ORDER_ID/claim endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_ORDERS_ORDER_ID_CLAIM_NEW_H +#define _TALER_MERCHANT__POST_ORDERS_ORDER_ID_CLAIM_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options for the POST /orders/$ORDER_ID/claim request. + */ +enum TALER_MERCHANT_PostOrdersClaimOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_ORDERS_CLAIM_OPTION_END = 0, + + /** + * Claim token for the order. + */ + TALER_MERCHANT_POST_ORDERS_CLAIM_OPTION_TOKEN + +}; + + +/** + * Value for an option for the POST /orders/$ORDER_ID/claim request. + */ +struct TALER_MERCHANT_PostOrdersClaimOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostOrdersClaimOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_ORDERS_CLAIM_OPTION_TOKEN. + */ + const struct TALER_ClaimTokenP *token; + + } details; + +}; + + +/** + * Handle for a POST /orders/$ORDER_ID/claim request. + */ +struct TALER_MERCHANT_PostOrdersClaimHandle; + + +/** + * Response details for a POST /orders/$ORDER_ID/claim request. + */ +struct TALER_MERCHANT_PostOrdersClaimResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * The claimed contract terms. + */ + const json_t *contract_terms; + + /** + * Merchant signature over the contract terms. + */ + struct TALER_MerchantSignatureP merchant_sig; + + } ok; + + } details; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_PostOrdersClaimOptionValue + */ +#define TALER_MERCHANT_post_orders_claim_option_end_() \ + (const struct TALER_MERCHANT_PostOrdersClaimOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_ORDERS_CLAIM_OPTION_END \ + } + +/** + * Set claim token. + * + * @param t claim token to use + * @return representation of the option as a struct TALER_MERCHANT_PostOrdersClaimOptionValue + */ +#define TALER_MERCHANT_post_orders_claim_option_token(t) \ + (const struct TALER_MERCHANT_PostOrdersClaimOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_ORDERS_CLAIM_OPTION_TOKEN, \ + .details.token = (t) \ + } + + +/** + * Set the requested options for the operation. + * + * @param poch the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_orders_claim_set_options_ ( + struct TALER_MERCHANT_PostOrdersClaimHandle *poch, + unsigned int num_options, + const struct TALER_MERCHANT_PostOrdersClaimOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param poch the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_orders_claim_set_options(poch,...) \ + TALER_MERCHANT_post_orders_claim_set_options_ ( \ + poch, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostOrdersClaimOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_orders_claim_option_end_ () } \ + )) + + +/** + * Set up POST /orders/$ORDER_ID/claim operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param order_id identifier of the order to claim + * @param nonce wallet nonce for claiming + * @return handle to operation + */ +struct TALER_MERCHANT_PostOrdersClaimHandle * +TALER_MERCHANT_post_orders_claim_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *order_id, + const struct GNUNET_CRYPTO_EddsaPublicKey *nonce); + + +#ifndef TALER_MERCHANT_POST_ORDERS_CLAIM_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostOrdersClaimCallback. + */ +#define TALER_MERCHANT_POST_ORDERS_CLAIM_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_ORDERS_CLAIM_RESULT_CLOSURE */ + +/** + * Callback for a POST /orders/$ORDER_ID/claim request. + * + * @param cls closure + * @param ocr response details + */ +typedef void +(*TALER_MERCHANT_PostOrdersClaimCallback)( + TALER_MERCHANT_POST_ORDERS_CLAIM_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostOrdersClaimResponse *ocr); + + +/** + * Start POST /orders/$ORDER_ID/claim operation. + * + * @param[in,out] poch operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_orders_claim_start ( + struct TALER_MERCHANT_PostOrdersClaimHandle *poch, + TALER_MERCHANT_PostOrdersClaimCallback cb, + TALER_MERCHANT_POST_ORDERS_CLAIM_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /orders/$ORDER_ID/claim operation. This function must not be + * called by clients after the TALER_MERCHANT_PostOrdersClaimCallback has + * been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] poch operation to cancel + */ +void +TALER_MERCHANT_post_orders_claim_cancel ( + struct TALER_MERCHANT_PostOrdersClaimHandle *poch); + + +#endif /* _TALER_MERCHANT__POST_ORDERS_ORDER_ID_CLAIM_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-orders-ORDER_ID-paid-new.h b/src/include/taler/taler-merchant/post-orders-ORDER_ID-paid-new.h @@ -0,0 +1,225 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-orders-ORDER_ID-paid-new.h + * @brief C interface for the POST /orders/$ORDER_ID/paid endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_ORDERS_ORDER_ID_PAID_NEW_H +#define _TALER_MERCHANT__POST_ORDERS_ORDER_ID_PAID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options for the POST /orders/$ORDER_ID/paid request. + */ +enum TALER_MERCHANT_PostOrdersPaidOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_ORDERS_PAID_OPTION_END = 0, + + /** + * Hash of wallet-specific data. + */ + TALER_MERCHANT_POST_ORDERS_PAID_OPTION_WALLET_DATA_HASH + +}; + + +/** + * Value for an option for the POST /orders/$ORDER_ID/paid request. + */ +struct TALER_MERCHANT_PostOrdersPaidOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostOrdersPaidOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_ORDERS_PAID_OPTION_WALLET_DATA_HASH. + */ + const struct GNUNET_HashCode *wallet_data_hash; + + } details; + +}; + + +/** + * Handle for a POST /orders/$ORDER_ID/paid request. + */ +struct TALER_MERCHANT_PostOrdersPaidHandle; + + +/** + * Response details for a POST /orders/$ORDER_ID/paid request. + */ +struct TALER_MERCHANT_PostOrdersPaidResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_PostOrdersPaidOptionValue + */ +#define TALER_MERCHANT_post_orders_paid_option_end_() \ + (const struct TALER_MERCHANT_PostOrdersPaidOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_ORDERS_PAID_OPTION_END \ + } + +/** + * Set hash of wallet-specific data. + * + * @param h hash of wallet data, or NULL + * @return representation of the option as a struct TALER_MERCHANT_PostOrdersPaidOptionValue + */ +#define TALER_MERCHANT_post_orders_paid_option_wallet_data_hash(h) \ + (const struct TALER_MERCHANT_PostOrdersPaidOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_ORDERS_PAID_OPTION_WALLET_DATA_HASH, \ + .details.wallet_data_hash = (h) \ + } + + +/** + * Set the requested options for the operation. + * + * @param poph the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_orders_paid_set_options_ ( + struct TALER_MERCHANT_PostOrdersPaidHandle *poph, + unsigned int num_options, + const struct TALER_MERCHANT_PostOrdersPaidOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param poph the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_orders_paid_set_options(poph,...) \ + TALER_MERCHANT_post_orders_paid_set_options_ ( \ + poph, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostOrdersPaidOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_orders_paid_option_end_ () } \ + )) + + +/** + * Set up POST /orders/$ORDER_ID/paid operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param order_id identifier of the order + * @param session_id session identifier + * @param h_contract_terms hash of the contract terms + * @param merchant_sig merchant signature over the session data + * @return handle to operation + */ +struct TALER_MERCHANT_PostOrdersPaidHandle * +TALER_MERCHANT_post_orders_paid_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *order_id, + const char *session_id, + const struct TALER_PrivateContractHashP *h_contract_terms, + const struct TALER_MerchantSignatureP *merchant_sig); + + +#ifndef TALER_MERCHANT_POST_ORDERS_PAID_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostOrdersPaidCallback. + */ +#define TALER_MERCHANT_POST_ORDERS_PAID_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_ORDERS_PAID_RESULT_CLOSURE */ + +/** + * Callback for a POST /orders/$ORDER_ID/paid request. + * + * @param cls closure + * @param opr response details + */ +typedef void +(*TALER_MERCHANT_PostOrdersPaidCallback)( + TALER_MERCHANT_POST_ORDERS_PAID_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostOrdersPaidResponse *opr); + + +/** + * Start POST /orders/$ORDER_ID/paid operation. + * + * @param[in,out] poph operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_orders_paid_start ( + struct TALER_MERCHANT_PostOrdersPaidHandle *poph, + TALER_MERCHANT_PostOrdersPaidCallback cb, + TALER_MERCHANT_POST_ORDERS_PAID_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /orders/$ORDER_ID/paid operation. This function must not be + * called by clients after the TALER_MERCHANT_PostOrdersPaidCallback has + * been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] poph operation to cancel + */ +void +TALER_MERCHANT_post_orders_paid_cancel ( + struct TALER_MERCHANT_PostOrdersPaidHandle *poph); + + +#endif /* _TALER_MERCHANT__POST_ORDERS_ORDER_ID_PAID_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-orders-ORDER_ID-pay-new.h b/src/include/taler/taler-merchant/post-orders-ORDER_ID-pay-new.h @@ -0,0 +1,647 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-orders-ORDER_ID-pay-new.h + * @brief C interface for the POST /orders/$ORDER_ID/pay endpoint + * @author Christian Grothoff + * @author Marcello Stanisci + */ +#ifndef _TALER_MERCHANT__POST_ORDERS_ORDER_ID_PAY_NEW_H +#define _TALER_MERCHANT__POST_ORDERS_ORDER_ID_PAY_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * One coin used to pay (frontend / external wallet mode). + */ +struct TALER_MERCHANT_PostOrdersPayPaidCoin +{ + + /** + * Denomination public key. + */ + struct TALER_DenominationPublicKey denom_pub; + + /** + * Hash of the denomination public key. + */ + struct TALER_DenominationHashP denom_pub_hash; + + /** + * Denomination signature over the coin. + */ + struct TALER_DenominationSignature denom_sig; + + /** + * Face value of the denomination. + */ + struct TALER_Amount denom_value; + + /** + * Public key of the coin. + */ + struct TALER_CoinSpendPublicKeyP coin_pub; + + /** + * Signature by the coin authorizing the deposit. + */ + struct TALER_CoinSpendSignatureP coin_sig; + + /** + * Hash of the age commitment for this coin. + */ + struct TALER_AgeCommitmentHashP h_age_commitment; + + /** + * Set to true if this coin has an age commitment. + */ + bool has_age_commitment; + + /** + * Total amount contributed including deposit fee. + */ + struct TALER_Amount amount_with_fee; + + /** + * Amount contributed without the deposit fee. + */ + struct TALER_Amount amount_without_fee; + + /** + * Deposit fee for this coin. + */ + struct TALER_Amount deposit_fee; + + /** + * Base URL of the exchange this coin was issued by. + */ + const char *exchange_url; + +}; + + +/** + * One coin used to pay (wallet-internal mode, private key available). + */ +struct TALER_MERCHANT_PostOrdersPayCoin +{ + + /** + * Denomination public key. + */ + struct TALER_DenominationPublicKey denom_pub; + + /** + * Denomination signature over the coin. + */ + struct TALER_DenominationSignature denom_sig; + + /** + * Face value of the denomination. + */ + struct TALER_Amount denom_value; + + /** + * Private key of the coin (to sign the deposit). + */ + struct TALER_CoinSpendPrivateKeyP coin_priv; + + /** + * Hash of the age commitment for this coin, or NULL if none. + */ + const struct TALER_AgeCommitmentHashP *h_age_commitment; + + /** + * Total amount contributed including deposit fee. + */ + struct TALER_Amount amount_with_fee; + + /** + * Amount contributed without the deposit fee. + */ + struct TALER_Amount amount_without_fee; + + /** + * URL of the exchange that issued @e coin_priv. + */ + const char *exchange_url; + +}; + + +/** + * Token to use for payment (public form, already obtained). + */ +struct TALER_MERCHANT_PostOrdersPayUsedToken +{ + + /** + * Signature on TALER_TokenUseRequestPS made with the token use private key. + */ + struct TALER_TokenUseSignatureP token_sig; + + /** + * Public key of the token. + */ + struct TALER_TokenUsePublicKeyP token_pub; + + /** + * Unblinded signature made by the token issue public key of the merchant. + */ + struct TALER_TokenIssueSignature ub_sig; + + /** + * Token issue public key associated with this token. + */ + struct TALER_TokenIssuePublicKey issue_pub; + +}; + + +/** + * Information we need from the wallet to use a token for an order. + */ +struct TALER_MERCHANT_PostOrdersPayUseToken +{ + + /** + * Private key of the token (to sign the use authorization). + */ + struct TALER_TokenUsePrivateKeyP token_priv; + + /** + * Unblinded signature made by the token issue public key of the merchant. + */ + struct TALER_TokenIssueSignature ub_sig; + + /** + * Token issue public key associated with this token. + */ + struct TALER_TokenIssuePublicKey issue_pub; + +}; + + +/** + * Output token: used both as input to pay (envelope to be signed) + * and as output in the pay response (blind signature received). + */ +struct TALER_MERCHANT_PostOrdersPayOutputToken +{ + + /** + * Blinded token envelope to be signed by the issuer (input to pay). + */ + struct TALER_TokenEnvelope envelope; + + /** + * Blinded token issue signature received from the issuer (output of pay). + */ + struct TALER_BlindedTokenIssueSignature blinded_sig; + +}; + + +/** + * Possible options for the POST /orders/$ORDER_ID/pay request. + */ +enum TALER_MERCHANT_PostOrdersPayOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_ORDERS_PAY_OPTION_END = 0, + + /** + * Session identifier for session-bound payments. + */ + TALER_MERCHANT_POST_ORDERS_PAY_OPTION_SESSION_ID, + + /** + * Wallet-specific data (JSON). + */ + TALER_MERCHANT_POST_ORDERS_PAY_OPTION_WALLET_DATA, + + /** + * Used tokens (public form, for frontend mode). + */ + TALER_MERCHANT_POST_ORDERS_PAY_OPTION_USED_TOKENS, + + /** + * Use tokens (private form, for wallet mode). + */ + TALER_MERCHANT_POST_ORDERS_PAY_OPTION_USE_TOKENS, + + /** + * Output tokens (for wallet mode). + */ + TALER_MERCHANT_POST_ORDERS_PAY_OPTION_OUTPUT_TOKENS, + + /** + * Output tokens as JSON array (for frontend mode). + */ + TALER_MERCHANT_POST_ORDERS_PAY_OPTION_OUTPUT_TOKENS_JSON + +}; + + +/** + * Value for an option for the POST /orders/$ORDER_ID/pay request. + */ +struct TALER_MERCHANT_PostOrdersPayOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostOrdersPayOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_ORDERS_PAY_OPTION_SESSION_ID. + */ + const char *session_id; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_ORDERS_PAY_OPTION_WALLET_DATA. + */ + const json_t *wallet_data; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_ORDERS_PAY_OPTION_USED_TOKENS. + */ + struct + { + unsigned int num; + const struct TALER_MERCHANT_PostOrdersPayUsedToken *tokens; + } used_tokens; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_ORDERS_PAY_OPTION_USE_TOKENS. + */ + struct + { + unsigned int num; + const struct TALER_MERCHANT_PostOrdersPayUseToken *tokens; + } use_tokens; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_ORDERS_PAY_OPTION_OUTPUT_TOKENS. + */ + struct + { + unsigned int num; + const struct TALER_MERCHANT_PostOrdersPayOutputToken *tokens; + } output_tokens; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_ORDERS_PAY_OPTION_OUTPUT_TOKENS_JSON. + */ + json_t *output_tokens_json; + + } details; + +}; + + +/** + * Handle for a POST /orders/$ORDER_ID/pay request. + */ +struct TALER_MERCHANT_PostOrdersPayHandle; + + +/** + * Response details for a POST /orders/$ORDER_ID/pay request. + */ +struct TALER_MERCHANT_PostOrdersPayResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Merchant signature confirming the payment. + */ + struct TALER_MerchantSignatureP merchant_sig; + + /** + * POS confirmation string, or NULL if not applicable. + */ + const char *pos_confirmation; + + /** + * Number of output tokens in @a tokens. + */ + unsigned int num_tokens; + + /** + * Array of output tokens issued upon payment. + */ + struct TALER_MERCHANT_PostOrdersPayOutputToken *tokens; + + } ok; + + /** + * Details on #MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS. + */ + struct + { + + /** + * Number of exchange URLs in @a exchanges. + */ + unsigned int num_exchanges; + + /** + * Array of exchange URLs that refused the payment for legal reasons. + */ + const char **exchanges; + + } unavailable_for_legal_reasons; + + } details; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object + */ +#define TALER_MERCHANT_post_orders_pay_option_end_() \ + (const struct TALER_MERCHANT_PostOrdersPayOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_ORDERS_PAY_OPTION_END \ + } + +/** + * Set session identifier. + * + * @param s session ID + * @return representation of the option + */ +#define TALER_MERCHANT_post_orders_pay_option_session_id(s) \ + (const struct TALER_MERCHANT_PostOrdersPayOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_ORDERS_PAY_OPTION_SESSION_ID, \ + .details.session_id = (s) \ + } + +/** + * Set wallet-specific data. + * + * @param w wallet data JSON object + * @return representation of the option + */ +#define TALER_MERCHANT_post_orders_pay_option_wallet_data(w) \ + (const struct TALER_MERCHANT_PostOrdersPayOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_ORDERS_PAY_OPTION_WALLET_DATA, \ + .details.wallet_data = (w) \ + } + +/** + * Set used tokens (public form, for frontend mode). + * + * @param n number of tokens + * @param t array of used tokens + * @return representation of the option + */ +#define TALER_MERCHANT_post_orders_pay_option_used_tokens(n,t) \ + (const struct TALER_MERCHANT_PostOrdersPayOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_ORDERS_PAY_OPTION_USED_TOKENS, \ + .details.used_tokens = { .num = (n), .tokens = (t) } \ + } + +/** + * Set use tokens (private form, for wallet mode). + * + * @param n number of tokens + * @param t array of use tokens + * @return representation of the option + */ +#define TALER_MERCHANT_post_orders_pay_option_use_tokens(n,t) \ + (const struct TALER_MERCHANT_PostOrdersPayOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_ORDERS_PAY_OPTION_USE_TOKENS, \ + .details.use_tokens = { .num = (n), .tokens = (t) } \ + } + +/** + * Set output tokens (for wallet mode). + * + * @param n number of output tokens + * @param t array of output tokens + * @return representation of the option + */ +#define TALER_MERCHANT_post_orders_pay_option_output_tokens(n,t) \ + (const struct TALER_MERCHANT_PostOrdersPayOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_ORDERS_PAY_OPTION_OUTPUT_TOKENS, \ + .details.output_tokens = { .num = (n), .tokens = (t) } \ + } + +/** + * Set output tokens as JSON array (for frontend mode). + * + * @param j JSON array describing desired output tokens + * @return representation of the option + */ +#define TALER_MERCHANT_post_orders_pay_option_output_tokens_json(j) \ + (const struct TALER_MERCHANT_PostOrdersPayOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_ORDERS_PAY_OPTION_OUTPUT_TOKENS_JSON, \ + .details.output_tokens_json = (j) \ + } + + +/** + * Set the requested options for the operation. + * + * @param poph the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_orders_pay_set_options_ ( + struct TALER_MERCHANT_PostOrdersPayHandle *poph, + unsigned int num_options, + const struct TALER_MERCHANT_PostOrdersPayOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param poph the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_orders_pay_set_options(poph,...) \ + TALER_MERCHANT_post_orders_pay_set_options_ ( \ + poph, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostOrdersPayOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_orders_pay_option_end_ () } \ + )) + + +/** + * Set up POST /orders/$ORDER_ID/pay operation in frontend mode + * (coins already signed by the wallet). + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param order_id identifier of the order to pay + * @param num_coins number of coins in @a coins + * @param coins array of coins to pay with (already signed) + * @return handle to operation + */ +struct TALER_MERCHANT_PostOrdersPayHandle * +TALER_MERCHANT_post_orders_pay_frontend_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *order_id, + unsigned int num_coins, + const struct TALER_MERCHANT_PostOrdersPayPaidCoin coins[static num_coins]); + + +/** + * Set up POST /orders/$ORDER_ID/pay operation in wallet-internal mode + * (signing done internally). + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param order_id identifier of the order to pay + * @param h_contract_terms hash of the contract terms + * @param choice_index payment choice index + * @param amount total payment amount + * @param max_fee maximum acceptable fee + * @param merchant_pub merchant public key + * @param merchant_sig merchant signature + * @param timestamp contract timestamp + * @param refund_deadline refund deadline + * @param pay_deadline payment deadline + * @param h_wire hash of the merchant wire details + * @param num_coins number of coins in @a coins + * @param coins array of coins with private keys + * @return handle to operation + */ +struct TALER_MERCHANT_PostOrdersPayHandle * +TALER_MERCHANT_post_orders_pay_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *order_id, + const struct TALER_PrivateContractHashP *h_contract_terms, + int choice_index, + const struct TALER_Amount *amount, + const struct TALER_Amount *max_fee, + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct TALER_MerchantSignatureP *merchant_sig, + struct GNUNET_TIME_Timestamp timestamp, + struct GNUNET_TIME_Timestamp refund_deadline, + struct GNUNET_TIME_Timestamp pay_deadline, + const struct TALER_MerchantWireHashP *h_wire, + unsigned int num_coins, + const struct TALER_MERCHANT_PostOrdersPayCoin coins[static num_coins]); + + +#ifndef TALER_MERCHANT_POST_ORDERS_PAY_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostOrdersPayCallback. + */ +#define TALER_MERCHANT_POST_ORDERS_PAY_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_ORDERS_PAY_RESULT_CLOSURE */ + +/** + * Callback for a POST /orders/$ORDER_ID/pay request. + * + * @param cls closure + * @param opr response details + */ +typedef void +(*TALER_MERCHANT_PostOrdersPayCallback)( + TALER_MERCHANT_POST_ORDERS_PAY_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostOrdersPayResponse *opr); + + +/** + * Start POST /orders/$ORDER_ID/pay operation. + * + * @param[in,out] poph operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_orders_pay_start ( + struct TALER_MERCHANT_PostOrdersPayHandle *poph, + TALER_MERCHANT_PostOrdersPayCallback cb, + TALER_MERCHANT_POST_ORDERS_PAY_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /orders/$ORDER_ID/pay operation. This function must not be + * called by clients after the TALER_MERCHANT_PostOrdersPayCallback has + * been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] poph operation to cancel + */ +void +TALER_MERCHANT_post_orders_pay_cancel ( + struct TALER_MERCHANT_PostOrdersPayHandle *poph); + + +#endif /* _TALER_MERCHANT__POST_ORDERS_ORDER_ID_PAY_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-orders-ORDER_ID-refund-new.h b/src/include/taler/taler-merchant/post-orders-ORDER_ID-refund-new.h @@ -0,0 +1,216 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-orders-ORDER_ID-refund-new.h + * @brief C interface for the POST /orders/$ORDER_ID/refund endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_ORDERS_ORDER_ID_REFUND_NEW_H +#define _TALER_MERCHANT__POST_ORDERS_ORDER_ID_REFUND_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a POST /orders/$ORDER_ID/refund request. + */ +struct TALER_MERCHANT_PostOrdersRefundHandle; + + +/** + * Details about one refund from the exchange. + */ +struct TALER_MERCHANT_PostOrdersRefundDetail +{ + + /** + * Exchange signature confirming the refund. + */ + struct TALER_ExchangeSignatureP exchange_sig; + + /** + * Exchange public key used for @e exchange_sig. + */ + struct TALER_ExchangePublicKeyP exchange_pub; + + /** + * Hash of the contract terms. + */ + struct TALER_PrivateContractHashP h_contract_terms; + + /** + * Merchant public key. + */ + struct TALER_MerchantPublicKeyP merchant_pub; + + /** + * Refund transaction ID. + */ + uint64_t rtransaction_id; + + /** + * Public key of the refunded coin. + */ + struct TALER_CoinSpendPublicKeyP coin_pub; + + /** + * Refund amount. + */ + struct TALER_Amount refund_amount; + + /** + * Refund fee charged by the exchange. + */ + struct TALER_Amount refund_fee; + + /** + * HTTP status returned by the exchange for this refund, 0 if not yet + * obtained. + */ + unsigned int exchange_http_status; + + /** + * Taler error code returned by the exchange. + */ + enum TALER_ErrorCode ec; + + /** + * Full exchange reply (JSON), or NULL. + */ + const json_t *exchange_reply; + + /** + * HTTP response details from the exchange. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Response details for a POST /orders/$ORDER_ID/refund request. + */ +struct TALER_MERCHANT_PostOrdersRefundResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Number of refund details in @a refunds. + */ + unsigned int num_refunds; + + /** + * Array of refund details. + */ + const struct TALER_MERCHANT_PostOrdersRefundDetail *refunds; + + /** + * Merchant public key. + */ + struct TALER_MerchantPublicKeyP merchant_pub; + + } ok; + + } details; + +}; + + +/** + * Set up POST /orders/$ORDER_ID/refund operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param order_id identifier of the order + * @param h_contract_terms hash of the contract terms + * @return handle to operation + */ +struct TALER_MERCHANT_PostOrdersRefundHandle * +TALER_MERCHANT_post_orders_refund_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *order_id, + const struct TALER_PrivateContractHashP *h_contract_terms); + + +#ifndef TALER_MERCHANT_POST_ORDERS_REFUND_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostOrdersRefundCallback. + */ +#define TALER_MERCHANT_POST_ORDERS_REFUND_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_ORDERS_REFUND_RESULT_CLOSURE */ + +/** + * Callback for a POST /orders/$ORDER_ID/refund request. + * + * @param cls closure + * @param orr response details + */ +typedef void +(*TALER_MERCHANT_PostOrdersRefundCallback)( + TALER_MERCHANT_POST_ORDERS_REFUND_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostOrdersRefundResponse *orr); + + +/** + * Start POST /orders/$ORDER_ID/refund operation. + * + * @param[in,out] porh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_orders_refund_start ( + struct TALER_MERCHANT_PostOrdersRefundHandle *porh, + TALER_MERCHANT_PostOrdersRefundCallback cb, + TALER_MERCHANT_POST_ORDERS_REFUND_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /orders/$ORDER_ID/refund operation. This function must not be + * called by clients after the TALER_MERCHANT_PostOrdersRefundCallback has + * been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] porh operation to cancel + */ +void +TALER_MERCHANT_post_orders_refund_cancel ( + struct TALER_MERCHANT_PostOrdersRefundHandle *porh); + + +#endif /* _TALER_MERCHANT__POST_ORDERS_ORDER_ID_REFUND_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-accounts-new.h b/src/include/taler/taler-merchant/post-private-accounts-new.h @@ -0,0 +1,271 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-accounts-new.h + * @brief C interface for the POST /private/accounts endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_ACCOUNTS_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_ACCOUNTS_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options for the POST /private/accounts request. + */ +enum TALER_MERCHANT_PostPrivateAccountsOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_OPTION_END = 0, + + /** + * URL of the credit facade. + */ + TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_OPTION_CREDIT_FACADE_URL, + + /** + * Credentials for the credit facade (JSON). + */ + TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_OPTION_CREDIT_FACADE_CREDENTIALS + +}; + + +/** + * Value for an option for the POST /private/accounts request. + */ +struct TALER_MERCHANT_PostPrivateAccountsOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostPrivateAccountsOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_OPTION_CREDIT_FACADE_URL. + */ + const char *credit_facade_url; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_OPTION_CREDIT_FACADE_CREDENTIALS. + */ + const json_t *credit_facade_credentials; + + } details; + +}; + + +/** + * Handle for a POST /private/accounts request. + */ +struct TALER_MERCHANT_PostPrivateAccountsHandle; + + +/** + * Response details for a POST /private/accounts request. + */ +struct TALER_MERCHANT_PostPrivateAccountsResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Hash of the wire details for the newly created account. + */ + struct TALER_MerchantWireHashP h_wire; + + /** + * Salt used in the wire hash computation. + */ + struct TALER_WireSaltP salt; + + } ok; + + } details; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_PostPrivateAccountsOptionValue + */ +#define TALER_MERCHANT_post_private_accounts_option_end_() \ + (const struct TALER_MERCHANT_PostPrivateAccountsOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_OPTION_END \ + } + +/** + * Set credit facade URL. + * + * @param u credit facade URL + * @return representation of the option as a struct TALER_MERCHANT_PostPrivateAccountsOptionValue + */ +#define TALER_MERCHANT_post_private_accounts_option_credit_facade_url(u) \ + (const struct TALER_MERCHANT_PostPrivateAccountsOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_OPTION_CREDIT_FACADE_URL, \ + .details.credit_facade_url = (u) \ + } + +/** + * Set credit facade credentials. + * + * @param c credentials JSON object + * @return representation of the option as a struct TALER_MERCHANT_PostPrivateAccountsOptionValue + */ +#define TALER_MERCHANT_post_private_accounts_option_credit_facade_credentials(c) \ + (const struct TALER_MERCHANT_PostPrivateAccountsOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_OPTION_CREDIT_FACADE_CREDENTIALS, \ + .details.credit_facade_credentials = (c) \ + } + + +/** + * Set the requested options for the operation. + * + * @param ppah the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_private_accounts_set_options_ ( + struct TALER_MERCHANT_PostPrivateAccountsHandle *ppah, + unsigned int num_options, + const struct TALER_MERCHANT_PostPrivateAccountsOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param ppah the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_private_accounts_set_options(ppah,...) \ + TALER_MERCHANT_post_private_accounts_set_options_ ( \ + ppah, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostPrivateAccountsOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_private_accounts_option_end_ () } \ + )) + + +/** + * Set up POST /private/accounts operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param payto_uri payto URI of the account to add + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateAccountsHandle * +TALER_MERCHANT_post_private_accounts_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_FullPayto payto_uri); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateAccountsCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/accounts request. + * + * @param cls closure + * @param apr response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateAccountsCallback)( + TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateAccountsResponse *apr); + + +/** + * Start POST /private/accounts operation. + * + * @param[in,out] ppah operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_accounts_start ( + struct TALER_MERCHANT_PostPrivateAccountsHandle *ppah, + TALER_MERCHANT_PostPrivateAccountsCallback cb, + TALER_MERCHANT_POST_PRIVATE_ACCOUNTS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/accounts operation. This function must not be + * called by clients after the TALER_MERCHANT_PostPrivateAccountsCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] ppah operation to cancel + */ +void +TALER_MERCHANT_post_private_accounts_cancel ( + struct TALER_MERCHANT_PostPrivateAccountsHandle *ppah); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_ACCOUNTS_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-categories-new.h b/src/include/taler/taler-merchant/post-private-categories-new.h @@ -0,0 +1,240 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-categories-new.h + * @brief C interface for the POST /private/categories endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_CATEGORIES_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_CATEGORIES_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options for the POST /private/categories request. + */ +enum TALER_MERCHANT_PostPrivateCategoriesOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_PRIVATE_CATEGORIES_OPTION_END = 0, + + /** + * Internationalized names (JSON). + */ + TALER_MERCHANT_POST_PRIVATE_CATEGORIES_OPTION_NAME_I18N + +}; + + +/** + * Value for an option for the POST /private/categories request. + */ +struct TALER_MERCHANT_PostPrivateCategoriesOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostPrivateCategoriesOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_CATEGORIES_OPTION_NAME_I18N. + */ + const json_t *name_i18n; + + } details; + +}; + + +/** + * Handle for a POST /private/categories request. + */ +struct TALER_MERCHANT_PostPrivateCategoriesHandle; + + +/** + * Response details for a POST /private/categories request. + */ +struct TALER_MERCHANT_PostPrivateCategoriesResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Numeric identifier of the newly created category. + */ + uint64_t category_id; + + } ok; + + } details; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object + */ +#define TALER_MERCHANT_post_private_categories_option_end_() \ + (const struct TALER_MERCHANT_PostPrivateCategoriesOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_CATEGORIES_OPTION_END \ + } + +/** + * Set internationalized names. + * + * @param n names JSON object + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_categories_option_name_i18n(n) \ + (const struct TALER_MERCHANT_PostPrivateCategoriesOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_CATEGORIES_OPTION_NAME_I18N, \ + .details.name_i18n = (n) \ + } + + +/** + * Set the requested options for the operation. + * + * @param ppch the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_private_categories_set_options_ ( + struct TALER_MERCHANT_PostPrivateCategoriesHandle *ppch, + unsigned int num_options, + const struct TALER_MERCHANT_PostPrivateCategoriesOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param ppch the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_private_categories_set_options(ppch,...) \ + TALER_MERCHANT_post_private_categories_set_options_ ( \ + ppch, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostPrivateCategoriesOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_private_categories_option_end_ () } \ + )) + + +/** + * Set up POST /private/categories operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param name human-readable name of the category + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateCategoriesHandle * +TALER_MERCHANT_post_private_categories_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *name); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_CATEGORIES_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateCategoriesCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_CATEGORIES_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_CATEGORIES_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/categories request. + * + * @param cls closure + * @param cpr response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateCategoriesCallback)( + TALER_MERCHANT_POST_PRIVATE_CATEGORIES_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateCategoriesResponse *cpr); + + +/** + * Start POST /private/categories operation. + * + * @param[in,out] ppch operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_categories_start ( + struct TALER_MERCHANT_PostPrivateCategoriesHandle *ppch, + TALER_MERCHANT_PostPrivateCategoriesCallback cb, + TALER_MERCHANT_POST_PRIVATE_CATEGORIES_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/categories operation. This function must not be + * called by clients after the TALER_MERCHANT_PostPrivateCategoriesCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] ppch operation to cancel + */ +void +TALER_MERCHANT_post_private_categories_cancel ( + struct TALER_MERCHANT_PostPrivateCategoriesHandle *ppch); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_CATEGORIES_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-donau-new.h b/src/include/taler/taler-merchant/post-private-donau-new.h @@ -0,0 +1,220 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-donau-new.h + * @brief C interface for the POST /private/donau endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_DONAU_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_DONAU_NEW_H + +#include <taler/taler-merchant/common.h> +#include <taler/taler-merchant/post-private-donau.h> + + +/** + * Possible options for the POST /private/donau request. + */ +enum TALER_MERCHANT_PostPrivateDonauOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_PRIVATE_DONAU_OPTION_END = 0, + + /** + * Authentication token for the Donau service. + */ + TALER_MERCHANT_POST_PRIVATE_DONAU_OPTION_AUTH_TOKEN + +}; + + +/** + * Value for an option for the POST /private/donau request. + */ +struct TALER_MERCHANT_PostPrivateDonauOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostPrivateDonauOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_DONAU_OPTION_AUTH_TOKEN. + */ + const char *auth_token; + + } details; + +}; + + +/** + * Handle for a POST /private/donau request. + */ +struct TALER_MERCHANT_PostPrivateDonauHandle; + + +/** + * Response details for a POST /private/donau request. + */ +struct TALER_MERCHANT_PostPrivateDonauResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object + */ +#define TALER_MERCHANT_post_private_donau_option_end_() \ + (const struct TALER_MERCHANT_PostPrivateDonauOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_DONAU_OPTION_END \ + } + +/** + * Set authentication token. + * + * @param t authentication token + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_donau_option_auth_token(t) \ + (const struct TALER_MERCHANT_PostPrivateDonauOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_DONAU_OPTION_AUTH_TOKEN, \ + .details.auth_token = (t) \ + } + + +/** + * Set the requested options for the operation. + * + * @param ppdh the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_private_donau_set_options_ ( + struct TALER_MERCHANT_PostPrivateDonauHandle *ppdh, + unsigned int num_options, + const struct TALER_MERCHANT_PostPrivateDonauOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param ppdh the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_private_donau_set_options(ppdh,...) \ + TALER_MERCHANT_post_private_donau_set_options_ ( \ + ppdh, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostPrivateDonauOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_private_donau_option_end_ () } \ + )) + + +/** + * Set up POST /private/donau operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param charity charity information to register + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateDonauHandle * +TALER_MERCHANT_post_private_donau_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const struct TALER_MERCHANT_Charity *charity); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_DONAU_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateDonauCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_DONAU_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_DONAU_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/donau request. + * + * @param cls closure + * @param pdr response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateDonauCallback)( + TALER_MERCHANT_POST_PRIVATE_DONAU_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateDonauResponse *pdr); + + +/** + * Start POST /private/donau operation. + * + * @param[in,out] ppdh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_donau_start ( + struct TALER_MERCHANT_PostPrivateDonauHandle *ppdh, + TALER_MERCHANT_PostPrivateDonauCallback cb, + TALER_MERCHANT_POST_PRIVATE_DONAU_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/donau operation. This function must not be + * called by clients after the TALER_MERCHANT_PostPrivateDonauCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] ppdh operation to cancel + */ +void +TALER_MERCHANT_post_private_donau_cancel ( + struct TALER_MERCHANT_PostPrivateDonauHandle *ppdh); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_DONAU_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-orders-ORDER_ID-refund-new.h b/src/include/taler/taler-merchant/post-private-orders-ORDER_ID-refund-new.h @@ -0,0 +1,143 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-orders-ORDER_ID-refund-new.h + * @brief C interface for the POST /private/orders/$ORDER_ID/refund endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_ORDERS_ORDER_ID_REFUND_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_ORDERS_ORDER_ID_REFUND_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a POST /private/orders/$ORDER_ID/refund request. + */ +struct TALER_MERCHANT_PostPrivateOrdersRefundHandle; + + +/** + * Response details for a POST /private/orders/$ORDER_ID/refund request. + */ +struct TALER_MERCHANT_PostPrivateOrdersRefundResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Taler refund URI for the wallet. + */ + const char *taler_refund_uri; + + /** + * Hash of the contract terms for this order. + */ + struct TALER_PrivateContractHashP h_contract; + + } ok; + + } details; + +}; + + +/** + * Set up POST /private/orders/$ORDER_ID/refund operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param order_id identifier of the order to refund + * @param refund amount to refund + * @param reason human-readable reason for the refund + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateOrdersRefundHandle * +TALER_MERCHANT_post_private_orders_refund_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *order_id, + const struct TALER_Amount *refund, + const char *reason); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_ORDERS_REFUND_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateOrdersRefundCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_ORDERS_REFUND_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_ORDERS_REFUND_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/orders/$ORDER_ID/refund request. + * + * @param cls closure + * @param rr response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateOrdersRefundCallback)( + TALER_MERCHANT_POST_PRIVATE_ORDERS_REFUND_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateOrdersRefundResponse *rr); + + +/** + * Start POST /private/orders/$ORDER_ID/refund operation. + * + * @param[in,out] porh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_orders_refund_start ( + struct TALER_MERCHANT_PostPrivateOrdersRefundHandle *porh, + TALER_MERCHANT_PostPrivateOrdersRefundCallback cb, + TALER_MERCHANT_POST_PRIVATE_ORDERS_REFUND_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/orders/$ORDER_ID/refund operation. This function + * must not be called by clients after the + * TALER_MERCHANT_PostPrivateOrdersRefundCallback has been invoked (as in + * those cases it'll be called internally by the implementation already). + * + * @param[in] porh operation to cancel + */ +void +TALER_MERCHANT_post_private_orders_refund_cancel ( + struct TALER_MERCHANT_PostPrivateOrdersRefundHandle *porh); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_ORDERS_ORDER_ID_REFUND_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-orders-new.h b/src/include/taler/taler-merchant/post-private-orders-new.h @@ -0,0 +1,472 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-orders-new.h + * @brief C interface for the POST /private/orders endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_ORDERS_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_ORDERS_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * A product from inventory to include in an order. + */ +struct TALER_MERCHANT_PostPrivateOrdersInventoryProduct +{ + + /** + * Identifier of the product. + */ + const char *product_id; + + /** + * Quantity of the product to include. + */ + uint32_t quantity; + + /** + * Fractional part of the quantity. + */ + uint32_t quantity_frac; + + /** + * Whether to use fractional quantity. + */ + bool use_fractional_quantity; + +}; + + +/** + * Possible options for the POST /private/orders request. + */ +enum TALER_MERCHANT_PostPrivateOrdersOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_END = 0, + + /** + * Refund delay. + */ + TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_REFUND_DELAY, + + /** + * Payment target (type of payment method). + */ + TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_PAYMENT_TARGET, + + /** + * Session identifier for session-bound payments. + */ + TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_SESSION_ID, + + /** + * Whether to create a claim token. + */ + TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_CREATE_TOKEN, + + /** + * OTP device ID. + */ + TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_OTP_ID, + + /** + * Inventory products to include in the order. + */ + TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_INVENTORY_PRODUCTS, + + /** + * Lock UUIDs for inventory locks. + */ + TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_LOCK_UUIDS + +}; + + +/** + * Value for an option for the POST /private/orders request. + */ +struct TALER_MERCHANT_PostPrivateOrdersOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostPrivateOrdersOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_REFUND_DELAY. + */ + struct GNUNET_TIME_Relative refund_delay; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_PAYMENT_TARGET. + */ + const char *payment_target; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_SESSION_ID. + */ + const char *session_id; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_CREATE_TOKEN. + */ + bool create_token; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_OTP_ID. + */ + const char *otp_id; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_INVENTORY_PRODUCTS. + */ + struct + { + unsigned int num; + const struct TALER_MERCHANT_PostPrivateOrdersInventoryProduct *products; + } inventory_products; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_LOCK_UUIDS. + */ + struct + { + unsigned int num; + const char **uuids; + } lock_uuids; + + } details; + +}; + + +/** + * Handle for a POST /private/orders request. + */ +struct TALER_MERCHANT_PostPrivateOrdersHandle; + + +/** + * Response details for a POST /private/orders request. + */ +struct TALER_MERCHANT_PostPrivateOrdersResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Identifier of the created order. + */ + const char *order_id; + + /** + * Claim token, or NULL. + */ + const struct TALER_ClaimTokenP *token; + + /** + * Payment deadline. + */ + struct GNUNET_TIME_Timestamp pay_deadline; + + } ok; + + /** + * Details on #MHD_HTTP_GONE (product out of stock). + */ + struct + { + + /** + * Product that is out of stock. + */ + const char *product_id; + + /** + * Requested quantity (integer part). + */ + uint64_t requested_quantity; + + /** + * Requested quantity (fractional part). + */ + uint32_t requested_quantity_frac; + + /** + * Available quantity (integer part). + */ + uint64_t available_quantity; + + /** + * Available quantity (fractional part). + */ + uint32_t available_quantity_frac; + + /** + * Expected restock time. + */ + struct GNUNET_TIME_Timestamp restock_expected; + + } gone; + + } details; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object + */ +#define TALER_MERCHANT_post_private_orders_option_end_() \ + (const struct TALER_MERCHANT_PostPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_END \ + } + +/** + * Set refund delay. + * + * @param d refund delay + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_orders_option_refund_delay(d) \ + (const struct TALER_MERCHANT_PostPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_REFUND_DELAY, \ + .details.refund_delay = (d) \ + } + +/** + * Set payment target. + * + * @param t payment target string + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_orders_option_payment_target(t) \ + (const struct TALER_MERCHANT_PostPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_PAYMENT_TARGET, \ + .details.payment_target = (t) \ + } + +/** + * Set session identifier. + * + * @param s session ID + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_orders_option_session_id(s) \ + (const struct TALER_MERCHANT_PostPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_SESSION_ID, \ + .details.session_id = (s) \ + } + +/** + * Set whether to create a claim token. + * + * @param c true to create token + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_orders_option_create_token(c) \ + (const struct TALER_MERCHANT_PostPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_CREATE_TOKEN, \ + .details.create_token = (c) \ + } + +/** + * Set OTP device ID. + * + * @param o OTP device ID + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_orders_option_otp_id(o) \ + (const struct TALER_MERCHANT_PostPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_OTP_ID, \ + .details.otp_id = (o) \ + } + +/** + * Set inventory products. + * + * @param n number of products + * @param p array of inventory products + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_orders_option_inventory_products(n,p) \ + (const struct TALER_MERCHANT_PostPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_INVENTORY_PRODUCTS \ + , \ + .details.inventory_products = { .num = (n), .products = (p) } \ + } + +/** + * Set lock UUIDs. + * + * @param n number of UUIDs + * @param u array of UUID strings + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_orders_option_lock_uuids(n,u) \ + (const struct TALER_MERCHANT_PostPrivateOrdersOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_ORDERS_OPTION_LOCK_UUIDS, \ + .details.lock_uuids = { .num = (n), .uuids = (u) } \ + } + + +/** + * Set the requested options for the operation. + * + * @param ppoh the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_private_orders_set_options_ ( + struct TALER_MERCHANT_PostPrivateOrdersHandle *ppoh, + unsigned int num_options, + const struct TALER_MERCHANT_PostPrivateOrdersOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param ppoh the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_private_orders_set_options(ppoh,...) \ + TALER_MERCHANT_post_private_orders_set_options_ ( \ + ppoh, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostPrivateOrdersOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_private_orders_option_end_ () } \ + )) + + +/** + * Set up POST /private/orders operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param order order contract (JSON) + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateOrdersHandle * +TALER_MERCHANT_post_private_orders_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const json_t *order); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_ORDERS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateOrdersCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_ORDERS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_ORDERS_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/orders request. + * + * @param cls closure + * @param por response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateOrdersCallback)( + TALER_MERCHANT_POST_PRIVATE_ORDERS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateOrdersResponse *por); + + +/** + * Start POST /private/orders operation. + * + * @param[in,out] ppoh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_orders_start ( + struct TALER_MERCHANT_PostPrivateOrdersHandle *ppoh, + TALER_MERCHANT_PostPrivateOrdersCallback cb, + TALER_MERCHANT_POST_PRIVATE_ORDERS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/orders operation. This function must not be + * called by clients after the TALER_MERCHANT_PostPrivateOrdersCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] ppoh operation to cancel + */ +void +TALER_MERCHANT_post_private_orders_cancel ( + struct TALER_MERCHANT_PostPrivateOrdersHandle *ppoh); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_ORDERS_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-otp-devices-new.h b/src/include/taler/taler-merchant/post-private-otp-devices-new.h @@ -0,0 +1,121 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-otp-devices-new.h + * @brief C interface for the POST /private/otp-devices endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_OTP_DEVICES_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_OTP_DEVICES_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a POST /private/otp-devices request. + */ +struct TALER_MERCHANT_PostPrivateOtpDevicesHandle; + + +/** + * Response details for a POST /private/otp-devices request. + */ +struct TALER_MERCHANT_PostPrivateOtpDevicesResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Set up POST /private/otp-devices operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param otp_device_id identifier for the new OTP device + * @param otp_device_description human-readable description + * @param otp_key base32-encoded OTP secret key + * @param otp_algorithm OTP algorithm to use + * @param otp_ctr initial counter value (for HOTP) + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateOtpDevicesHandle * +TALER_MERCHANT_post_private_otp_devices_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *otp_device_id, + const char *otp_device_description, + const char *otp_key, + enum TALER_MerchantConfirmationAlgorithm otp_algorithm, + uint64_t otp_ctr); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_OTP_DEVICES_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateOtpDevicesCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_OTP_DEVICES_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_OTP_DEVICES_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/otp-devices request. + * + * @param cls closure + * @param odr response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateOtpDevicesCallback)( + TALER_MERCHANT_POST_PRIVATE_OTP_DEVICES_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateOtpDevicesResponse *odr); + + +/** + * Start POST /private/otp-devices operation. + * + * @param[in,out] ppoh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_otp_devices_start ( + struct TALER_MERCHANT_PostPrivateOtpDevicesHandle *ppoh, + TALER_MERCHANT_PostPrivateOtpDevicesCallback cb, + TALER_MERCHANT_POST_PRIVATE_OTP_DEVICES_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/otp-devices operation. This function must not be + * called by clients after the TALER_MERCHANT_PostPrivateOtpDevicesCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] ppoh operation to cancel + */ +void +TALER_MERCHANT_post_private_otp_devices_cancel ( + struct TALER_MERCHANT_PostPrivateOtpDevicesHandle *ppoh); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_OTP_DEVICES_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-products-PRODUCT_ID-lock-new.h b/src/include/taler/taler-merchant/post-private-products-PRODUCT_ID-lock-new.h @@ -0,0 +1,253 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-products-PRODUCT_ID-lock-new.h + * @brief C interface for the POST /private/products/$PRODUCT_ID/lock endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_PRODUCTS_PRODUCT_ID_LOCK_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_PRODUCTS_PRODUCT_ID_LOCK_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options for the POST /private/products/$PRODUCT_ID/lock request. + */ +enum TALER_MERCHANT_PostPrivateProductsLockOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_OPTION_END = 0, + + /** + * Fractional part of the quantity to lock. + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_OPTION_QUANTITY_FRAC, + + /** + * Whether to use fractional quantity. + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_OPTION_USE_FRACTIONAL_QUANTITY + +}; + + +/** + * Value for an option for the POST /private/products/$PRODUCT_ID/lock request. + */ +struct TALER_MERCHANT_PostPrivateProductsLockOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostPrivateProductsLockOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_OPTION_QUANTITY_FRAC. + */ + uint32_t quantity_frac; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_OPTION_USE_FRACTIONAL_QUANTITY. + */ + bool use_fractional_quantity; + + } details; + +}; + + +/** + * Handle for a POST /private/products/$PRODUCT_ID/lock request. + */ +struct TALER_MERCHANT_PostPrivateProductsLockHandle; + + +/** + * Response details for a POST /private/products/$PRODUCT_ID/lock request. + */ +struct TALER_MERCHANT_PostPrivateProductsLockResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object + */ +#define TALER_MERCHANT_post_private_products_lock_option_end_() \ + (const struct TALER_MERCHANT_PostPrivateProductsLockOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_OPTION_END \ + } + +/** + * Set fractional part of quantity. + * + * @param f fractional part + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_products_lock_option_quantity_frac(f) \ + (const struct TALER_MERCHANT_PostPrivateProductsLockOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_OPTION_QUANTITY_FRAC, \ + .details.quantity_frac = (f) \ + } + +/** + * Set whether to use fractional quantity. + * + * @param b true to use fractional quantity + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_products_lock_option_use_fractional_quantity \ + (b) \ + (const struct TALER_MERCHANT_PostPrivateProductsLockOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_OPTION_USE_FRACTIONAL_QUANTITY, \ + .details.use_fractional_quantity = (b) \ + } + + +/** + * Set the requested options for the operation. + * + * @param pplh the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_private_products_lock_set_options_ ( + struct TALER_MERCHANT_PostPrivateProductsLockHandle *pplh, + unsigned int num_options, + const struct TALER_MERCHANT_PostPrivateProductsLockOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param pplh the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_private_products_lock_set_options(pplh,...) \ + TALER_MERCHANT_post_private_products_lock_set_options_ ( \ + pplh, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostPrivateProductsLockOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_private_products_lock_option_end_ \ + () } \ + )) + + +/** + * Set up POST /private/products/$PRODUCT_ID/lock operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param product_id identifier of the product to lock + * @param uuid idempotency UUID for this lock operation + * @param duration how long to lock the inventory + * @param quantity number of units to lock + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateProductsLockHandle * +TALER_MERCHANT_post_private_products_lock_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *product_id, + const char *uuid, + struct GNUNET_TIME_Relative duration, + uint64_t quantity); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateProductsLockCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/products/$PRODUCT_ID/lock request. + * + * @param cls closure + * @param plr response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateProductsLockCallback)( + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateProductsLockResponse *plr); + + +/** + * Start POST /private/products/$PRODUCT_ID/lock operation. + * + * @param[in,out] pplh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_products_lock_start ( + struct TALER_MERCHANT_PostPrivateProductsLockHandle *pplh, + TALER_MERCHANT_PostPrivateProductsLockCallback cb, + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_LOCK_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/products/$PRODUCT_ID/lock operation. This function + * must not be called by clients after the + * TALER_MERCHANT_PostPrivateProductsLockCallback has been invoked (as in + * those cases it'll be called internally by the implementation already). + * + * @param[in] pplh operation to cancel + */ +void +TALER_MERCHANT_post_private_products_lock_cancel ( + struct TALER_MERCHANT_PostPrivateProductsLockHandle *pplh); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_PRODUCTS_PRODUCT_ID_LOCK_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-products-new.h b/src/include/taler/taler-merchant/post-private-products-new.h @@ -0,0 +1,459 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-products-new.h + * @brief C interface for the POST /private/products endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_PRODUCTS_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_PRODUCTS_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options for the POST /private/products request. + */ +enum TALER_MERCHANT_PostPrivateProductsOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_END = 0, + + /** + * Internationalized descriptions (JSON). + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_DESCRIPTION_I18N, + + /** + * Tax information (JSON array). + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_TAXES, + + /** + * Storage location (JSON). + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_ADDRESS, + + /** + * Expected restock time. + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_NEXT_RESTOCK, + + /** + * Minimum age requirement. + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_MINIMUM_AGE, + + /** + * Category IDs. + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_CATEGORIES, + + /** + * Additional unit prices. + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_UNIT_PRICES, + + /** + * Fractional part of total stock. + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_TOTAL_STOCK_FRAC, + + /** + * Whether fractional quantities are allowed. + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_UNIT_ALLOW_FRACTION, + + /** + * Precision level for fractions. + */ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_UNIT_PRECISION_LEVEL + +}; + + +/** + * Value for an option for the POST /private/products request. + */ +struct TALER_MERCHANT_PostPrivateProductsOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostPrivateProductsOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_DESCRIPTION_I18N. + */ + const json_t *description_i18n; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_TAXES. + */ + const json_t *taxes; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_ADDRESS. + */ + const json_t *address; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_NEXT_RESTOCK. + */ + struct GNUNET_TIME_Timestamp next_restock; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_MINIMUM_AGE. + */ + uint32_t minimum_age; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_CATEGORIES. + */ + struct + { + unsigned int num; + const uint64_t *cats; + } categories; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_UNIT_PRICES. + */ + struct + { + const struct TALER_Amount *prices; + size_t len; + } unit_prices; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_TOTAL_STOCK_FRAC. + */ + uint32_t total_stock_frac; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_UNIT_ALLOW_FRACTION. + */ + bool unit_allow_fraction; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_UNIT_PRECISION_LEVEL. + */ + uint32_t unit_precision_level; + + } details; + +}; + + +/** + * Handle for a POST /private/products request. + */ +struct TALER_MERCHANT_PostPrivateProductsHandle; + + +/** + * Response details for a POST /private/products request. + */ +struct TALER_MERCHANT_PostPrivateProductsResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object of struct TALER_MERCHANT_PostPrivateProductsOptionValue + */ +#define TALER_MERCHANT_post_private_products_option_end_() \ + (const struct TALER_MERCHANT_PostPrivateProductsOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_END \ + } + +/** + * Set internationalized descriptions. + * + * @param d descriptions JSON object + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_products_option_description_i18n(d) \ + (const struct TALER_MERCHANT_PostPrivateProductsOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_DESCRIPTION_I18N \ + , \ + .details.description_i18n = (d) \ + } + +/** + * Set tax information. + * + * @param t taxes JSON array + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_products_option_taxes(t) \ + (const struct TALER_MERCHANT_PostPrivateProductsOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_TAXES, \ + .details.taxes = (t) \ + } + +/** + * Set storage address. + * + * @param a address JSON object + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_products_option_address(a) \ + (const struct TALER_MERCHANT_PostPrivateProductsOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_ADDRESS, \ + .details.address = (a) \ + } + +/** + * Set expected restock time. + * + * @param r restock timestamp + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_products_option_next_restock(r) \ + (const struct TALER_MERCHANT_PostPrivateProductsOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_NEXT_RESTOCK, \ + .details.next_restock = (r) \ + } + +/** + * Set minimum age requirement. + * + * @param a minimum age (0 for none) + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_products_option_minimum_age(a) \ + (const struct TALER_MERCHANT_PostPrivateProductsOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_MINIMUM_AGE, \ + .details.minimum_age = (a) \ + } + +/** + * Set category IDs. + * + * @param n number of categories + * @param c array of category IDs + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_products_option_categories(n,c) \ + (const struct TALER_MERCHANT_PostPrivateProductsOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_CATEGORIES, \ + .details.categories = { .num = (n), .cats = (c) } \ + } + +/** + * Set additional unit prices. + * + * @param p array of unit prices + * @param l number of prices + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_products_option_unit_prices(p,l) \ + (const struct TALER_MERCHANT_PostPrivateProductsOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_UNIT_PRICES, \ + .details.unit_prices = { .prices = (p), .len = (l) } \ + } + +/** + * Set fractional part of total stock. + * + * @param f fractional part + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_products_option_total_stock_frac(f) \ + (const struct TALER_MERCHANT_PostPrivateProductsOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_TOTAL_STOCK_FRAC \ + , \ + .details.total_stock_frac = (f) \ + } + +/** + * Set whether fractional quantities are allowed. + * + * @param b true to allow fractions + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_products_option_unit_allow_fraction(b) \ + (const struct TALER_MERCHANT_PostPrivateProductsOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_UNIT_ALLOW_FRACTION, \ + .details.unit_allow_fraction = (b) \ + } + +/** + * Set precision level for fractional quantities. + * + * @param p precision level + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_products_option_unit_precision_level(p) \ + (const struct TALER_MERCHANT_PostPrivateProductsOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_OPTION_UNIT_PRECISION_LEVEL, \ + .details.unit_precision_level = (p) \ + } + + +/** + * Set the requested options for the operation. + * + * @param ppph the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_private_products_set_options_ ( + struct TALER_MERCHANT_PostPrivateProductsHandle *ppph, + unsigned int num_options, + const struct TALER_MERCHANT_PostPrivateProductsOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param ppph the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_private_products_set_options(ppph,...) \ + TALER_MERCHANT_post_private_products_set_options_ ( \ + ppph, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostPrivateProductsOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_private_products_option_end_ () } \ + )) + + +/** + * Set up POST /private/products operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param product_id identifier for the new product + * @param description human-readable product description + * @param unit unit of measurement + * @param price unit price + * @param image base64-encoded image, or empty string + * @param total_stock total stock (-1 for unlimited) + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateProductsHandle * +TALER_MERCHANT_post_private_products_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *product_id, + const char *description, + const char *unit, + const struct TALER_Amount *price, + const char *image, + int64_t total_stock); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_PRODUCTS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateProductsCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_PRODUCTS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_PRODUCTS_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/products request. + * + * @param cls closure + * @param ppr response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateProductsCallback)( + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateProductsResponse *ppr); + + +/** + * Start POST /private/products operation. + * + * @param[in,out] ppph operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_products_start ( + struct TALER_MERCHANT_PostPrivateProductsHandle *ppph, + TALER_MERCHANT_PostPrivateProductsCallback cb, + TALER_MERCHANT_POST_PRIVATE_PRODUCTS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/products operation. This function must not be + * called by clients after the TALER_MERCHANT_PostPrivateProductsCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] ppph operation to cancel + */ +void +TALER_MERCHANT_post_private_products_cancel ( + struct TALER_MERCHANT_PostPrivateProductsHandle *ppph); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_PRODUCTS_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-templates-new.h b/src/include/taler/taler-merchant/post-private-templates-new.h @@ -0,0 +1,223 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-templates-new.h + * @brief C interface for the POST /private/templates endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_TEMPLATES_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_TEMPLATES_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options for the POST /private/templates request. + */ +enum TALER_MERCHANT_PostPrivateTemplatesOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_PRIVATE_TEMPLATES_OPTION_END = 0, + + /** + * OTP device ID to associate with the template. + */ + TALER_MERCHANT_POST_PRIVATE_TEMPLATES_OPTION_OTP_ID + +}; + + +/** + * Value for an option for the POST /private/templates request. + */ +struct TALER_MERCHANT_PostPrivateTemplatesOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostPrivateTemplatesOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_TEMPLATES_OPTION_OTP_ID. + */ + const char *otp_id; + + } details; + +}; + + +/** + * Handle for a POST /private/templates request. + */ +struct TALER_MERCHANT_PostPrivateTemplatesHandle; + + +/** + * Response details for a POST /private/templates request. + */ +struct TALER_MERCHANT_PostPrivateTemplatesResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object + */ +#define TALER_MERCHANT_post_private_templates_option_end_() \ + (const struct TALER_MERCHANT_PostPrivateTemplatesOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_TEMPLATES_OPTION_END \ + } + +/** + * Set OTP device ID. + * + * @param o OTP device ID + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_templates_option_otp_id(o) \ + (const struct TALER_MERCHANT_PostPrivateTemplatesOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_TEMPLATES_OPTION_OTP_ID, \ + .details.otp_id = (o) \ + } + + +/** + * Set the requested options for the operation. + * + * @param ppth the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_private_templates_set_options_ ( + struct TALER_MERCHANT_PostPrivateTemplatesHandle *ppth, + unsigned int num_options, + const struct TALER_MERCHANT_PostPrivateTemplatesOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param ppth the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_private_templates_set_options(ppth,...) \ + TALER_MERCHANT_post_private_templates_set_options_ ( \ + ppth, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostPrivateTemplatesOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_private_templates_option_end_ () } \ + )) + + +/** + * Set up POST /private/templates operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param template_id identifier for the new template + * @param template_description human-readable description + * @param template_contract template contract (JSON) + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateTemplatesHandle * +TALER_MERCHANT_post_private_templates_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *template_id, + const char *template_description, + const json_t *template_contract); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_TEMPLATES_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateTemplatesCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_TEMPLATES_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_TEMPLATES_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/templates request. + * + * @param cls closure + * @param ptr response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateTemplatesCallback)( + TALER_MERCHANT_POST_PRIVATE_TEMPLATES_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateTemplatesResponse *ptr); + + +/** + * Start POST /private/templates operation. + * + * @param[in,out] ppth operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_templates_start ( + struct TALER_MERCHANT_PostPrivateTemplatesHandle *ppth, + TALER_MERCHANT_PostPrivateTemplatesCallback cb, + TALER_MERCHANT_POST_PRIVATE_TEMPLATES_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/templates operation. This function must not be + * called by clients after the TALER_MERCHANT_PostPrivateTemplatesCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] ppth operation to cancel + */ +void +TALER_MERCHANT_post_private_templates_cancel ( + struct TALER_MERCHANT_PostPrivateTemplatesHandle *ppth); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_TEMPLATES_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-token-new.h b/src/include/taler/taler-merchant/post-private-token-new.h @@ -0,0 +1,119 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-token-new.h + * @brief C interface for the POST /private/token endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_TOKEN_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_TOKEN_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a POST /private/token request. + */ +struct TALER_MERCHANT_PostPrivateTokenHandle; + + +/** + * Response details for a POST /private/token request. + */ +struct TALER_MERCHANT_PostPrivateTokenResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Set up POST /private/token operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param instance_id identifier of the instance + * @param scope scope for the token + * @param duration how long the token should be valid + * @param refreshable whether the token may be refreshed + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateTokenHandle * +TALER_MERCHANT_post_private_token_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *instance_id, + const char *scope, + struct GNUNET_TIME_Relative duration, + bool refreshable); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_TOKEN_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateTokenCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_TOKEN_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_TOKEN_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/token request. + * + * @param cls closure + * @param ptr response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateTokenCallback)( + TALER_MERCHANT_POST_PRIVATE_TOKEN_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateTokenResponse *ptr); + + +/** + * Start POST /private/token operation. + * + * @param[in,out] ppth operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_token_start ( + struct TALER_MERCHANT_PostPrivateTokenHandle *ppth, + TALER_MERCHANT_PostPrivateTokenCallback cb, + TALER_MERCHANT_POST_PRIVATE_TOKEN_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/token operation. This function must not be + * called by clients after the TALER_MERCHANT_PostPrivateTokenCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] ppth operation to cancel + */ +void +TALER_MERCHANT_post_private_token_cancel ( + struct TALER_MERCHANT_PostPrivateTokenHandle *ppth); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_TOKEN_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-tokenfamilies-new.h b/src/include/taler/taler-merchant/post-private-tokenfamilies-new.h @@ -0,0 +1,261 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-tokenfamilies-new.h + * @brief C interface for the POST /private/tokenfamilies endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_TOKENFAMILIES_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_TOKENFAMILIES_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options for the POST /private/tokenfamilies request. + */ +enum TALER_MERCHANT_PostPrivateTokenfamiliesOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_OPTION_END = 0, + + /** + * Internationalized descriptions (JSON). + */ + TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_OPTION_DESCRIPTION_I18N, + + /** + * Extra data (JSON). + */ + TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_OPTION_EXTRA_DATA + +}; + + +/** + * Value for an option for the POST /private/tokenfamilies request. + */ +struct TALER_MERCHANT_PostPrivateTokenfamiliesOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostPrivateTokenfamiliesOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_OPTION_DESCRIPTION_I18N. + */ + const json_t *description_i18n; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_OPTION_EXTRA_DATA. + */ + const json_t *extra_data; + + } details; + +}; + + +/** + * Handle for a POST /private/tokenfamilies request. + */ +struct TALER_MERCHANT_PostPrivateTokenfamiliesHandle; + + +/** + * Response details for a POST /private/tokenfamilies request. + */ +struct TALER_MERCHANT_PostPrivateTokenfamiliesResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object + */ +#define TALER_MERCHANT_post_private_tokenfamilies_option_end_() \ + (const struct TALER_MERCHANT_PostPrivateTokenfamiliesOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_OPTION_END \ + } + +/** + * Set internationalized descriptions. + * + * @param d descriptions JSON object + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_tokenfamilies_option_description_i18n(d) \ + (const struct TALER_MERCHANT_PostPrivateTokenfamiliesOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_OPTION_DESCRIPTION_I18N, \ + .details.description_i18n = (d) \ + } + +/** + * Set extra data. + * + * @param e extra data JSON object + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_tokenfamilies_option_extra_data(e) \ + (const struct TALER_MERCHANT_PostPrivateTokenfamiliesOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_OPTION_EXTRA_DATA, \ + .details.extra_data = (e) \ + } + + +/** + * Set the requested options for the operation. + * + * @param ptfh the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_private_tokenfamilies_set_options_ ( + struct TALER_MERCHANT_PostPrivateTokenfamiliesHandle *ptfh, + unsigned int num_options, + const struct TALER_MERCHANT_PostPrivateTokenfamiliesOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param ptfh the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_private_tokenfamilies_set_options(ptfh,...) \ + TALER_MERCHANT_post_private_tokenfamilies_set_options_ ( \ + ptfh, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostPrivateTokenfamiliesOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_private_tokenfamilies_option_end_ \ + () } \ + )) + + +/** + * Set up POST /private/tokenfamilies operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param slug URL-safe slug identifier for the new token family + * @param name human-readable name + * @param description human-readable description + * @param valid_after start of validity period + * @param valid_before end of validity period + * @param duration duration of individual token validity + * @param validity_granularity granularity for validity alignment + * @param start_offset offset from purchase to start of validity + * @param kind kind of token family ("subscription" or "discount") + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateTokenfamiliesHandle * +TALER_MERCHANT_post_private_tokenfamilies_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *slug, + const char *name, + const char *description, + struct GNUNET_TIME_Timestamp valid_after, + struct GNUNET_TIME_Timestamp valid_before, + struct GNUNET_TIME_Relative duration, + struct GNUNET_TIME_Relative validity_granularity, + struct GNUNET_TIME_Relative start_offset, + const char *kind); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateTokenfamiliesCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/tokenfamilies request. + * + * @param cls closure + * @param tfr response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateTokenfamiliesCallback)( + TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateTokenfamiliesResponse *tfr); + + +/** + * Start POST /private/tokenfamilies operation. + * + * @param[in,out] ptfh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_tokenfamilies_start ( + struct TALER_MERCHANT_PostPrivateTokenfamiliesHandle *ptfh, + TALER_MERCHANT_PostPrivateTokenfamiliesCallback cb, + TALER_MERCHANT_POST_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/tokenfamilies operation. This function must not be + * called by clients after the + * TALER_MERCHANT_PostPrivateTokenfamiliesCallback has been invoked (as in + * those cases it'll be called internally by the implementation already). + * + * @param[in] ptfh operation to cancel + */ +void +TALER_MERCHANT_post_private_tokenfamilies_cancel ( + struct TALER_MERCHANT_PostPrivateTokenfamiliesHandle *ptfh); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_TOKENFAMILIES_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-transfers-new.h b/src/include/taler/taler-merchant/post-private-transfers-new.h @@ -0,0 +1,145 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-transfers-new.h + * @brief C interface for the POST /private/transfers endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_TRANSFERS_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_TRANSFERS_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a POST /private/transfers request. + */ +struct TALER_MERCHANT_PostPrivateTransfersHandle; + + +/** + * Response details for a POST /private/transfers request. + */ +struct TALER_MERCHANT_PostPrivateTransfersResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_BAD_GATEWAY (exchange returned an error). + */ + struct + { + + /** + * Error code returned by the exchange. + */ + enum TALER_ErrorCode exchange_ec; + + /** + * HTTP status code returned by the exchange. + */ + unsigned int exchange_http_status; + + } bad_gateway; + + } details; + +}; + + +/** + * Set up POST /private/transfers operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param credit_amount amount credited in this transfer + * @param wtid wire transfer identifier + * @param payto_uri payto URI of the merchant account that received the funds + * @param exchange_url base URL of the exchange that made the transfer + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateTransfersHandle * +TALER_MERCHANT_post_private_transfers_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const struct TALER_Amount *credit_amount, + const struct TALER_WireTransferIdentifierRawP *wtid, + struct TALER_FullPayto payto_uri, + const char *exchange_url); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_TRANSFERS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateTransfersCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_TRANSFERS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_TRANSFERS_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/transfers request. + * + * @param cls closure + * @param ptr response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateTransfersCallback)( + TALER_MERCHANT_POST_PRIVATE_TRANSFERS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateTransfersResponse *ptr); + + +/** + * Start POST /private/transfers operation. + * + * @param[in,out] ppth operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_transfers_start ( + struct TALER_MERCHANT_PostPrivateTransfersHandle *ppth, + TALER_MERCHANT_PostPrivateTransfersCallback cb, + TALER_MERCHANT_POST_PRIVATE_TRANSFERS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/transfers operation. This function must not be + * called by clients after the TALER_MERCHANT_PostPrivateTransfersCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] ppth operation to cancel + */ +void +TALER_MERCHANT_post_private_transfers_cancel ( + struct TALER_MERCHANT_PostPrivateTransfersHandle *ppth); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_TRANSFERS_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-units-new.h b/src/include/taler/taler-merchant/post-private-units-new.h @@ -0,0 +1,255 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-units-new.h + * @brief C interface for the POST /private/units endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_UNITS_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_UNITS_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options for the POST /private/units request. + */ +enum TALER_MERCHANT_PostPrivateUnitsOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_PRIVATE_UNITS_OPTION_END = 0, + + /** + * Internationalized long names (JSON). + */ + TALER_MERCHANT_POST_PRIVATE_UNITS_OPTION_UNIT_NAME_LONG_I18N, + + /** + * Internationalized short names (JSON). + */ + TALER_MERCHANT_POST_PRIVATE_UNITS_OPTION_UNIT_NAME_SHORT_I18N + +}; + + +/** + * Value for an option for the POST /private/units request. + */ +struct TALER_MERCHANT_PostPrivateUnitsOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostPrivateUnitsOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_UNITS_OPTION_UNIT_NAME_LONG_I18N. + */ + const json_t *unit_name_long_i18n; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_PRIVATE_UNITS_OPTION_UNIT_NAME_SHORT_I18N. + */ + const json_t *unit_name_short_i18n; + + } details; + +}; + + +/** + * Handle for a POST /private/units request. + */ +struct TALER_MERCHANT_PostPrivateUnitsHandle; + + +/** + * Response details for a POST /private/units request. + */ +struct TALER_MERCHANT_PostPrivateUnitsResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object + */ +#define TALER_MERCHANT_post_private_units_option_end_() \ + (const struct TALER_MERCHANT_PostPrivateUnitsOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_UNITS_OPTION_END \ + } + +/** + * Set internationalized long names. + * + * @param j long names JSON object + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_units_option_unit_name_long_i18n(j) \ + (const struct TALER_MERCHANT_PostPrivateUnitsOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_PRIVATE_UNITS_OPTION_UNIT_NAME_LONG_I18N \ + , \ + .details.unit_name_long_i18n = (j) \ + } + +/** + * Set internationalized short names. + * + * @param j short names JSON object + * @return representation of the option + */ +#define TALER_MERCHANT_post_private_units_option_unit_name_short_i18n(j) \ + (const struct TALER_MERCHANT_PostPrivateUnitsOptionValue) \ + { \ + .option = \ + TALER_MERCHANT_POST_PRIVATE_UNITS_OPTION_UNIT_NAME_SHORT_I18N, \ + .details.unit_name_short_i18n = (j) \ + } + + +/** + * Set the requested options for the operation. + * + * @param ppuh the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_private_units_set_options_ ( + struct TALER_MERCHANT_PostPrivateUnitsHandle *ppuh, + unsigned int num_options, + const struct TALER_MERCHANT_PostPrivateUnitsOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param ppuh the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_private_units_set_options(ppuh,...) \ + TALER_MERCHANT_post_private_units_set_options_ ( \ + ppuh, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostPrivateUnitsOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_private_units_option_end_ () } \ + )) + + +/** + * Set up POST /private/units operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param unit_id identifier for the new unit + * @param unit_name_long long human-readable name + * @param unit_name_short short symbol for the unit + * @param unit_allow_fraction whether fractional quantities are allowed + * @param unit_precision_level precision level for fractional quantities + * @param unit_active whether the unit is active + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateUnitsHandle * +TALER_MERCHANT_post_private_units_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *unit_id, + const char *unit_name_long, + const char *unit_name_short, + bool unit_allow_fraction, + uint32_t unit_precision_level, + bool unit_active); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_UNITS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateUnitsCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_UNITS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_UNITS_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/units request. + * + * @param cls closure + * @param pur response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateUnitsCallback)( + TALER_MERCHANT_POST_PRIVATE_UNITS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateUnitsResponse *pur); + + +/** + * Start POST /private/units operation. + * + * @param[in,out] ppuh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_units_start ( + struct TALER_MERCHANT_PostPrivateUnitsHandle *ppuh, + TALER_MERCHANT_PostPrivateUnitsCallback cb, + TALER_MERCHANT_POST_PRIVATE_UNITS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/units operation. This function must not be + * called by clients after the TALER_MERCHANT_PostPrivateUnitsCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] ppuh operation to cancel + */ +void +TALER_MERCHANT_post_private_units_cancel ( + struct TALER_MERCHANT_PostPrivateUnitsHandle *ppuh); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_UNITS_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-private-webhooks-new.h b/src/include/taler/taler-merchant/post-private-webhooks-new.h @@ -0,0 +1,123 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-private-webhooks-new.h + * @brief C interface for the POST /private/webhooks endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_PRIVATE_WEBHOOKS_NEW_H +#define _TALER_MERCHANT__POST_PRIVATE_WEBHOOKS_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Handle for a POST /private/webhooks request. + */ +struct TALER_MERCHANT_PostPrivateWebhooksHandle; + + +/** + * Response details for a POST /private/webhooks request. + */ +struct TALER_MERCHANT_PostPrivateWebhooksResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + +}; + + +/** + * Set up POST /private/webhooks operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param webhook_id identifier for the new webhook + * @param event_type event type that triggers this webhook + * @param notification_url URL to send notifications to + * @param http_method HTTP method to use for notifications + * @param header_template template for HTTP request headers + * @param body_template template for the HTTP request body + * @return handle to operation + */ +struct TALER_MERCHANT_PostPrivateWebhooksHandle * +TALER_MERCHANT_post_private_webhooks_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *webhook_id, + const char *event_type, + const char *notification_url, + const char *http_method, + const char *header_template, + const char *body_template); + + +#ifndef TALER_MERCHANT_POST_PRIVATE_WEBHOOKS_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostPrivateWebhooksCallback. + */ +#define TALER_MERCHANT_POST_PRIVATE_WEBHOOKS_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_PRIVATE_WEBHOOKS_RESULT_CLOSURE */ + +/** + * Callback for a POST /private/webhooks request. + * + * @param cls closure + * @param wpr response details + */ +typedef void +(*TALER_MERCHANT_PostPrivateWebhooksCallback)( + TALER_MERCHANT_POST_PRIVATE_WEBHOOKS_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostPrivateWebhooksResponse *wpr); + + +/** + * Start POST /private/webhooks operation. + * + * @param[in,out] ppwh operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_private_webhooks_start ( + struct TALER_MERCHANT_PostPrivateWebhooksHandle *ppwh, + TALER_MERCHANT_PostPrivateWebhooksCallback cb, + TALER_MERCHANT_POST_PRIVATE_WEBHOOKS_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /private/webhooks operation. This function must not be + * called by clients after the TALER_MERCHANT_PostPrivateWebhooksCallback + * has been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] ppwh operation to cancel + */ +void +TALER_MERCHANT_post_private_webhooks_cancel ( + struct TALER_MERCHANT_PostPrivateWebhooksHandle *ppwh); + + +#endif /* _TALER_MERCHANT__POST_PRIVATE_WEBHOOKS_NEW_H */ diff --git a/src/include/taler/taler-merchant/post-templates-TEMPLATE_ID-new.h b/src/include/taler/taler-merchant/post-templates-TEMPLATE_ID-new.h @@ -0,0 +1,298 @@ +/* + This file is part of TALER + Copyright (C) 2014-2026 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file include/taler/taler-merchant/post-templates-TEMPLATE_ID-new.h + * @brief C interface for the POST /templates/$TEMPLATE_ID endpoint + * @author Christian Grothoff + */ +#ifndef _TALER_MERCHANT__POST_TEMPLATES_TEMPLATE_ID_NEW_H +#define _TALER_MERCHANT__POST_TEMPLATES_TEMPLATE_ID_NEW_H + +#include <taler/taler-merchant/common.h> + + +/** + * Possible options for the POST /templates/$TEMPLATE_ID request. + */ +enum TALER_MERCHANT_PostTemplatesOption +{ + /** + * End of list of options. + */ + TALER_MERCHANT_POST_TEMPLATES_OPTION_END = 0, + + /** + * Order summary. + */ + TALER_MERCHANT_POST_TEMPLATES_OPTION_SUMMARY, + + /** + * Total amount for the order. + */ + TALER_MERCHANT_POST_TEMPLATES_OPTION_AMOUNT, + + /** + * Detailed contract customization (JSON). + */ + TALER_MERCHANT_POST_TEMPLATES_OPTION_DETAILS + +}; + + +/** + * Value for an option for the POST /templates/$TEMPLATE_ID request. + */ +struct TALER_MERCHANT_PostTemplatesOptionValue +{ + + /** + * Type of the option being set. + */ + enum TALER_MERCHANT_PostTemplatesOption option; + + /** + * Specific option value. + */ + union + { + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_TEMPLATES_OPTION_SUMMARY. + */ + const char *summary; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_TEMPLATES_OPTION_AMOUNT. + */ + const struct TALER_Amount *amount; + + /** + * Value if @e option is + * #TALER_MERCHANT_POST_TEMPLATES_OPTION_DETAILS. + */ + const json_t *details; + + } details; + +}; + + +/** + * Handle for a POST /templates/$TEMPLATE_ID request. + */ +struct TALER_MERCHANT_PostTemplatesHandle; + + +/** + * Response details for a POST /templates/$TEMPLATE_ID request. + */ +struct TALER_MERCHANT_PostTemplatesResponse +{ + + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Identifier of the created order. + */ + const char *order_id; + + /** + * Claim token, or NULL. + */ + const struct TALER_ClaimTokenP *token; + + /** + * Payment deadline. + */ + struct GNUNET_TIME_Timestamp pay_deadline; + + } ok; + + } details; + +}; + + +/** + * Terminate the list of the options. + * + * @return the terminating object + */ +#define TALER_MERCHANT_post_templates_option_end_() \ + (const struct TALER_MERCHANT_PostTemplatesOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_TEMPLATES_OPTION_END \ + } + +/** + * Set order summary. + * + * @param s summary string + * @return representation of the option + */ +#define TALER_MERCHANT_post_templates_option_summary(s) \ + (const struct TALER_MERCHANT_PostTemplatesOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_TEMPLATES_OPTION_SUMMARY, \ + .details.summary = (s) \ + } + +/** + * Set total amount. + * + * @param a amount + * @return representation of the option + */ +#define TALER_MERCHANT_post_templates_option_amount(a) \ + (const struct TALER_MERCHANT_PostTemplatesOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_TEMPLATES_OPTION_AMOUNT, \ + .details.amount = (a) \ + } + +/** + * Set detailed contract customization. + * + * @param d details JSON object + * @return representation of the option + */ +#define TALER_MERCHANT_post_templates_option_details(d) \ + (const struct TALER_MERCHANT_PostTemplatesOptionValue) \ + { \ + .option = TALER_MERCHANT_POST_TEMPLATES_OPTION_DETAILS, \ + .details.details = (d) \ + } + + +/** + * Set the requested options for the operation. + * + * @param pth the request to set the options for + * @param num_options length of the @a options array + * @param options an array of options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_post_templates_set_options_ ( + struct TALER_MERCHANT_PostTemplatesHandle *pth, + unsigned int num_options, + const struct TALER_MERCHANT_PostTemplatesOptionValue *options); + + +/** + * Set the requested options for the operation. + * + * @param pth the request to set the options for + * @param ... the list of the options + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure, + * #GNUNET_SYSERR on internal error + */ +#define TALER_MERCHANT_post_templates_set_options(pth,...) \ + TALER_MERCHANT_post_templates_set_options_ ( \ + pth, \ + TALER_MERCHANT_COMMON_OPTIONS_ARRAY_MAX_SIZE, \ + ((const struct TALER_MERCHANT_PostTemplatesOptionValue[]) \ + {__VA_ARGS__, TALER_MERCHANT_post_templates_option_end_ () } \ + )) + + +/** + * Set up POST /templates/$TEMPLATE_ID operation. + * Note that you must explicitly start the operation after + * possibly setting options. + * + * @param ctx the context + * @param url base URL of the merchant backend + * @param template_id identifier of the template to use + * @return handle to operation + */ +struct TALER_MERCHANT_PostTemplatesHandle * +TALER_MERCHANT_post_templates_create ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const char *template_id); + + +#ifndef TALER_MERCHANT_POST_TEMPLATES_RESULT_CLOSURE +/** + * Type of the closure used by + * the #TALER_MERCHANT_PostTemplatesCallback. + */ +#define TALER_MERCHANT_POST_TEMPLATES_RESULT_CLOSURE void +#endif /* TALER_MERCHANT_POST_TEMPLATES_RESULT_CLOSURE */ + +/** + * Callback for a POST /templates/$TEMPLATE_ID request. + * + * @param cls closure + * @param ptr response details + */ +typedef void +(*TALER_MERCHANT_PostTemplatesCallback)( + TALER_MERCHANT_POST_TEMPLATES_RESULT_CLOSURE *cls, + const struct TALER_MERCHANT_PostTemplatesResponse *ptr); + + +/** + * Start POST /templates/$TEMPLATE_ID operation. + * + * @param[in,out] pth operation to start + * @param cb function to call with the merchant's result + * @param cb_cls closure for @a cb + * @return status code, #TALER_EC_NONE on success + */ +enum TALER_ErrorCode +TALER_MERCHANT_post_templates_start ( + struct TALER_MERCHANT_PostTemplatesHandle *pth, + TALER_MERCHANT_PostTemplatesCallback cb, + TALER_MERCHANT_POST_TEMPLATES_RESULT_CLOSURE *cb_cls); + + +/** + * Cancel POST /templates/$TEMPLATE_ID operation. This function must not be + * called by clients after the TALER_MERCHANT_PostTemplatesCallback has + * been invoked (as in those cases it'll be called internally by the + * implementation already). + * + * @param[in] pth operation to cancel + */ +void +TALER_MERCHANT_post_templates_cancel ( + struct TALER_MERCHANT_PostTemplatesHandle *pth); + + +#endif /* _TALER_MERCHANT__POST_TEMPLATES_TEMPLATE_ID_NEW_H */