gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated: implement refund gone response w


From: gnunet
Subject: [taler-merchant] branch master updated: implement refund gone response when claim token is present on paid order
Date: Tue, 11 Aug 2020 16:36:04 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 61f5a1f  implement refund gone response when claim token is present on 
paid order
61f5a1f is described below

commit 61f5a1fb6baf24ba1c84e00f52e67a266ac3150b
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Tue Aug 11 20:05:57 2020 +0530

    implement refund gone response when claim token is present on paid order
---
 src/backend/taler-merchant-httpd_get-orders-ID.c | 78 ++++++++++++++++++++++--
 1 file changed, 73 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 fc551a1..d60b158 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -875,6 +875,54 @@ god_cleanup (void *cls)
   GNUNET_free (god);
 }
 
+/**
+ * Function to call to handle the request by sending
+ * back a redirect to the fulfillment URL.
+ *
+ * @param connection the MHD connection to handle
+ * @param url fulfillment URL
+ * @return MHD result code
+ */
+static MHD_RESULT
+reply_fulfillment_redirect (struct MHD_Connection *connection,
+                            const char *url)
+{
+  const char *text = "Redirecting to fulfillment URL ...";
+  struct MHD_Response *response;
+
+  response = MHD_create_response_from_buffer (strlen (text),
+                                              (void *) text,
+                                              MHD_RESPMEM_PERSISTENT);
+  if (NULL == response)
+  {
+    GNUNET_break (0);
+    return MHD_NO;
+  }
+  TALER_MHD_add_global_headers (response);
+  GNUNET_break (MHD_YES ==
+                MHD_add_response_header (response,
+                                         MHD_HTTP_HEADER_CONTENT_TYPE,
+                                         "text/plain"));
+  if (MHD_NO ==
+      MHD_add_response_header (response,
+                               MHD_HTTP_HEADER_LOCATION,
+                               url))
+  {
+    GNUNET_break (0);
+    MHD_destroy_response (response);
+    return MHD_NO;
+  }
+
+  {
+    MHD_RESULT ret;
+
+    ret = MHD_queue_response (connection,
+                              MHD_HTTP_FOUND,
+                              response);
+    MHD_destroy_response (response);
+    return ret;
+  }
+}
 
 /**
  * Handle a GET "/orders/$ID" request.
@@ -892,6 +940,8 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
   struct GetOrderData *god = hc->ctx;
   const char *order_id = hc->infix;
   enum GNUNET_DB_QueryStatus qs;
+  /* Will we reply with HTTP 410 Gone and just the fulfillment URL? */
+  bool reply_gone = false;
 
   if (NULL == god)
   {
@@ -1049,11 +1099,16 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
           GNUNET_memcmp (&h,
                          &god->h_contract_terms))
       {
-        GNUNET_break_op (0);
-        return TALER_MHD_reply_with_error (connection,
-                                           MHD_HTTP_FORBIDDEN,
-                                           TALER_EC_GET_ORDER_WRONG_CONTRACT,
-                                           "Contract hash does not match 
order");
+        if (0 == GNUNET_is_zero (&god->claim_token))
+        {
+          /* The client did not provide any claim token, just a wrong 
h_contract */
+          GNUNET_break_op (0);
+          return TALER_MHD_reply_with_error (connection,
+                                             MHD_HTTP_FORBIDDEN,
+                                             TALER_EC_GET_ORDER_WRONG_CONTRACT,
+                                             "Contract hash does not match 
order");
+        }
+        reply_gone = true;
       }
     }
 
@@ -1131,6 +1186,19 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
                              NULL);
   }
 
+  if (reply_gone)
+  {
+    GNUNET_assert (NULL != god->fulfillment_url);
+    if (god->generate_html)
+      return reply_fulfillment_redirect (connection,
+                                         god->fulfillment_url);
+    else
+      return TALER_MHD_reply_json_pack (connection,
+                                        MHD_HTTP_GONE,
+                                        "fulfillment_url",
+                                        god->fulfillment_url);
+  }
+
   if ( (NULL != god->session_id) &&
        (NULL != god->fulfillment_url) )
   {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]