gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated: misc style improvements


From: gnunet
Subject: [taler-merchant] branch master updated: misc style improvements
Date: Sat, 03 Jun 2023 17:54:13 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new cea5867b misc style improvements
cea5867b is described below

commit cea5867be3735f7c418a456b93ba9a45535f8cbc
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Jun 3 17:54:10 2023 +0200

    misc style improvements
---
 src/include/taler_merchant_service.h               | 263 ++++++++++++++++-----
 src/lib/merchant_api_get_config.c                  |  50 ++--
 src/lib/merchant_api_get_orders.c                  |  66 ++----
 src/lib/merchant_api_get_product.c                 | 147 +++++-------
 src/lib/merchant_api_post_order_claim.c            |  62 ++---
 src/testing/testing_api_cmd_claim_order.c          |  31 +--
 src/testing/testing_api_cmd_config.c               |  20 +-
 src/testing/testing_api_cmd_get_orders.c           |  50 ++--
 src/testing/testing_api_cmd_get_product.c          |  66 ++----
 src/testing/testing_api_cmd_post_orders.c          |  35 ++-
 src/testing/testing_api_cmd_post_using_templates.c |  35 ++-
 11 files changed, 424 insertions(+), 401 deletions(-)

diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index 32364fa5..83035455 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -303,21 +303,51 @@ struct TALER_MERCHANT_ConfigInformation
 };
 
 
