summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-22 19:28:33 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-22 19:28:33 +0200
commit9cfa86ff0c6382d3ed9bbfe990bb7ad1ae865473 (patch)
tree4f572db2ed07d6eef15a4d07eac167db47965ddd /src
parent0d05df558c80b88a75397bfeea0a4249103952f2 (diff)
downloadmerchant-9cfa86ff0c6382d3ed9bbfe990bb7ad1ae865473.tar.gz
merchant-9cfa86ff0c6382d3ed9bbfe990bb7ad1ae865473.tar.bz2
merchant-9cfa86ff0c6382d3ed9bbfe990bb7ad1ae865473.zip
revert patch 838e8bf4f11a6713c61a80addfc5517254f72759
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_get-orders-ID.c99
1 files changed, 50 insertions, 49 deletions
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c
index c289ea22..2af92e89 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -834,9 +834,9 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
contract_match = (0 ==
GNUNET_memcmp (&h,
&god->h_contract_terms));
- /* No matter what, the contract terms are required to match if the order
- has been claimed. */
- if (! contract_match)
+ if ( (GNUNET_NO ==
+ GNUNET_is_zero (&god->h_contract_terms)) &&
+ (! contract_match) )
{
GNUNET_break_op (0);
return TALER_MHD_reply_with_error (connection,
@@ -846,7 +846,8 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
}
}
- if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+ if ( (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) ||
+ (! contract_match) )
{
struct TALER_ClaimTokenP db_claim_token;
@@ -882,7 +883,6 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
TALER_EC_GET_ORDERS_ID_UNKNOWN,
"order_id not found in database");
}
-
token_match = (0 == GNUNET_memcmp (&db_claim_token,
&god->claim_token));
} /* end unclaimed order logic */
@@ -918,6 +918,47 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
TALER_EC_MERCHANT_GET_ORDER_INVALID_TOKEN,
"Claim token invalid");
}
+ if ( (! token_match) &&
+ (! contract_match) )
+ {
+ if (god->generate_html)
+ {
+ /* Contract was claimed (maybe by another device), so this client
+ cannot get the status information. Redirect to fulfillment page,
+ where the client may be able to pickup a fresh order -- or might
+ be able authenticate via session ID */
+ struct MHD_Response *reply;
+ MHD_RESULT ret;
+
+ reply = MHD_create_response_from_buffer (0,
+ NULL,
+ MHD_RESPMEM_PERSISTENT);
+ if (NULL == reply)
+ {
+ GNUNET_break (0);
+ return MHD_NO;
+ }
+ GNUNET_break (MHD_YES ==
+ MHD_add_response_header (reply,
+ MHD_HTTP_HEADER_LOCATION,
+ god->fulfillment_url));
+ ret = MHD_queue_response (connection,
+ MHD_HTTP_FOUND,
+ reply);
+ MHD_destroy_response (reply);
+ return ret;
+ }
+ else
+ {
+ /* Need to generate JSON reply */
+ return TALER_MHD_reply_json_pack (
+ connection,
+ MHD_HTTP_ACCEPTED,
+ "{s:s}",
+ "fulfillment_url",
+ god->fulfillment_url);
+ }
+ }
if (god->unclaimed)
{
@@ -993,54 +1034,13 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
return send_pay_request (god,
NULL);
}
- else if (GNUNET_NO == GNUNET_is_zero (&god->claim_token))
- {
- /* If the order has been paid but the request was made with a claim token,
- redirect to the fulfillment url. */
- if (god->generate_html)
- {
- /* Contract was claimed (maybe by another device), so this client
- cannot get the status information. Redirect to fulfillment page,
- where the client may be able to pickup a fresh order -- or might
- be able authenticate via session ID */
- struct MHD_Response *reply;
- MHD_RESULT ret;
-
- reply = MHD_create_response_from_buffer (0,
- NULL,
- MHD_RESPMEM_PERSISTENT);
- if (NULL == reply)
- {
- GNUNET_break (0);
- return MHD_NO;
- }
- GNUNET_break (MHD_YES ==
- MHD_add_response_header (reply,
- MHD_HTTP_HEADER_LOCATION,
- god->fulfillment_url));
- ret = MHD_queue_response (connection,
- MHD_HTTP_FOUND,
- reply);
- MHD_destroy_response (reply);
- return ret;
- }
- else
- {
- /* Need to generate JSON reply */
- return TALER_MHD_reply_json_pack (
- connection,
- MHD_HTTP_ACCEPTED,
- "{s:s}",
- "fulfillment_url",
- god->fulfillment_url);
- }
- }
}
/* At this point, we know the contract was paid. Let's check for
refunds. First, clear away refunds found from previous invocations. */
- GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (TMH_currency,
- &god->refund_amount));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (TMH_currency,
+ &god->refund_amount));
qs = TMH_db->lookup_refunds_detailed (TMH_db->cls,
hc->instance->settings.id,
&god->h_contract_terms,
@@ -1131,6 +1131,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
else
{
json_t *context;
+
context = json_pack ("{s:O, s:s, s:s}",
"contract_terms",
god->contract_terms,