gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] branch master updated (f52a678 -> 074f548)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (f52a678 -> 074f548)
Date: Thu, 18 Jan 2018 01:06:03 +0100

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

dold pushed a change to branch master
in repository merchant.

    from f52a678  use correct label
     new 69eefa5  convert refund amount if it is a string
     new 074f548  add backend redirect url to refund response

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/backend/taler-merchant-httpd.c          | 25 +++++++++++++++++++++
 src/backend/taler-merchant-httpd.h          | 12 ++++++++++
 src/backend/taler-merchant-httpd_proposal.c | 27 +---------------------
 src/backend/taler-merchant-httpd_refund.c   | 35 +++++++++++++++++++++++++----
 4 files changed, 69 insertions(+), 30 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c 
b/src/backend/taler-merchant-httpd.c
index ea3b7b4..572f5cf 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -1455,3 +1455,28 @@ TMH_make_absolute_backend_url (struct MHD_Connection 
*connection,
 
   return res;
 }
+
+
+/**
+ * Convert an amount in a JSON object from the string amount format to the JSON
+ * amount format.  Does nothing if the field is missing or already a JSON
+ * object.
+ *
+ * @param json json with the amount to convert
+ * @param field_name name of the field to convert
+ * @returns #GNUNET_OK on success, #GNUNET_SYSERR on invalid format
+ */
+int
+TMH_convert_amount (json_t *json, char *field_name)
+{
+  if (! json_is_string (json_object_get (json, field_name)))
+    return GNUNET_OK;
+  const char *amount_str = json_string_value (json_object_get (json, 
field_name));
+  GNUNET_assert (NULL != amount_str);
+  struct TALER_Amount amount;
+  if (GNUNET_OK != TALER_string_to_amount (amount_str, &amount))
+    return GNUNET_SYSERR;
+  json_object_del (json, field_name);
+  json_object_set_new (json, field_name, TALER_JSON_from_amount (&amount));
+  return GNUNET_OK;
+}
diff --git a/src/backend/taler-merchant-httpd.h 
b/src/backend/taler-merchant-httpd.h
index e86d387..b10b964 100644
--- a/src/backend/taler-merchant-httpd.h
+++ b/src/backend/taler-merchant-httpd.h
@@ -346,4 +346,16 @@ char *
 TMH_make_absolute_backend_url (struct MHD_Connection *connection, char *path, 
...);
 
 
+/**
+ * Convert an amount in a JSON object from the string amount format to the JSON
+ * amount format.  Does nothing if the field is missing or already a JSON
+ * object.
+ *
+ * @param json json with the amount to convert
+ * @param field_name name of the field to convert
+ * @returns #GNUNET_OK on success, #GNUNET_SYSERR on invalid format
+ */
+int
+TMH_convert_amount (json_t *json, char *field_name);
+
 #endif
diff --git a/src/backend/taler-merchant-httpd_proposal.c 
b/src/backend/taler-merchant-httpd_proposal.c
index 33f8d93..97aa193 100644
--- a/src/backend/taler-merchant-httpd_proposal.c
+++ b/src/backend/taler-merchant-httpd_proposal.c
@@ -122,31 +122,6 @@ json_parse_cleanup (struct TM_HandlerContext *hc)
 
 
 /**
- * Convert an amount in a JSON object from the string amount format to the JSON
- * amount format.  Does nothing if the field is missing or already a JSON
- * object.
- *
- * @param json json with the amount to convert
- * @param field_name name of the field to convert
- * @returns #GNUNET_OK on success, #GNUNET_SYSERR on invalid format
- */
-static int
-convert_amount (json_t *json, char *field_name)
-{
-  if (! json_is_string (json_object_get (json, field_name)))
-    return GNUNET_OK;
-  const char *amount_str = json_string_value (json_object_get (json, 
field_name));
-  GNUNET_assert (NULL != amount_str);
-  struct TALER_Amount amount;
-  if (GNUNET_OK != TALER_string_to_amount (amount_str, &amount))
-    return GNUNET_SYSERR;
-  json_object_del (json, field_name);
-  json_object_set_new (json, field_name, TALER_JSON_from_amount (&amount));
-  return GNUNET_OK;
-}
-
-
-/**
  * Transform an order into a proposal and store it in the database.
  * Write the resulting proposal or an error message ot a MHD connection
  *
@@ -216,7 +191,7 @@ proposal_put (struct MHD_Connection *connection,
                          json_string (buf));
   }
 
-  if (GNUNET_OK != convert_amount (order, "amount"))
+  if (GNUNET_OK != TMH_convert_amount (order, "amount"))
     return TMH_RESPONSE_reply_arg_invalid (connection,
                                            TALER_EC_PARAMETER_MALFORMED,
                                            "amount");
diff --git a/src/backend/taler-merchant-httpd_refund.c 
b/src/backend/taler-merchant-httpd_refund.c
index c81be52..9d18b1e 100644
--- a/src/backend/taler-merchant-httpd_refund.c
+++ b/src/backend/taler-merchant-httpd_refund.c
@@ -153,6 +153,11 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
        (NULL == root) )
     return MHD_YES;
 
+  if (GNUNET_OK != TMH_convert_amount (root, "refund"))
+    return TMH_RESPONSE_reply_arg_invalid (connection,
+                                           TALER_EC_PARAMETER_MALFORMED,
+                                           "refund");
+
   res = TMH_PARSE_json_data (connection,
                              root,
                              spec);
@@ -283,10 +288,32 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
 
   }
 
-  return TMH_RESPONSE_reply_json_pack (connection,
-                                       MHD_HTTP_OK,
-                                       "{s:o}",
-                                       "sig", GNUNET_JSON_from_data_auto 
(&sig));
+  {
+    int ret;
+    char *refund_pickup_url;
+    char *refund_redirect_url;
+
+    refund_pickup_url = TMH_make_absolute_backend_url (connection,
+                                                       "refund",
+                                                       NULL);
+    GNUNET_assert (NULL != refund_pickup_url);
+    refund_redirect_url = TMH_make_absolute_backend_url (connection,
+                                                         "trigger-pay",
+                                                         "refund_url",
+                                                         refund_pickup_url,
+                                                         NULL);
+    GNUNET_assert (NULL != refund_redirect_url);
+    ret = TMH_RESPONSE_reply_json_pack (connection,
+                                        MHD_HTTP_OK,
+                                        "{s:o, s:s}",
+                                        "sig",
+                                        GNUNET_JSON_from_data_auto (&sig),
+                                        "refund_redirect_url",
+                                        refund_redirect_url);
+    GNUNET_free (refund_pickup_url);
+    GNUNET_free (refund_redirect_url);
+    return ret;
+  }
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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