diff options
Diffstat (limited to 'src/backenddb/plugin_merchantdb_postgres.c')
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 1174fb79..d0c36367 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -1100,7 +1100,9 @@ postgres_delete_order (void *cls, * * @param cls closure * @param instance_id instance to obtain order of - * @param order id order id used to perform the lookup + * @param order_id order id used to perform the lookup + * @param[out] claim_token the claim token generated for the order, + * NULL to only test if the order exists * @param[out] contract_terms where to store the retrieved contract terms, * NULL to only test if the order exists * @return transaction status @@ -1109,10 +1111,12 @@ static enum GNUNET_DB_QueryStatus postgres_lookup_order (void *cls, const char *instance_id, const char *order_id, + struct TALER_ClaimTokenP *claim_token, json_t **contract_terms) { struct PostgresClosure *pg = cls; json_t *j; + struct TALER_ClaimTokenP ct; enum GNUNET_DB_QueryStatus qs; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (instance_id), @@ -1122,6 +1126,8 @@ postgres_lookup_order (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { TALER_PQ_result_spec_json ("contract_terms", &j), + GNUNET_PQ_result_spec_auto_from_type ("claim_token", + &ct), GNUNET_PQ_result_spec_end }; @@ -1140,6 +1146,8 @@ postgres_lookup_order (void *cls, *contract_terms = j; else json_decref (j); + if (NULL != claim_token) + *claim_token = ct; } else { @@ -1478,14 +1486,12 @@ postgres_lookup_contract_terms (void *cls, * contract terms (to be hashed), the creation_time and pay_deadline (to be * obtained from the merchant_orders table). The "session_id" should be * initially set to the empty string. The "fulfillment_url" and "refund_deadline" - * must be extracted from @a contract_terms. This function will only - * succeed if @a claim_token matches the token created for the order. + * must be extracted from @a contract_terms. * * @param cls closure * @param instance_id instance's identifier * @param order_id order_id used to store - * @param claim_token the token belonging to the order (NULL for none) - * @param contract_terms contract to store + * @param claim_token the token belonging to the order * @return transaction status, #GNUNET_DB_STATUS_HARD_ERROR if @a contract_terms * is malformed */ @@ -1493,7 +1499,6 @@ static enum GNUNET_DB_QueryStatus postgres_insert_contract_terms (void *cls, const char *instance_id, const char *order_id, - const struct TALER_ClaimTokenP *claim_token, json_t *contract_terms) { struct PostgresClosure *pg = cls; @@ -1542,7 +1547,6 @@ postgres_insert_contract_terms (void *cls, GNUNET_PQ_query_param_absolute_time (&pay_deadline), GNUNET_PQ_query_param_absolute_time (&refund_deadline), GNUNET_PQ_query_param_string (fulfillment_url), - GNUNET_PQ_query_param_auto_from_type (claim_token), GNUNET_PQ_query_param_end }; @@ -6238,6 +6242,7 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) GNUNET_PQ_make_prepare ("lookup_order", "SELECT" " contract_terms" + ",claim_token" " FROM merchant_orders" " WHERE merchant_orders.merchant_serial=" " (SELECT merchant_serial " @@ -7134,9 +7139,8 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) " AND merchant_serial=" " (SELECT merchant_serial" " FROM merchant_instances" - " WHERE merchant_id=$1)" - " AND claim_token=$8", - 8), + " WHERE merchant_id=$1)", + 7), /* for postgres_update_contract_terms() */ GNUNET_PQ_make_prepare ("update_contract_terms", "UPDATE merchant_contract_terms SET" |