From 51add29ac66fef6b05b4392bf89dfe2c6367c29a Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Thu, 8 Jun 2017 14:06:07 +0200 Subject: refund_fee is returned to the callback when fetching a deposit from the db. --- src/backenddb/plugin_merchantdb_postgres.c | 25 ++++++++++++++++++++++++- src/backenddb/test_merchantdb.c | 8 +++++--- 2 files changed, 29 insertions(+), 4 deletions(-) (limited to 'src/backenddb') diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 6fbb7aba..6b749dba 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -323,6 +323,9 @@ postgres_initialize (void *cls) ",deposit_fee_val" ",deposit_fee_frac" ",deposit_fee_curr" + ",refund_fee_val" + ",refund_fee_frac" + ",refund_fee_curr" ",exchange_proof" " FROM merchant_deposits" " WHERE h_contract_terms=$1" @@ -362,6 +365,9 @@ postgres_initialize (void *cls) ",merchant_deposits.deposit_fee_val" ",merchant_deposits.deposit_fee_frac" ",merchant_deposits.deposit_fee_curr" + ",merchant_deposits.refund_fee_val" + ",merchant_deposits.refund_fee_frac" + ",merchant_deposits.refund_fee_curr" ",merchant_deposits.exchange_proof" " FROM merchant_transfers" " JOIN merchant_deposits" @@ -1194,6 +1200,7 @@ postgres_find_payments (void *cls, struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_Amount amount_with_fee; struct TALER_Amount deposit_fee; + struct TALER_Amount refund_fee; json_t *exchange_proof; struct GNUNET_PQ_ResultSpec rs[] = { @@ -1203,6 +1210,8 @@ postgres_find_payments (void *cls, &amount_with_fee), TALER_PQ_result_spec_amount ("deposit_fee", &deposit_fee), + TALER_PQ_result_spec_amount ("refund_fee", + &refund_fee), TALER_PQ_result_spec_json ("exchange_proof", &exchange_proof), GNUNET_PQ_result_spec_end @@ -1222,6 +1231,7 @@ postgres_find_payments (void *cls, &coin_pub, &amount_with_fee, &deposit_fee, + &refund_fee, exchange_proof); GNUNET_PQ_cleanup_result (rs); } @@ -1283,6 +1293,7 @@ postgres_find_payments_by_hash_and_coin (void *cls, { struct TALER_Amount amount_with_fee; struct TALER_Amount deposit_fee; + struct TALER_Amount refund_fee; json_t *exchange_proof; struct GNUNET_PQ_ResultSpec rs[] = { @@ -1290,6 +1301,8 @@ postgres_find_payments_by_hash_and_coin (void *cls, &amount_with_fee), TALER_PQ_result_spec_amount ("deposit_fee", &deposit_fee), + TALER_PQ_result_spec_amount ("refund_fee", + &refund_fee), TALER_PQ_result_spec_json ("exchange_proof", &exchange_proof), GNUNET_PQ_result_spec_end @@ -1309,6 +1322,7 @@ postgres_find_payments_by_hash_and_coin (void *cls, coin_pub, &amount_with_fee, &deposit_fee, + &refund_fee, exchange_proof); GNUNET_PQ_cleanup_result (rs); } @@ -1449,6 +1463,7 @@ postgres_find_deposits_by_wtid (void *cls, struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_Amount amount_with_fee; struct TALER_Amount deposit_fee; + struct TALER_Amount refund_fee; json_t *exchange_proof; struct GNUNET_PQ_ResultSpec rs[] = { @@ -1460,6 +1475,8 @@ postgres_find_deposits_by_wtid (void *cls, &amount_with_fee), TALER_PQ_result_spec_amount ("deposit_fee", &deposit_fee), + TALER_PQ_result_spec_amount ("refund_fee", + &refund_fee), TALER_PQ_result_spec_json ("exchange_proof", &exchange_proof), GNUNET_PQ_result_spec_end @@ -1479,6 +1496,7 @@ postgres_find_deposits_by_wtid (void *cls, &coin_pub, &amount_with_fee, &deposit_fee, + &refund_fee, exchange_proof); GNUNET_PQ_cleanup_result (rs); } @@ -1590,7 +1608,12 @@ postgres_increase_refund_for_contract (void *cls, const struct TALER_Amount *refund, const char *reason) { - /*FIXME, put logic*/ + /*FIXME, logic incomplete*/ + + /* 1 Get coins for a given contract + 2 "Spread" the refund amount among those coins + 3 Store the solution into table merchant_refund */ + return GNUNET_SYSERR; } diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index cca5f19f..c0857375 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -249,8 +249,9 @@ pd_cb (void *cls, * @param cls closure * @param transaction_id of the contract * @param coin_pub public key of the coin - * @param amount_with_fee amount the exchange will deposit for this coin - * @param deposit_fee fee the exchange will charge for this coin + * @param aamount_with_fee amount the exchange will deposit for this coin + * @param adeposit_fee fee the exchange will charge for this coin + * @param adeposit_fee fee the exchange will charge for refunding this coin * @param exchange_proof proof from exchange that coin was accepted */ static void @@ -259,6 +260,7 @@ deposit_cb (void *cls, const struct TALER_CoinSpendPublicKeyP *acoin_pub, const struct TALER_Amount *aamount_with_fee, const struct TALER_Amount *adeposit_fee, + const struct TALER_Amount *arefund_fee, const json_t *aexchange_proof) { CHECK ((0 == memcmp (ah_contract_terms, @@ -534,7 +536,7 @@ run (void *cls) &h_contract_terms, &refund_cb, NULL)); - FAILIF (GNUNET_OK != + FAILIF (GNUNET_SYSERR != plugin->increase_refund_for_contract (plugin->cls, &h_contract_terms, &refund_amount, -- cgit v1.2.3