gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 184/277: work on implementing GET /private/orders/ID


From: gnunet
Subject: [taler-merchant] 184/277: work on implementing GET /private/orders/ID
Date: Sun, 05 Jul 2020 20:51:37 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

commit fcf60499c3ab3e23c458cecdf8f51dd7cf5e16d3
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Jun 7 21:58:18 2020 +0200

    work on implementing GET /private/orders/ID
---
 .../taler-merchant-httpd_private-get-orders-ID.c   | 79 +++++++++++++---------
 1 file changed, 48 insertions(+), 31 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c 
b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
index e82a121..78fe4e1 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -514,21 +514,24 @@ gorc_cleanup (void *cls)
  * It is responsible for summing up the refund amount.
  *
  * @param cls closure
+ * @param refund_serial unique serial number of the refund
+ * @param timestamp time of the refund (for grouping of refunds in the wallet 
UI)
  * @param coin_pub public coin from which the refund comes from
  * @param exchange_url URL of the exchange that issued @a coin_pub
  * @param rtransaction_id identificator of the refund
  * @param reason human-readable explanation of the refund
+ * @param timestamp when was the refund made
  * @param refund_amount refund amount which is being taken from @a coin_pub
- * @param refund_fee cost of this refund operation
  */
 static void
 process_refunds_cb (void *cls,
+                    uint64_t refund_serial,
+                    struct GNUNET_TIME_Absolute timestamp,
                     const struct TALER_CoinSpendPublicKeyP *coin_pub,
                     const char *exchange_url,
                     uint64_t rtransaction_id,
                     const char *reason,
-                    const struct TALER_Amount *refund_amount,
-                    const struct TALER_Amount *refund_fee)
+                    const struct TALER_Amount *refund_amount)
 {
   struct GetOrderRequestContext *gorc = cls;
 
@@ -538,12 +541,15 @@ process_refunds_cb (void *cls,
     GNUNET_assert (NULL != gorc->refund_details);
   }
   GNUNET_assert (0 ==
-                 json_array_append_new (json_pack ("{s:s}",
+                 json_array_append_new (json_pack ("{s:o, s:o, s:s}",
+                                                   "amount",
+                                                   TALER_JSON_from_amount (
+                                                     refund_amount),
+                                                   "timestamp",
+                                                   
GNUNET_JSON_from_time_absolute (
+                                                     timestamp),
                                                    "reason",
                                                    reason)));
-  // FIXME: properly setup json_pack above
-  // with the details on the refund
-  // FIXME: update spec accordingly!
   if (gorc->refunded)
   {
     GNUNET_assert (0 <=
@@ -877,12 +883,11 @@ TMH_private_get_orders_ID (const struct 
TMH_RequestHandler *rh,
 
   /* Accumulate refunds, if any. */
   {
-
-    qs = TMH_db->lookup_refunds (TMH_db->cls,
-                                 hc->instance.settings->id,
-                                 &h_contract_terms,
-                                 &process_refunds_cb,
-                                 gorc);
+    qs = TMH_db->lookup_refunds_detailed (TMH_db->cls,
+                                          hc->instance.settings->id,
+                                          &h_contract_terms,
+                                          &process_refunds_cb,
+                                          gorc);
   }
   if (0 > qs)
   {
@@ -945,26 +950,38 @@ TMH_private_get_orders_ID (const struct 
TMH_RequestHandler *rh,
       }
     }
 
-    // FIXME: also return gorc->ec/exchange_(hc,ec) codes
-    // and the gorc->value_total/deposits_total/etc.
     ret = TALER_MHD_reply_json_pack (connection,
                                      MHD_HTTP_OK,
-                                     "{s:O, s:b, s:b, s:o?, s:o?, s:o}",
-                                     "contract_terms",
-                                     gorc->contract_terms,
-                                     "paid",
-                                     true,
-                                     "refunded",
-                                     gorc->refunded,
-                                     "refund_amount",
-                                     (gorc->refunded)
-                                     ? TALER_JSON_from_amount (
-                                       &gorc->refund_amount)
-                                     : NULL,
-                                     "wire_details",
-                                     gorc->wire_details,
-                                     "refund_details",
-                                     gorc->refund_details);
+                                     "{s:I, s:I, s:I, s:o, s:o,"
+                                     " s:O, s:b, s:b, s:o?, s:o?, s:o?}",
+                                     "wire_ec",
+                                     (json_int_t) gorc->wire_ec,
+                                     "exchange_ec",
+                                     (json_int_t) gorc->exchange_ec,
+                                     "exchange_hc",
+                                     (json_int_t) gorc->exchange_hc,
+                                     "transfer_value_total",
+                                     TALER_JSON_from_amount (
+                                       &gorc->value_total)
+                                     "deposit_total",
+                                     TALER_JSON_from_amount (
+                                       &gorc->deposits_total)
+                                       : NULL,
+                                       "contract_terms",
+                                       gorc->contract_terms,
+                                       "paid",
+                                       true,
+                                       "refunded",
+                                       gorc->refunded,
+                                       "refund_amount",
+                                       (gorc->refunded)
+                                       ? TALER_JSON_from_amount (
+                                         &gorc->refund_amount)
+                                       : NULL,
+                                       "wire_details",
+                                       gorc->wire_details,
+                                       "refund_details",
+                                       gorc->refund_details);
     gorc->wire_details = NULL;
     gorc->refund_details = NULL;
     return ret;

-- 
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]