-// FIXME: change signature!
+/**
+ * Response to /config request.
+ */
+struct TALER_MERCHANT_ConfigResponse
+{
+  /**
+   * HTTP response.
+   */
+  struct TALER_MERCHANT_HttpResponse hr;
+
+  /**
+   * Status-dependent details.
+   */
+  union
+  {
+    /**
+     * Information returned on #MHD_HTTP_OK.
+     */
+    struct
+    {
+
+      /**
+       * basic information about the merchant
+       */
+      struct TALER_MERCHANT_ConfigInformation ci;
+
+      /**
+       * protocol compatibility information
+       */
+      enum TALER_MERCHANT_VersionCompatibility compat;
+    } ok;
+  } details;
+};
+
+
 /**
  * Function called with information about the merchant.
  *
  * @param cls closure
- * @param hr HTTP response data
- * @param ci basic information about the merchant
- * @param compat protocol compatibility information
+ * @param cr response data
  */
 typedef void
 (*TALER_MERCHANT_ConfigCallback) (
   void *cls,
-  const struct TALER_MERCHANT_HttpResponse *hr,
-  const struct TALER_MERCHANT_ConfigInformation *ci,
-  enum TALER_MERCHANT_VersionCompatibility compat);
+  const struct TALER_MERCHANT_ConfigResponse *cr);
 
 
 /**
@@ -1177,46 +1207,105 @@ TALER_MERCHANT_products_get_cancel (
 struct TALER_MERCHANT_ProductGetHandle;
 
 
-// FIXME: change signature!
+/**
+ * Response to GET /product/$ID operation.
+ */
+struct TALER_MERCHANT_ProductGetResponse
+{
+  /**
+   * HTTP response details
+   */
+  struct TALER_MERCHANT_HttpResponse hr;
+
+  /**
+   * Details depending on HTTP status.
+   */
+  union
+  {
+    /**
+     * Details for #MHD_HTTP_OK.
+     */
+    struct
+    {
+
+      /**
+       * description of the product
+       */
+      const char *description;
+
+      /**
+       * Map from IETF BCP 47 language tags to localized descriptions
+       */
+      const json_t *description_i18n;
+
+      /**
+       * unit in which the product is measured (liters, kilograms, packages, 
etc.)
+       */
+      const char *unit;
+
+      /**
+       * the price for one @a unit of the product, zero is used to imply that
+       * this product is not sold separately or that the price is
+       * not fixed and must be supplied by the front-end.  If
+       * non-zero, price must include applicable taxes.
+       */
+      struct TALER_Amount price;
+
+      /**
+       * base64-encoded product image
+       */
+      const char *image;
+
+      /**
+       * list of taxes paid by the merchant
+       */
+      const json_t *taxes;
+
+      /**
+       * total_stock in @e units, -1 to indicate "infinite" (i.e. electronic
+       * books), does NOT indicate remaining stocks, to get remaining stocks,
+       * subtract @e total_sold and @e total_lost. Note that this still does
+       * not then say how many of the remaining inventory are locked.
+       */
+      int64_t total_stock;
+
+      /**
+       * in @e units, total number of @e unit of product sold
+       */
+      uint64_t total_sold;
+
+      /**
+       * in @e units, total number of @e unit of product lost from inventory
+       */
+      uint64_t total_lost;
+
+      /**
+       * where the product is in stock
+       */
+      const json_t *location;
+
+      /**
+       * when the next restocking is expected to happen, 0 for unknown,
+       * #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
+       */
+      struct GNUNET_TIME_Timestamp next_restock;
+    } ok;
+
+  } details;
+
+};
+
+
 /**
  * Function called with the result of the GET /products operation.
  *
  * @param cls closure
- * @param hr HTTP response details
- * @param description description of the product
- * @param description_i18n Map from IETF BCP 47 language tags to localized 
descriptions
- * @param unit unit in which the product is measured (liters, kilograms, 
packages, etc.)
- * @param price the price for one @a unit of the product, zero is used to 
imply that
- *              this product is not sold separately or that the price is not 
fixed and
- *              must be supplied by the front-end.  If non-zero, price must 
include
- *              applicable taxes.
- * @param image base64-encoded product image
- * @param taxes list of taxes paid by the merchant
- * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic 
books),
- *                does NOT indicate remaining stocks, to get remaining stocks,
- *                subtract @a total_sold and @a total_lost. Note that this 
still
- *                does not then say how many of the remaining inventory are 
locked.
- * @param total_sold in @a units, total number of @a unit of product sold
- * @param total_lost in @a units, total number of @a unit of product lost from 
inventory
- * @param location where the product is in stock
- * @param next_restock when the next restocking is expected to happen, 0 for 
unknown,
- *                     #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
+ * @param pgr response details
  */
 typedef void
 (*TALER_MERCHANT_ProductGetCallback)(
   void *cls,
-  const struct TALER_MERCHANT_HttpResponse *hr,
-  const char *description,
-  const json_t *description_i18n,
-  const char *unit,
-  const struct TALER_Amount *price,
-  const char *image,
-  const json_t *taxes,
-  int64_t total_stock,
-  uint64_t total_sold,
-  uint64_t total_lost,
-  const json_t *location,
-  struct GNUNET_TIME_Timestamp next_restock);
+  const struct TALER_MERCHANT_ProductGetResponse *pgr);
 
 
 /**
@@ -1730,21 +1819,52 @@ struct TALER_MERCHANT_OrderEntry
 };
 
 
-// FIXME: change signature!
+/**
+ * Response for a GET /private/orders request.
+ */
+struct TALER_MERCHANT_OrdersGetResponse
+{
+  /**
+   * HTTP response details.
+   */
+  struct TALER_MERCHANT_HttpResponse hr;
+
+  /**
+   * Details depending on HTTP status.
+   */
+  union
+  {
+    /**
+     * Details for #MHD_HTTP_OK.
+     */
+    struct
+    {
+
+      /**
+       * length of the @e orders array
+       */
+      unsigned int orders_length;
+
+      /**
+       * array of orders the requested instance has made
+       */
+      const struct TALER_MERCHANT_OrderEntry *orders;
+    } ok;
+  } details;
+
+};
+
+
 /**
  * Function called with the result of the GET /orders operation.
  *
  * @param cls closure
- * @param hr HTTP response details
- * @param orders_length length of the @a orders array
- * @param orders array of orders the requested instance has made
+ * @param ogr response details
  */
 typedef void
 (*TALER_MERCHANT_OrdersGetCallback)(
   void *cls,
-  const struct TALER_MERCHANT_HttpResponse *hr,
-  unsigned int orders_length,
-  const struct TALER_MERCHANT_OrderEntry orders[]);
+  const struct TALER_MERCHANT_OrdersGetResponse *ogr);
 
 
 /**
@@ -2338,24 +2458,55 @@ TALER_MERCHANT_order_delete_cancel (
 struct TALER_MERCHANT_OrderClaimHandle;
 
 
-// FIXME: change signature!
+/**
+ * Response to a POST /orders/$ID/claim request.
+ */
+struct TALER_MERCHANT_OrderClaimResponse
+{
+  /**
+   * HTTP response details
+   */
+  struct TALER_MERCHANT_HttpResponse hr;
+
+  /**
+   * Details depending on HTTP status.
+   */
+  union
+  {
+    /**
+     * Details for #MHD_HTTP_OK.
+     */
+    struct
+    {
+      /**
+       * the details of the contract
+       */
+      const json_t *contract_terms;
+
+      /**
+       * merchant's signature over @e contract_terms (already verified)
+       */
+      struct TALER_MerchantSignatureP sig;
+
+      /**
+       * hash over @e contract_terms (computed client-side to verify @e sig)
+       */
+      struct TALER_PrivateContractHashP h_contract_terms;
+    } ok;
+
+  } details;
+};
+
 /**
  * Callback called to process a POST /orders/$ID/claim response.
  *
  * @param cls closure
- * @param hr HTTP response details
- * @param contract_terms the details of the contract
- * @param sig merchant's signature over @a contract_terms (already verified)
- * @param h_contract_terms hash over @a contract_terms (computed
- *        client-side to verify @a sig)
+ * @param ocr response details
  */
 typedef void
 (*TALER_MERCHANT_OrderClaimCallback) (
   void *cls,
-  const struct TALER_MERCHANT_HttpResponse *hr,
-  const json_t *contract_terms,
-  const struct TALER_MerchantSignatureP *sig,
-  const struct TALER_PrivateContractHashP *h_contract_terms);
+  const struct TALER_MERCHANT_OrderClaimResponse *ocr);
 
 
 /**
diff --git a/src/lib/merchant_api_get_config.c 
b/src/lib/merchant_api_get_config.c
index bf957428..b6023bdb 100644
--- a/src/lib/merchant_api_get_config.c
+++ b/src/lib/merchant_api_get_config.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014-2018, 2020 Taler Systems SA
+  Copyright (C) 2014-2023 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
@@ -90,9 +90,9 @@ handle_config_finished (void *cls,
 {
   struct TALER_MERCHANT_ConfigGetHandle *vgh = cls;
   const json_t *json = response;
-  struct TALER_MERCHANT_HttpResponse hr = {
-    .http_status = (unsigned int) response_code,
-    .reply = json
+  struct TALER_MERCHANT_ConfigResponse cr = {
+    .hr.http_status = (unsigned int) response_code,
+    .hr.reply = json
   };
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -104,24 +104,22 @@ handle_config_finished (void *cls,
   {
   case MHD_HTTP_OK:
     {
-      struct TALER_MERCHANT_ConfigInformation vi;
-      enum TALER_MERCHANT_VersionCompatibility vc =
-        TALER_MERCHANT_VC_PROTOCOL_ERROR;
       struct GNUNET_JSON_Specification spec[] = {
         GNUNET_JSON_spec_string ("currency",
-                                 &vi.currency),
+                                 &cr.details.ok.ci.currency),
         GNUNET_JSON_spec_string ("version",
-                                 &vi.version),
+                                 &cr.details.ok.ci.version),
         GNUNET_JSON_spec_end ()
       };
 
+      cr.details.ok.compat = TALER_MERCHANT_VC_PROTOCOL_ERROR;
       if (GNUNET_OK !=
           GNUNET_JSON_parse (json,
                              spec,
                              NULL, NULL))
       {
-        hr.http_status = 0;
-        hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+        cr.hr.http_status = 0;
+        cr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
       }
       else
       {
@@ -129,51 +127,47 @@ handle_config_finished (void *cls,
         unsigned int revision;
         unsigned int current;
 
-        if (3 != sscanf (vi.version,
+        if (3 != sscanf (cr.details.ok.ci.version,
                          "%u:%u:%u",
                          &current,
                          &revision,
                          &age))
         {
-          hr.http_status = 0;
-          hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+          cr.hr.http_status = 0;
+          cr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
         }
         else
         {
-          vc = TALER_MERCHANT_VC_MATCH;
+          cr.details.ok.compat = TALER_MERCHANT_VC_MATCH;
           if (MERCHANT_PROTOCOL_CURRENT < current)
           {
-            vc |= TALER_MERCHANT_VC_NEWER;
+            cr.details.ok.compat |= TALER_MERCHANT_VC_NEWER;
             if (MERCHANT_PROTOCOL_CURRENT < current - age)
-              vc |= TALER_MERCHANT_VC_INCOMPATIBLE;
+              cr.details.ok.compat |= TALER_MERCHANT_VC_INCOMPATIBLE;
           }
           if (MERCHANT_PROTOCOL_CURRENT > current)
           {
-            vc |= TALER_MERCHANT_VC_OLDER;
+            cr.details.ok.compat |= TALER_MERCHANT_VC_OLDER;
             if (MERCHANT_PROTOCOL_CURRENT - MERCHANT_PROTOCOL_AGE > current)
-              vc |= TALER_MERCHANT_VC_INCOMPATIBLE;
+              cr.details.ok.compat |= TALER_MERCHANT_VC_INCOMPATIBLE;
           }
         }
       }
       vgh->cb (vgh->cb_cls,
-               &hr,
-               &vi,
-               vc);
+               &cr);
       TALER_MERCHANT_config_get_cancel (vgh);
       return;
     }
   default:
     /* unexpected response code */
