diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2017-03-13 16:08:28 +0100 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2017-03-13 16:08:28 +0100 |
commit | a42bfbd0d95620cbd08754961086d325bcbaffaf (patch) | |
tree | 339c8593e177bd335b37e0ac33aee33ee5b34f3a | |
parent | 41878462c87141f2c0b782bcfd68e8c7ce30ce11 (diff) | |
download | merchant-a42bfbd0d95620cbd08754961086d325bcbaffaf.tar.gz merchant-a42bfbd0d95620cbd08754961086d325bcbaffaf.tar.bz2 merchant-a42bfbd0d95620cbd08754961086d325bcbaffaf.zip |
Returining order_id in place of h_proposal_data among
tracked transfers.
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transfer.c | 35 | ||||
-rw-r--r-- | src/include/taler_merchant_service.h | 6 | ||||
-rw-r--r-- | 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 26cdff67..150c8e65 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 0ed9802d..0d37111d 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 e34730fd..94dac1e3 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() |