summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2017-06-08 14:06:07 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2017-06-08 14:06:07 +0200
commit51add29ac66fef6b05b4392bf89dfe2c6367c29a (patch)
treec6f3997cd8c2d4f364d007bda4707d755cc2595d
parentea11919916555637c0ef329e439c0322e6e51c00 (diff)
downloadmerchant-51add29ac66fef6b05b4392bf89dfe2c6367c29a.tar.gz
merchant-51add29ac66fef6b05b4392bf89dfe2c6367c29a.tar.bz2
merchant-51add29ac66fef6b05b4392bf89dfe2c6367c29a.zip
refund_fee is returned to the callback when fetching
a deposit from the db.
-rw-r--r--src/backend/taler-merchant-httpd_pay.c2
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c25
-rw-r--r--src/backenddb/test_merchantdb.c8
-rw-r--r--src/include/taler_merchantdb_plugin.h2
4 files changed, 33 insertions, 4 deletions
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
index 3ef8f9f4..902a7dc8 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -916,6 +916,7 @@ handle_pay_timeout (void *cls)
* @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 refund_fee fee the exchange will charge for refunding this coin
* @param exchange_proof proof from exchange that coin was accepted
*/
static void
@@ -924,6 +925,7 @@ check_coin_paid (void *cls,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *deposit_fee,
+ const struct TALER_Amount *refund_fee,
const json_t *exchange_proof)
{
struct PayContext *pc = cls;
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,
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index a006ae0a..41152266 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -76,6 +76,7 @@ typedef void
* @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 refund_fee fee the exchange will charge for refunding this coin
* @param exchange_proof proof from exchange that coin was accepted,
* matches the `interface DepositSuccess` of the documentation.
*/
@@ -85,6 +86,7 @@ typedef void
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *deposit_fee,
+ const struct TALER_Amount *refund_fee,
const json_t *exchange_proof);