/*
  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.h
 * @brief C interface for POST /orders/$ORDER_ID/paid of the merchant backend
 * @author Jonathan Buchanan
 * @author Christian Grothoff
 */
#ifndef _TALER_MERCHANT__POST_ORDERS_ORDER_ID_PAID_H
#define _TALER_MERCHANT__POST_ORDERS_ORDER_ID_PAID_H

#include <taler/taler-merchant/common.h>


/**
 * Handle for a POST /orders/$ORDER_ID/paid request.
 */
struct TALER_MERCHANT_OrderPaidHandle;


/**
 * Response details for a POST /orders/$ORDER_ID/paid request.
 */
struct TALER_MERCHANT_OrderPaidResponse
{

  /**
   * HTTP response details.
   */
  struct TALER_MERCHANT_HttpResponse hr;

  /**
   * Details depending on the HTTP status code.
   */
  union
  {

    /**
     * Details on #MHD_HTTP_OK.
     */
    struct
    {
      /* currently empty */
      int _dummy;
    } ok;

  } details;

};


/**
 * Callback for a POST /orders/$ORDER_ID/paid request.
 *
 * @param cls closure
 * @param opr response details
 */
typedef void
(*TALER_MERCHANT_OrderPaidCallback)(
  void *cls,
  const struct TALER_MERCHANT_OrderPaidResponse *opr);


/**
 * Issue a POST /orders/$ORDER_ID/paid request to confirm payment
 * (used for session-based repurchase detection).
 *
 * @param ctx CURL context to use
 * @param merchant_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 wallet_data_hash hash of wallet-specific data, or NULL
 * @param merchant_sig merchant signature over the session data
 * @param paid_cb callback to invoke with the result
 * @param paid_cb_cls closure for @a paid_cb
 * @return handle for the request, NULL on hard error
 */
struct TALER_MERCHANT_OrderPaidHandle *
TALER_MERCHANT_order_paid (
  struct GNUNET_CURL_Context *ctx,
  const char *merchant_url,
  const char *order_id,
  const char *session_id,
  const struct TALER_PrivateContractHashP *h_contract_terms,
  const struct GNUNET_HashCode *wallet_data_hash,
  const struct TALER_MerchantSignatureP *merchant_sig,
  TALER_MERCHANT_OrderPaidCallback paid_cb,
  void *paid_cb_cls);


/**
 * Cancel a POST /orders/$ORDER_ID/paid request.
 *
 * @param[in] oph handle to cancel
 */
void
TALER_MERCHANT_order_paid_cancel (
  struct TALER_MERCHANT_OrderPaidHandle *oph);


#endif
