gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 02/02: use string type tag for refund status


From: gnunet
Subject: [taler-merchant] 02/02: use string type tag for refund status
Date: Fri, 24 Jul 2020 11:01:35 +0200

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

dold pushed a commit to branch master
in repository merchant.

commit 31b17ff2582bbc6890b829ef4746aa0d37b6d9d9
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Fri Jul 24 14:31:27 2020 +0530

    use string type tag for refund status
---
 src/backend/taler-merchant-httpd_get-orders-ID.c | 16 ++++++++--------
 src/lib/merchant_api_wallet_get_order.c          | 20 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c 
b/src/backend/taler-merchant-httpd_get-orders-ID.c
index 8604578..2158269 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -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",
diff --git a/src/lib/merchant_api_wallet_get_order.c 
b/src/lib/merchant_api_wallet_get_order.c
index 680f856..7b7c86e 100644
--- a/src/lib/merchant_api_wallet_get_order.c
+++ b/src/lib/merchant_api_wallet_get_order.c
@@ -275,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[] = {
@@ -299,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",
@@ -315,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",
@@ -352,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]