/*
     This file is part of GNUnet.
     Copyright (C) 2026 Taler Systems SA

     Paivana is free software; you can redistribute it and/or
     modify it under the terms of the GNU Affero General Public License
     as published by the Free Software Foundation; either version
     3, or (at your option) any later version.

     Paivana 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 Affero General Public License for more details.

     You should have received a copy of the GNU Affero General Public
     License along with Paivana; see the file COPYING.  If not,
     write to the Free Software Foundation, Inc., 51 Franklin
     Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

/**
 * @author Christian Grothoff
 * @file paivana-httpd_pay.h
 *
 * @brief payment processing logic
 */
#ifndef PAIVANA_HTTPD_PAY_H
#define PAIVANA_HTTPD_PAY_H

#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h>
#include "paivana-httpd.h"

/**
 * Handle for processing actual payment.
 */
struct PayRequest;

/**
 * The server is shutting down, clean up suspended requests.
 */
void
PAIVANA_HTTPD_payment_shutdown (void);


/**
 * Create context for handling a request to check a payment.
 *
 * @param connection the request context
 */
struct PayRequest *
PAIVANA_HTTPD_payment_create (struct MHD_Connection *connection);


/**
 * Make progress on handling the upload of the client.
 *
 * @param[in,out] ph payment request handle
 * @param upload_data data uploaded by the client
 * @param[in,out] upload_data_size number of bytes uploaded,
 *          set to the number of bytes of upload that were not handled
 * @return MHD status code to return
 */
enum MHD_Result
PAIVANA_HTTPD_payment_handle (struct PayRequest *ph,
                              const char *upload_data,
                              size_t *upload_data_size);

/**
 * Clean up payment request handle.
 *
 * @param[in] ph handle to clean up
 */
void
PAIVANA_HTTPD_payment_destroy (struct PayRequest *ph);


#endif
