diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-06-07 21:58:18 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-06-07 21:58:18 +0200 |
commit | fcf60499c3ab3e23c458cecdf8f51dd7cf5e16d3 (patch) | |
tree | 68ac61d6c36dc40a93fb457412eb1e64c4453adf /src/backend/taler-merchant-httpd_private-get-orders-ID.c | |
parent | fbd93498c3a1135986470c869a9db1a75b8886c4 (diff) | |
download | merchant-fcf60499c3ab3e23c458cecdf8f51dd7cf5e16d3.tar.gz merchant-fcf60499c3ab3e23c458cecdf8f51dd7cf5e16d3.tar.bz2 merchant-fcf60499c3ab3e23c458cecdf8f51dd7cf5e16d3.zip |
work on implementing GET /private/orders/ID
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-get-orders-ID.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-orders-ID.c | 79 |
1 files 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 e82a1219..78fe4e19 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; |