[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] branch master updated: fix name extraction
From: |
gnunet |
Subject: |
[taler-merchant] branch master updated: fix name extraction |
Date: |
Mon, 03 Aug 2020 12:27:30 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new 9776c13 fix name extraction
9776c13 is described below
commit 9776c13c24d52521ef46eac35fb4ad73b3d86260
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Aug 3 12:27:24 2020 +0200
fix name extraction
---
src/backend/taler-merchant-httpd_get-orders-ID.c | 83 ++++++++++++++++++++++--
src/backend/taler-merchant-httpd_get-orders-ID.h | 1 -
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 f51b196..d587745 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -297,6 +297,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 6f1e773..1eb9a18 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.
*
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-merchant] branch master updated: fix name extraction,
gnunet <=