From 4b7d9f5e19e9f28ec1163f3b6e5c00f0805e6221 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 23 Apr 2023 14:40:05 +0200 Subject: modernize POST /transfers API --- src/include/taler_merchant_service.h | 89 +++++++++++++++++++++++++++++------- 1 file changed, 73 insertions(+), 16 deletions(-) (limited to 'src/include/taler_merchant_service.h') diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index 49bc83fd..92e18335 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -2898,31 +2898,88 @@ struct TALER_MERCHANT_TrackTransferDetail }; + +/** + * @brief Response to a POST /transfers operation from a merchant's backend. + */ +struct TALER_MERCHANT_PostTransfersResponse +{ + /** + * HTTP response details + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on HTTP status. + */ + union + { + + /** + * Details in case of success (#MHD_HTTP_OK). + */ + struct + { + + /** + * when did the transfer happen (according to the exchange) + */ + struct GNUNET_TIME_Timestamp execution_time; + + /** + * total amount of the wire transfer + */ + struct TALER_Amount total_amount; + + /** + * how much did the exchange charge in terms of wire fees + */ + struct TALER_Amount wire_fee; + + /** + * Length of the @e details array + */ + unsigned int details_length; + + /** + * array with details about the combined transactions + */ + const struct TALER_MERCHANT_TrackTransferDetail *details; + } success; + + /** + * Details if we got an #MHD_HTTP_BAD_GATEWAY. + */ + struct + { + /** + * HTTP status of the exchange (or 0 if not available). + */ + unsigned int exchange_http_status; + + /** + * Error code of the exchange (or TALER_EC_NONE if not available). + */ + enum TALER_ErrorCode exchange_ec; + + } bad_gateway; + + } details; + +}; + + /** * Callbacks of this type are used to work the result of submitting a * POST /transfers request to a merchant * * @param cls closure - * @param hr HTTP response details - * @param execution_time when did the transfer happen (according to the exchange), - * #GNUNET_TIME_UNIT_FOREVER_ABS if the transfer did not yet happen or if - * we have no data from the exchange about it - * @param total_amount total amount of the wire transfer, or NULL if the exchange did - * not provide any details - * @param wire_fee how much did the exchange charge in terms of wire fees, or NULL - * if the exchange did not provide any details - * @param details_length length of the @a details array - * @param details array with details about the combined transactions + * @param ptr response details */ typedef void (*TALER_MERCHANT_PostTransfersCallback) ( void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, - struct GNUNET_TIME_Timestamp execution_time, - const struct TALER_Amount *total_amount, - const struct TALER_Amount *wire_fee, - unsigned int details_length, - const struct TALER_MERCHANT_TrackTransferDetail details[]); + const struct TALER_MERCHANT_PostTransfersResponse *ptr); /** -- cgit v1.2.3