summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-04-17 14:01:55 +0200
committerChristian Grothoff <christian@grothoff.org>2017-04-17 14:01:55 +0200
commit164c125528e4af078815c0156df54fa0120eed8a (patch)
tree9d0a82d7a678059850f260b1f5fda79db3f57c32 /src
parent5a321621f40d09b4f38bdd6dd43ee6580915fba2 (diff)
downloadexchange-164c125528e4af078815c0156df54fa0120eed8a.tar.gz
exchange-164c125528e4af078815c0156df54fa0120eed8a.tar.bz2
exchange-164c125528e4af078815c0156df54fa0120eed8a.zip
introducing closing fee
Diffstat (limited to 'src')
-rw-r--r--src/exchange-lib/exchange_api_wire.c4
-rw-r--r--src/exchange-lib/test_exchange_api.conf21
-rw-r--r--src/exchange-tools/taler-exchange-keyup.c36
-rw-r--r--src/exchange/taler-exchange-httpd_wire.c3
-rw-r--r--src/exchange/test-taler-exchange-aggregator-postgres.conf11
-rw-r--r--src/exchangedb/exchangedb_fees.c4
-rw-r--r--src/include/taler_exchange_service.h8
-rw-r--r--src/include/taler_exchangedb_lib.h7
-rw-r--r--src/include/taler_signatures.h5
9 files changed, 96 insertions, 3 deletions
diff --git a/src/exchange-lib/exchange_api_wire.c b/src/exchange-lib/exchange_api_wire.c
index bdf4dc87..f1056fdd 100644
--- a/src/exchange-lib/exchange_api_wire.c
+++ b/src/exchange-lib/exchange_api_wire.c
@@ -332,6 +332,8 @@ parse_json_fees (struct TALER_EXCHANGE_WireAggregateFees *af,
&af->master_sig),
TALER_JSON_spec_amount ("wire_fee",
&af->wire_fee),
+ TALER_JSON_spec_amount ("closing_fee",
+ &af->closing_fee),
GNUNET_JSON_spec_absolute_time ("start_date",
&af->start_date),
GNUNET_JSON_spec_absolute_time ("end_date",
@@ -376,6 +378,8 @@ check_sig (const struct TALER_EXCHANGE_WireAggregateFees *af,
wp.end_date = GNUNET_TIME_absolute_hton (af->end_date);
TALER_amount_hton (&wp.wire_fee,
&af->wire_fee);
+ TALER_amount_hton (&wp.closing_fee,
+ &af->closing_fee);
return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_WIRE_FEES,
&wp.purpose,
&af->master_sig.eddsa_signature,
diff --git a/src/exchange-lib/test_exchange_api.conf b/src/exchange-lib/test_exchange_api.conf
index 42861eae..19119b7d 100644
--- a/src/exchange-lib/test_exchange_api.conf
+++ b/src/exchange-lib/test_exchange_api.conf
@@ -43,6 +43,17 @@ WIRE-FEE-2024 = EUR:0.01
WIRE-FEE-2025 = EUR:0.01
WIRE-FEE-2026 = EUR:0.01
+CLOSING-FEE-2017 = EUR:0.01
+CLOSING-FEE-2018 = EUR:0.01
+CLOSING-FEE-2019 = EUR:0.01
+CLOSING-FEE-2020 = EUR:0.01
+CLOSING-FEE-2021 = EUR:0.01
+CLOSING-FEE-2022 = EUR:0.01
+CLOSING-FEE-2023 = EUR:0.01
+CLOSING-FEE-2024 = EUR:0.01
+CLOSING-FEE-2025 = EUR:0.01
+CLOSING-FEE-2026 = EUR:0.01
+
[exchange-wire-incoming-sepa]
# This is the response we give out for the /wire request. It provides
# wallets with the bank information for transfers to the exchange.
@@ -65,6 +76,16 @@ WIRE-FEE-2024 = EUR:0.01
WIRE-FEE-2025 = EUR:0.01
WIRE-FEE-2026 = EUR:0.01
+CLOSING-FEE-2017 = EUR:0.01
+CLOSING-FEE-2018 = EUR:0.01
+CLOSING-FEE-2019 = EUR:0.01
+CLOSING-FEE-2020 = EUR:0.01
+CLOSING-FEE-2021 = EUR:0.01
+CLOSING-FEE-2022 = EUR:0.01
+CLOSING-FEE-2023 = EUR:0.01
+CLOSING-FEE-2024 = EUR:0.01
+CLOSING-FEE-2025 = EUR:0.01
+CLOSING-FEE-2026 = EUR:0.01
[exchange-wire-incoming-test]
# This is the response we give out for the /wire request. It provides
diff --git a/src/exchange-tools/taler-exchange-keyup.c b/src/exchange-tools/taler-exchange-keyup.c
index f5e5961f..ce6f2ba2 100644
--- a/src/exchange-tools/taler-exchange-keyup.c
+++ b/src/exchange-tools/taler-exchange-keyup.c
@@ -949,6 +949,8 @@ create_wire_fee_for_method (void *cls,
af = GNUNET_new (struct TALER_EXCHANGEDB_AggregateFees);
af->start_date = start_date;
af->end_date = end_date;
+
+ /* handle wire fee */
GNUNET_asprintf (&opt,
"wire-fee-%u",
year);
@@ -980,6 +982,40 @@ create_wire_fee_for_method (void *cls,
break;
}
GNUNET_free (amounts);
+
+ /* handle closing fee */
+ GNUNET_asprintf (&opt,
+ "closing-fee-%u",
+ year);
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (kcfg,
+ section,
+ opt,
+ &amounts))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ opt);
+ *ret = GNUNET_SYSERR;
+ GNUNET_free (opt);
+ break;
+ }
+ if (GNUNET_OK !=
+ TALER_string_to_amount (amounts,
+ &af->closing_fee))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid amount `%s' specified in `%s' under `%s'\n",
+ amounts,
+ wiremethod,
+ opt);
+ *ret = GNUNET_SYSERR;
+ GNUNET_free (amounts);
+ GNUNET_free (opt);
+ break;
+ }
+ GNUNET_free (amounts);
+
GNUNET_free (opt);
sign_af (af,
wiremethod,
diff --git a/src/exchange/taler-exchange-httpd_wire.c b/src/exchange/taler-exchange-httpd_wire.c
index 2109395c..22581ab6 100644
--- a/src/exchange/taler-exchange-httpd_wire.c
+++ b/src/exchange/taler-exchange-httpd_wire.c
@@ -56,8 +56,9 @@ fees_to_json (struct TALER_EXCHANGEDB_AggregateFees *af)
}
if (0 !=
json_array_append_new (a,
- json_pack ("{s:o, s:o, s:o, s:o}",
+ json_pack ("{s:o, s:o, s:o, s:o, s:o}",
"wire_fee", TALER_JSON_from_amount (&af->wire_fee),
+ "closing_fee", TALER_JSON_from_amount (&af->closing_fee),
"start_date", GNUNET_JSON_from_time_abs (af->start_date),
"end_date", GNUNET_JSON_from_time_abs (af->end_date),
"sig", GNUNET_JSON_from_data_auto (&af->master_sig))))
diff --git a/src/exchange/test-taler-exchange-aggregator-postgres.conf b/src/exchange/test-taler-exchange-aggregator-postgres.conf
index e70a933b..a5ee91aa 100644
--- a/src/exchange/test-taler-exchange-aggregator-postgres.conf
+++ b/src/exchange/test-taler-exchange-aggregator-postgres.conf
@@ -42,6 +42,17 @@ WIRE-FEE-2024 = EUR:0.01
WIRE-FEE-2025 = EUR:0.01
WIRE-FEE-2026 = EUR:0.01
+CLOSING-FEE-2017 = EUR:0.01
+CLOSING-FEE-2018 = EUR:0.01
+CLOSING-FEE-2019 = EUR:0.01
+CLOSING-FEE-2020 = EUR:0.01
+CLOSING-FEE-2021 = EUR:0.01
+CLOSING-FEE-2022 = EUR:0.01
+CLOSING-FEE-2023 = EUR:0.01
+CLOSING-FEE-2024 = EUR:0.01
+CLOSING-FEE-2025 = EUR:0.01
+CLOSING-FEE-2026 = EUR:0.01
+
[exchange-wire-outgoing-test]
# What is the main website of the bank?
diff --git a/src/exchangedb/exchangedb_fees.c b/src/exchangedb/exchangedb_fees.c
index 228015c0..d6fdac4d 100644
--- a/src/exchangedb/exchangedb_fees.c
+++ b/src/exchangedb/exchangedb_fees.c
@@ -62,6 +62,8 @@ wd2af (const struct TALER_WireFeeDiskP *wd)
af->end_date = GNUNET_TIME_absolute_ntoh (wd->wf.end_date);
TALER_amount_ntoh (&af->wire_fee,
&wd->wf.wire_fee);
+ TALER_amount_ntoh (&af->closing_fee,
+ &wd->wf.closing_fee);
af->master_sig = wd->master_sig;
return af;
}
@@ -162,6 +164,8 @@ TALER_EXCHANGEDB_fees_2_wf (const char *wireplugin,
wf->end_date = GNUNET_TIME_absolute_hton (af->end_date);
TALER_amount_hton (&wf->wire_fee,
&af->wire_fee);
+ TALER_amount_hton (&wf->closing_fee,
+ &af->closing_fee);
}
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index c097dff1..9e8caab8 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -351,11 +351,17 @@ struct TALER_EXCHANGE_WireAggregateFees
struct TALER_EXCHANGE_WireAggregateFees *next;
/**
- * Fee to be paid.
+ * Fee to be paid whenever the exchange wires funds to the merchant.
*/
struct TALER_Amount wire_fee;
/**
+ * Fee to be paid when the exchange closes a reserve and wires funds
+ * back to a customer.
+ */
+ struct TALER_Amount closing_fee;
+
+ /**
* Time when this fee goes into effect (inclusive)
*/
struct GNUNET_TIME_Absolute start_date;
diff --git a/src/include/taler_exchangedb_lib.h b/src/include/taler_exchangedb_lib.h
index 70ae3634..561738c2 100644
--- a/src/include/taler_exchangedb_lib.h
+++ b/src/include/taler_exchangedb_lib.h
@@ -332,11 +332,16 @@ struct TALER_EXCHANGEDB_AggregateFees
struct TALER_EXCHANGEDB_AggregateFees *next;
/**
- * Fee to be paid.
+ * Fee to be paid for wire transfers to a merchant.
*/
struct TALER_Amount wire_fee;
/**
+ * Fee to be paid when we close a reserve and send funds back.
+ */
+ struct TALER_Amount closing_fee;
+
+ /**
* Time when this fee goes into effect (inclusive)
*/
struct GNUNET_TIME_Absolute start_date;
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h
index d4c5d864..70560b4b 100644
--- a/src/include/taler_signatures.h
+++ b/src/include/taler_signatures.h
@@ -938,6 +938,11 @@ struct TALER_MasterWireFeePS
*/
struct TALER_AmountNBO wire_fee;
+ /**
+ * Closing fee charged when we wire back funds of a reserve.
+ */
+ struct TALER_AmountNBO closing_fee;
+
};