diff options
-rw-r--r-- | src/backend/taler-merchant-httpd_get-orders-ID.c | 16 | ||||
-rw-r--r-- | src/lib/merchant_api_wallet_get_order.c | 20 |
2 files changed, 28 insertions, 8 deletions
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c index 8604578c..21582699 100644 --- a/src/backend/taler-merchant-httpd_get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_get-orders-ID.c @@ -997,9 +997,9 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, { if (NULL == cr->exchange_reply) { - refund = json_pack ("{s:b, s:I,s:I,s:o,s:o,s:o}" - "success", - false, + refund = json_pack ("{s:s, s:I,s:I,s:o,s:o,s:o}" + "type", + "failure", "exchange_status", (json_int_t) cr->exchange_status, "rtransaction_id", @@ -1013,9 +1013,9 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, } else { - refund = json_pack ("{s:b,s:I,s:I,s:o,s:I,s:o,s:o,s:o}" - "success", - false, + refund = json_pack ("{s:s,s:I,s:I,s:o,s:I,s:o,s:o,s:o}" + "type", + "failure", "exchange_status", (json_int_t) cr->exchange_status, "exchange_code", @@ -1034,9 +1034,9 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, } else { - refund = json_pack ("{s:b,s:I,s:o,s:o,s:I,s:o,s:o,s:o}", + refund = json_pack ("{s:s,s:I,s:o,s:o,s:I,s:o,s:o,s:o}", + "type", "success", - true, "exchange_status", (json_int_t) cr->exchange_status, "exchange_sig", diff --git a/src/lib/merchant_api_wallet_get_order.c b/src/lib/merchant_api_wallet_get_order.c index 680f856c..7b7c86e6 100644 --- a/src/lib/merchant_api_wallet_get_order.c +++ b/src/lib/merchant_api_wallet_get_order.c @@ -275,6 +275,7 @@ handle_wallet_get_order_finished (void *cls, struct TALER_MERCHANT_RefundDetail *rd = &rds[i]; const json_t *jrefund = json_array_get (refunds, i); + const char *refund_status_type; uint32_t exchange_status; int ret; struct GNUNET_JSON_Specification espec[] = { @@ -299,6 +300,8 @@ handle_wallet_get_order_finished (void *cls, if (MHD_HTTP_OK == exchange_status) { struct GNUNET_JSON_Specification rspec[] = { + GNUNET_JSON_spec_string ("type", + &refund_status_type), GNUNET_JSON_spec_fixed_auto ("exchange_sig", &rd->exchange_sig), GNUNET_JSON_spec_fixed_auto ("exchange_pub", @@ -315,10 +318,21 @@ handle_wallet_get_order_finished (void *cls, ret = GNUNET_JSON_parse (jrefund, rspec, NULL, NULL); + if (GNUNET_OK == ret) + { + /* check that type field is correct */ + if (0 != strcmp ("success", refund_status_type)) + { + GNUNET_break_op (0); + ret = GNUNET_SYSERR; + } + } } else { struct GNUNET_JSON_Specification rspec[] = { + GNUNET_JSON_spec_string ("type", + &refund_status_type), GNUNET_JSON_spec_fixed_auto ("coin_pub", &rd->coin_pub), GNUNET_JSON_spec_uint64 ("rtransaction_id", @@ -352,6 +366,12 @@ handle_wallet_get_order_finished (void *cls, } rd->hr.reply = json_object_get (jrefund, "exchange_reply"); + /* check that type field is correct */ + if (0 != strcmp ("failure", refund_status_type)) + { + GNUNET_break_op (0); + ret = GNUNET_SYSERR; + } } } if (GNUNET_OK != ret) |