merchant

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

commit fc51e020796e4faa5435520adb5e3ca67ee6105f
parent 4e099d5fc559795715b8a4e038a05e675fc4e9f8
Author: Florian Dold <florian.dold@gmail.com>
Date:   Tue, 29 Sep 2020 17:30:02 +0530

generate working order_status_url in private API

Diffstat:
Msrc/backend/taler-merchant-httpd_private-get-orders-ID.c | 54++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 40 insertions(+), 14 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -834,15 +834,6 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, &gorc->order_serial); if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { - struct GNUNET_HashCode unused; - - /* We don't have contract terms, but the order may still exist. */ - qs = TMH_db->lookup_order (TMH_db->cls, - hc->instance->settings.id, - hc->infix, - &claim_token, - &unused, - &gorc->contract_terms); order_only = true; } if (0 > qs) @@ -857,12 +848,47 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, TALER_EC_GET_ORDERS_DB_FETCH_CONTRACT_TERMS_ERROR, NULL); } - if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) + { - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_GET_ORDERS_ORDER_NOT_FOUND, - hc->infix); + struct GNUNET_HashCode unused; + json_t *ct = NULL; + + /* We need the order for two cases: Either when the contract doesn't exist yet, + * or when the order is claimed but unpaid, and we need the claim token. */ + qs = TMH_db->lookup_order (TMH_db->cls, + hc->instance->settings.id, + hc->infix, + &claim_token, + &unused, + &ct); + + if (0 > qs) + { + /* single, read-only SQL statements should never cause + serialization problems */ + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); + /* Always report on hard error as well to enable diagnostics */ + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GET_ORDERS_DB_FETCH_CONTRACT_TERMS_ERROR, + NULL); + } + if (order_only && (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) ) + { + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_GET_ORDERS_ORDER_NOT_FOUND, + hc->infix); + } + if (order_only) + { + gorc->contract_terms = ct; + } + else if (NULL != ct) + { + json_decref (ct); + } } /* extract the fulfillment URL and total amount from the contract terms! */ {