diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-04 18:11:35 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-04 18:11:35 +0200 |
commit | 99eb36e490f5f0ca16cb451941ca873b03016b27 (patch) | |
tree | 9da20e4ef9dd7b5b1e9a860afc92c55b431df648 /src/backend/taler-merchant-httpd_private-post-orders.c | |
parent | 977c3d47538d071e2b37599bb71c0fae3ad36d44 (diff) | |
download | merchant-99eb36e490f5f0ca16cb451941ca873b03016b27.tar.gz merchant-99eb36e490f5f0ca16cb451941ca873b03016b27.tar.bz2 merchant-99eb36e490f5f0ca16cb451941ca873b03016b27.zip |
-implement #6953 + #6948
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-post-orders.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-orders.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c index 403036af..5a10e449 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders.c +++ b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -327,10 +327,13 @@ execute_order (struct MHD_Connection *connection, struct TALER_Amount total; const char *order_id; const char *summary; + const char *fulfillment_msg = NULL; json_t *products; json_t *merchant; + json_t *summary_i18n = NULL; + json_t *fulfillment_i18n = NULL; struct GNUNET_TIME_Absolute timestamp; - struct GNUNET_TIME_Absolute refund_deadline; + struct GNUNET_TIME_Absolute refund_deadline = { 0 }; struct GNUNET_TIME_Absolute wire_transfer_deadline; struct GNUNET_TIME_Absolute pay_deadline; struct GNUNET_JSON_Specification spec[] = { @@ -348,10 +351,20 @@ execute_order (struct MHD_Connection *connection, &products), GNUNET_JSON_spec_json ("merchant", &merchant), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_json ("summary_i18n", + &summary_i18n)), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ("fulfillment_message", + &fulfillment_msg)), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_json ("fulfillment_message_i18n", + &fulfillment_i18n)), TALER_JSON_spec_absolute_time ("timestamp", ×tamp), - TALER_JSON_spec_absolute_time ("refund_deadline", - &refund_deadline), + GNUNET_JSON_spec_mark_optional ( + TALER_JSON_spec_absolute_time ("refund_deadline", + &refund_deadline)), TALER_JSON_spec_absolute_time ("pay_deadline", &pay_deadline), TALER_JSON_spec_absolute_time ("wire_transfer_deadline", @@ -387,6 +400,23 @@ execute_order (struct MHD_Connection *connection, "order:products"); } + if (! TALER_JSON_check_i18n (fulfillment_i18n)) + { + GNUNET_JSON_parse_free (spec); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + "order:fulfillment_i18n"); + } + if (! TALER_JSON_check_i18n (summary_i18n)) + { + GNUNET_JSON_parse_free (spec); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + "order:summary_i18n"); + } + /* Test if we already have an order with this id */ { struct TALER_ClaimTokenP token; @@ -1169,7 +1199,7 @@ merge_inventory (struct MHD_Connection *connection, "products", json_array ())); } - else if (! json_is_array (jprod)) + else if (! TMH_products_array_valid (jprod)) { return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, |