-    hr.ec = TALER_JSON_get_error_code (json);
-    hr.hint = TALER_JSON_get_error_hint (json);
+    cr.hr.ec = TALER_JSON_get_error_code (json);
+    cr.hr.hint = TALER_JSON_get_error_hint (json);
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Unexpected response code %u/%d\n",
                 (unsigned int) response_code,
-                (int) hr.ec);
+                (int) cr.hr.ec);
     vgh->cb (vgh->cb_cls,
-             &hr,
-             NULL,
-             TALER_MERCHANT_VC_PROTOCOL_ERROR);
+             &cr);
     break;
   }
   TALER_MERCHANT_config_get_cancel (vgh);
diff --git a/src/lib/merchant_api_get_orders.c 
b/src/lib/merchant_api_get_orders.c
index 0a0ba3f0..5bad47e0 100644
--- a/src/lib/merchant_api_get_orders.c
+++ b/src/lib/merchant_api_get_orders.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014-2018, 2020, 2021 Taler Systems SA
+  Copyright (C) 2014-2023 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
@@ -68,20 +68,20 @@ struct TALER_MERCHANT_OrdersGetHandle
  * Parse order information from @a ia.
  *
  * @param ia JSON array (or NULL!) with order data
+ * @param[in] ogr response to fill
  * @param ogh operation handle
  * @return #GNUNET_OK on success
  */
 static enum GNUNET_GenericReturnValue
 parse_orders (const json_t *ia,
+              struct TALER_MERCHANT_OrdersGetResponse *ogr,
               struct TALER_MERCHANT_OrdersGetHandle *ogh)
 {
   unsigned int oes_len = json_array_size (ia);
   struct TALER_MERCHANT_OrderEntry oes[GNUNET_NZL (oes_len)];
   size_t index;
   json_t *value;
-  int ret;
 
-  ret = GNUNET_OK;
   json_array_foreach (ia, index, value) {
     struct TALER_MERCHANT_OrderEntry *ie = &oes[index];
     struct GNUNET_JSON_Specification spec[] = {
@@ -108,25 +108,15 @@ parse_orders (const json_t *ia,
                            NULL, NULL))
     {
       GNUNET_break_op (0);
-      ret = GNUNET_SYSERR;
-      continue;
+      return GNUNET_SYSERR;
     }
-    if (GNUNET_SYSERR == ret)
-      break;
-  }
-  if (GNUNET_OK == ret)
-  {
-    struct TALER_MERCHANT_HttpResponse hr = {
-      .http_status = MHD_HTTP_OK
-    };
-
-    ogh->cb (ogh->cb_cls,
-             &hr,
-             oes_len,
-             oes);
-    ogh->cb = NULL; /* just to be sure */
   }
-  return ret;
+  ogr->details.ok.orders_length = oes_len;
+  ogr->details.ok.orders = oes;
+  ogh->cb (ogh->cb_cls,
+           ogr);
+  ogh->cb = NULL;   /* just to be sure */
+  return GNUNET_OK;
 }
 
 
@@ -145,9 +135,9 @@ handle_get_orders_finished (void *cls,
 {
   struct TALER_MERCHANT_OrdersGetHandle *ogh = cls;
   const json_t *json = response;
-  struct TALER_MERCHANT_HttpResponse hr = {
-    .http_status = (unsigned int) response_code,
-    .reply = json
+  struct TALER_MERCHANT_OrdersGetResponse ogr = {
+    .hr.http_status = (unsigned int) response_code,
+    .hr.reply = json
   };
 
   ogh->job = NULL;
@@ -170,52 +160,48 @@ handle_get_orders_finished (void *cls,
                              spec,
                              NULL, NULL))
       {
-        hr.http_status = 0;
-        hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+        ogr.hr.http_status = 0;
+        ogr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
       }
       else
       {
         if ( (! json_is_array (orders)) ||
              (GNUNET_OK ==
               parse_orders (orders,
+                            &ogr,
                             ogh)) )
         {
           GNUNET_JSON_parse_free (spec);
           TALER_MERCHANT_orders_get_cancel (ogh);
           return;
         }
-        else
-        {
-          hr.http_status = 0;
-          hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
-        }
+        ogr.hr.http_status = 0;
+        ogr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
       }
       GNUNET_JSON_parse_free (spec);
       break;
     }
   case MHD_HTTP_UNAUTHORIZED:
-    hr.ec = TALER_JSON_get_error_code (json);
-    hr.hint = TALER_JSON_get_error_hint (json);
+    ogr.hr.ec = TALER_JSON_get_error_code (json);
+    ogr.hr.hint = TALER_JSON_get_error_hint (json);
     /* Nothing really to verify, merchant says we need to authenticate. */
     break;
   case MHD_HTTP_NOT_FOUND:
-    hr.ec = TALER_JSON_get_error_code (json);
-    hr.hint = TALER_JSON_get_error_hint (json);
+    ogr.hr.ec = TALER_JSON_get_error_code (json);
+    ogr.hr.hint = TALER_JSON_get_error_hint (json);
     break;
   default:
     /* unexpected response code */
-    hr.ec = TALER_JSON_get_error_code (json);
-    hr.hint = TALER_JSON_get_error_hint (json);
+    ogr.hr.ec = TALER_JSON_get_error_code (json);
+    ogr.hr.hint = TALER_JSON_get_error_hint (json);
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Unexpected response code %u/%d\n",
                 (unsigned int) response_code,
-                (int) hr.ec);
+                (int) ogr.hr.ec);
     break;
   }
   ogh->cb (ogh->cb_cls,
-           &hr,
-           0,
-           NULL);
+           &ogr);
   TALER_MERCHANT_orders_get_cancel (ogh);
 }
 
