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: unify resource_url


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: unify resource_url and fulfillment_url
Date: Tue, 27 Aug 2019 00:28:15 +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 ef7253c  unify resource_url and fulfillment_url
ef7253c is described below

commit ef7253cbcd2d4906a2326f25e0423f7fea97afa1
Author: Florian Dold <address@hidden>
AuthorDate: Tue Aug 27 00:28:10 2019 +0200

    unify resource_url and fulfillment_url
---
 src/backend/taler-merchant-httpd_check-payment.c | 70 ++++++++++++------------
 src/backenddb/plugin_merchantdb_postgres.c       | 24 ++++----
 src/include/taler_merchant_service.h             |  2 -
 src/include/taler_merchantdb_plugin.h            |  8 +--
 src/lib/merchant_api_check_payment.c             |  3 -
 src/lib/testing_api_cmd_pay.c                    |  1 -
 6 files changed, 50 insertions(+), 58 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_check-payment.c 
b/src/backend/taler-merchant-httpd_check-payment.c
index c2b2a83..e5e82da 100644
--- a/src/backend/taler-merchant-httpd_check-payment.c
+++ b/src/backend/taler-merchant-httpd_check-payment.c
@@ -146,7 +146,7 @@ process_refunds_cb (void *cls,
  * @param order_id order ID for the payment
  * @param final_contract_url where to get the contract
  * @param session_id session of the client
- * @param resource_url where the resource will be (?), can be NULL!
+ * @param fulfillment_url fulfillment URL of the contract
  * @param h_contract_terms_str hash of the contract terms, stringified
  * @param mi merchant instance
  * @return #MHD_YES on success
@@ -156,7 +156,7 @@ send_pay_request (struct MHD_Connection *connection,
                   const char *order_id,
                   const char *final_contract_url,
                   const char *session_id,
-                  const char *resource_url,
+                  const char *fulfillment_url,
                   const char *h_contract_terms_str,
                   const struct MerchantInstance *mi)
 {
@@ -168,12 +168,12 @@ send_pay_request (struct MHD_Connection *connection,
   /* Check if resource_id has been paid for in the same session
    * with another order_id.
    */
-  if ( (NULL != session_id) && (NULL != resource_url) )
+  if ( (NULL != session_id) && (NULL != fulfillment_url) )
   {
     qs = db->find_session_info (db->cls,
                                 &already_paid_order_id,
                                 session_id,
-                                resource_url,
+                                fulfillment_url,
                                 &mi->pubkey);
     if (qs < 0)
     {
@@ -216,7 +216,7 @@ send_pay_request (struct MHD_Connection *connection,
  * @param mi the merchant's instance
  * @param final_contract_url where to redirect for the contract
  * @param session_id the session_id
- * @param resource_url where the resource will be (?), can be NULL!
+ * @param fulfillment_url fulfillment URL of the contract
  * @param order_id the order to look up
  * @return #MHD_YES on success
  */
@@ -225,7 +225,7 @@ check_order_and_request_payment (struct MHD_Connection 
*connection,
                                  struct MerchantInstance *mi,
                                  const char *final_contract_url,
                                  const char *session_id,
-                                 const char *resource_url,
+                                 const char *fulfillment_url,
                                  const char *order_id)
 {
   enum GNUNET_DB_QueryStatus qs;
@@ -272,7 +272,7 @@ check_order_and_request_payment (struct MHD_Connection 
*connection,
                           order_id,
                           final_contract_url,
                           session_id,
-                          resource_url,
+                          fulfillment_url,
                           h_contract_terms_str,
                           mi);
   GNUNET_free_non_null (h_contract_terms_str);
@@ -304,7 +304,7 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
   const char *contract_url;
   const char *session_id;
   const char *instance_str;
-  const char *resource_url;
+  const char *fulfillment_url;
   char *final_contract_url;
   char *h_contract_terms_str;
   struct MerchantInstance *mi;
@@ -352,10 +352,6 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
   {
     final_contract_url = GNUNET_strdup (contract_url);
   }
-  resource_url = MHD_lookup_connection_value (connection,
-                                              MHD_GET_ARGUMENT_KIND,
-                                              "resource_url");
-  /* NULL is allowed for resource_url! */
   session_id = MHD_lookup_connection_value (connection,
                                                 MHD_GET_ARGUMENT_KIND,
                                                 "session_id");
@@ -377,6 +373,28 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
                                               
TALER_EC_CHECK_PAYMENT_DB_FETCH_CONTRACT_TERMS_ERROR,
                                               "db error fetching contract 
terms");
   }
+
+  /* Get the amount and fulfillment_url from the contract. */
+  {
+    struct TALER_Amount amount;
+    struct GNUNET_JSON_Specification spec[] = {
+      TALER_JSON_spec_amount ("amount", &amount),
+      GNUNET_JSON_spec_string ("fulfillment_url", &fulfillment_url),
+      GNUNET_JSON_spec_end ()
+    };
+
+    if (GNUNET_OK != GNUNET_JSON_parse (contract_terms, spec, NULL, NULL))
+    {
+      GNUNET_free (final_contract_url);
+      json_decref (contract_terms);
+      return TMH_RESPONSE_reply_internal_error (connection,
+                                                
TALER_EC_CHECK_PAYMENT_DB_FETCH_CONTRACT_TERMS_ERROR,
+                                                "Merchant database error 
(contract terms corrupted)");
+    }
+    TALER_amount_get_zero (amount.currency, &refund_amount);
+  }
+
+
   if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
   {
     /* Check that we're at least aware of the order */
@@ -384,7 +402,7 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
                                            mi,
                                            final_contract_url,
                                            session_id,
-                                           resource_url,
+                                           fulfillment_url,
                                            order_id);
     GNUNET_free (final_contract_url);
     return ret;
@@ -419,7 +437,7 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
     qs = db->find_session_info (db->cls,
                                 &already_paid_order_id,
                                 session_id,
-                                resource_url,
+                                fulfillment_url,
                                 &mi->pubkey);
     if (qs < 0)
     {
@@ -438,7 +456,7 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
                               order_id,
                               final_contract_url,
                               session_id,
-                              resource_url,
+                              fulfillment_url,
                               h_contract_terms_str,
                               mi);
       GNUNET_free_non_null (already_paid_order_id);
@@ -476,7 +494,7 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
                               order_id,
                               final_contract_url,
                               session_id,
-                              resource_url,
+                              fulfillment_url,
                               h_contract_terms_str,
                               mi);
       GNUNET_free_non_null (h_contract_terms_str);
@@ -490,26 +508,6 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
     json_decref (xcontract_terms);
   }
 
-  /* Get the amount from the contract. */
-  {
-    struct TALER_Amount amount;
-    struct GNUNET_JSON_Specification spec[] = {
-      TALER_JSON_spec_amount ("amount", &amount),
-      GNUNET_JSON_spec_end ()
-    };
-
-    if (GNUNET_OK != GNUNET_JSON_parse (contract_terms, spec, NULL, NULL))
-    {
-      GNUNET_free_non_null (h_contract_terms_str);
-      GNUNET_free (final_contract_url);
-      json_decref (contract_terms);
-      return TMH_RESPONSE_reply_internal_error (connection,
-                                                
TALER_EC_CHECK_PAYMENT_DB_FETCH_CONTRACT_TERMS_ERROR,
-                                                "Merchant database error 
(contract terms corrupted)");
-    }
-    TALER_amount_get_zero (amount.currency, &refund_amount);
-  }
-
   /* Accumulate refunds, if any. */
   for (unsigned int i=0;i<MAX_RETRIES;i++)
   {
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 1d3cb8c..28a79f6 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -257,15 +257,15 @@ postgres_initialize (void *cls)
                             ",amount_frac INT4 NOT NULL"
                             ",PRIMARY KEY (pickup_id)"
                             ");"),
-    /* sessions and their order_id/resource_url mapping */
+    /* sessions and their order_id/fulfillment_url mapping */
     GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS merchant_session_info 
("
                             " session_id VARCHAR NOT NULL"
-                            ",resource_url VARCHAR NOT NULL"
+                            ",fulfillment_url VARCHAR NOT NULL"
                             ",order_id VARCHAR NOT NULL"
                             ",merchant_pub BYTEA NOT NULL CHECK 
(LENGTH(merchant_pub)=32)"
                             ",timestamp INT8 NOT NULL"
-                            ",PRIMARY KEY (session_id, resource_url, 
merchant_pub)"
-                            ",UNIQUE (session_id, resource_url, order_id, 
merchant_pub)"
+                            ",PRIMARY KEY (session_id, fulfillment_url, 
merchant_pub)"
+                            ",UNIQUE (session_id, fulfillment_url, order_id, 
merchant_pub)"
                             ");"),
     GNUNET_PQ_EXECUTE_STATEMENT_END
   };
@@ -339,7 +339,7 @@ postgres_initialize (void *cls)
     GNUNET_PQ_make_prepare ("insert_session_info",
                             "INSERT INTO merchant_session_info"
                             "(session_id"
-                            ",resource_url"
+                            ",fulfillment_url"
                             ",order_id"
                             ",merchant_pub"
                             ",timestamp)"
@@ -437,7 +437,7 @@ postgres_initialize (void *cls)
                             " order_id"
                             " FROM merchant_session_info"
                             " WHERE"
-                            " resource_url=$1"
+                            " fulfillment_url=$1"
                             " AND session_id=$2"
                             " AND merchant_pub=$3",
                             2),
@@ -1135,7 +1135,7 @@ postgres_mark_proposal_paid (void *cls,
  *
  * @param cls closure
  * @param session_id session id
- * @param resource_url URL that canonically identifies the resource
+ * @param fulfillment_url URL that canonically identifies the resource
  *        being paid for
  * @param order_id the order ID that was used when paying for the resource URL
  * @param merchant_pub public key of the merchant, identifying the instance
@@ -1144,7 +1144,7 @@ postgres_mark_proposal_paid (void *cls,
 enum GNUNET_DB_QueryStatus
 postgres_insert_session_info (void *cls,
                               const char *session_id,
-                              const char *resource_url,
+                              const char *fulfillment_url,
                               const char *order_id,
                               const struct TALER_MerchantPublicKeyP 
*merchant_pub)
 {
@@ -1153,7 +1153,7 @@ postgres_insert_session_info (void *cls,
   struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_string (session_id),
-    GNUNET_PQ_query_param_string (resource_url),
+    GNUNET_PQ_query_param_string (fulfillment_url),
     GNUNET_PQ_query_param_string (order_id),
     GNUNET_PQ_query_param_auto_from_type (merchant_pub),
     GNUNET_PQ_query_param_absolute_time (&now),
@@ -1172,7 +1172,7 @@ postgres_insert_session_info (void *cls,
  * @param[out] order_id location to store the order ID that was used when
  *             paying for the resource URL
  * @param session_id session id
- * @param resource_url URL that canonically identifies the resource
+ * @param fulfillment_url URL that canonically identifies the resource
  *        being paid for
  * @param merchant_pub public key of the merchant, identifying the instance
  * @return transaction status
@@ -1181,13 +1181,13 @@ enum GNUNET_DB_QueryStatus
 postgres_find_session_info (void *cls,
                             char **order_id,
                             const char *session_id,
-                            const char *resource_url,
+                            const char *fulfillment_url,
                             const struct TALER_MerchantPublicKeyP 
*merchant_pub)
 {
   struct PostgresClosure *pg = cls;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_string (resource_url),
+    GNUNET_PQ_query_param_string (fulfillment_url),
     GNUNET_PQ_query_param_string (session_id),
     GNUNET_PQ_query_param_auto_from_type (merchant_pub),
     GNUNET_PQ_query_param_end
diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index 5bbad14..a5a9e36 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -984,7 +984,6 @@ typedef void
  * @param backend_url base URL of the merchant backend
  * @param instance instance used for the transaction
  * @param order_id order id to identify the payment
- * @parem resource_url resource URL to identify duplicate payments (can be 
NULL)
  * @parem session_id sesion id for the payment (or NULL if the payment is not 
bound to a session) 
  * @param check_payment_cb callback which will work the response gotten from 
the backend
  * @param check_payment_cb_cls closure to pass to @a check_payment_cb
@@ -995,7 +994,6 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context 
*ctx,
                               const char *backend_url,
                               const char *instance,
                               const char *order_id,
-                              const char *resource_url,
                               const char *session_id,
                               TALER_MERCHANT_CheckPaymentCallback 
check_payment_cb,
                               void *check_payment_cls);
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index 44cd068..a1e3b0e 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -251,7 +251,7 @@ struct TALER_MERCHANTDB_Plugin
    *
    * @param cls closure
    * @param session_id session id
-   * @param resource_url URL that canonically identifies the resource
+   * @param fulfillment_url URL that canonically identifies the resource
    *        being paid for
    * @param order_id the order ID that was used when paying for the resource 
URL
    * @param merchant_pub public key of the merchant, identifying the instance
@@ -260,7 +260,7 @@ struct TALER_MERCHANTDB_Plugin
   enum GNUNET_DB_QueryStatus
   (*insert_session_info) (void *cls,
                           const char *session_id,
-                          const char *resource_url,
+                          const char *fulfillment_url,
                           const char *order_id,
                           const struct TALER_MerchantPublicKeyP *merchant_pub);
 
@@ -271,7 +271,7 @@ struct TALER_MERCHANTDB_Plugin
    * @param[out] order_id location to store the order ID that was used when
    *             paying for the resource URL
    * @param session_id session id
-   * @param resource_url URL that canonically identifies the resource
+   * @param fulfillment_url URL that canonically identifies the resource
    *        being paid for
    * @param merchant_pub public key of the merchant, identifying the instance
    * @return transaction status
@@ -280,7 +280,7 @@ struct TALER_MERCHANTDB_Plugin
   (*find_session_info) (void *cls,
                         char **order_id,
                         const char *session_id,
-                        const char *resource_url,
+                        const char *fulfillment_url,
                         const struct TALER_MerchantPublicKeyP *merchant_pub);
 
   /**
diff --git a/src/lib/merchant_api_check_payment.c 
b/src/lib/merchant_api_check_payment.c
index 213f1ba..8c05707 100644
--- a/src/lib/merchant_api_check_payment.c
+++ b/src/lib/merchant_api_check_payment.c
@@ -176,7 +176,6 @@ handle_check_payment_finished (void *cls,
  * @param backend_url base URL of the merchant backend
  * @param instance instance used for the transaction
  * @param order_id order id to identify the payment
- * @parem resource_url resource URL to identify duplicate payments (can be 
NULL)
  * @parem session_id sesion id for the payment (or NULL if the payment is not 
bound to a session) 
  * @param check_payment_cb callback which will work the response gotten from 
the backend
  * @param check_payment_cb_cls closure to pass to @a check_payment_cb
@@ -187,7 +186,6 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context 
*ctx,
                               const char *backend_url,
                               const char *instance,
                               const char *order_id,
-                              const char *resource_url,
                               const char *session_id,
                               TALER_MERCHANT_CheckPaymentCallback 
check_payment_cb,
                               void *check_payment_cb_cls)
@@ -206,7 +204,6 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context 
*ctx,
   cpo->url = TALER_url_join (backend_url, "/check-payment",
                              "instance", instance,
                              "order_id", order_id,
-                             "resource_url", resource_url,
                              "session_id", session_id,
                              NULL);
   eh = curl_easy_init ();
diff --git a/src/lib/testing_api_cmd_pay.c b/src/lib/testing_api_cmd_pay.c
index 252fc81..e24105e 100644
--- a/src/lib/testing_api_cmd_pay.c
+++ b/src/lib/testing_api_cmd_pay.c
@@ -389,7 +389,6 @@ check_payment_run (void *cls,
      "default", // only default instance for now.
      order_id,
      NULL,
-     NULL,
      check_payment_cb,
      cps);
 

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



reply via email to

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