merchant

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

commit 2dc9f4973d7eca15cfe6c2215d07719dcb000f6e
parent 67b6b6638f51789acdd9b338a0190778c15f382b
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date:   Tue, 21 Mar 2017 21:20:26 +0100

Adding function that concatenates amount strings.
Needed as payment generator now reads currency dynamically.

Diffstat:
Msrc/samples/generate_payments.c | 30++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/samples/generate_payments.c b/src/samples/generate_payments.c @@ -1255,6 +1255,28 @@ do_shutdown (void *cls) } /** + * Take currency and the part after ":" in the + * "CURRENCY:XX.YY" format, and return a string + * in the format "CURRENCY:XX.YY". + * + * @param currency currency + * @param rpart float numbers after the ":", in string form + * @return pointer to allocated and concatenated "CURRENCY:XX.YY" + * formatted string. + * + * FIXME: deallocate this string from within the interpreter + * commands who use it. + */ +char * +amount_concat (char *currency, char *rpart) +{ + char *ret; + GNUNET_asprintf (&ret, "%s:%s", + currency, rpart); + return ret; +} + +/** * Main function that will be run by the scheduler. * * @param cls closure @@ -1285,25 +1307,25 @@ run (void *cls) .expected_response_code = MHD_HTTP_OK, .details.admin_add_incoming.sender_details = "{ \"type\":\"test\", \"account_number\":62, \"uuid\":1 }", .details.admin_add_incoming.transfer_details = "{ \"uuid\": 1}", - .details.admin_add_incoming.amount = CURRENCY ":5.01" }, + .details.admin_add_incoming.amount = amount_concat (currency, "5.01") }, /* Withdraw a 5 EUR coin, at fee of 1 ct */ { .oc = OC_WITHDRAW_SIGN, .label = "withdraw-coin-1", .expected_response_code = MHD_HTTP_OK, .details.reserve_withdraw.reserve_reference = "create-reserve-1", - .details.reserve_withdraw.amount = CURRENCY ":5" }, + .details.reserve_withdraw.amount = amount_concat (currency, "5") }, /* Withdraw a 5 EUR coin, at fee of 1 ct */ { .oc = OC_WITHDRAW_SIGN, .label = "withdraw-coin-2", .expected_response_code = MHD_HTTP_OK, .details.reserve_withdraw.reserve_reference = "create-reserve-2", - .details.reserve_withdraw.amount = CURRENCY ":5" }, + .details.reserve_withdraw.amount = amount_concat (currency, "5") }, /* Withdraw a 5 EUR coin, at fee of 1 ct */ { .oc = OC_WITHDRAW_SIGN, .label = "withdraw-coin-3", .expected_response_code = MHD_HTTP_OK, .details.reserve_withdraw.reserve_reference = "create-reserve-3", - .details.reserve_withdraw.amount = CURRENCY ":5" }, + .details.reserve_withdraw.amount = amount_concat (currency, "5") }, /* Create proposal */ { .oc = OC_PROPOSAL,