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 (8bfff6a -> 870ca3f)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (8bfff6a -> 870ca3f)
Date: Mon, 19 Jun 2017 18:02:23 +0200

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

marcello pushed a change to branch master
in repository merchant.

    from 8bfff6a  defining /refund testcases data structs
     new 45b9b9a  /refund test op codes
     new 5a8bf79  get refund increase test compiled
     new 870ca3f  get /refund increase requested from the tests

The 3 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_refund.c |   3 +-
 src/lib/merchant_api_refund.c             |   4 +-
 src/lib/test_merchant_api.c               | 104 ++++++++++++++++++++++++++++--
 3 files changed, 103 insertions(+), 8 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_refund.c 
b/src/backend/taler-merchant-httpd_refund.c
index e731cf5..2149df1 100644
--- a/src/backend/taler-merchant-httpd_refund.c
+++ b/src/backend/taler-merchant-httpd_refund.c
@@ -235,12 +235,11 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
    * Just a "200 OK" should be fine here, as the frontend has all
    * the information needed to generate the right response.
    */
-  return MHD_YES;
 
   json_decref (contract_terms);
   json_decref (root);
   GNUNET_JSON_parse_free (spec);
-  return res;
+  return MHD_YES;
 }
 
 
diff --git a/src/lib/merchant_api_refund.c b/src/lib/merchant_api_refund.c
index 7b76dac..f0cf99c 100644
--- a/src/lib/merchant_api_refund.c
+++ b/src/lib/merchant_api_refund.c
@@ -198,7 +198,7 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context 
*ctx,
                    "%s%s",
                    backend_uri,
                    "/refund");
-  req = json_pack ("{s:o, s:s, s:s}",
+  req = json_pack ("{s:o, s:s, s:s, s:s}",
                    "refund", TALER_JSON_from_amount (refund),
                    "order_id", order_id,
                    "reason", reason,
@@ -230,7 +230,7 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context 
*ctx,
                                   GNUNET_YES,
                                   &handle_refund_increase_finished,
                                   rio);
-  return NULL;
+  return rio;
 }
 
 /**
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index 1d6b981..b45799b 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -190,7 +190,17 @@ enum OpCode
   /**
    * Test getting transactions based on timestamp
    */
-  OC_HISTORY
+  OC_HISTORY,
+
+  /**
+   * Test the increase of a order refund
+   */
+  OC_REFUND_INCREASE,
+
+  /**
+   * Test refund lookup
+   */
+  OC_REFUND_LOOKUP 
 
 };
 
@@ -624,6 +634,11 @@ struct Command
        * Amount to refund
        */
       const char *refund_amount;
+      
+      /**
+       * Reason for refunding
+       */
+      const char *reason;
 
     } refund_increase;
 
@@ -1119,12 +1134,64 @@ proposal_cb (void *cls,
 
 
 /**
+ * Process POST /refund (increase) response
+ *
+ * @param cls closure
+ * @param http_status HTTP status code
+ * @param ec taler-specific error object
+ * @param obj response body; is NULL on success.
+ */
+static void
+refund_increase_cb (void *cls,
+                    unsigned int http_status,
+                    enum TALER_ErrorCode ec,
+                    const json_t *obj)
+{
+  struct InterpreterState *is = cls;
+
+  if (MHD_HTTP_OK != http_status)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Refund increase failed\n");
+    fail (is);
+    return;
+  }
+}
+
+/**
+ * Process GET /refund (increase) response
+ *
+ * @param cls closure
+ * @param http_status HTTP status code
+ * @param ec taler-specific error object
+ * @param obj response body; is NULL on success.
+ */
+static void
+refund_lookup_cb (void *cls,
+                  unsigned int http_status,
+                  enum TALER_ErrorCode ec,
+                  const json_t *obj)
+{
+  struct InterpreterState *is = cls;
+
+  if (MHD_HTTP_OK != http_status)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Refund lookup failed\n");
+    fail (is);
+    return;
+  }
+}
+
+
+
+/**
  * Function called with the result of a /pay operation.
  *
  * @param cls closure with the interpreter state
  * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful 
deposit;
  *                    0 if the exchange's reply is bogus (fails to follow the 
protocol)
- * @param ec taler-specific error code
+ * @param ec taler-specific error object
  * @param obj the received JSON reply, should be kept as proof (and, in case 
of errors,
  *            be forwarded to the customer)
  */
@@ -2061,8 +2128,32 @@ interpreter_run (void *cls)
       fail (is);
       return;
     }
-  break;
+    break;
+  case OC_REFUND_INCREASE:
+  {
+    struct TALER_Amount refund_amount;
 
+    GNUNET_assert (GNUNET_OK ==
+      TALER_string_to_amount (cmd->details.refund_increase.refund_amount,
+                              &refund_amount));
+    if (NULL ==
+       (cmd->details.refund_increase.rio =
+          TALER_MERCHANT_refund_increase (ctx,
+                                          MERCHANT_URI,
+                                          
cmd->details.refund_increase.order_id,
+                                          &refund_amount,
+                                          cmd->details.refund_increase.reason,
+                                          instance,
+                                          refund_increase_cb,
+                                          NULL)))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Could not issue a /refund increase request\n");
+      fail (is);
+      return; 
+    }
+    break;
+  }
   default:
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Unknown instruction %d at %u (%s)\n",
@@ -2423,7 +2514,12 @@ run (void *cls)
       .details.history.start = 10,
       .details.history.nrows = 10
     },
-
+    { .oc = OC_REFUND_INCREASE,
+      .label = "increase-1",
+      .details.refund_increase.refund_amount = "EUR:0.1",
+      .details.refund_increase.reason = "refund test",
+      .details.refund_increase.order_id = "1"    
+    },
     /* end of testcase */
     { .oc = OC_END }
   };

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



reply via email to

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