summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-22 19:20:51 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-22 19:20:51 +0200
commit97b02a22a9904c42d26e7973a82b9751e60f2135 (patch)
treec3f1ae5d40a01529bb0dac421f1465409828014b /src
parent13e71102938d16ff4777501532b3f8d1f574ad62 (diff)
downloadmerchant-97b02a22a9904c42d26e7973a82b9751e60f2135.tar.gz
merchant-97b02a22a9904c42d26e7973a82b9751e60f2135.tar.bz2
merchant-97b02a22a9904c42d26e7973a82b9751e60f2135.zip
pass h_contract separate from URI, that is cleaner
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c18
-rw-r--r--src/lib/merchant_api_common.c46
2 files changed, 51 insertions, 13 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c
index b5ef07bd..d308bf4b 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c
@@ -40,14 +40,12 @@
* @param connection MHD connection to take host and path from
* @param instance_id merchant's instance ID, must not be NULL
* @param order_id order ID to show a refund for, must not be NULL
- * @param h_contract hash of the contract to pass for authorization
* @returns the URI, must be freed with #GNUNET_free
*/
static char *
make_taler_refund_uri (struct MHD_Connection *connection,
const char *instance_id,
- const char *order_id,
- const struct GNUNET_HashCode *h_contract)
+ const char *order_id)
{
const char *host;
const char *forwarded_host;
@@ -89,11 +87,6 @@ make_taler_refund_uri (struct MHD_Connection *connection,
GNUNET_buffer_write_path (&buf, order_id);
GNUNET_buffer_write_path (&buf,
""); // Trailing slash
- GNUNET_buffer_write_str (&buf,
- "?h_contract=");
- GNUNET_buffer_write_data_encoded (&buf,
- &h_contract,
- sizeof (*h_contract));
return GNUNET_buffer_reap_str (&buf);
}
@@ -294,13 +287,14 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh,
taler_refund_uri = make_taler_refund_uri (connection,
hc->instance->settings.id,
- hc->infix,
- &h_contract);
+ hc->infix);
ret = TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK,
- "{s:s}",
+ "{s:s, s:o}",
"taler_refund_uri",
- taler_refund_uri);
+ taler_refund_uri,
+ "h_contract",
+ GNUNET_JSON_from_data_auto (&h_contract));
GNUNET_free (taler_refund_uri);
return ret;
}
diff --git a/src/lib/merchant_api_common.c b/src/lib/merchant_api_common.c
index 55d4209f..8e5c896f 100644
--- a/src/lib/merchant_api_common.c
+++ b/src/lib/merchant_api_common.c
@@ -159,7 +159,7 @@ TALER_MERCHANT_baseurl_add_instance (const char *base_url,
* @param uri the uri to parse.
* @param[out] action the action the URI is indicating.
* @param[out] rest the substring of the URI following the action.
- * @return GNUNET_SYSERR if the URI is malformed, GNUNET_OK otherwise.
+ * @return #GNUNET_SYSERR if the URI is malformed, #GNUNET_OK otherwise.
*/
static int
parse_taler_uri_scheme_action (const char *uri,
@@ -170,6 +170,7 @@ parse_taler_uri_scheme_action (const char *uri,
/* Check that the uri starts with "taler://pay" or "taler+http://pay" and
then remove it */
char *path = strchr (scheme, ':');
+
if ((NULL == path) ||
(strlen (path) < 3))
{
@@ -414,6 +415,49 @@ TALER_MERCHANT_parse_refund_uri (
*order_id = '\0';
++order_id;
+
+ {
+ char *ct_str = strchr (last_seg,
+ '?');
+ char *ct_data;
+
+ if (NULL != ct_str)
+ {
+ *ct_str = '\0';
+ ++ct_str;
+
+ ct_data = strchr (ct_str,
+ '=');
+ if (NULL == ct_data)
+ {
+ GNUNET_break_op (0);
+ GNUNET_free (path);
+ return GNUNET_SYSERR;
+ }
+ *ct_data = '\0';
+ ++ct_data;
+ if ((0 != strcmp ("h_contract",
+ ct_str)) ||
+ (GNUNET_OK !=
+ GNUNET_STRINGS_string_to_data (ct_data,
+ strlen (ct_data),
+ &parse_data->h_contract,
+ sizeof (struct GNUNET_HashCode))))
+ {
+ GNUNET_break_op (0);
+ GNUNET_free (path);
+ return GNUNET_SYSERR;
+ }
+ }
+ else
+ {
+ memset (&parse_data->h_contract,
+ 0,
+ sizeof (struct GNUNET_HashCode));
+ }
+ }
+
+
ssid = strchr (last_seg,
'#');
if (NULL != ssid)