From 8029214856fb5619802e0128c06257dc1dd2113a Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 24 Jul 2020 14:17:47 +0530 Subject: use order_status string tag --- src/lib/merchant_api_merchant_get_order.c | 36 +++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'src/lib/merchant_api_merchant_get_order.c') diff --git a/src/lib/merchant_api_merchant_get_order.c b/src/lib/merchant_api_merchant_get_order.c index 25cce306..a339c699 100644 --- a/src/lib/merchant_api_merchant_get_order.c +++ b/src/lib/merchant_api_merchant_get_order.c @@ -323,6 +323,7 @@ handle_merchant_order_get_finished (void *cls, { struct TALER_MERCHANT_OrderMerchantGetHandle *omgh = cls; const json_t *json = response; + const char *order_status; struct TALER_MERCHANT_HttpResponse hr = { .http_status = (unsigned int) response_code, .reply = json @@ -357,13 +358,40 @@ handle_merchant_order_get_finished (void *cls, return; } - /* HTTP OK */ - if (! json_boolean_value (json_object_get (json, "paid"))) + order_status = json_string_value (json_object_get (json, "order_status")); + + if (NULL == order_status) + { + GNUNET_break_op (0); + hr.http_status = 0; + hr.ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED; + omgh->cb (omgh->cb_cls, + &hr, + NULL); + TALER_MERCHANT_merchant_order_get_cancel (omgh); + return; + } + + if (0 == strcmp ("paid", order_status)) + { + handle_paid (omgh, + &hr); + } + else if (0 == strcmp ("unpaid", order_status)) + { handle_unpaid (omgh, &hr); + } else - handle_paid (omgh, - &hr); + { + GNUNET_break_op (0); + hr.http_status = 0; + hr.ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED; + omgh->cb (omgh->cb_cls, + &hr, + NULL); + TALER_MERCHANT_merchant_order_get_cancel (omgh); + } } -- cgit v1.2.3