diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-07-24 14:17:47 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-07-24 14:17:47 +0530 |
commit | 8029214856fb5619802e0128c06257dc1dd2113a (patch) | |
tree | 4a081260479cf55895e3d79f88e261ec8f4858a8 /src/lib/merchant_api_merchant_get_order.c | |
parent | 974b2b2c3077c929850c1598af1e1e124f530a7f (diff) | |
download | merchant-8029214856fb5619802e0128c06257dc1dd2113a.tar.gz merchant-8029214856fb5619802e0128c06257dc1dd2113a.tar.bz2 merchant-8029214856fb5619802e0128c06257dc1dd2113a.zip |
use order_status string tag
Diffstat (limited to 'src/lib/merchant_api_merchant_get_order.c')
-rw-r--r-- | src/lib/merchant_api_merchant_get_order.c | 36 |
1 files changed, 32 insertions, 4 deletions
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); + } } |