merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 31b17ff2582bbc6890b829ef4746aa0d37b6d9d9
parent 8029214856fb5619802e0128c06257dc1dd2113a
Author: Florian Dold <florian.dold@gmail.com>
Date:   Fri, 24 Jul 2020 14:31:27 +0530

use string type tag for refund status

Diffstat:
Msrc/backend/taler-merchant-httpd_get-orders-ID.c | 16++++++++--------
Msrc/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 @@ -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 @@ -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)