diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-get-orders-ID.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-orders-ID.c | 59 |
1 files changed, 36 insertions, 23 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 index de5cb980..850b72c0 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -752,6 +752,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, enum GNUNET_DB_QueryStatus qs; bool paid; bool wired; + bool order_only = false; if (NULL == gorc) { @@ -832,6 +833,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, hc->instance->settings.id, hc->infix, &gorc->contract_terms); + order_only = true; } if (0 > qs) { @@ -887,15 +889,18 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, "Merchant database error (contract terms in wrong currency)"); } } - if (GNUNET_OK != - TALER_JSON_contract_hash (gorc->contract_terms, - &gorc->h_contract_terms)) + if (! order_only) { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_FAILED_COMPUTE_PROPOSAL_HASH, - "Failed to hash contract terms"); + if (GNUNET_OK != + TALER_JSON_contract_hash (gorc->contract_terms, + &gorc->h_contract_terms)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GET_ORDERS_FAILED_COMPUTE_PROPOSAL_HASH, + "Failed to hash contract terms"); + } } } if (TALER_EC_NONE != gorc->wire_ec) @@ -909,22 +914,29 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_assert (NULL != gorc->contract_terms); TMH_db->preflight (TMH_db->cls); - qs = TMH_db->lookup_payment_status (TMH_db->cls, - gorc->order_serial, - gorc->session_id, - &paid, - &wired); - if (0 > qs) + if (order_only) { - /* single, read-only SQL statements should never cause - serialization problems, and the entry should exist as per above */ - 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_PAYMENT_STATUS, - "DB error fetching payment status"); + paid = false; + wired = false; + } + else + { + qs = TMH_db->lookup_payment_status (TMH_db->cls, + gorc->order_serial, + gorc->session_id, + &paid, + &wired); + if (0 > qs) + { + /* single, read-only SQL statements should never cause + serialization problems, and the entry should exist as per above */ + 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_PAYMENT_STATUS, + "DB error fetching payment status"); + } } - /* qs == 0: the order hasn't been claimed, but this is okay. */ if ((! paid) && (NULL != gorc->session_id)) { @@ -1037,7 +1049,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, } /* Here we know the user DID pay, compute refunds... */ - + GNUNET_assert (! order_only); + GNUNET_assert (paid); /* Accumulate refunds, if any. */ { GNUNET_assert (GNUNET_OK == |