summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_private-get-orders-ID.c57
-rw-r--r--src/include/taler_merchant_service.h15
-rw-r--r--src/lib/merchant_api_merchant_get_order.c43
3 files changed, 70 insertions, 45 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 0e38b48c..5d471aa4 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -759,6 +759,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
bool wired;
bool order_only = false;
struct TALER_ClaimTokenP claim_token = { 0 };
+ const char *summary;
+ struct GNUNET_TIME_Absolute timestamp;
if (NULL == gorc)
{
@@ -904,11 +906,19 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
json_decref (ct);
}
}
- /* extract the fulfillment URL and total amount from the contract terms! */
+ /* extract the fulfillment URL, total amount, summary and timestamp
+ from the contract terms! */
{
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount ("amount",
&gorc->contract_amount),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("fulfillment_url",
+ &gorc->fulfillment_url)),
+ GNUNET_JSON_spec_string ("summary",
+ &summary),
+ TALER_JSON_spec_absolute_time ("timestamp",
+ &timestamp),
GNUNET_JSON_spec_end ()
};
@@ -938,9 +948,6 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
gorc->contract_amount.currency);
}
}
- gorc->fulfillment_url
- = json_string_value (json_object_get (gorc->contract_terms,
- "fulfillment_url"));
if (! order_only)
{
if (GNUNET_OK !=
@@ -1040,7 +1047,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
NULL);
ret = TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK,
- "{s:s, s:s, s:s, s:s, s:s}",
+ "{s:s, s:s, s:s, s:s, s:s"
+ " s:o, s:s, s:o}",
"taler_pay_uri",
taler_pay_uri,
"order_status_url",
@@ -1050,7 +1058,14 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
"already_paid_order_id",
already_paid_order_id,
"already_paid_fulfillment_url",
- gorc->fulfillment_url);
+ gorc->fulfillment_url,
+ "total_amount",
+ TALER_JSON_from_amount (
+ &gorc->contract_amount),
+ "summary",
+ summary,
+ "creation_time",
+ GNUNET_JSON_from_time_abs (timestamp));
GNUNET_free (taler_pay_uri);
GNUNET_free (already_paid_order_id);
return ret;
@@ -1153,13 +1168,20 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
NULL);
ret = TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK,
- "{s:s, s:s, s:s}",
+ "{s:s, s:s, s:s, s:o, s:s, s:o}",
"taler_pay_uri",
taler_pay_uri,
"order_status_url",
order_status_url,
"order_status",
- "unpaid");
+ "unpaid",
+ "total_amount",
+ TALER_JSON_from_amount (
+ &gorc->contract_amount),
+ "summary",
+ summary,
+ "creation_time",
+ GNUNET_JSON_from_time_abs (timestamp));
GNUNET_free (taler_pay_uri);
GNUNET_free (order_status_url);
return ret;
@@ -1246,30 +1268,11 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
TALER_amount_cmp (&expect_total,
&gorc->deposits_total))
{
- struct GNUNET_TIME_Absolute timestamp;
-
/* expect_total <= gorc->deposits_total: good: we got paid */
wired = true;
qs = TMH_db->mark_order_wired (TMH_db->cls,
gorc->order_serial);
GNUNET_break (qs >= 0); /* just warn if transaction failed */
- {
- struct GNUNET_JSON_Specification spec[] = {
- TALER_JSON_spec_absolute_time ("timestamp",
- &timestamp),
- GNUNET_JSON_spec_end ()
- };
- enum GNUNET_GenericReturnValue res;
-
- res = TALER_MHD_parse_internal_json_data (connection,
- gorc->contract_terms,
- spec);
- if (GNUNET_YES != res)
- {
- GNUNET_break (0);
- return res;
- }
- }
TMH_notify_order_change (hc->instance,
hc->infix,
true, /* paid */
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index 8a8cc25b..76f8bc66 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -1868,6 +1868,21 @@ struct TALER_MERCHANT_OrderStatusResponse
*/
const char *already_paid_order_id;
+ /**
+ * Order summary.
+ */
+ const char *summary;
+
+ /**
+ * Time when the order was created.
+ */
+ struct GNUNET_TIME_Absolute creation_time;
+
+ /**
+ * Total amount the order is about (amount to be paid by customer).
+ */
+ struct TALER_Amount contract_amount;
+
} unpaid;
} details;
diff --git a/src/lib/merchant_api_merchant_get_order.c b/src/lib/merchant_api_merchant_get_order.c
index 466f2cd1..025460c2 100644
--- a/src/lib/merchant_api_merchant_get_order.c
+++ b/src/lib/merchant_api_merchant_get_order.c
@@ -77,13 +77,28 @@ static void
handle_unpaid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
struct TALER_MERCHANT_HttpResponse *hr)
{
- const char *taler_pay_uri
- = json_string_value (json_object_get (hr->reply,
- "taler_pay_uri"));
- const char *already_paid_order_id
- = json_string_value (json_object_get (hr->reply,
- "already_paid_order_id"));
- if (NULL == taler_pay_uri)
+ struct TALER_MERCHANT_OrderStatusResponse osr = {
+ .status = TALER_MERCHANT_OSC_UNPAID
+ };
+ struct GNUNET_JSON_Specification spec[] = {
+ TALER_JSON_spec_amount ("total_amount",
+ &osr.details.unpaid.contract_amount),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("already_paid_order_id",
+ &osr.details.unpaid.already_paid_order_id)),
+ GNUNET_JSON_spec_string ("taler_pay_uri",
+ &osr.details.unpaid.taler_pay_uri),
+ GNUNET_JSON_spec_string ("summary",
+ &osr.details.unpaid.summary),
+ TALER_JSON_spec_absolute_time ("creation_time",
+ &osr.details.unpaid.creation_time),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (hr->reply,
+ spec,
+ NULL, NULL))
{
GNUNET_break_op (0);
hr->http_status = 0;
@@ -93,17 +108,9 @@ handle_unpaid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
NULL);
return;
}
- {
- struct TALER_MERCHANT_OrderStatusResponse osr = {
- .status = TALER_MERCHANT_OSC_UNPAID,
- .details.unpaid.taler_pay_uri = taler_pay_uri,
- .details.unpaid.already_paid_order_id = already_paid_order_id
- };
-
- omgh->cb (omgh->cb_cls,
- hr,
- &osr);
- }
+ omgh->cb (omgh->cb_cls,
+ hr,
+ &osr);
}