commit 6115b134556a32febfc577334814a3d611a8bd6b
parent bb206d8597d99dd216fbb1b2f745dff25bf4eacb
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 22 Mar 2026 16:15:39 +0100
adapt to latest merchant API
Diffstat:
| M | src/taler-mdb.c | | | 162 | ++++++++++++++++++++++++++++++++++++++++++++----------------------------------- |
1 file changed, 91 insertions(+), 71 deletions(-)
diff --git a/src/taler-mdb.c b/src/taler-mdb.c
@@ -367,12 +367,12 @@ struct PaymentActivity
/**
* Handle to a POST /orders operation
*/
- struct TALER_MERCHANT_PostOrdersHandle *po;
+ struct TALER_MERCHANT_PostPrivateOrdersHandle *po;
/**
* Handle for a GET /private/orders/$ID operation.
*/
- struct TALER_MERCHANT_OrderMerchantGetHandle *ogh;
+ struct TALER_MERCHANT_GetPrivateOrderHandle *ogh;
/**
* The product being sold.
@@ -427,7 +427,7 @@ struct PaymentActivity
/**
* Handle for our attempt to delete an ongoing order.
*/
- struct TALER_MERCHANT_OrderDeleteHandle *odh;
+ struct TALER_MERCHANT_DeletePrivateOrderHandle *odh;
/**
* Member to see if the wallet already received a uri
@@ -594,7 +594,7 @@ struct Refund
/**
* Handle to the ongoing operation.
*/
- struct TALER_MERCHANT_OrderRefundHandle *orh;
+ struct TALER_MERCHANT_PostPrivateOrdersRefundHandle *orh;
};
@@ -1214,23 +1214,23 @@ cleanup_payment (struct PaymentActivity *pa);
* Function called with the result of the DELETE /orders/$ID operation.
*
* @param cls closure with the `struct PaymentActivity *`
- * @param hr HTTP response details
+ * @param dpor HTTP response details
*/
static void
order_delete_cb (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr)
+ const struct TALER_MERCHANT_DeletePrivateOrderResponse *dpor)
{
struct PaymentActivity *pa = cls;
pa->odh = NULL;
- if ( (MHD_HTTP_OK != hr->http_status) &&
- (MHD_HTTP_NO_CONTENT != hr->http_status) )
+ if ( (MHD_HTTP_OK != dpor->hr.http_status) &&
+ (MHD_HTTP_NO_CONTENT != dpor->hr.http_status) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to delete incomplete order from backend: %d/%u\n",
- (int) hr->http_status,
- (unsigned int) hr->ec);
+ (int) dpor->hr.http_status,
+ (unsigned int) dpor->hr.ec);
}
cleanup_payment (pa);
}
@@ -1273,19 +1273,25 @@ cleanup_payment (struct PaymentActivity *pa)
oid = pa->order_id;
pa->order_id = NULL;
- pa->odh = TALER_MERCHANT_order_delete (
+ pa->odh = TALER_MERCHANT_delete_private_order_create (
pa->ctx,
pa->base_url,
- oid,
- true, /* delete even claimed orders */
- &order_delete_cb,
- pa);
+ oid);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_MERCHANT_delete_private_order_set_options (
+ pa->odh,
+ TALER_MERCHANT_delete_private_order_set_option_force ()));
+ GNUNET_assert (TALER_EC_NONE ==
+ TALER_MERCHANT_delete_private_order_start (
+ pa->odh,
+ &order_delete_cb,
+ pa));
GNUNET_free (oid);
return;
}
if (NULL != pa->odh)
{
- TALER_MERCHANT_order_delete_cancel (pa->odh);
+ TALER_MERCHANT_delete_private_order_cancel (pa->odh);
pa->odh = NULL;
}
if (NULL != pa->pnd)
@@ -1303,12 +1309,12 @@ cleanup_payment (struct PaymentActivity *pa)
}
if (NULL != pa->po)
{
- TALER_MERCHANT_orders_post_cancel (pa->po);
+ TALER_MERCHANT_post_private_orders_cancel (pa->po);
pa->po = NULL;
}
if (NULL != pa->ogh)
{
- TALER_MERCHANT_merchant_order_get_cancel (pa->ogh);
+ TALER_MERCHANT_get_private_order_cancel (pa->ogh);
pa->ogh = NULL;
}
GNUNET_CURL_gnunet_scheduler_reschedule (&pa->rc);
@@ -1393,7 +1399,7 @@ shutdown_task (void *cls)
GNUNET_CONTAINER_DLL_remove (refund_head,
refund_tail,
r);
- TALER_MERCHANT_post_order_refund_cancel (r->orh);
+ TALER_MERCHANT_post_private_orders_refund_cancel (r->orh);
GNUNET_free (r);
}
if (NULL != context)
@@ -1749,14 +1755,15 @@ start_read_keyboard (void);
/**
- * @brief Callback to process a GET /check-payment request
+ * @brief Callback to process a GET /private/orders/$ORDER_ID request
*
* @param cls closure
* @param osr order status response details (on success)
*/
static void
-check_payment_cb (void *cls,
- const struct TALER_MERCHANT_OrderStatusResponse *osr)
+check_payment_cb (
+ void *cls,
+ const struct TALER_MERCHANT_GetPrivateOrderResponse *osr)
{
struct PaymentActivity *pa = cls;
const struct TALER_MERCHANT_HttpResponse *hr = &osr->hr;
@@ -1844,26 +1851,33 @@ check_payment_again (void *cls)
pa->delay_pay_task = NULL;
GNUNET_assert (NULL == pa->ogh);
- pa->ogh = TALER_MERCHANT_merchant_order_get (pa->ctx,
- pa->base_url,
- pa->order_id,
- NULL /* snack machine, no Web crap */
- ,
- BACKEND_POLL_TIMEOUT,
- &check_payment_cb,
- pa);
+ pa->ogh = TALER_MERCHANT_get_private_order_create (
+ pa->ctx,
+ pa->base_url,
+ pa->order_id);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_MERCHANT_get_private_order_set_options (
+ pa->ogh,
+ TALER_MERCHANT_get_private_order_option_timeout (
+ BACKEND_POLL_TIMEOUT)));
+ GNUNET_assert (TALER_EC_NONE ==
+ TALER_MERCHANT_get_private_order_start (
+ pa->ogh,
+ &check_payment_cb,
+ pa));
}
/**
- * @brief Callback for a POST /orders request
+ * @brief Callback for a POST /private/orders request
*
* @param cls closure
* @param por response for this request
*/
static void
-proposal_cb (void *cls,
- const struct TALER_MERCHANT_PostOrdersReply *por)
+proposal_cb (
+ void *cls,
+ const struct TALER_MERCHANT_PostPrivateOrdersResponse *por)
{
struct PaymentActivity *pa = cls;
@@ -1891,14 +1905,15 @@ proposal_cb (void *cls,
"Backend successfully created order `%s'\n",
por->details.ok.order_id);
pa->order_id = GNUNET_strdup (por->details.ok.order_id);
- pa->ogh = TALER_MERCHANT_merchant_order_get (pa->ctx,
- pa->base_url,
- pa->order_id,
- NULL /* snack machine, no Web crap */
- ,
- GNUNET_TIME_UNIT_ZERO,
- &check_payment_cb,
- pa);
+ pa->ogh = TALER_MERCHANT_get_private_order_create (pa->ctx,
+ pa->base_url,
+ pa->order_id);
+ GNUNET_assert (NULL != pa->ogh);
+ GNUNET_assert (TALER_EC_NONE ==
+ TALER_MERCHANT_get_private_order_start (
+ pa->ogh,
+ &check_payment_cb,
+ pa));
}
@@ -1915,7 +1930,6 @@ start_read_cancel_button (void);
static struct PaymentActivity *
launch_payment (struct Product *product)
{
- static const char *uuids[1];
struct PaymentActivity *pa;
json_t *orderReq;
char *msg;
@@ -2022,18 +2036,9 @@ launch_payment (struct Product *product)
? backend_base_url
: product->instance;
GNUNET_assert (NULL == pa->po);
- pa->po = TALER_MERCHANT_orders_post2 (pa->ctx,
- pa->base_url,
- orderReq,
- MAX_REFUND_DELAY,
- NULL, /* no payment target preference */
- 0,
- NULL, /* no inventory */
- 0,
- uuids, /* no locks */
- false, /* no claim token */
- &proposal_cb,
- pa);
+ pa->po = TALER_MERCHANT_post_private_orders_create (pa->ctx,
+ pa->base_url,
+ orderReq);
json_decref (orderReq);
if (NULL == pa->po)
{
@@ -2043,6 +2048,16 @@ launch_payment (struct Product *product)
cleanup_payment (pa);
return NULL;
}
+ GNUNET_assert (GNUNET_OK ==
+ TALER_MERCHANT_post_private_orders_set_options (
+ pa->po,
+ TALER_MERCHANT_post_private_orders_option_refund_delay (
+ MAX_REFUND_DELAY)));
+ GNUNET_assert (TALER_EC_NONE ==
+ TALER_MERCHANT_post_private_orders_start (
+ pa->po,
+ &proposal_cb,
+ pa));
/* Start to read the button on the VM to cancel this payment */
if (-1 != cancel_button.cancelbuttonfd)
{
@@ -2102,8 +2117,9 @@ async_refund_cleanup_job (void *cls)
* @param rr response details
*/
static void
-refund_complete_cb (void *cls,
- const struct TALER_MERCHANT_RefundResponse *rr)
+refund_complete_cb (
+ void *cls,
+ const struct TALER_MERCHANT_PostPrivateOrdersRefundResponse *rr)
{
struct Refund *r = cls;
@@ -2151,27 +2167,31 @@ vend_failure (void)
GNUNET_assert (GNUNET_OK ==
GNUNET_CURL_append_header (r->ctx,
p->auth_header));
- r->orh = TALER_MERCHANT_post_order_refund (r->ctx,
- (NULL == p->instance)
- ? backend_base_url
- : p->instance,
- payment_activity->order_id,
- &payment_activity->amount,
- "failed to dispense product",
- &refund_complete_cb,
- r);
+ r->orh = TALER_MERCHANT_post_private_orders_refund_create (
+ r->ctx,
+ (NULL == p->instance)
+ ? backend_base_url
+ : p->instance,
+ payment_activity->order_id,
+ &payment_activity->amount,
+ "failed to dispense product");
if (NULL == r->orh)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to launch refund interaction with the merchant backend!\n");
GNUNET_free (r);
+ cleanup_payment (payment_activity);
+ payment_activity = NULL;
+ return;
}
- else
- {
- GNUNET_CONTAINER_DLL_insert (refund_head,
- refund_tail,
- r);
- }
+ GNUNET_assert (TALER_EC_NONE ==
+ TALER_MERCHANT_post_private_orders_refund_start (
+ r->orh,
+ &refund_complete_cb,
+ r));
+ GNUNET_CONTAINER_DLL_insert (refund_head,
+ refund_tail,
+ r);
if (NULL != payment_activity)
{
cleanup_payment (payment_activity);