aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpriscilla <priscilla.huang@efrei.net>2023-02-21 07:20:09 -0500
committerpriscilla <priscilla.huang@efrei.net>2023-02-21 07:20:09 -0500
commit90c821d0575383a650c96c37c48b6f346b66ef4f (patch)
treef6c5691cbd8ca1c8ca85c1e48873cb894b0e4900
parentc1976d63028260964cf0eda49ab7b6892e23c647 (diff)
added alter table for merchant order and merchant contract terms
-rw-r--r--src/backenddb/merchant-0004.sql21
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c62
-rw-r--r--src/backenddb/test_merchantdb.c24
-rw-r--r--src/include/taler_merchantdb_plugin.h24
4 files changed, 114 insertions, 17 deletions
diff --git a/src/backenddb/merchant-0004.sql b/src/backenddb/merchant-0004.sql
index 0696886d..fec64fd2 100644
--- a/src/backenddb/merchant-0004.sql
+++ b/src/backenddb/merchant-0004.sql
@@ -111,6 +111,7 @@ COMMENT ON COLUMN merchant_kyc.aml_decision
ALTER TABLE merchant_orders
+<<<<<<< HEAD
ADD COLUMN pos_key VARCHAR;
COMMENT ON COLUMN merchant_orders.pos_key
IS 'point-of-sale key which is used for the verification of payment';
@@ -120,6 +121,26 @@ ALTER TABLE merchant_contract_terms
ADD COLUMN pos_key VARCHAR;
COMMENT ON COLUMN merchant_contract_terms.pos_key
IS 'point-of-sale key which is used for the verification of payment';
+=======
+ ADD COLUMN pos_key VARCHAR DEFAULT NULL;
+ ADD COLUMN pricing_algorithm INT8;
+
+COMMENT ON COLUMN merchant_orders.pos_key
+ IS 'encoded based key which is used for the verification of payment';
+COMMENT ON COLUMN merchant_orders.pricing_algorithm
+ IS 'algorithm to put the price of the order. It is link with the pos_key';
+
+
+
+ALTER TABLE merchant_contract_terms
+ ADD COLUMN pos_key VARCHAR DEFAULT NULL;
+ ADD COLUMN pricing_algorithm INT8;
+
+COMMENT ON COLUMN merchant_contract_terms.pos_key
+ IS 'enconded based key which is used for the verification of payment';
+COMMENT ON COLUMN merchant_orders.pricing_algorithm
+ IS 'algorithm to put the price of the order. It is link with the pos_key';
+>>>>>>> 43030855 (added alter table for merchant order and merchant contract terms)
COMMIT;
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 836eb07a..48e0d63c 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1694,6 +1694,8 @@ postgres_delete_order (void *cls,
* @param[out] h_post_data set to the hash of the POST data that created the order
* @param[out] contract_terms where to store the retrieved contract terms,
* NULL to only test if the order exists
+ * @param pos_key encoded key for payment verification
+ * @param pricing_algorithm to show the price in the payment verification
* @return transaction status
*/
static enum GNUNET_DB_QueryStatus
@@ -1702,7 +1704,9 @@ postgres_lookup_order (void *cls,
const char *order_id,
struct TALER_ClaimTokenP *claim_token,
struct TALER_MerchantPostDataHashP *h_post_data,
- json_t **contract_terms)
+ json_t **contract_terms,
+ char *pos_key,
+ uint64_t pricing_algorithm)
{
struct PostgresClosure *pg = cls;
json_t *j;
@@ -1720,6 +1724,14 @@ postgres_lookup_order (void *cls,
&ct),
GNUNET_PQ_result_spec_auto_from_type ("h_post_data",
h_post_data),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_string ("pos_key",
+ &pos_key),
+ NULL),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_uint64 ("pricing_algorithm",
+ &pricing_algorithm),
+ NULL),
GNUNET_PQ_result_spec_end
};
@@ -1937,6 +1949,8 @@ postgres_lookup_orders (void *cls,
* @param pay_deadline how long does the customer have to pay for the order
* @param claim_token token to use for access control
* @param contract_terms proposal data to store
+ * @param pos_key encoded key for payment verification
+ * @param pricing_algorithm to show the price in the payment verification
* @return transaction status
*/
static enum GNUNET_DB_QueryStatus
@@ -1946,7 +1960,9 @@ postgres_insert_order (void *cls,
const struct TALER_MerchantPostDataHashP *h_post_data,
struct GNUNET_TIME_Timestamp pay_deadline,
const struct TALER_ClaimTokenP *claim_token,
- const json_t *contract_terms)
+ const json_t *contract_terms,
+ const char *pos_key,
+ uint64_t pricing_algorithm)
{
struct PostgresClosure *pg = cls;
struct GNUNET_TIME_Timestamp now;
@@ -1958,6 +1974,12 @@ postgres_insert_order (void *cls,
GNUNET_PQ_query_param_auto_from_type (h_post_data),
GNUNET_PQ_query_param_timestamp (&now),
TALER_PQ_query_param_json (contract_terms),
+ (NULL == pos_key)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (pos_key),
+ (NULL == pos_key)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_uint64 (&pricing_algorithm),
GNUNET_PQ_query_param_end
};
@@ -2045,6 +2067,7 @@ postgres_insert_order_lock (void *cls,
* @param[out] order_serial set to the order's serial number
* @param[out] paid set to true if the order is fully paid
* @param[out] claim_token set to the claim token, NULL to only check for existence
+ * @param[out] pos_key encoded key for payment verification
* @return transaction status
*/
static enum GNUNET_DB_QueryStatus
@@ -2054,7 +2077,9 @@ postgres_lookup_contract_terms (void *cls,
json_t **contract_terms,
uint64_t *order_serial,
bool *paid,
- struct TALER_ClaimTokenP *claim_token)
+ struct TALER_ClaimTokenP *claim_token,
+ char *pos_key,
+ uint64_t pricing_algorithm)
{
struct PostgresClosure *pg = cls;
enum GNUNET_DB_QueryStatus qs;
@@ -2074,6 +2099,14 @@ postgres_lookup_contract_terms (void *cls,
paid),
GNUNET_PQ_result_spec_auto_from_type ("claim_token",
&ct),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_string ("pos_key",
+ &pos_key),
+ NULL),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_uint64 ("pricing_algorithm",
+ &pricing_algorithm),
+ NULL),
GNUNET_PQ_result_spec_end
};
@@ -2103,6 +2136,8 @@ postgres_lookup_contract_terms (void *cls,
* @param order_id order_id used to store
* @param contract_terms contract terms to store
* @param[out] order_serial set to the serial of the order
+ * @param pos_key encoded key for payment verification
+ * @param pricing_algorithm to show the price in the payment verification
* @return transaction status, #GNUNET_DB_STATUS_HARD_ERROR if @a contract_terms
* is malformed
*/
@@ -2111,7 +2146,9 @@ postgres_insert_contract_terms (void *cls,
const char *instance_id,
const char *order_id,
json_t *contract_terms,
- uint64_t *order_serial)
+ uint64_t *order_serial,
+ const char *pos_key,
+ uint64_t pricing_algorithm)
{
struct PostgresClosure *pg = cls;
struct GNUNET_TIME_Timestamp pay_deadline;
@@ -2162,6 +2199,12 @@ postgres_insert_contract_terms (void *cls,
(NULL == fulfillment_url)
? GNUNET_PQ_query_param_null ()
: GNUNET_PQ_query_param_string (fulfillment_url),
+ (NULL == pos_key)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (pos_key),
+ (NULL == pos_key)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_uint64 (&pricing_algorithm),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -8186,6 +8229,7 @@ postgres_connect (void *cls)
" contract_terms"
",claim_token"
",h_post_data"
+ ",pos_key"
" FROM merchant_orders"
" WHERE merchant_orders.merchant_serial="
" (SELECT merchant_serial "
@@ -8983,9 +9027,10 @@ postgres_connect (void *cls)
",claim_token"
",h_post_data"
",creation_time"
- ",contract_terms)"
+ ",contract_terms"
+ ",pos_key)"
" SELECT merchant_serial,"
- " $2, $3, $4, $5, $6, $7"
+ " $2, $3, $4, $5, $6, $7, $8"
" FROM merchant_instances"
" WHERE merchant_id=$1"),
/* for postgres_unlock_inventory() */
@@ -9030,6 +9075,7 @@ postgres_connect (void *cls)
",order_serial"
",claim_token"
",paid"
+ ",pos_key"
" FROM merchant_contract_terms"
" WHERE order_id=$2"
" AND merchant_serial="
@@ -9048,7 +9094,8 @@ postgres_connect (void *cls)
",pay_deadline"
",refund_deadline"
",fulfillment_url"
- ",claim_token)"
+ ",claim_token"
+ ",pos_key)"
"SELECT"
" mo.order_serial"
",mo.merchant_serial"
@@ -9059,6 +9106,7 @@ postgres_connect (void *cls)
",$5" /* pay_deadline */
",$6" /* refund_deadline */
",$7" /* fulfillment_url */
+ ",$8" /* pos_key */
",mo.claim_token "
"FROM merchant_orders mo"
" WHERE order_id=$2"
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 5a84e8b2..82710fe4 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -1363,7 +1363,9 @@ test_insert_order (const struct InstanceData *instance,
&h_post,
order->pay_deadline,
&order->claim_token,
- order->contract),
+ order->contract,
+ NULL,
+ 0),
"Insert order failed\n");
return 0;
}
@@ -1394,7 +1396,9 @@ test_lookup_order (const struct InstanceData *instance,
order->id,
&ct,
&oh,
- &lookup_terms))
+ &lookup_terms,
+ NULL,
+ 0))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Lookup order failed\n");
@@ -1652,7 +1656,9 @@ test_insert_contract_terms (const struct InstanceData *instance,
instance->instance.id,
order->id,
order->contract,
- &os),
+ &os,
+ NULL,
+ 0),
"Insert contract terms failed\n");
return 0;
}
@@ -1703,7 +1709,9 @@ test_lookup_contract_terms (const struct InstanceData *instance,
&contract,
&order_serial,
&paid,
- NULL))
+ NULL,
+ NULL,
+ 0))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Lookup contract terms failed\n");
@@ -2034,7 +2042,9 @@ run_test_orders (struct TestOrders_Closure *cls)
cls->orders[1].id,
NULL,
&unused,
- NULL))
+ NULL,
+ NULL,
+ 0))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Lookup order failed\n");
@@ -2089,7 +2099,9 @@ run_test_orders (struct TestOrders_Closure *cls)
&lookup_contract,
&lookup_order_serial,
&paid,
- NULL))
+ NULL,
+ NULL,
+ 0))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Lookup contract terms failed\n");
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index dc44ba86..496bc77c 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -1416,6 +1416,8 @@ struct TALER_MERCHANTDB_Plugin
* @param[out] h_post_data set to the hash of the POST data that created the order
* @param[out] contract_terms where to store the retrieved contract terms,
* NULL to only test if the order exists
+ * @param pos_key [out] encoded key for payment verification
+ * @param pricing_algorithm [out] to show the price in the payment verification
* @return transaction status
*/
enum GNUNET_DB_QueryStatus
@@ -1424,7 +1426,9 @@ struct TALER_MERCHANTDB_Plugin
const char *order_id,
struct TALER_ClaimTokenP *claim_token,
struct TALER_MerchantPostDataHashP *h_post_data,
- json_t **contract_terms);
+ json_t **contract_terms,
+ char *pos_key,
+ uint64_t pricing_algorithm);
/**
@@ -1473,6 +1477,8 @@ struct TALER_MERCHANTDB_Plugin
* @param pay_deadline how long does the customer have to pay for the order
* @param claim_token token to use for access control
* @param contract_terms proposal data to store
+ * @param pos_key encoded key for payment verification
+ * @param pricing_algorithm to show the price in the payment verification
* @return transaction status
*/
enum GNUNET_DB_QueryStatus
@@ -1482,7 +1488,9 @@ struct TALER_MERCHANTDB_Plugin
const struct TALER_MerchantPostDataHashP *h_post_data,
struct GNUNET_TIME_Timestamp pay_deadline,
const struct TALER_ClaimTokenP *claim_token,
- const json_t *contract_terms);
+ const json_t *contract_terms,
+ const char *pos_key,
+ uint64_t pricing_algorithm);
/**
@@ -1530,6 +1538,8 @@ struct TALER_MERCHANTDB_Plugin
* @param[out] order_serial set to the order's serial number
* @param[out] paid set to true if the order is fully paid
* @param[out] claim_token set to the claim token, NULL to only check for existence
+ * @param[out] pos_key encoded key for payment verification
+ * @param pricing_algorithm [out] to show the price in the payment verification
* @return transaction status
*/
enum GNUNET_DB_QueryStatus
@@ -1539,7 +1549,9 @@ struct TALER_MERCHANTDB_Plugin
json_t **contract_terms,
uint64_t *order_serial,
bool *paid,
- struct TALER_ClaimTokenP *claim_token);
+ struct TALER_ClaimTokenP *claim_token,
+ char *pos_key,
+ uint64_t pricing_algorithm);
/**
@@ -1555,6 +1567,8 @@ struct TALER_MERCHANTDB_Plugin
* @param order_id order_id used to store
* @param claim_token the token belonging to the order
* @param[out] order_serial set to the serial of the order
+ * @param pos_key encoded key for payment verification
+ * @param pricing_algorithm to show the price in the payment verification
* @return transaction status, #GNUNET_DB_STATUS_HARD_ERROR if @a contract_terms
* is malformed
*/
@@ -1563,7 +1577,9 @@ struct TALER_MERCHANTDB_Plugin
const char *instance_id,
const char *order_id,
json_t *contract_terms,
- uint64_t *order_serial);
+ uint64_t *order_serial,
+ const char *pos_key,
+ uint64_t pricing_algorithm);
/**