gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated (974b2b2 -> 31b17ff)


From: gnunet
Subject: [taler-merchant] branch master updated (974b2b2 -> 31b17ff)
Date: Fri, 24 Jul 2020 11:01:33 +0200

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

dold pushed a change to branch master
in repository merchant.

    from 974b2b2  implement & test POST /paid
     new 8029214  use order_status string tag
     new 31b17ff  use string type tag for refund status

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_get-orders-ID.c   | 24 ++++----
 .../taler-merchant-httpd_private-get-orders-ID.c   | 16 ++---
 src/lib/merchant_api_merchant_get_order.c          | 36 +++++++++--
 src/lib/merchant_api_wallet_get_order.c            | 69 +++++++++++++++++++++-
 4 files changed, 120 insertions(+), 25 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c 
b/src/backend/taler-merchant-httpd_get-orders-ID.c
index 05bdf38..2158269 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -377,9 +377,9 @@ send_pay_request (struct GetOrderData *god,
                                           god->hc->instance->settings.id);
   ret = TALER_MHD_reply_json_pack (god->sc.con,
                                    MHD_HTTP_OK,
-                                   "{s:s, s:b, s:s?}",
+                                   "{s:s, s:s, s:s?}",
                                    "taler_pay_uri", taler_pay_uri,
-                                   "paid", false,
+                                   "order_status", "unpaid",
                                    "already_paid_order_id",
                                    already_paid_order_id);
   GNUNET_free (taler_pay_uri);
