merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 7305041655d62c3db960ff7235c63ff3eb7d818f
parent f407c514fca6e58f3599f839be2f210b80aba472
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Wed, 27 Jun 2018 16:10:18 +0200

Towards #5366..

Diffstat:
Msrc/backend/taler-merchant-httpd_pay.c | 29++++++++++++++++++++++++++++-
Msrc/merchant-tools/taler-merchant-generate-payments-alt.c | 16++++++++++------
Msrc/merchant-tools/taler-merchant-generate-payments.c | 1-
3 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c @@ -1316,6 +1316,7 @@ parse_pay (struct MHD_Connection *connection, }; enum GNUNET_DB_QueryStatus qs; const char *session_id; + struct GNUNET_TIME_Relative used_wire_transfer_delay; res = TMH_PARSE_json_data (connection, root, @@ -1452,9 +1453,35 @@ parse_pay (struct MHD_Connection *connection, return (GNUNET_NO == res) ? MHD_YES : MHD_NO; } + /* Use the value from config as default. */ + used_wire_transfer_delay = wire_transfer_delay; + if (NULL != json_object_get (pc->contract_terms, + "wire_transfer_delay")) + { + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Frontend specified wire transfer delay\n"); + + struct GNUNET_JSON_Specification wspec[] = { + GNUNET_JSON_spec_relative_time ("wire_transfer_delay", + &used_wire_transfer_delay), + GNUNET_JSON_spec_end() + }; + + res = TMH_PARSE_json_data (connection, + pc->contract_terms, + wspec); + if (GNUNET_YES != res) + { + GNUNET_JSON_parse_free (spec); + GNUNET_break (0); + return (GNUNET_NO == res) ? MHD_YES : MHD_NO; + } + } + pc->wire_transfer_deadline = GNUNET_TIME_absolute_add (pc->timestamp, - wire_transfer_delay); + used_wire_transfer_delay); if (pc->wire_transfer_deadline.abs_value_us < pc->refund_deadline.abs_value_us) { diff --git a/src/merchant-tools/taler-merchant-generate-payments-alt.c b/src/merchant-tools/taler-merchant-generate-payments-alt.c @@ -150,7 +150,7 @@ static char *currency; "%s:5.01", \ currency); \ GNUNET_asprintf (&CURRENCY_5, \ - "%s:5.01", \ + "%s:5", \ currency); \ GNUNET_asprintf (&CURRENCY_4_99, \ "%s:4.99", \ @@ -169,8 +169,9 @@ static char *currency; {\"currency\":\"%s\",\ \"value\":0,\ \"fraction\":50000000},\ - \"refund_deadline\":\"\\/Date(99999999999)\\/\",\ - \"pay_deadline\":\"\\/Date(99999999999)\\/\",\ + \"wire_transfer_delay\":\"\\/forever\\/\",\ + \"refund_deadline\":\"\\/end of time\\/\",\ + \"pay_deadline\":\"\\/end of time\\/\",\ \"amount\":\ {\"currency\":\"%s\",\ \"value\":5,\ @@ -287,17 +288,21 @@ run (void *cls, ("create-reserve-2", CURRENCY_10_02), + TALER_TESTING_cmd_exec_wirewatch + ("wirewatch-2", + cfg_filename), + TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2", is->exchange, - "create-reserve-1", + "create-reserve-2", CURRENCY_5, MHD_HTTP_OK), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-3", is->exchange, - "create-reserve-1", + "create-reserve-2", CURRENCY_5, MHD_HTTP_OK), @@ -492,7 +497,6 @@ main (int argc, bank_url))) { TALER_LOG_ERROR ("Failed to run the bank\n"); - terminate_process (bankd); terminate_process (merchantd); return FAILED_TO_LAUNCH_BANK; } diff --git a/src/merchant-tools/taler-merchant-generate-payments.c b/src/merchant-tools/taler-merchant-generate-payments.c @@ -543,7 +543,6 @@ main (int argc, bank_url))) { TALER_LOG_ERROR ("Failed to run the bank\n"); - terminate_process (bankd); terminate_process (merchantd); return FAILED_TO_LAUNCH_BANK; }