diff --git a/src/lib/merchant_api_get_product.c 
b/src/lib/merchant_api_get_product.c
index 94d38ec7..f38dcf62 100644
--- a/src/lib/merchant_api_get_product.c
+++ b/src/lib/merchant_api_get_product.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014-2018, 2020 Taler Systems SA
+  Copyright (C) 2014-2023 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
@@ -79,9 +79,9 @@ handle_get_product_finished (void *cls,
 {
   struct TALER_MERCHANT_ProductGetHandle *pgh = cls;
   const json_t *json = response;
-  struct TALER_MERCHANT_HttpResponse hr = {
-    .http_status = (unsigned int) response_code,
-    .reply = json
+  struct TALER_MERCHANT_ProductGetResponse pgr = {
+    .hr.http_status = (unsigned int) response_code,
+    .hr.reply = json
   };
 
   pgh->job = NULL;
@@ -92,121 +92,80 @@ handle_get_product_finished (void *cls,
   {
   case MHD_HTTP_OK:
     {
-      const char *description;
-      json_t *description_i18n;
-      const char *unit;
-      struct TALER_Amount price;
-      const char *image;
-      json_t *taxes;
-      int64_t total_stock;
-      uint64_t total_sold;
-      uint64_t total_lost;
-      json_t *address;
-      bool rst_ok = true;
-      struct GNUNET_TIME_Timestamp next_restock
-        = GNUNET_TIME_UNIT_ZERO_TS;
       struct GNUNET_JSON_Specification spec[] = {
-        GNUNET_JSON_spec_string ("description",
-                                 &description),
-        GNUNET_JSON_spec_json ("description_i18n",
-                               &description_i18n),
-        GNUNET_JSON_spec_string ("unit",
-                                 &unit),
-        TALER_JSON_spec_amount_any ("price",
-                                    &price),
-        GNUNET_JSON_spec_string ("image",
-                                 &image),
-        GNUNET_JSON_spec_json ("taxes",
-                               &taxes),
-        GNUNET_JSON_spec_int64 ("total_stock",
-                                &total_stock),
-        GNUNET_JSON_spec_uint64 ("total_sold",
-                                 &total_sold),
-        GNUNET_JSON_spec_uint64 ("total_lost",
-                                 &total_lost),
-        GNUNET_JSON_spec_json ("address",
-                               &address),
+        GNUNET_JSON_spec_string (
+          "description",
+          &pgr.details.ok.description),
+        GNUNET_JSON_spec_object_const (
+          "description_i18n",
+          &pgr.details.ok.description_i18n),
+        GNUNET_JSON_spec_string (
+          "unit",
+          &pgr.details.ok.unit),
+        TALER_JSON_spec_amount_any (
+          "price",
+          &pgr.details.ok.price),
+        GNUNET_JSON_spec_string (
+          "image",
+          &pgr.details.ok.image),
+        GNUNET_JSON_spec_object_const (
+          "taxes",
+          &pgr.details.ok.taxes),
+        GNUNET_JSON_spec_int64 (
+          "total_stock",
+          &pgr.details.ok.total_stock),
+        GNUNET_JSON_spec_uint64 (
+          "total_sold",
+          &pgr.details.ok.total_sold),
+        GNUNET_JSON_spec_uint64 (
+          "total_lost",
+          &pgr.details.ok.total_lost),
+        GNUNET_JSON_spec_object_const (
+          "address",
+          &pgr.details.ok.location),
+        GNUNET_JSON_spec_mark_optional (
+          GNUNET_JSON_spec_timestamp ("next_restock",
+                                      &pgr.details.ok.next_restock),
+          NULL),
         GNUNET_JSON_spec_end ()
       };
 
-      if (NULL !=
-          json_object_get (json,
-                           "next_restock"))
-      {
-        struct GNUNET_JSON_Specification spect[] = {
-          GNUNET_JSON_spec_timestamp ("next_restock",
-                                      &next_restock),
-          GNUNET_JSON_spec_end ()
-        };
-
-        if (GNUNET_OK !=
-            GNUNET_JSON_parse (json,
-                               spect,
-                               NULL, NULL))
-          rst_ok = false;
-      }
-
-
-      if ( (rst_ok) &&
-           (GNUNET_OK ==
-            GNUNET_JSON_parse (json,
-                               spec,
-                               NULL, NULL)) )
+      if (GNUNET_OK ==
+          GNUNET_JSON_parse (json,
+                             spec,
+                             NULL, NULL))
       {
         pgh->cb (pgh->cb_cls,
-                 &hr,
-                 description,
-                 description_i18n,
-                 unit,
-                 &price,
-                 image,
-                 taxes,
-                 total_stock,
-                 total_sold,
-                 total_lost,
-                 address,
-                 next_restock);
+                 &pgr);
         GNUNET_JSON_parse_free (spec);
         TALER_MERCHANT_product_get_cancel (pgh);
         return;
       }
-      hr.http_status = 0;
-      hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
-      GNUNET_JSON_parse_free (spec);
+      pgr.hr.http_status = 0;
+      pgr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
       break;
     }
   case MHD_HTTP_UNAUTHORIZED:
-    hr.ec = TALER_JSON_get_error_code (json);
-    hr.hint = TALER_JSON_get_error_hint (json);
+    pgr.hr.ec = TALER_JSON_get_error_code (json);
+    pgr.hr.hint = TALER_JSON_get_error_hint (json);
     /* Nothing really to verify, merchant says we need to authenticate. */
     break;
   case MHD_HTTP_NOT_FOUND:
-    hr.ec = TALER_JSON_get_error_code (json);
-    hr.hint = TALER_JSON_get_error_hint (json);
+    pgr.hr.ec = TALER_JSON_get_error_code (json);
+    pgr.hr.hint = TALER_JSON_get_error_hint (json);
     break;
   default:
     /* unexpected response code */
-    hr.ec = TALER_JSON_get_error_code (json);
-    hr.hint = TALER_JSON_get_error_hint (json);
+    pgr.hr.ec = TALER_JSON_get_error_code (json);
+    pgr.hr.hint = TALER_JSON_get_error_hint (json);
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Unexpected response code %u/%d\n",
                 (unsigned int) response_code,
-                (int) hr.ec);
+                (int) pgr.hr.ec);
     break;
   }
   pgh->cb (pgh->cb_cls,
-           &hr,
-           NULL,
-           NULL,
-           NULL,
-           NULL,
-           NULL,
-           NULL,
-           0,
-           0,
-           0,
-           NULL,
-           GNUNET_TIME_UNIT_FOREVER_TS);
+           &pgr);
   TALER_MERCHANT_product_get_cancel (pgh);
 }
 