@@ -997,9 +997,9 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
       {
         if (NULL == cr->exchange_reply)
         {
-          refund = json_pack ("{s:b, s:I,s:I,s:o,s:o,s:o}"
-                              "success",
-                              false,
+          refund = json_pack ("{s:s, s:I,s:I,s:o,s:o,s:o}"
+                              "type",
+                              "failure",
                               "exchange_status",
                               (json_int_t) cr->exchange_status,
                               "rtransaction_id",
@@ -1013,9 +1013,9 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
         }
         else
         {
-          refund = json_pack ("{s:b,s:I,s:I,s:o,s:I,s:o,s:o,s:o}"
-                              "success",
-                              false,
+          refund = json_pack ("{s:s,s:I,s:I,s:o,s:I,s:o,s:o,s:o}"
+                              "type",
+                              "failure",
                               "exchange_status",
                               (json_int_t) cr->exchange_status,
                               "exchange_code",
@@ -1034,9 +1034,9 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
       }
       else
       {
-        refund = json_pack ("{s:b,s:I,s:o,s:o,s:I,s:o,s:o,s:o}",
+        refund = json_pack ("{s:s,s:I,s:o,s:o,s:I,s:o,s:o,s:o}",
+                            "type",
                             "success",
-                            true,
                             "exchange_status",
                             (json_int_t) cr->exchange_status,
                             "exchange_sig",
@@ -1061,8 +1061,8 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
     return TALER_MHD_reply_json_pack (
       connection,
       MHD_HTTP_OK,
-      "{s:b, s:b, s:o, s:o, s:o}",
-      "paid", true,
+      "{s:s, s:b, s:o, s:o, s:o}",
+      "order_status", "paid",
       "refunded", god->refunded,
       "refund_amount",
       TALER_JSON_from_amount (&god->refund_amount),
diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c 
b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
index 850b72c..e3286dd 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -970,11 +970,11 @@ TMH_private_get_orders_ID (const struct 
TMH_RequestHandler *rh,
                                               hc->instance->settings.id);
       ret = TALER_MHD_reply_json_pack (connection,
                                        MHD_HTTP_OK,
-                                       "{s:s, s:b, s:s}",
+                                       "{s:s, s:s, s:s}",
                                        "taler_pay_uri",
                                        taler_pay_uri,
-                                       "paid",
-                                       false,
+                                       "order_status",
+                                       "unpaid",
                                        "already_paid_order_id",
                                        already_paid_order_id);
       GNUNET_free (taler_pay_uri);
@@ -1037,13 +1037,13 @@ TMH_private_get_orders_ID (const struct 
TMH_RequestHandler *rh,
                                             hc->instance->settings.id);
     ret = TALER_MHD_reply_json_pack (connection,
                                      MHD_HTTP_OK,
-                                     "{s:s, s:O, s:b}",
+                                     "{s:s, s:O, s:s}",
                                      "taler_pay_uri",
                                      taler_pay_uri,
                                      "contract_terms",
                                      gorc->contract_terms,
-                                     "paid",
-                                     false);
+                                     "order_status",
+                                     "unpaid");
     GNUNET_free (taler_pay_uri);
     return ret;
   }
@@ -1163,7 +1163,7 @@ TMH_private_get_orders_ID (const struct 
TMH_RequestHandler *rh,
     ret = TALER_MHD_reply_json_pack (connection,
                                      MHD_HTTP_OK,
                                      "{s:o, s:I, s:I, s:o, s:O,"
-                                     " s:b, s:b, s:b, s:o, s:o, s:o}",
+                                     " s:s, s:b, s:b, s:o, s:o, s:o}",
                                      "wire_reports",
                                      gorc->wire_reports,
                                      "exchange_ec",
@@ -1175,8 +1175,8 @@ TMH_private_get_orders_ID (const struct 
TMH_RequestHandler *rh,
                                        &gorc->deposits_total),
                                      "contract_terms",
                                      gorc->contract_terms,
+                                     "order_status",
                                      "paid",
-                                     true,
                                      "refunded",
                                      gorc->refunded,
                                      "wired",
diff --git a/src/lib/merchant_api_merchant_get_order.c 
b/src/lib/merchant_api_merchant_get_order.c
index 25cce30..a339c69 100644
--- a/src/lib/merchant_api_merchant_get_order.c
+++ b/src/lib/merchant_api_merchant_get_order.c
@@ -323,6 +323,7 @@ handle_merchant_order_get_finished (void *cls,
 {
   struct TALER_MERCHANT_OrderMerchantGetHandle *omgh = cls;
   const json_t *json = response;
+  const char *order_status;
   struct TALER_MERCHANT_HttpResponse hr = {
     .http_status = (unsigned int) response_code,
     .reply = json
@@ -357,13 +358,40 @@ handle_merchant_order_get_finished (void *cls,
     return;
   }
 
-  /* HTTP OK */
-  if (! json_boolean_value (json_object_get (json, "paid")))
+  order_status = json_string_value (json_object_get (json, "order_status"));
+
+  if (NULL == order_status)
+  {
+    GNUNET_break_op (0);
+    hr.http_status = 0;
+    hr.ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED;
+    omgh->cb (omgh->cb_cls,
+              &hr,
+              NULL);
+    TALER_MERCHANT_merchant_order_get_cancel (omgh);
+    return;
+  }
+
+  if (0 == strcmp ("paid", order_status))
+  {
+    handle_paid (omgh,
+                 &hr);
+  }
+  else if (0 == strcmp ("unpaid", order_status))
+  {
     handle_unpaid (omgh,
                    &hr);
+  }
   else
-    handle_paid (omgh,
-                 &hr);
+  {
+    GNUNET_break_op (0);
+    hr.http_status = 0;
+    hr.ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED;
+    omgh->cb (omgh->cb_cls,
+              &hr,
+              NULL);
+    TALER_MERCHANT_merchant_order_get_cancel (omgh);
+  }
 }
 
 
diff --git a/src/lib/merchant_api_wallet_get_order.c 
b/src/lib/merchant_api_wallet_get_order.c
index b5468f6..7b7c86e 100644
--- a/src/lib/merchant_api_wallet_get_order.c
+++ b/src/lib/merchant_api_wallet_get_order.c
@@ -110,6 +110,7 @@ handle_wallet_get_order_finished (void *cls,
 {
   struct TALER_MERCHANT_OrderWalletGetHandle *owgh = cls;
   const json_t *json = response;
+  const char *order_status;
 
   owgh->job = NULL;
   if (MHD_HTTP_OK != response_code)
@@ -138,7 +139,31 @@ handle_wallet_get_order_finished (void *cls,
     return;
   }
 
-  if (! json_boolean_value (json_object_get (json, "paid")))
+  order_status = json_string_value (json_object_get (json, "order_status"));
+
+  if (NULL == order_status)
+  {
+    struct TALER_MERCHANT_HttpResponse hr = {
+      .reply = json,
+      .http_status = 0,
+      .ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED,
+    };
+    GNUNET_break_op (0);
+    owgh->cb (owgh->cb_cls,
+              &hr,
+              GNUNET_SYSERR,
+              GNUNET_SYSERR,
+              NULL,
+              NULL,
+              NULL,
+              NULL,
+              0,
+              NULL);
+    TALER_MERCHANT_wallet_order_get_cancel (owgh);
+    return;
+  }
+
+  if (0 == strcmp (order_status, "unpaid"))
   {
     /* Status is: unpaid */
     const char *taler_pay_uri = json_string_value (json_object_get (json,
@@ -174,6 +199,28 @@ handle_wallet_get_order_finished (void *cls,
     return;
   }
 
+  if (0 != strcmp (order_status, "paid"))
+  {
+    struct TALER_MERCHANT_HttpResponse hr = {
+      .reply = json,
+      .http_status = 0,
+      .ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED,
+    };
+    GNUNET_break_op (0);
+    owgh->cb (owgh->cb_cls,
+              &hr,
+              GNUNET_SYSERR,
+              GNUNET_SYSERR,
+              NULL,
+              NULL,
+              NULL,
+              NULL,
+              0,
+              NULL);
+    TALER_MERCHANT_wallet_order_get_cancel (owgh);
+    return;
+  }
+
   {
     struct TALER_Amount refund_amount;
     json_t *refunds;
@@ -228,6 +275,7 @@ handle_wallet_get_order_finished (void *cls,
         struct TALER_MERCHANT_RefundDetail *rd = &rds[i];
         const json_t *jrefund = json_array_get (refunds,
                                                 i);
+        const char *refund_status_type;
         uint32_t exchange_status;
         int ret;
         struct GNUNET_JSON_Specification espec[] = {
@@ -252,6 +300,8 @@ handle_wallet_get_order_finished (void *cls,
         if (MHD_HTTP_OK == exchange_status)
         {
           struct GNUNET_JSON_Specification rspec[] = {
+            GNUNET_JSON_spec_string ("type",
+                                     &refund_status_type),
             GNUNET_JSON_spec_fixed_auto ("exchange_sig",
                                          &rd->exchange_sig),
             GNUNET_JSON_spec_fixed_auto ("exchange_pub",
@@ -268,10 +318,21 @@ handle_wallet_get_order_finished (void *cls,
           ret = GNUNET_JSON_parse (jrefund,
                                    rspec,
                                    NULL, NULL);
+          if (GNUNET_OK == ret)
+          {
+            /* check that type field is correct */
+            if (0 != strcmp ("success", refund_status_type))
+            {
+              GNUNET_break_op (0);
+              ret = GNUNET_SYSERR;
+            }
+          }
         }
         else
         {
           struct GNUNET_JSON_Specification rspec[] = {
+            GNUNET_JSON_spec_string ("type",
+                                     &refund_status_type),
             GNUNET_JSON_spec_fixed_auto ("coin_pub",
                                          &rd->coin_pub),
             GNUNET_JSON_spec_uint64 ("rtransaction_id",
@@ -305,6 +366,12 @@ handle_wallet_get_order_finished (void *cls,
             }
             rd->hr.reply = json_object_get (jrefund,
                                             "exchange_reply");
+            /* check that type field is correct */
+            if (0 != strcmp ("failure", refund_status_type))
+            {
+              GNUNET_break_op (0);
+              ret = GNUNET_SYSERR;
+            }
           }
         }
         if (GNUNET_OK != ret)

-- 
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]