merchant

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

commit 6a792c799ff158e41ec98e2fd1a8ad4db56d6a05
parent ed56de150c2ea1b983a9a2f400bfd388dee9fbeb
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date:   Fri,  1 Aug 2025 14:55:38 +0200

Merge branch 'master' into dev/bohdan-potuzhnyi/donau-integration

Diffstat:
Msrc/backend/taler-merchant-httpd_private-post-orders.c | 14++++++++++++++
Msrc/include/taler_merchant_testing_lib.h | 2++
Msrc/include/taler_merchant_util.h | 11+++++++++++
Msrc/testing/test_merchant_api.c | 8++++++++
Msrc/testing/testing_api_cmd_post_orders.c | 8++++++++
Msrc/util/contract_parse.c | 14++++++++++++++
Msrc/util/contract_serialize.c | 6++++++
Msrc/util/test_contract.c | 5+++++
8 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -947,6 +947,12 @@ clean_order (void *cls) } for (unsigned int i = 0; i<oc->parse_choices.choices_len; i++) { + GNUNET_free (oc->parse_choices.choices[i].description); + if (NULL != oc->parse_choices.choices[i].description_i18n) + { + json_decref (oc->parse_choices.choices[i].description_i18n); + oc->parse_choices.choices[i].description_i18n = NULL; + } GNUNET_array_grow (oc->parse_choices.choices[i].inputs, oc->parse_choices.choices[i].inputs_len, 0); @@ -3329,6 +3335,14 @@ phase_parse_choices (struct OrderContext *oc) &choice->max_fee), &no_fee), GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string_copy ("description", + &choice->description), + NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_object_copy ("description_i18n", + &choice->description_i18n), + NULL), + GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_array_const ("inputs", &jinputs), NULL), diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h @@ -683,6 +683,8 @@ TALER_TESTING_cmd_merchant_post_orders_choices ( const char *merchant_url, unsigned int http_status, const char *token_family_slug, + const char *choice_description, + json_t *choice_description_i18n, unsigned int num_inputs, unsigned int num_outputs, const char *order_id, diff --git a/src/include/taler_merchant_util.h b/src/include/taler_merchant_util.h @@ -271,6 +271,17 @@ struct TALER_MERCHANT_ContractChoice struct TALER_Amount amount; /** + * Human readable description of the semantics of the choice within the + * contract to be shown to the user at payment. + */ + char *description; + + /** + * Map from IETF BCP 47 language tags to localized description. + */ + json_t *description_i18n; + + /** * Maximum fee the merchant is willing to pay for this choice. * Set to an invalid amount to use instance defaults (zero or STEFAN). */ diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c @@ -1750,6 +1750,8 @@ run (void *cls, merchant_url, MHD_HTTP_OK, "subscription-upcoming", + "A choice in the contract", + NULL, 0, 1, "5-upcoming-output", @@ -1776,6 +1778,8 @@ run (void *cls, merchant_url, MHD_HTTP_OK, "subscription-1", + "A choice in the contract", + NULL, 0, 1, "5-output", @@ -1799,6 +1803,8 @@ run (void *cls, merchant_url, MHD_HTTP_OK, "subscription-1", + "A choice in the contract", + NULL, 1, 1, "5-input-output", @@ -1832,6 +1838,8 @@ run (void *cls, merchant_url, MHD_HTTP_OK, "subscription-1", + "A choice in the contract", + NULL, 1, 1, "5-input-output-2", diff --git a/src/testing/testing_api_cmd_post_orders.c b/src/testing/testing_api_cmd_post_orders.c @@ -886,6 +886,8 @@ TALER_TESTING_cmd_merchant_post_orders_choices ( const char *merchant_url, unsigned int http_status, const char *token_family_slug, + const char *choice_description, + json_t *choice_description_i18n, unsigned int num_inputs, unsigned int num_outputs, const char *order_id, @@ -940,6 +942,12 @@ TALER_TESTING_cmd_merchant_post_orders_choices ( = GNUNET_JSON_PACK ( TALER_JSON_pack_amount ("amount", &brutto), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_string ("description", + choice_description)), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_object_steal ("description_i18n", + choice_description_i18n)), GNUNET_JSON_pack_array_steal ("inputs", inputs), GNUNET_JSON_pack_array_steal ("outputs", diff --git a/src/util/contract_parse.c b/src/util/contract_parse.c @@ -377,6 +377,14 @@ parse_choices ( struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount_any ("amount", &choice->amount), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string_copy ("description", + &choice->description), + NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_object_copy ("description_i18n", + &choice->description_i18n), + NULL), TALER_JSON_spec_amount_any ("max_fee", &choice->max_fee), GNUNET_JSON_spec_array_const ("inputs", @@ -520,6 +528,12 @@ contract_choice_free ( GNUNET_free (output->details.coin.exchange_url); } + GNUNET_free (choice->description); + if (NULL != choice->description_i18n) + { + json_decref (choice->description_i18n); + choice->description_i18n = NULL; + } GNUNET_free (choice->inputs); GNUNET_free (choice->outputs); } diff --git a/src/util/contract_serialize.c b/src/util/contract_serialize.c @@ -182,6 +182,12 @@ TALER_MERCHANT_json_from_contract_choice ( return GNUNET_JSON_PACK ( TALER_JSON_pack_amount ("amount", &choice->amount), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_string ("description", + choice->description)), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_object_steal ("description_i18n", + choice->description_i18n)), (order) ? GNUNET_JSON_pack_allow_null ( TALER_JSON_pack_amount ("max_fee", diff --git a/src/util/test_contract.c b/src/util/test_contract.c @@ -83,6 +83,11 @@ const char *contract_v1 = "{\n" " {\n" " \"amount\": \"KUDOS:1\",\n" " \"max_fee\": \"KUDOS:0.5\",\n" + " \"description\": \"Subscription in, discount out\",\n" + " \"description_i18n\": {\n" + " \"en\": \"This is a test choice\",\n" + " \"es\": \"Esta es una opción de prueba\"\n" + " },\n" " \"inputs\": [\n" " {\n" " \"type\": \"token\",\n"