diff --git a/src/lib/merchant_api_post_order_claim.c 
b/src/lib/merchant_api_post_order_claim.c
index ebab679a..76802ea5 100644
--- a/src/lib/merchant_api_post_order_claim.c
+++ b/src/lib/merchant_api_post_order_claim.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014-2021 Taler Systems SA
+  Copyright (C) 2014-2023 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
@@ -86,21 +86,20 @@ handle_post_order_claim_finished (void *cls,
                                   const void *response)
 {
   struct TALER_MERCHANT_OrderClaimHandle *och = cls;
-  json_t *contract_terms;
-  struct TALER_MerchantSignatureP sig;
-  struct TALER_PrivateContractHashP hash;
   const json_t *json = response;
+  struct TALER_MERCHANT_OrderClaimResponse ocr = {
+    .hr.http_status = (unsigned int) response_code,
+    .hr.reply = json
+  };
   struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_json ("contract_terms",
-                           &contract_terms),
-    GNUNET_JSON_spec_fixed_auto ("sig",
-                                 &sig),
+    GNUNET_JSON_spec_object_const (
+      "contract_terms",
+      &ocr.details.ok.contract_terms),
+    GNUNET_JSON_spec_fixed_auto (
+      "sig",
+      &ocr.details.ok.sig),
     GNUNET_JSON_spec_end ()
   };
-  struct TALER_MERCHANT_HttpResponse hr = {
-    .http_status = (unsigned int) response_code,
-    .reply = json
-  };
 
   och->job = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -109,17 +108,14 @@ handle_post_order_claim_finished (void *cls,
 
   if (MHD_HTTP_OK != response_code)
   {
-    hr.ec = TALER_JSON_get_error_code (json);
-    hr.hint = TALER_JSON_get_error_hint (json);
+    ocr.hr.ec = TALER_JSON_get_error_code (json);
+    ocr.hr.hint = TALER_JSON_get_error_hint (json);
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Proposal lookup failed with HTTP status code %u/%d\n",
                 (unsigned int) response_code,
-                (int) hr.ec);
+                (int) ocr.hr.ec);
     och->cb (och->cb_cls,
-             &hr,
-             NULL,
-             NULL,
-             NULL);
+             &ocr);
     TALER_MERCHANT_order_claim_cancel (och);
     return;
   }
@@ -132,39 +128,29 @@ handle_post_order_claim_finished (void *cls,
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Claiming order failed: could not parse JSON response\n");
     GNUNET_break_op (0);
-    hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
-    hr.http_status = 0;
+    ocr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+    ocr.hr.http_status = 0;
     och->cb (och->cb_cls,
-             &hr,
-             NULL,
-             NULL,
-             NULL);
+             &ocr);
     TALER_MERCHANT_order_claim_cancel (och);
     return;
   }
 
   if (GNUNET_OK !=
-      TALER_JSON_contract_hash (contract_terms,
-                                &hash))
+      TALER_JSON_contract_hash (ocr.details.ok.contract_terms,
+                                &ocr.details.ok.h_contract_terms))
   {
     GNUNET_break (0);
-    hr.ec = TALER_EC_MERCHANT_POST_ORDERS_ID_CLAIM_CLIENT_INTERNAL_FAILURE;
-    hr.http_status = 0;
+    ocr.hr.ec = TALER_EC_MERCHANT_POST_ORDERS_ID_CLAIM_CLIENT_INTERNAL_FAILURE;
+    ocr.hr.http_status = 0;
     GNUNET_JSON_parse_free (spec);
     och->cb (och->cb_cls,
-             &hr,
-             NULL,
-             NULL,
-             NULL);
+             &ocr);
     TALER_MERCHANT_order_claim_cancel (och);
     return;
   }
-
   och->cb (och->cb_cls,
-           &hr,
-           contract_terms,
-           &sig,
-           &hash);
+           &ocr);
   GNUNET_JSON_parse_free (spec);
   TALER_MERCHANT_order_claim_cancel (och);
 }
