post-private-orders-ORDER_ID-refund.h (4102B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2014-2026 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Lesser General Public License as published by the Free Software 7 Foundation; either version 2.1, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 12 13 You should have received a copy of the GNU Lesser General Public License along with 14 TALER; see the file COPYING.LGPL. If not, see 15 <http://www.gnu.org/licenses/> 16 */ 17 /** 18 * @file src/include/taler/merchant/post-private-orders-ORDER_ID-refund.h 19 * @brief C interface for the POST /private/orders/$ORDER_ID/refund endpoint 20 * @author Christian Grothoff 21 */ 22 #ifndef _TALER_MERCHANT__POST_PRIVATE_ORDERS_ORDER_ID_REFUND_H 23 #define _TALER_MERCHANT__POST_PRIVATE_ORDERS_ORDER_ID_REFUND_H 24 25 #include <taler/merchant/common.h> 26 27 28 /** 29 * Handle for a POST /private/orders/$ORDER_ID/refund request. 30 */ 31 struct TALER_MERCHANT_PostPrivateOrdersRefundHandle; 32 33 34 /** 35 * Response details for a POST /private/orders/$ORDER_ID/refund request. 36 */ 37 struct TALER_MERCHANT_PostPrivateOrdersRefundResponse 38 { 39 40 /** 41 * HTTP response details. 42 */ 43 struct TALER_MERCHANT_HttpResponse hr; 44 45 /** 46 * Details depending on the HTTP status code. 47 */ 48 union 49 { 50 51 /** 52 * Details on #MHD_HTTP_OK. 53 */ 54 struct 55 { 56 57 /** 58 * Taler refund URI for the wallet. 59 */ 60 const char *taler_refund_uri; 61 62 /** 63 * Hash of the contract terms for this order. 64 */ 65 struct TALER_PrivateContractHashP h_contract; 66 67 } ok; 68 69 } details; 70 71 }; 72 73 74 /** 75 * Set up POST /private/orders/$ORDER_ID/refund operation. 76 * Note that you must explicitly start the operation after 77 * possibly setting options. 78 * 79 * @param ctx the context 80 * @param url base URL of the merchant backend 81 * @param order_id identifier of the order to refund 82 * @param refund amount to refund 83 * @param reason human-readable reason for the refund 84 * @return handle to operation 85 */ 86 struct TALER_MERCHANT_PostPrivateOrdersRefundHandle * 87 TALER_MERCHANT_post_private_orders_refund_create ( 88 struct GNUNET_CURL_Context *ctx, 89 const char *url, 90 const char *order_id, 91 const struct TALER_Amount *refund, 92 const char *reason); 93 94 95 #ifndef TALER_MERCHANT_POST_PRIVATE_ORDERS_REFUND_RESULT_CLOSURE 96 /** 97 * Type of the closure used by 98 * the #TALER_MERCHANT_PostPrivateOrdersRefundCallback. 99 */ 100 #define TALER_MERCHANT_POST_PRIVATE_ORDERS_REFUND_RESULT_CLOSURE void 101 #endif /* TALER_MERCHANT_POST_PRIVATE_ORDERS_REFUND_RESULT_CLOSURE */ 102 103 /** 104 * Callback for a POST /private/orders/$ORDER_ID/refund request. 105 * 106 * @param cls closure 107 * @param rr response details 108 */ 109 typedef void 110 (*TALER_MERCHANT_PostPrivateOrdersRefundCallback)( 111 TALER_MERCHANT_POST_PRIVATE_ORDERS_REFUND_RESULT_CLOSURE *cls, 112 const struct TALER_MERCHANT_PostPrivateOrdersRefundResponse *rr); 113 114 115 /** 116 * Start POST /private/orders/$ORDER_ID/refund operation. 117 * 118 * @param[in,out] porh operation to start 119 * @param cb function to call with the merchant's result 120 * @param cb_cls closure for @a cb 121 * @return status code, #TALER_EC_NONE on success 122 */ 123 enum TALER_ErrorCode 124 TALER_MERCHANT_post_private_orders_refund_start ( 125 struct TALER_MERCHANT_PostPrivateOrdersRefundHandle *porh, 126 TALER_MERCHANT_PostPrivateOrdersRefundCallback cb, 127 TALER_MERCHANT_POST_PRIVATE_ORDERS_REFUND_RESULT_CLOSURE *cb_cls); 128 129 130 /** 131 * Cancel POST /private/orders/$ORDER_ID/refund operation. This function 132 * must not be called by clients after the 133 * TALER_MERCHANT_PostPrivateOrdersRefundCallback has been invoked (as in 134 * those cases it'll be called internally by the implementation already). 135 * 136 * @param[in] porh operation to cancel 137 */ 138 void 139 TALER_MERCHANT_post_private_orders_refund_cancel ( 140 struct TALER_MERCHANT_PostPrivateOrdersRefundHandle *porh); 141 142 143 #endif /* _TALER_MERCHANT__POST_PRIVATE_ORDERS_ORDER_ID_REFUND_H */