commit 2aab5f342e452b41cedc9817eed5f8796fe510d2
parent a1fc2db1340437153cc5d6ba4a7277d171c1daba
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date: Wed, 7 Jun 2017 15:17:17 +0200
refund fee stored along deposit
Diffstat:
5 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/doc/version.texi b/doc/version.texi
@@ -1,4 +1,4 @@
-@set UPDATED 7 June 2017
-@set UPDATED-MONTH June 2017
+@set UPDATED 31 May 2017
+@set UPDATED-MONTH May 2017
@set EDITION 0.3.0
@set VERSION 0.3.0
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
@@ -78,6 +78,11 @@ struct DepositConfirmation
struct TALER_Amount deposit_fee;
/**
+ * Fee charged by the exchange for the refund operation of this coin.
+ */
+ struct TALER_Amount refund_fee;
+
+ /**
* Public key of the coin.
*/
struct TALER_CoinSpendPublicKeyP coin_pub;
@@ -496,6 +501,7 @@ deposit_cb (void *cls,
&dc->coin_pub,
&dc->amount_with_fee,
&dc->deposit_fee,
+ &dc->refund_fee,
sign_key,
proof))
{
@@ -662,6 +668,7 @@ process_pay_with_exchange (void *cls,
return;
}
dc->deposit_fee = denom_details->fee_deposit;
+ dc->refund_fee = denom_details->fee_refund;
if (0 == i)
{
acc_fee = denom_details->fee_deposit;
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
@@ -212,10 +212,13 @@ postgres_initialize (void *cls)
",deposit_fee_val"
",deposit_fee_frac"
",deposit_fee_curr"
+ ",refund_fee_val"
+ ",refund_fee_frac"
+ ",refund_fee_curr"
",signkey_pub"
",exchange_proof) VALUES "
- "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
- 11),
+ "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)",
+ 14),
GNUNET_PQ_make_prepare ("insert_transfer",
"INSERT INTO merchant_transfers"
"(h_contract_terms"
@@ -633,6 +636,7 @@ postgres_store_transaction (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 signkey_pub public key used by the exchange for @a exchange_proof
* @param exchange_proof proof from exchange that coin was accepted
* @return #GNUNET_OK on success, #GNUNET_SYSERR upon error
@@ -644,6 +648,7 @@ postgres_store_deposit (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 struct TALER_ExchangePublicKeyP *signkey_pub,
const json_t *exchange_proof)
{
@@ -656,6 +661,7 @@ postgres_store_deposit (void *cls,
GNUNET_PQ_query_param_auto_from_type (coin_pub),
TALER_PQ_query_param_amount (amount_with_fee),
TALER_PQ_query_param_amount (deposit_fee),
+ TALER_PQ_query_param_amount (refund_fee),
GNUNET_PQ_query_param_auto_from_type (signkey_pub),
TALER_PQ_query_param_json (exchange_proof),
GNUNET_PQ_query_param_end
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
@@ -112,6 +112,11 @@ static struct TALER_Amount amount_with_fee;
static struct TALER_Amount deposit_fee;
/**
+ * Refund fee for the coin.
+ */
+static struct TALER_Amount refund_fee;
+
+/**
* Public key of the coin. Set to some random value.
*/
static struct TALER_CoinSpendPublicKeyP coin_pub;
@@ -348,6 +353,9 @@ run (void *cls)
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":0.000010",
&deposit_fee));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":0.000010",
+ &refund_fee));
RND_BLK (&coin_pub);
deposit_proof = json_object ();
GNUNET_assert (0 ==
@@ -447,6 +455,7 @@ run (void *cls)
&coin_pub,
&amount_with_fee,
&deposit_fee,
+ &refund_fee,
&signkey_pub,
deposit_proof));
FAILIF (GNUNET_OK !=
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
@@ -347,7 +347,7 @@ struct TALER_MERCHANTDB_Plugin
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, // FIXME: modify logic!
+ const struct TALER_Amount *refund_fee,
const struct TALER_ExchangePublicKeyP *signkey_pub,
const json_t *exchange_proof);