diff --git a/src/testing/testing_api_cmd_claim_order.c 
b/src/testing/testing_api_cmd_claim_order.c
index d7a3ec41..98b3a68b 100644
--- a/src/testing/testing_api_cmd_claim_order.c
+++ b/src/testing/testing_api_cmd_claim_order.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014-2018, 2020 Taler Systems SA
+  Copyright (C) 2014-2023 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as
@@ -123,34 +123,23 @@ order_claim_cleanup (void *cls,
  * response code is as expected.
  *
  * @param cls closure
- * @param hr HTTP response we got
- * @param contract_terms the contract terms; they are the
- *        backend-filled up order minus cryptographic
- *        information.
- * @param sig merchant signature over the contract terms.
- * @param hash hash code of the contract terms.
+ * @param ocr response we got
  */
 static void
 order_claim_cb (void *cls,
-                const struct TALER_MERCHANT_HttpResponse *hr,
-                const json_t *contract_terms,
-                const struct TALER_MerchantSignatureP *sig,
-                const struct TALER_PrivateContractHashP *hash)
+                const struct TALER_MERCHANT_OrderClaimResponse *ocr)
 {
   struct OrderClaimState *pls = cls;
 
   pls->och = NULL;
-  if (pls->http_status != hr->http_status)
+  if (pls->http_status != ocr->hr.http_status)
     TALER_TESTING_FAIL (pls->is);
-  if (MHD_HTTP_OK == hr->http_status)
+  if (MHD_HTTP_OK == ocr->hr.http_status)
   {
-    pls->contract_terms = json_object_get (hr->reply,
-                                           "contract_terms");
-    if (NULL == pls->contract_terms)
-      TALER_TESTING_FAIL (pls->is);
-    json_incref (pls->contract_terms);
-    pls->contract_terms_hash = *hash;
-    pls->merchant_sig = *sig;
+    pls->contract_terms
+      = json_incref ((json_t *) ocr->details.ok.contract_terms);
+    pls->contract_terms_hash = ocr->details.ok.h_contract_terms;
+    pls->merchant_sig = ocr->details.ok.sig;
     {
       const char *error_name;
       unsigned int error_line;
@@ -161,7 +150,7 @@ order_claim_cb (void *cls,
       };
 
       if (GNUNET_OK !=
-          GNUNET_JSON_parse (contract_terms,
+          GNUNET_JSON_parse (pls->contract_terms,
                              spec,
                              &error_name,
                              &error_line))
diff --git a/src/testing/testing_api_cmd_config.c 
b/src/testing/testing_api_cmd_config.c
index 6487be4e..64f58c65 100644
--- a/src/testing/testing_api_cmd_config.c
+++ b/src/testing/testing_api_cmd_config.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2020 Taler Systems SA
+  Copyright (C) 2020-2023 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as
@@ -84,24 +84,22 @@ config_cleanup (void *cls,
  * Process "GET /public/config" (lookup) response.
  *
  * @param cls closure
- * @param hr HTTP response we got
- * @param ci basic information about the merchant
- * @param compat protocol compatibility information
+ * @param cr response we got
  */
 static void
 config_cb (void *cls,
-           const struct TALER_MERCHANT_HttpResponse *hr,
-           const struct TALER_MERCHANT_ConfigInformation *ci,
-           enum TALER_MERCHANT_VersionCompatibility compat)
+           const struct TALER_MERCHANT_ConfigResponse *cr)
 {
   struct ConfigState *cs = cls;
 
-  (void) ci;
   cs->vgh = NULL;
-  if (cs->http_code != hr->http_status)
-    TALER_TESTING_FAIL (cs->is);
-  if (TALER_MERCHANT_VC_MATCH != compat)
+  if (cs->http_code != cr->hr.http_status)
     TALER_TESTING_FAIL (cs->is);
+  if (MHD_HTTP_OK == cr->hr.http_status)
+  {
+    if (TALER_MERCHANT_VC_MATCH != cr->details.ok.compat)
+      TALER_TESTING_FAIL (cs->is);
+  }
   TALER_TESTING_interpreter_next (cs->is);
 }
 
diff --git a/src/testing/testing_api_cmd_get_orders.c 
b/src/testing/testing_api_cmd_get_orders.c
index 7a271521..91695194 100644
--- a/src/testing/testing_api_cmd_get_orders.c
+++ b/src/testing/testing_api_cmd_get_orders.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2020 Taler Systems SA
+  Copyright (C) 2020-2023 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as
@@ -71,41 +71,39 @@ struct GetOrdersState
  * Callback for a GET /orders operation.
  *
  * @param cls closure for this function
- * @param hr HTTP response
- * @param orders_length how many orders are returned
- * @param orders all the orders' details
+ * @param ogr response
  */
 static void
 get_orders_cb (void *cls,
-               const struct TALER_MERCHANT_HttpResponse *hr,
-               unsigned int orders_length,
-               const struct TALER_MERCHANT_OrderEntry orders[])
+               const struct TALER_MERCHANT_OrdersGetResponse *ogr)
 {
   struct GetOrdersState *gos = cls;
 
   gos->ogh = NULL;
-  if (gos->http_status != hr->http_status)
+  if (gos->http_status != ogr->hr.http_status)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Unexpected response code %u (%d) to command %s\n",
-                hr->http_status,
-                (int) hr->ec,
+                ogr->hr.http_status,
+                (int) ogr->hr.ec,
                 TALER_TESTING_interpreter_get_current_label (gos->is));
     TALER_TESTING_interpreter_fail (gos->is);
     return;
   }
-  switch (hr->http_status)
+  switch (ogr->hr.http_status)
   {
   case MHD_HTTP_OK:
-    if (orders_length != gos->orders_length)
+    if (ogr->details.ok.orders_length != gos->orders_length)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   "Number of orders found does not match\n");
       TALER_TESTING_interpreter_fail (gos->is);
       return;
     }
-    for (unsigned int i = 0; i < orders_length; ++i)
+    for (unsigned int i = 0; i < ogr->details.ok.orders_length; ++i)
     {
+      const struct TALER_MERCHANT_OrderEntry *order =
+        &ogr->details.ok.orders[i];
       const struct TALER_TESTING_Command *order_cmd;
 
       order_cmd = TALER_TESTING_interpreter_lookup_command (
@@ -124,7 +122,7 @@ get_orders_cb (void *cls,
           TALER_TESTING_interpreter_fail (gos->is);
           return;
         }
-        if (0 != strcmp (orders[i].order_id,
+        if (0 != strcmp (order->order_id,
                          *order_id))
         {
           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -165,11 +163,11 @@ get_orders_cb (void *cls,
           return;
         }
         if ((0 != strcmp (summary,
-                          orders[i].summary)) ||
+                          order->summary)) ||
             (GNUNET_OK != TALER_amount_cmp_currency (&amount,
-                                                     &orders[i].amount)) ||
+                                                     &order->amount)) ||
             (0 != TALER_amount_cmp (&amount,
-                                    &orders[i].amount)))
+                                    &order->amount)))
         {
           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                       "Order summary and/or amount does not match\n");
@@ -396,31 +394,27 @@ conclude_task (void *cls)
  * Callback to process a GET /orders request
  *
  * @param cls closure
- * @param hr HTTP response details
- * @param orders_length how many orders are returned
- * @param orders the returned orders
+ * @param ogr response details
  */
 static void
 merchant_poll_orders_cb (
   void *cls,
-  const struct TALER_MERCHANT_HttpResponse *hr,
-  unsigned int orders_length,
-  const struct TALER_MERCHANT_OrderEntry orders[])
+  const struct TALER_MERCHANT_OrdersGetResponse *ogr)
 {
   struct MerchantPollOrdersStartState *pos = cls;
 
   pos->ogh = NULL;
-  if (MHD_HTTP_OK != hr->http_status)
+  if (MHD_HTTP_OK != ogr->hr.http_status)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Unexpected response code %u (%d) to command %s\n",
-                hr->http_status,
-                (int) hr->ec,
+                ogr->hr.http_status,
+                (int) ogr->hr.ec,
                 TALER_TESTING_interpreter_get_current_label (pos->is));
     TALER_TESTING_interpreter_fail (pos->is);
     return;
   }
