aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-08-04 17:15:09 +0200
committerChristian Grothoff <christian@grothoff.org>2021-08-04 17:15:13 +0200
commit977c3d47538d071e2b37599bb71c0fae3ad36d44 (patch)
tree1ebed69157919e9eaa822852f5c80d6ce11edb39
parentf0602d7d9a55a4eb913543e766c94d10c7e6498b (diff)
-work on #6975, still does not pass
-rw-r--r--src/backend/taler-merchant-httpd_get-orders-ID.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c
index ffe7657a..c679211f 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -125,11 +125,11 @@ struct GetOrderData
bool suspended;
/**
- * Set to true if we are dealing with an unclaimed order
- * (and thus @e h_contract_terms is not set, and certain
+ * Set to true if we are dealing with a claimed order
+ * (and thus @e h_contract_terms is set, otherwise certain
* DB queries will not work).
*/
- bool unclaimed;
+ bool claimed;
/**
* Set to true if this payment has been refunded and
@@ -748,11 +748,9 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
"token");
}
}
-
god->session_id = MHD_lookup_connection_value (connection,
MHD_GET_ARGUMENT_KIND,
"session_id");
-
{
const char *long_poll_timeout_ms;
@@ -847,7 +845,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
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);
+ GNUNET_break (0);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
@@ -887,7 +885,11 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
}
}
- if (! contract_match)
+ if (contract_match)
+ {
+ god->claimed = true;
+ }
+ else
{
struct TALER_ClaimTokenP db_claim_token;
struct GNUNET_HashCode unused;
@@ -906,16 +908,14 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
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);
+ GNUNET_break (0);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
"lookup_order");
}
- god->unclaimed = (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) &&
- ! contract_available;
if ( (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) &&
- (NULL == god->contract_terms) )
+ (! contract_available) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Unknown order id given: `%s'\n",
@@ -925,8 +925,11 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN,
order_id);
}
- token_match = (0 == GNUNET_memcmp (&db_claim_token,
- &god->claim_token));
+ god->claimed = ( (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) ||
+ (contract_available) );
+ token_match = ( (0 == GNUNET_memcmp (&db_claim_token,
+ &god->claim_token)) &&
+ (! god->claimed) );
} /* end unclaimed order logic */
GNUNET_assert (NULL != god->contract_terms);
@@ -946,11 +949,12 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
god->contract_terms,
"fulfillment_url"));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Token match: %d, contract match: %d, unclaimed: %d\n",
+ "Token match: %d, contract_available: %d, contract match: %d, claimed: %d\n",
token_match,
+ contract_available,
contract_match,
- god->unclaimed);
- if ( (god->unclaimed) &&
+ god->claimed);
+ if ( (! god->claimed) &&
(! token_match) )
{
/* Token wrong, and required because contract is unclaimed */
@@ -972,8 +976,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
if (NULL == public_reorder_url)
{
/* We cannot give the client a new order, just fail */
- if (GNUNET_NO ==
- GNUNET_is_zero (&god->h_contract_terms))
+ if (! GNUNET_is_zero (&god->h_contract_terms))
{
GNUNET_break_op (0);
return TALER_MHD_reply_with_error (
@@ -982,7 +985,6 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
TALER_EC_MERCHANT_GENERIC_CONTRACT_HASH_DOES_NOT_MATCH_ORDER,
NULL);
}
- GNUNET_break_op (0);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_MERCHANT_GET_ORDERS_ID_INVALID_TOKEN,
@@ -1027,8 +1029,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
GNUNET_JSON_pack_string ("public_reorder_url",
public_reorder_url));
}
-
- if (god->unclaimed)
+ if (! god->claimed)
{
/* Order is unclaimed, no need to check for payments or even
refunds, simply always generate payment request */