summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-08-17 21:03:45 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-08-17 21:03:45 -0400
commitd8e64ae258b911d4243a0fd62e46585f54bb445b (patch)
tree45955e85655a3cbeb5d776738ed9ca271c762eaf /src/include
parent14dda234f724e59eefb49d9d98b048ce1ce9059f (diff)
downloadmerchant-d8e64ae258b911d4243a0fd62e46585f54bb445b.tar.gz
merchant-d8e64ae258b911d4243a0fd62e46585f54bb445b.tar.bz2
merchant-d8e64ae258b911d4243a0fd62e46585f54bb445b.zip
testing and lib sources for new endpoint
Diffstat (limited to 'src/include')
-rw-r--r--src/include/taler_merchant_service.h144
-rw-r--r--src/include/taler_merchant_testing_lib.h29
2 files changed, 118 insertions, 55 deletions
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index 46d14ead..2da5e03c 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -1456,48 +1456,6 @@ struct TALER_MERCHANT_OrderWalletGetHandle;
/**
- * Detail about a refund lookup result.
- */
-struct TALER_MERCHANT_RefundDetail
-{
-
- /**
- * Exchange response details. Full details are only included
- * upon failure (HTTP status is not #MHD_HTTP_OK).
- */
- struct TALER_EXCHANGE_HttpResponse hr;
-
- /**
- * Coin this detail is about.
- */
- struct TALER_CoinSpendPublicKeyP coin_pub;
-
- /**
- * Refund transaction ID used.
- */
- uint64_t rtransaction_id;
-
- /**
- * Amount to be refunded for this coin.
- */
- struct TALER_Amount refund_amount;
-
- /**
- * Public key of the exchange affirming the refund,
- * only valid if the @e hr http_status is #MHD_HTTP_OK.
- */
- struct TALER_ExchangePublicKeyP exchange_pub;
-
- /**
- * Signature of the exchange affirming the refund,
- * only valid if the @e hr http_status is #MHD_HTTP_OK.
- */
- struct TALER_ExchangeSignatureP exchange_sig;
-
-};
-
-
-/**
* Callback to process a GET /orders/$ID request
*
* @param cls closure
@@ -1513,9 +1471,6 @@ struct TALER_MERCHANT_RefundDetail
* the payment
* @param already_paid_order_id equivalent order that this customer
* paid already, or NULL for none
- * @param merchant_pub public key of the merchant
- * @param num_refunds length of the @a refunds array
- * @param refunds details about the refund processing
*/
typedef void
(*TALER_MERCHANT_OrderWalletGetCallback) (
@@ -1525,10 +1480,7 @@ typedef void
enum GNUNET_GenericReturnValue refunded,
struct TALER_Amount *refund_amount,
const char *taler_pay_uri,
- const char *already_paid_order_id,
- const struct TALER_MerchantPublicKeyP *merchant_pub,
- unsigned int num_refunds,
- const struct TALER_MERCHANT_RefundDetail *refunds);
+ const char *already_paid_order_id);
/**
@@ -2433,6 +2385,100 @@ TALER_MERCHANT_post_order_refund_cancel (
struct TALER_MERCHANT_OrderRefundHandle *orh);
+/**
+ * Handle for a (public) POST /orders/ID/refund operation.
+ */
+struct TALER_MERCHANT_WalletOrderRefundHandle;
+
+
+/**
+ * Detail about a refund lookup result.
+ */
+struct TALER_MERCHANT_RefundDetail
+{
+
+ /**
+ * Exchange response details. Full details are only included
+ * upon failure (HTTP status is not #MHD_HTTP_OK).
+ */
+ struct TALER_EXCHANGE_HttpResponse hr;
+
+ /**
+ * Coin this detail is about.
+ */
+ struct TALER_CoinSpendPublicKeyP coin_pub;
+
+ /**
+ * Refund transaction ID used.
+ */
+ uint64_t rtransaction_id;
+
+ /**
+ * Amount to be refunded for this coin.
+ */
+ struct TALER_Amount refund_amount;
+
+ /**
+ * Public key of the exchange affirming the refund,
+ * only valid if the @e hr http_status is #MHD_HTTP_OK.
+ */
+ struct TALER_ExchangePublicKeyP exchange_pub;
+
+ /**
+ * Signature of the exchange affirming the refund,
+ * only valid if the @e hr http_status is #MHD_HTTP_OK.
+ */
+ struct TALER_ExchangeSignatureP exchange_sig;
+
+};
+
+
+/**
+ * Callback to process a (public) POST /orders/ID/refund request
+ *
+ * @param cls closure
+ * @param http_status HTTP status code for this request
+ * @param ec taler-specific error code
+ */
+typedef void
+(*TALER_MERCHANT_WalletRefundCallback) (
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr,
+ const struct TALER_Amount *refund_amount,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ struct TALER_MERCHANT_RefundDetail refunds[],
+ unsigned int refunds_length);
+
+
+/**
+ * Obtain the refunds that have been granted for an order.
+ *
+ * @param ctx the CURL context used to connect to the backend
+ * @param backend_url backend's base URL, including final "/"
+ * @param order_id id of the order whose refund is to be increased
+ * @param h_contract_terms hash of the contract terms of the order
+ * @param cb callback processing the response from /refund
+ * @param cb_cls closure for cb
+ */
+struct TALER_MERCHANT_WalletOrderRefundHandle *
+TALER_MERCHANT_wallet_post_order_refund (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *order_id,
+ const struct GNUNET_HashCode *h_contract_terms,
+ TALER_MERCHANT_WalletRefundCallback cb,
+ void *cb_cls);
+
+/**
+ * Cancel a (public) POST /refund request.
+ *
+ * @param orh the refund operation to cancel
+ */
+void
+TALER_MERCHANT_wallet_post_order_refund_cancel (
+ struct TALER_MERCHANT_WalletOrderRefundHandle *orh);
+
+
/* ********************* /transfers *********************** */
/**
diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h
index a9aa2b48..5618b441 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -601,10 +601,6 @@ TALER_TESTING_cmd_poll_orders_conclude (const char *label,
* @param paid whether the order has been paid for or not.
* @param refunded whether the order has been refunded.
* @param http_status expected HTTP response code for the request.
- * @param ... NULL-terminated list of labels (const char *) of
- * refunds (commands) we expect to be aggregated in the transfer
- * (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false,
- * this parameter is ignored.
*/
struct TALER_TESTING_Command
TALER_TESTING_cmd_wallet_get_order (const char *label,
@@ -612,8 +608,7 @@ TALER_TESTING_cmd_wallet_get_order (const char *label,
const char *order_reference,
bool paid,
bool refunded,
- unsigned int http_status,
- ...);
+ unsigned int http_status);
/**
@@ -820,6 +815,28 @@ TALER_TESTING_cmd_merchant_order_refund (const char *label,
/**
+ * Define a "refund order" CMD.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the backend serving the
+ * "refund increase" request.
+ * @param order_ref order id of the contract to refund.
+ * @param http_code expected HTTP response code.
+ * @param ... NULL-terminated list of labels (const char *) of
+ * refunds (commands) we expect to be aggregated in the transfer
+ * (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false,
+ * this parameter is ignored.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_wallet_order_refund (const char *label,
+ const char *merchant_url,
+ const char *order_ref,
+ unsigned int http_code,
+ ...);
+
+
+/**
* Define a "DELETE order" CMD.
*
* @param label command label.