-  switch (hr->http_status)
+  switch (ogr->hr.http_status)
   {
   case MHD_HTTP_OK:
     // FIXME: use order references to check if the data returned matches that 
from the POST / PATCH
@@ -429,7 +423,7 @@ merchant_poll_orders_cb (
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Unhandled HTTP status.\n");
   }
-  pos->http_status = hr->http_status;
+  pos->http_status = ogr->hr.http_status;
   if (NULL != pos->cs)
   {
     GNUNET_SCHEDULER_cancel (pos->cs->task);
diff --git a/src/testing/testing_api_cmd_get_product.c 
b/src/testing/testing_api_cmd_get_product.c
index ece36e71..c2bfbaa9 100644
--- a/src/testing/testing_api_cmd_get_product.c
+++ b/src/testing/testing_api_cmd_get_product.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2020 Taler Systems SA
+  Copyright (C) 2020-2023 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as
@@ -71,56 +71,27 @@ struct GetProductState
  * Callback for a /get/product/$ID operation.
  *
  * @param cls closure for this function
- * @param hr HTTP response details
- * @param description description of the product
- * @param description_i18n Map from IETF BCP 47 language tags to localized 
descriptions
- * @param unit unit in which the product is measured (liters, kilograms, 
packages, etc.)
- * @param price the price for one @a unit of the product, zero is used to 
imply that
- *              this product is not sold separately or that the price is not 
fixed and
- *              must be supplied by the front-end.  If non-zero, price must 
include
- *              applicable taxes.
- * @param image base64-encoded product image
- * @param taxes list of taxes paid by the merchant
- * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic 
books),
- *                does NOT indicate remaining stocks, to get remaining stocks,
- *                subtract @a total_sold and @a total_lost. Note that this 
still
- *                does not then say how many of the remaining inventory are 
locked.
- * @param total_sold in @a units, total number of @a unit of product sold
- * @param total_lost in @a units, total number of @a unit of product lost from 
inventory
- * @param location where the product is in stock
- * @param next_restock when the next restocking is expected to happen, 0 for 
unknown,
- *                     #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
+ * @param pgr response details
  */
 static void
 get_product_cb (void *cls,
-                const struct TALER_MERCHANT_HttpResponse *hr,
-                const char *description,
-                const json_t *description_i18n,
-                const char *unit,
-                const struct TALER_Amount *price,
-                const char *image,
-                const json_t *taxes,
-                int64_t total_stock,
-                uint64_t total_sold,
-                uint64_t total_lost,
-                const json_t *location,
-                struct GNUNET_TIME_Timestamp next_restock)
+                const struct TALER_MERCHANT_ProductGetResponse *pgr)
 {
   struct GetProductState *gis = cls;
   const struct TALER_TESTING_Command *product_cmd;
 
   gis->igh = NULL;
-  if (gis->http_status != hr->http_status)
+  if (gis->http_status != pgr->hr.http_status)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Unexpected response code %u (%d) to command %s\n",
-                hr->http_status,
-                (int) hr->ec,
+                pgr->hr.http_status,
+                (int) pgr->hr.ec,
                 TALER_TESTING_interpreter_get_current_label (gis->is));
     TALER_TESTING_interpreter_fail (gis->is);
     return;
   }
