[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant] branch master updated: add wire fee persis
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant] branch master updated: add wire fee persisting per coin for /pay |
Date: |
Wed, 27 Dec 2017 11:07:47 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new ae5490c add wire fee persisting per coin for /pay
ae5490c is described below
commit ae5490c0c96c7173889b314e4e99bd26a08c1c14
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Dec 27 11:07:44 2017 +0100
add wire fee persisting per coin for /pay
---
src/backend/taler-merchant-httpd_pay.c | 7 +++---
src/backenddb/plugin_merchantdb_postgres.c | 34 ++++++++++++++++++++++++++++--
src/backenddb/test_merchantdb.c | 12 +++++++++++
src/include/taler_merchantdb_plugin.h | 4 ++++
4 files changed, 52 insertions(+), 5 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_pay.c
b/src/backend/taler-merchant-httpd_pay.c
index 142a99e..829c006 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -21,7 +21,6 @@
* @author Florian Dold
*
* TODO:
- * - persist wire fee per coin (as exchange is per coin now)
* - fix wire fee check
* - add API to allow wallet to request refunds
* - write testcase for new logic
@@ -897,6 +896,7 @@ deposit_cb (void *cls,
&dc->amount_with_fee,
&dc->deposit_fee,
&dc->refund_fee,
+ &dc->wire_fee,
sign_key,
proof);
if (0 > qs)
@@ -1144,6 +1144,7 @@ handle_pay_timeout (void *cls)
* @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 wire_fee wire fee the exchange of this coin charges
* @param exchange_proof proof from exchange that coin was accepted
*/
static void
@@ -1154,7 +1155,7 @@ check_coin_paid (void *cls,
const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *deposit_fee,
const struct TALER_Amount *refund_fee,
- // FIXME: also store AND fetch wire fee!
+ const struct TALER_Amount *wire_fee,
const json_t *exchange_proof)
{
struct PayContext *pc = cls;
@@ -1205,7 +1206,7 @@ check_coin_paid (void *cls,
}
dc->deposit_fee = *deposit_fee;
dc->refund_fee = *refund_fee;
- // dc->wire_fee = *wire_fee; // TBD...
+ dc->wire_fee = *wire_fee;
dc->amount_with_fee = *amount_with_fee;
dc->found_in_db = GNUNET_YES;
pc->pending--;
diff --git a/src/backenddb/plugin_merchantdb_postgres.c
b/src/backenddb/plugin_merchantdb_postgres.c
index e6e992e..54d532f 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -135,6 +135,9 @@ postgres_initialize (void *cls)
",refund_fee_val INT8 NOT NULL"
",refund_fee_frac INT4 NOT NULL"
",refund_fee_curr VARCHAR(" TALER_CURRENCY_LEN_STR
") NOT NULL"
+ ",wire_fee_val INT8 NOT NULL"
+ ",wire_fee_frac INT4 NOT NULL"
+ ",wire_fee_curr VARCHAR(" TALER_CURRENCY_LEN_STR
") NOT NULL"
",signkey_pub BYTEA NOT NULL CHECK
(LENGTH(signkey_pub)=32)"
",exchange_proof BYTEA NOT NULL"
",PRIMARY KEY (h_contract_terms, coin_pub)"
@@ -262,10 +265,13 @@ postgres_initialize (void *cls)
",refund_fee_val"
",refund_fee_frac"
",refund_fee_curr"
+ ",wire_fee_val"
+ ",wire_fee_frac"
+ ",wire_fee_curr"
",signkey_pub"
",exchange_proof) VALUES "
- "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11,
$12, $13, $14, $15)",
- 15),
+ "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11,
$12, $13, $14, $15, $16, $17, $18)",
+ 18),
GNUNET_PQ_make_prepare ("insert_transfer",
"INSERT INTO merchant_transfers"
"(h_contract_terms"
@@ -463,6 +469,9 @@ postgres_initialize (void *cls)
",refund_fee_val"
",refund_fee_frac"
",refund_fee_curr"
+ ",wire_fee_val"
+ ",wire_fee_frac"
+ ",wire_fee_curr"
",exchange_proof"
" FROM merchant_deposits"
" WHERE h_contract_terms=$1"
@@ -479,6 +488,9 @@ postgres_initialize (void *cls)
",refund_fee_val"
",refund_fee_frac"
",refund_fee_curr"
+ ",wire_fee_val"
+ ",wire_fee_frac"
+ ",wire_fee_curr"
",exchange_url"
",exchange_proof"
" FROM merchant_deposits"
@@ -509,6 +521,9 @@ postgres_initialize (void *cls)
",merchant_deposits.refund_fee_val"
",merchant_deposits.refund_fee_frac"
",merchant_deposits.refund_fee_curr"
+ ",merchant_deposits.wire_fee_val"
+ ",merchant_deposits.wire_fee_frac"
+ ",merchant_deposits.wire_fee_curr"
",merchant_deposits.exchange_url"
",merchant_deposits.exchange_proof"
" FROM merchant_transfers"
@@ -957,6 +972,7 @@ postgres_store_transaction (void *cls,
* @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 wire_fee wire fee changed by the exchange
* @param signkey_pub public key used by the exchange for @a exchange_proof
* @param exchange_proof proof from exchange that coin was accepted
* @return transaction status
@@ -970,6 +986,7 @@ postgres_store_deposit (void *cls,
const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *deposit_fee,
const struct TALER_Amount *refund_fee,
+ const struct TALER_Amount *wire_fee,
const struct TALER_ExchangePublicKeyP *signkey_pub,
const json_t *exchange_proof)
{
@@ -982,6 +999,7 @@ postgres_store_deposit (void *cls,
TALER_PQ_query_param_amount (amount_with_fee),
TALER_PQ_query_param_amount (deposit_fee),
TALER_PQ_query_param_amount (refund_fee),
+ TALER_PQ_query_param_amount (wire_fee),
GNUNET_PQ_query_param_auto_from_type (signkey_pub),
TALER_PQ_query_param_json (exchange_proof),
GNUNET_PQ_query_param_end
@@ -1402,6 +1420,7 @@ find_payments_cb (void *cls,
struct TALER_Amount amount_with_fee;
struct TALER_Amount deposit_fee;
struct TALER_Amount refund_fee;
+ struct TALER_Amount wire_fee;
json_t *exchange_proof;
char *exchange_url;
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -1415,6 +1434,8 @@ find_payments_cb (void *cls,
&deposit_fee),
TALER_PQ_result_spec_amount ("refund_fee",
&refund_fee),
+ TALER_PQ_result_spec_amount ("wire_fee",
+ &wire_fee),
TALER_PQ_result_spec_json ("exchange_proof",
&exchange_proof),
GNUNET_PQ_result_spec_end
@@ -1437,6 +1458,7 @@ find_payments_cb (void *cls,
&amount_with_fee,
&deposit_fee,
&refund_fee,
+ &wire_fee,
exchange_proof);
GNUNET_PQ_cleanup_result (rs);
}
@@ -1541,6 +1563,7 @@ find_payments_by_coin_cb (void *cls,
struct TALER_Amount amount_with_fee;
struct TALER_Amount deposit_fee;
struct TALER_Amount refund_fee;
+ struct TALER_Amount wire_fee;
char *exchange_url;
json_t *exchange_proof;
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -1550,6 +1573,8 @@ find_payments_by_coin_cb (void *cls,
&deposit_fee),
TALER_PQ_result_spec_amount ("refund_fee",
&refund_fee),
+ TALER_PQ_result_spec_amount ("wire_fee",
+ &wire_fee),
GNUNET_PQ_result_spec_string ("exchange_url",
&exchange_url),
TALER_PQ_result_spec_json ("exchange_proof",
@@ -1574,6 +1599,7 @@ find_payments_by_coin_cb (void *cls,
&amount_with_fee,
&deposit_fee,
&refund_fee,
+ &wire_fee,
exchange_proof);
GNUNET_PQ_cleanup_result (rs);
}
@@ -1796,6 +1822,7 @@ find_deposits_cb (void *cls,
struct TALER_Amount amount_with_fee;
struct TALER_Amount deposit_fee;
struct TALER_Amount refund_fee;
+ struct TALER_Amount wire_fee;
char *exchange_url;
json_t *exchange_proof;
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -1809,6 +1836,8 @@ find_deposits_cb (void *cls,
&deposit_fee),
TALER_PQ_result_spec_amount ("refund_fee",
&refund_fee),
+ TALER_PQ_result_spec_amount ("wire_fee",
+ &wire_fee),
GNUNET_PQ_result_spec_string ("exchange_url",
&exchange_url),
TALER_PQ_result_spec_json ("exchange_proof",
@@ -1833,6 +1862,7 @@ find_deposits_cb (void *cls,
&amount_with_fee,
&deposit_fee,
&refund_fee,
+ &wire_fee,
exchange_proof);
GNUNET_PQ_cleanup_result (rs);
}
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index cd37149..a5dcc35 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -113,6 +113,11 @@ static struct TALER_Amount amount_with_fee;
static struct TALER_Amount deposit_fee;
/**
+ * Wire fee of the exchange.
+ */
+static struct TALER_Amount wire_fee;
+
+/**
* Refund fee for the coin.
*/
static struct TALER_Amount refund_fee;
@@ -254,6 +259,7 @@ deposit_cb (void *cls,
const struct TALER_Amount *aamount_with_fee,
const struct TALER_Amount *adeposit_fee,
const struct TALER_Amount *arefund_fee,
+ const struct TALER_Amount *awire_fee,
const json_t *aexchange_proof)
{
CHECK ((0 == memcmp (ah_contract_terms,
@@ -268,6 +274,8 @@ deposit_cb (void *cls,
&amount_with_fee));
CHECK (0 == TALER_amount_cmp (adeposit_fee,
&deposit_fee));
+ CHECK (0 == TALER_amount_cmp (awire_fee,
+ &wire_fee));
CHECK (1 == json_equal ((json_t *) aexchange_proof,
deposit_proof));
}
@@ -778,6 +786,9 @@ run (void *cls)
TALER_string_to_amount (CURRENCY ":0.000010",
&deposit_fee));
GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":0.000001",
+ &wire_fee));
+ GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":0.000010",
&refund_fee));
GNUNET_assert (GNUNET_OK ==
@@ -915,6 +926,7 @@ run (void *cls)
&amount_with_fee,
&deposit_fee,
&refund_fee,
+ &wire_fee,
&signkey_pub,
deposit_proof));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
diff --git a/src/include/taler_merchantdb_plugin.h
b/src/include/taler_merchantdb_plugin.h
index 6b83306..228fa90 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -77,6 +77,7 @@ typedef void
* @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 wire_fee wire fee the exchange charges
* @param exchange_proof proof from exchange that coin was accepted,
* matches the `interface DepositSuccess` of the documentation.
*/
@@ -88,6 +89,7 @@ typedef void
const struct TALER_Amount
*amount_with_fee,
const struct TALER_Amount *deposit_fee,
const struct TALER_Amount *refund_fee,
+ const struct TALER_Amount *wire_fee,
const json_t *exchange_proof);
@@ -355,6 +357,7 @@ struct TALER_MERCHANTDB_Plugin
* @param exchange_url URL of the exchange that issued @a coin_pub
* @param amount_with_fee amount the exchange will deposit for this coin
* @param deposit_fee fee the exchange will charge for this coin
+ * @param wire_fee wire fee the exchange charges
* @param signkey_pub public key used by the exchange for @a exchange_proof
* @param exchange_proof proof from exchange that coin was accepted
* @return transaction status
@@ -368,6 +371,7 @@ struct TALER_MERCHANTDB_Plugin
const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *deposit_fee,
const struct TALER_Amount *refund_fee,
+ const struct TALER_Amount *wire_fee,
const struct TALER_ExchangePublicKeyP *signkey_pub,
const json_t *exchange_proof);
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-merchant] branch master updated: add wire fee persisting per coin for /pay,
gnunet <=