merchant

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

commit b3e2c2f442cb97ab0feef71f60044ce4e72d9eef
parent 84d79e5c8eda85d4dc2af6528de19a35350ad60e
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
Date:   Sun, 16 Aug 2020 02:43:11 -0400

Merge branch 'master' of ssh://git.taler.net/merchant

Diffstat:
Msrc/backend/taler-merchant-httpd_private-get-orders.c | 53+++++++++++++++++++++++++----------------------------
1 file changed, 25 insertions(+), 28 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c @@ -39,14 +39,10 @@ struct AddOrderState const char *instance_id; /** - * The result after adding the orders (0 for okay, anything else for an error). + * The result after adding the orders (#TALER_EC_NONE for okay, anything else for an error). */ - int result; + enum TALER_ErrorCode result; - /** - * In the case of an error, what message to respond with. - */ - const char *ec_msg; }; @@ -276,8 +272,7 @@ add_order (void *cls, paid = false; if (qs < 0) { - aos->result = 1; - aos->ec_msg = "failed to lookup order status in database"; + aos->result = TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_STATUS_DB_LOOKUP_ERROR; return; } } @@ -304,8 +299,7 @@ add_order (void *cls, if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { - aos->result = 1; - aos->ec_msg = "failed to lookup order in database"; + aos->result = TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_CONTRACT_DB_LOOKUP_ERROR; json_decref (contract_terms); return; } @@ -329,8 +323,7 @@ add_order (void *cls, spec, NULL, NULL)) { - aos->result = 1; - aos->ec_msg = "failed to parse order contract terms"; + aos->result = TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_PARSE_CONTRACT_ERROR; json_decref (contract_terms); return; } @@ -350,8 +343,8 @@ add_order (void *cls, &refund_amount); if (0 > qs) { - aos->result = 1; - aos->ec_msg = "failed to lookup order refunds in database"; + aos->result = + TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_REFUND_DB_LOOKUP_ERROR; json_decref (contract_terms); return; } @@ -476,13 +469,15 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, /* resumed from long-polling, return answer we already have in 'hc->ctx' */ struct AddOrderState *aos = hc->ctx; - if (0 != aos->result) + + if (TALER_EC_NONE != aos->result) { GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ORDERS_GET_DB_LOOKUP_ERROR, - aos->ec_msg); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + aos->result, + TALER_ErrorCode_get_hint (aos->result)); } return TALER_MHD_reply_json_pack (connection, MHD_HTTP_OK, @@ -625,7 +620,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, GNUNET_assert (NULL != aos); aos->pa = json_array (); aos->instance_id = hc->instance->settings.id; - aos->result = 0; + aos->result = TALER_EC_NONE; GNUNET_assert (NULL != aos->pa); { qs = TMH_db->lookup_orders (TMH_db->cls, @@ -633,21 +628,23 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, &of, &add_order, aos); - if ((0 > qs) || - (0 != aos->result)) + if (0 > qs) + { + aos->result = + TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_BY_FILTER_DB_LOOKUP_ERROR; + } + if (TALER_EC_NONE != aos->result) { - int aos_result = aos->result; - const char *aos_ec_msg = aos->ec_msg; + enum TALER_ErrorCode aos_result = aos->result; GNUNET_break (0); json_decref (aos->pa); GNUNET_free (aos); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ORDERS_GET_DB_LOOKUP_ERROR, - 0 != aos_result ? - aos_ec_msg : - "failed to lookup orders in database"); + aos_result, + TALER_ErrorCode_get_hint ( + aos_result)); } } if ( (0 == qs) &&