diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 51 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd.h | 7 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_proposal.c | 15 |
3 files changed, 42 insertions, 31 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 9c95b8b9..bb4b4586 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -88,6 +88,13 @@ struct GNUNET_TIME_Relative default_pay_deadline; struct TALER_Amount default_max_wire_fee; /** + * Default max deposit fee that the merchant is willing to + * pay; if deposit costs more, then the customer will cover + * the difference. + */ +struct TALER_Amount default_max_deposit_fee; + +/** * Default factor for wire fee amortization. */ unsigned long long default_wire_fee_amortization; @@ -751,7 +758,6 @@ iterate_instances (const struct GNUNET_CONFIGURATION_Handle *config, return GNUNET_SYSERR; } - /** * Main function that will be run by the scheduler. * @@ -836,33 +842,24 @@ run (void *cls, "DEFAULT_MAX_WIRE_FEE", &default_max_wire_fee)) { - char *currency; + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "merchant", + "DEFAULT_MAX_WIRE_FEE"); + GNUNET_SCHEDULER_shutdown (); + return; + } - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (config, - "taler", - "CURRENCY", - ¤cy)) - { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "taler", - "CURRENCY"); - GNUNET_SCHEDULER_shutdown (); - return; - } - if (GNUNET_OK != - TALER_amount_get_zero (currency, - &default_max_wire_fee)) - { - GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, - "taler", - "CURRENCY", - "Specified value not legal for a Taler currency"); - GNUNET_SCHEDULER_shutdown (); - GNUNET_free (currency); - return; - } - GNUNET_free (currency); + if (GNUNET_OK != + TALER_config_get_denom (config, + "merchant", + "DEFAULT_MAX_DEPOSIT_FEE", + &default_max_deposit_fee)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "merchant", + "DEFAULT_MAX_DEPOSIT_FEE"); + GNUNET_SCHEDULER_shutdown (); + return; } if (GNUNET_OK != diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h index 83e9c07f..6fd31956 100644 --- a/src/backend/taler-merchant-httpd.h +++ b/src/backend/taler-merchant-httpd.h @@ -243,6 +243,13 @@ extern json_t *j_wire; extern struct TALER_Amount default_max_wire_fee; /** + * Default max deposit fee that the merchant is willing to + * pay; if deposit costs more, then the customer will cover + * the difference. + */ +extern struct TALER_Amount default_max_deposit_fee; + +/** * Default factor for wire fee amortization. */ extern unsigned long long default_wire_fee_amortization; diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c index 59bd62a8..df69bb68 100644 --- a/src/backend/taler-merchant-httpd_proposal.c +++ b/src/backend/taler-merchant-httpd_proposal.c @@ -138,7 +138,6 @@ proposal_put (struct MHD_Connection *connection, struct TALER_ProposalDataPS pdps; struct GNUNET_CRYPTO_EddsaSignature merchant_sig; struct TALER_Amount total; - struct TALER_Amount max_fee; const char *order_id; json_t *products; json_t *merchant; @@ -148,9 +147,9 @@ proposal_put (struct MHD_Connection *connection, struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount ("amount", &total), GNUNET_JSON_spec_string ("order_id", &order_id), - TALER_JSON_spec_amount ("max_fee", &max_fee), - /* The following entries we don't actually need, except to check that - the order is well-formed */ + /** + * The following entries we don't actually need, + * except to check that the order is well-formed */ GNUNET_JSON_spec_json ("products", &products), GNUNET_JSON_spec_json ("merchant", &merchant), GNUNET_JSON_spec_absolute_time ("timestamp", ×tamp), @@ -229,6 +228,14 @@ proposal_put (struct MHD_Connection *connection, } if (NULL == json_object_get (order, + "max_fee")) + { + json_object_set_new (order, + "max_fee", + TALER_JSON_from_amount (&default_max_deposit_fee)); + } + + if (NULL == json_object_get (order, "wire_fee_amortization")) { json_object_set_new (order, |