-  switch (hr->http_status)
+  switch (pgr->hr.http_status)
   {
   case MHD_HTTP_OK:
     {
@@ -133,7 +104,7 @@ get_product_cb (void *cls,
           TALER_TESTING_get_trait_product_description (product_cmd,
                                                        &expected_description))
         TALER_TESTING_interpreter_fail (gis->is);
-      if (0 != strcmp (description,
+      if (0 != strcmp (pgr->details.ok.description,
                        *expected_description))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -149,7 +120,7 @@ get_product_cb (void *cls,
           TALER_TESTING_get_trait_i18n_description (product_cmd,
                                                     
&expected_description_i18n))
         TALER_TESTING_interpreter_fail (gis->is);
-      if (1 != json_equal (description_i18n,
+      if (1 != json_equal (pgr->details.ok.description_i18n,
                            expected_description_i18n))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -165,9 +136,10 @@ get_product_cb (void *cls,
           TALER_TESTING_get_trait_amount (product_cmd,
                                           &expected_price))
         TALER_TESTING_interpreter_fail (gis->is);
-      if ((GNUNET_OK != TALER_amount_cmp_currency (price,
-                                                   expected_price)) ||
-          (0 != TALER_amount_cmp (price,
+      if ((GNUNET_OK !=
+           TALER_amount_cmp_currency (&pgr->details.ok.price,
+                                      expected_price)) ||
+          (0 != TALER_amount_cmp (&pgr->details.ok.price,
                                   expected_price)))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -183,7 +155,7 @@ get_product_cb (void *cls,
           TALER_TESTING_get_trait_product_image (product_cmd,
                                                  &expected_image))
         TALER_TESTING_interpreter_fail (gis->is);
-      if (0 != strcmp (image,
+      if (0 != strcmp (pgr->details.ok.image,
                        *expected_image))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -199,7 +171,7 @@ get_product_cb (void *cls,
           TALER_TESTING_get_trait_taxes (product_cmd,
                                          &expected_taxes))
         TALER_TESTING_interpreter_fail (gis->is);
-      if (1 != json_equal (taxes,
+      if (1 != json_equal (pgr->details.ok.taxes,
                            expected_taxes))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -215,7 +187,7 @@ get_product_cb (void *cls,
           TALER_TESTING_get_trait_product_unit (product_cmd,
                                                 &expected_unit))
         TALER_TESTING_interpreter_fail (gis->is);
-      if (0 != strcmp (unit,
+      if (0 != strcmp (pgr->details.ok.unit,
                        *expected_unit))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -231,7 +203,7 @@ get_product_cb (void *cls,
           TALER_TESTING_get_trait_address (product_cmd,
                                            &expected_location))
         TALER_TESTING_interpreter_fail (gis->is);
-      if (1 != json_equal (location,
+      if (1 != json_equal (pgr->details.ok.location,
                            expected_location))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -247,7 +219,7 @@ get_product_cb (void *cls,
           TALER_TESTING_get_trait_product_stock (product_cmd,
                                                  &expected_total_stock))
         TALER_TESTING_interpreter_fail (gis->is);
-      if (total_stock != *expected_total_stock)
+      if (pgr->details.ok.total_stock != *expected_total_stock)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                     "Product total stock does not match\n");
@@ -263,7 +235,7 @@ get_product_cb (void *cls,
                                              0,
                                              &expected_next_restock))
         TALER_TESTING_interpreter_fail (gis->is);
-      if (GNUNET_TIME_timestamp_cmp (next_restock,
+      if (GNUNET_TIME_timestamp_cmp (pgr->details.ok.next_restock,
                                      !=,
                                      *expected_next_restock))
       {
diff --git a/src/testing/testing_api_cmd_post_orders.c 
b/src/testing/testing_api_cmd_post_orders.c
index b818bd8c..4669a8d1 100644
--- a/src/testing/testing_api_cmd_post_orders.c
+++ b/src/testing/testing_api_cmd_post_orders.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014-2021 Taler Systems SA
+  Copyright (C) 2014-2023 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as
@@ -181,43 +181,41 @@ orders_traits (void *cls,
  * created.
  *
  * @param cls closure
- * @param hr HTTP response we got
- * @param contract_terms contract terms of this order
- * @param sig merchant's signature
- * @param hash hash over the contract
+ * @param ocr response we got
  */
 static void
 orders_claim_cb (void *cls,
-                 const struct TALER_MERCHANT_HttpResponse *hr,
-                 const json_t *contract_terms,
-                 const struct TALER_MerchantSignatureP *sig,
-                 const struct TALER_PrivateContractHashP *hash)
+                 const struct TALER_MERCHANT_OrderClaimResponse *ocr)
 {
   struct OrdersState *ps = cls;
-  struct TALER_MerchantPublicKeyP merchant_pub;
   const char *error_name;
   unsigned int error_line;
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_fixed_auto ("merchant_pub",
-                                 &merchant_pub),
+                                 &ps->merchant_pub),
     GNUNET_JSON_spec_end ()
   };
 
   ps->och = NULL;
-  if (ps->http_status != hr->http_status)
+  if (ps->http_status != ocr->hr.http_status)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Expected status %u, got %u\n",
                 ps->http_status,
-                hr->http_status);
+                ocr->hr.http_status);
     TALER_TESTING_FAIL (ps->is);
   }
-
-  ps->contract_terms = json_deep_copy (contract_terms);
-  ps->h_contract_terms = *hash;
-  ps->merchant_sig = *sig;
+  if (MHD_HTTP_OK != ocr->hr.http_status)
+  {
+    TALER_TESTING_interpreter_next (ps->is);
+    return;
+  }
+  ps->contract_terms = json_deep_copy (
+    (json_t *) ocr->details.ok.contract_terms);
+  ps->h_contract_terms = ocr->details.ok.h_contract_terms;
+  ps->merchant_sig = ocr->details.ok.sig;
   if (GNUNET_OK !=
-      GNUNET_JSON_parse (contract_terms,
+      GNUNET_JSON_parse (ps->contract_terms,
                          spec,
                          &error_name,
                          &error_line))
@@ -236,7 +234,6 @@ orders_claim_cb (void *cls,
     free (log);
     TALER_TESTING_FAIL (ps->is);
   }
-  ps->merchant_pub = merchant_pub;
   TALER_TESTING_interpreter_next (ps->is);
 }
 
diff --git a/src/testing/testing_api_cmd_post_using_templates.c 
b/src/testing/testing_api_cmd_post_using_templates.c
index 38743281..28eab0eb 100644
--- a/src/testing/testing_api_cmd_post_using_templates.c
+++ b/src/testing/testing_api_cmd_post_using_templates.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2022 Taler Systems SA
+  Copyright (C) 2022-2023 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as
@@ -155,43 +155,41 @@ struct PostUsingTemplatesState
  * created.
  *
  * @param cls closure
- * @param hr HTTP response we got
- * @param contract_terms contract terms of this order
- * @param sig merchant's signature
- * @param hash hash over the contract
+ * @param ocr response we got
  */
 static void
 using_claim_cb (void *cls,
-                const struct TALER_MERCHANT_HttpResponse *hr,
-                const json_t *contract_terms,
-                const struct TALER_MerchantSignatureP *sig,
-                const struct TALER_PrivateContractHashP *hash)
+                const struct TALER_MERCHANT_OrderClaimResponse *ocr)
 {
   struct PostUsingTemplatesState *tis = cls;
-  struct TALER_MerchantPublicKeyP merchant_pub;
   const char *error_name;
   unsigned int error_line;
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_fixed_auto ("merchant_pub",
-                                 &merchant_pub),
+                                 &tis->merchant_pub),
     GNUNET_JSON_spec_end ()
   };
 
   tis->och = NULL;
-  if (tis->http_status != hr->http_status)
+  if (tis->http_status != ocr->hr.http_status)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Expected status %u, got %u\n",
                 tis->http_status,
-                hr->http_status);
+                ocr->hr.http_status);
     TALER_TESTING_FAIL (tis->is);
   }
-
-  tis->contract_terms = json_deep_copy (contract_terms);
-  tis->h_contract_terms = *hash;
-  tis->merchant_sig = *sig;
+  if (MHD_HTTP_OK != ocr->hr.http_status)
+  {
+    TALER_TESTING_interpreter_next (tis->is);
+    return;
+  }
+  tis->contract_terms = json_deep_copy (
+    (json_t *) ocr->details.ok.contract_terms);
+  tis->h_contract_terms = ocr->details.ok.h_contract_terms;
+  tis->merchant_sig = ocr->details.ok.sig;
   if (GNUNET_OK !=
-      GNUNET_JSON_parse (contract_terms,
+      GNUNET_JSON_parse (tis->contract_terms,
                          spec,
                          &error_name,
                          &error_line))
@@ -210,7 +208,6 @@ using_claim_cb (void *cls,
     free (log);
     TALER_TESTING_FAIL (tis->is);
   }
-  tis->merchant_pub = merchant_pub;
   TALER_TESTING_interpreter_next (tis->is);
 }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]