gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] branch master updated: Returining order_id


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: Returining order_id in place of h_proposal_data among tracked transfers.
Date: Mon, 13 Mar 2017 16:08:47 +0100

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

marcello pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new a42bfbd  Returining order_id in place of h_proposal_data among tracked 
transfers.
a42bfbd is described below

commit a42bfbd0d95620cbd08754961086d325bcbaffaf
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Mar 13 16:08:28 2017 +0100

    Returining order_id in place of h_proposal_data among
    tracked transfers.
---
 src/backend/taler-merchant-httpd_track-transfer.c | 35 +++++++++++++++--------
 src/include/taler_merchant_service.h              |  6 ++--
 src/lib/merchant_api_track_transfer.c             |  2 +-
 3 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_track-transfer.c 
b/src/backend/taler-merchant-httpd_track-transfer.c
index 26cdff6..150c8e6 100644
--- a/src/backend/taler-merchant-httpd_track-transfer.c
+++ b/src/backend/taler-merchant-httpd_track-transfer.c
@@ -143,6 +143,11 @@ struct Entry {
   };
 
 /**
+ * Modified response to return to the frontend.
+ */
+static json_t *deposits_response;
+
+/**
  * Free the @a rctx.
  *
  * @param rctx data to free
@@ -209,20 +214,27 @@ build_deposits_response (void *cls,
                          const struct GNUNET_HashCode *key,
                          void *value)
 {
-  json_t *response = cls;
+  struct TrackTransferContext *rctx = cls;
   json_t *element;
-  /*FIXME make Entry global*/
   struct Entry *entry = value;
+  json_t *proposal_data;
+  json_t *order_id;
+
+  /*FIXME put error check*/
+  GNUNET_assert (GNUNET_OK == db->find_proposal_data_from_hash (db->cls,
+                                                                &proposal_data,
+                                                                key,
+                                                                
&rctx->mi->pubkey));
 
+  order_id = json_object_get (proposal_data, "order_id");
   /*FIXME put error check*/
-  element = json_pack ("{s:o, s:o, s:o}",
-                       "h_proposal_data",
-                       GNUNET_JSON_from_data_auto (key),
+  element = json_pack ("{s:s, s:o, s:o}",
+                       "order_id", json_string_value (order_id),
                        "deposit_value", TALER_JSON_from_amount 
(&entry->deposit_value),
                        "deposit_fee", TALER_JSON_from_amount 
(&entry->deposit_fee));
 
   /*FIXME put error check*/
-  json_array_append_new (response, element);
+  json_array_append_new (deposits_response, element);
 
   return GNUNET_YES;
 }
@@ -235,12 +247,11 @@ build_deposits_response (void *cls,
  * @result pointer to new JSON, or NULL upon errors.
  */
 json_t *
-transform_response (const json_t *result)
+transform_response (const json_t *result, struct TrackTransferContext *rctx)
 {
   json_t *deposits;
   json_t *value;
   json_t *result_mod = NULL;
-  json_t *deposits_response;
   size_t index;
   const char *key;
   struct GNUNET_HashCode h_key;
@@ -263,7 +274,7 @@ transform_response (const json_t *result)
   deposits = json_object_get (result, "deposits");
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Inspecting deposits: '%s'\n",
+              "Transforming deposits: '%s'\n",
               json_dumps (deposits, JSON_INDENT (1)));
 
   json_array_foreach (deposits, index, value)
@@ -313,7 +324,7 @@ transform_response (const json_t *result)
   
   GNUNET_CONTAINER_multihashmap_iterate (map,
                                          build_deposits_response,
-                                         deposits_response);
+                                         rctx);
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Fresh built deposits array: '%s'.\n",
@@ -589,7 +600,7 @@ wire_transfer_cb (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "About to call tracks transformator.\n");
 
-  if (NULL == (jresponse = transform_response (json)))
+  if (NULL == (jresponse = transform_response (json, rctx)))
   {
     resume_track_transfer_with_response
       (rctx,
@@ -683,7 +694,7 @@ proof_cb (void *cls,
   struct TrackTransferContext *rctx = cls;
   json_t *transformed_response;
 
-  if (NULL == (transformed_response = transform_response (proof)))
+  if (NULL == (transformed_response = transform_response (proof, rctx)))
   {
     rctx->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
     rctx->response = TMH_RESPONSE_make_internal_error 
(TALER_EC_TRACK_TRANSFER_JSON_RESPONSE_ERROR,
diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index 0ed9802..0d37111 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -376,11 +376,9 @@ struct TALER_MERCHANT_TrackTransferDetails {
   struct TALER_Amount deposit_fee;
 
   /**
-   * Proposal data's hashcode associated whit this
-   * payment.  NOTE, this value is temporary, as the
-   * order ID is supposed to be returned here.
+   * Order ID associated whit this payment.
    */
-  struct GNUNET_HashCode h_proposal_data;
+  char *order_id;
 
 };
 
diff --git a/src/lib/merchant_api_track_transfer.c 
b/src/lib/merchant_api_track_transfer.c
index e34730f..94dac1e 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -118,7 +118,7 @@ check_track_transfer_response_ok (struct 
TALER_MERCHANT_TrackTransferHandle *wdh
       struct TALER_MERCHANT_TrackTransferDetails *detail = &details[i];
       json_t *deposit = json_array_get (deposits, i);
       struct GNUNET_JSON_Specification spec_detail[] = {
-        GNUNET_JSON_spec_fixed_auto ("h_proposal_data", 
&detail->h_proposal_data),
+        GNUNET_JSON_spec_string ("order_id", &detail->order_id),
         TALER_JSON_spec_amount ("deposit_value", &detail->deposit_value),
         TALER_JSON_spec_amount ("deposit_fee", &detail->deposit_fee),
         GNUNET_JSON_spec_end()

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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