summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-03 12:27:24 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-03 12:27:24 +0200
commit9776c13c24d52521ef46eac35fb4ad73b3d86260 (patch)
treec11a527ba5e215ceb111b270008fd14a2e7d36f5 /src/backend
parent91f07f2b0a5e6c2213f8a903b8751176ad9c72fe (diff)
downloadmerchant-9776c13c24d52521ef46eac35fb4ad73b3d86260.tar.gz
merchant-9776c13c24d52521ef46eac35fb4ad73b3d86260.tar.bz2
merchant-9776c13c24d52521ef46eac35fb4ad73b3d86260.zip
fix name extraction
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/taler-merchant-httpd_get-orders-ID.c83
-rw-r--r--src/backend/taler-merchant-httpd_get-orders-ID.h1
2 files changed, 79 insertions, 5 deletions
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c
index f51b1962..d587745c 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -298,6 +298,73 @@ suspend_god (struct GetOrderData *god)
/**
+ * Create a taler://refund/ URI for the given @a con and @a order_id
+ * and @a instance_id.
+ *
+ * @param con HTTP connection
+ * @param order_id the order id
+ * @param instance_id instance, may be "default"
+ * @return corresponding taler://refund/ URI, or NULL on missing "host"
+ */
+static char *
+make_taler_refund_uri (struct MHD_Connection *con,
+ const char *order_id,
+ const char *instance_id)
+{
+ const char *host;
+ const char *forwarded_host;
+ const char *uri_path;
+ struct GNUNET_Buffer buf = { 0 };
+
+ host = MHD_lookup_connection_value (con,
+ MHD_HEADER_KIND,
+ "Host");
+ forwarded_host = MHD_lookup_connection_value (con,
+ MHD_HEADER_KIND,
+ "X-Forwarded-Host");
+
+ uri_path = MHD_lookup_connection_value (con,
+ MHD_HEADER_KIND,
+ "X-Forwarded-Prefix");
+ if (NULL != forwarded_host)
+ host = forwarded_host;
+
+ if (NULL == host)
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
+
+ GNUNET_assert (NULL != instance_id);
+ GNUNET_assert (NULL != order_id);
+
+ GNUNET_buffer_write_str (&buf,
+ "taler");
+ if (GNUNET_NO == TALER_mhd_is_https (con))
+ GNUNET_buffer_write_str (&buf,
+ "+http");
+ GNUNET_buffer_write_str (&buf,
+ "://refund/");
+ GNUNET_buffer_write_str (&buf,
+ host);
+ if (NULL != uri_path)
+ GNUNET_buffer_write_path (&buf,
+ uri_path);
+ if (0 != strcmp ("default",
+ instance_id))
+ {
+ GNUNET_buffer_write_path (&buf,
+ "instances");
+ GNUNET_buffer_write_path (&buf,
+ instance_id);
+ }
+ GNUNET_buffer_write_path (&buf,
+ order_id);
+ return GNUNET_buffer_reap_str (&buf);
+}
+
+
+/**
* Create a taler://pay/ URI for the given @a con and @a order_id
* and @a session_id and @a instance_id.
*
@@ -320,7 +387,6 @@ TMH_make_taler_pay_uri (struct MHD_Connection *con,
const char *uri_path;
struct GNUNET_Buffer buf = { 0 };
-
host = MHD_lookup_connection_value (con,
MHD_HEADER_KIND,
"Host");
@@ -433,7 +499,10 @@ send_pay_request (struct GetOrderData *god,
{ "taler_pay_qrcode_svg",
qr },
{ "order_summary",
- "FIXME" },
+ // FIXME: implement logic to extract summary based on
+ // language preferences from summary_i18n if present.
+ json_string_value (json_object_get (god->contract_terms,
+ "summary")) },
{ NULL, NULL }
};
enum GNUNET_GenericReturnValue res;
@@ -1241,11 +1310,16 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
if (god->refunded) // FIXME: don't check for refunded, but for PENDING refund!
{
char *qr;
+ char *uri;
- qr = TMH_create_qrcode ("taler://refund/FIXME");
+ uri = make_taler_refund_uri (god->sc.con,
+ order_id,
+ hc->instance->settings.id);
+ qr = TMH_create_qrcode (uri);
if (NULL == qr)
{
GNUNET_break (0);
+ GNUNET_free (uri);
return MHD_NO; // FIXME: add nicer error reply...
}
{
@@ -1260,9 +1334,10 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
res = TMH_return_from_template (god->sc.con,
MHD_HTTP_OK,
"offer_refund",
- "FIXME: refund-URI here",
+ uri,
kvc);
}
+ GNUNET_free (uri);
GNUNET_free (qr);
}
else
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.h b/src/backend/taler-merchant-httpd_get-orders-ID.h
index 6f1e7731..1eb9a18a 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.h
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.h
@@ -43,7 +43,6 @@ TMH_make_taler_pay_uri (struct MHD_Connection *con,
struct TALER_ClaimTokenP *claim_token);
-
/**
* Handle a GET "/orders/$ID" request.
*