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 | |
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')
-rw-r--r-- | src/lib/merchant_api_merchant_get_order.c | 36 | ||||
-rw-r--r-- | src/lib/merchant_api_wallet_get_order.c | 49 |
2 files changed, 80 insertions, 5 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); + } } diff --git a/src/lib/merchant_api_wallet_get_order.c b/src/lib/merchant_api_wallet_get_order.c index b5468f65..680f856c 100644 --- a/src/lib/merchant_api_wallet_get_order.c +++ b/src/lib/merchant_api_wallet_get_order.c @@ -110,6 +110,7 @@ handle_wallet_get_order_finished (void *cls, { struct TALER_MERCHANT_OrderWalletGetHandle *owgh = cls; const json_t *json = response; + const char *order_status; owgh->job = NULL; if (MHD_HTTP_OK != response_code) @@ -138,7 +139,31 @@ handle_wallet_get_order_finished (void *cls, return; } - if (! json_boolean_value (json_object_get (json, "paid"))) + order_status = json_string_value (json_object_get (json, "order_status")); + + if (NULL == order_status) + { + struct TALER_MERCHANT_HttpResponse hr = { + .reply = json, + .http_status = 0, + .ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED, + }; + GNUNET_break_op (0); + owgh->cb (owgh->cb_cls, + &hr, + GNUNET_SYSERR, + GNUNET_SYSERR, + NULL, + NULL, + NULL, + NULL, + 0, + NULL); + TALER_MERCHANT_wallet_order_get_cancel (owgh); + return; + } + + if (0 == strcmp (order_status, "unpaid")) { /* Status is: unpaid */ const char *taler_pay_uri = json_string_value (json_object_get (json, @@ -174,6 +199,28 @@ handle_wallet_get_order_finished (void *cls, return; } + if (0 != strcmp (order_status, "paid")) + { + struct TALER_MERCHANT_HttpResponse hr = { + .reply = json, + .http_status = 0, + .ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED, + }; + GNUNET_break_op (0); + owgh->cb (owgh->cb_cls, + &hr, + GNUNET_SYSERR, + GNUNET_SYSERR, + NULL, + NULL, + NULL, + NULL, + 0, + NULL); + TALER_MERCHANT_wallet_order_get_cancel (owgh); + return; + } + { struct TALER_Amount refund_amount; json_t *refunds; |