merchant

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

commit 5e9a041c084f70c7bb80d13b960402d30cd5e6fe
parent 968b356e271ac67685dc5df2018e1750076f5a5e
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
Date:   Fri, 14 Aug 2020 02:38:56 -0400

check instance currency matches config

Diffstat:
Msrc/backend/taler-merchant-httpd_private-patch-instances-ID.c | 18++++++++++++++++--
Msrc/backend/taler-merchant-httpd_private-post-instances.c | 13+++++++++++++
Msrc/testing/test_merchant_api.c | 10++++++++--
3 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c @@ -120,6 +120,19 @@ TMH_private_patch_instances_ID (const struct TMH_RequestHandler *rh, free_wm (wm); } } + if ((0 != strcasecmp (is.default_max_deposit_fee.currency, + TMH_currency)) || + (0 != strcasecmp (is.default_max_wire_fee.currency, + TMH_currency))) + { + GNUNET_break (0); + GNUNET_JSON_parse_free (spec); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_POST_INSTANCES_BAD_CURRENCY, + "Max deposit fee or max wire fee currency incompatible with config"); + break; + } if (GNUNET_OK != TMH_db->start (TMH_db->cls, "PATCH /instances")) @@ -142,8 +155,9 @@ TMH_private_patch_instances_ID (const struct TMH_RequestHandler *rh, &is.default_max_deposit_fee)) && (0 == TALER_amount_cmp (&mi->settings.default_max_deposit_fee, &is.default_max_deposit_fee)) && - (GNUNET_YES == TALER_amount_cmp_currency (&mi->settings.default_max_wire_fee, - &is.default_max_wire_fee)) && + (GNUNET_YES == TALER_amount_cmp_currency ( + &mi->settings.default_max_wire_fee, + &is.default_max_wire_fee)) && (0 == TALER_amount_cmp (&mi->settings.default_max_wire_fee, &is.default_max_wire_fee)) && (mi->settings.default_wire_fee_amortization == diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c @@ -180,6 +180,19 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, : MHD_NO; } + if ((0 != strcasecmp (is.default_max_deposit_fee.currency, + TMH_currency)) || + (0 != strcasecmp (is.default_max_wire_fee.currency, + TMH_currency))) + { + GNUNET_break (0); + GNUNET_JSON_parse_free (spec); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_POST_INSTANCES_BAD_CURRENCY, + "Max deposit fee or max wire fee currency incompatible with config"); + } + { /* Test if an instance of this id is known */ struct TMH_MerchantInstance *mi; diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c @@ -1170,7 +1170,7 @@ run (void *cls, "i1", MHD_HTTP_OK, "instance-create-i1"), - TALER_TESTING_cmd_merchant_patch_instance ("instance-patch-i1-other-currency", + TALER_TESTING_cmd_merchant_patch_instance ("instance-patch-i1-bad-currency", merchant_url, "i1", 2, @@ -1187,7 +1187,7 @@ run (void *cls, "USD:0.5", GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_MINUTES, - MHD_HTTP_NO_CONTENT), + MHD_HTTP_BAD_REQUEST), TALER_TESTING_cmd_merchant_patch_instance ("instance-patch-i1", merchant_url, "i1", @@ -1248,6 +1248,12 @@ run (void *cls, "i2", MHD_HTTP_NOT_FOUND, NULL), + TALER_TESTING_cmd_merchant_post_instances ("instance-create-bad-currency", + merchant_url, + "i2", + PAYTO_I1, + "USD", + MHD_HTTP_BAD_REQUEST), TALER_TESTING_cmd_merchant_post_instances ("instance-create-i2", merchant_url, "i2",