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 (cb8472b -> 5eab12f)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (cb8472b -> 5eab12f)
Date: Fri, 30 Aug 2019 13:45:03 +0200

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

dold pushed a change to branch master
in repository merchant.

    from cb8472b  move documentation to docs repo
     new 68247a1  no more tip_redirect url, as we're moving to taler:// URIs
     new 2a2a99d  format string
     new 5eab12f  mobile-friendly tipping

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.c               |   9 +-
 src/backend/taler-merchant-httpd_tip-authorize.c | 107 ++++++++++-----------
 src/backend/taler-merchant-httpd_tip-pickup.c    | 115 ++++++++++++++++++++++-
 src/backenddb/plugin_merchantdb_postgres.c       |  24 ++++-
 src/backenddb/test_merchantdb.c                  |   7 +-
 src/include/taler_merchant_service.h             |   8 +-
 src/include/taler_merchantdb_plugin.h            |   4 +
 src/lib/merchant_api_tip_authorize.c             |  16 ++--
 src/lib/testing_api_cmd_tip.c                    |  30 ++----
 9 files changed, 219 insertions(+), 101 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c 
b/src/backend/taler-merchant-httpd.c
index c19eb9a..04d4fe2 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -272,15 +272,14 @@ url_handler (void *cls,
       { "/tip-authorize", NULL, "application/json",
         "Only POST is allowed", 0,
         &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED},
-      /* backwards compatibility alias for /public/tip-pickup */
-      { "/tip-pickup", MHD_HTTP_METHOD_POST, "text/plain",
+      { "/public/tip-pickup", MHD_HTTP_METHOD_POST, "text/plain",
         NULL, 0,
         &MH_handler_tip_pickup, MHD_HTTP_OK},
-      { "/public/tip-pickup", MHD_HTTP_METHOD_POST, "text/plain",
+      { "/public/tip-pickup", MHD_HTTP_METHOD_GET, "text/plain",
         NULL, 0,
         &MH_handler_tip_pickup, MHD_HTTP_OK},
-      { "/tip-pickup", NULL, "application/json",
-        "Only POST is allowed", 0,
+      { "/public/tip-pickup", NULL, "application/json",
+        "Only POST/GET are allowed", 0,
         &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED},
       { "/tip-query", MHD_HTTP_METHOD_GET, "text/plain",
         NULL, 0,
diff --git a/src/backend/taler-merchant-httpd_tip-authorize.c 
b/src/backend/taler-merchant-httpd_tip-authorize.c
index 4a8ae03..4c2451e 100644
--- a/src/backend/taler-merchant-httpd_tip-authorize.c
+++ b/src/backend/taler-merchant-httpd_tip-authorize.c
@@ -55,16 +55,6 @@ struct TipAuthContext
   const char *justification;
 
   /**
-   * Pickup URL to use.
-   */
-  const char *pickup_url;
-
-  /**
-   * URL to navigate to after tip.
-   */
-  const char *next_url;
-
-  /**
    * JSON request received.
    */
   json_t *root;
@@ -137,6 +127,7 @@ MH_handler_tip_authorize (struct TMH_RequestHandler *rh,
   enum TALER_ErrorCode ec;
   struct GNUNET_TIME_Absolute expiration;
   struct GNUNET_HashCode tip_id;
+  json_t *extra;
 
   if (NULL == *connection_cls)
   {
@@ -164,8 +155,6 @@ MH_handler_tip_authorize (struct TMH_RequestHandler *rh,
       TALER_JSON_spec_amount ("amount", &tac->amount),
       GNUNET_JSON_spec_string ("instance", &tac->instance),
       GNUNET_JSON_spec_string ("justification", &tac->justification),
-      GNUNET_JSON_spec_string ("pickup_url", &tac->pickup_url),
-      GNUNET_JSON_spec_string ("next_url", &tac->next_url),
       GNUNET_JSON_spec_end()
     };
 
@@ -181,19 +170,6 @@ MH_handler_tip_authorize (struct TMH_RequestHandler *rh,
          (NULL == tac->root) )
       return MHD_YES;
 
-    if (NULL == json_object_get (tac->root,
-                                 "pickup_url"))
-    {
-      char *pickup_url = TALER_url_absolute_mhd (connection,
-                                                 "/public/tip-pickup",
-                                                 NULL);
-      GNUNET_assert (NULL != pickup_url);
-      json_object_set_new (tac->root,
-                           "pickup_url",
-                           json_string (pickup_url));
-      GNUNET_free (pickup_url);
-    }
-
     res = TMH_PARSE_json_data (connection,
                                tac->root,
                                spec);
@@ -225,14 +201,23 @@ MH_handler_tip_authorize (struct TMH_RequestHandler *rh,
                                          "exchange for tipping not configured 
for the instance");
   }
   tac->ctr.reserve_priv = mi->tip_reserve;
+  extra = json_object_get (tac->root, "extra");
+  if (NULL == extra)
+    extra = json_object ();
+  else
+    json_incref (extra);
+
+
   db->preflight (db->cls);
   ec = db->authorize_tip_TR (db->cls,
                              tac->justification,
+                             extra,
                              &tac->amount,
                              &mi->tip_reserve,
                              mi->tip_exchange,
                              &expiration,
                              &tip_id);
+  json_decref (extra);
   /* If we have insufficient funds according to OUR database,
      check with exchange to see if the reserve has been topped up
      in the meantime (or if tips were not withdrawn yet). */
@@ -280,36 +265,52 @@ MH_handler_tip_authorize (struct TMH_RequestHandler *rh,
 
   /* generate success response */
   {
-    json_t *tip_token;
-    char *tip_token_str;
-    char *tip_redirect_url;
-
-    tip_token = json_pack ("{s:o, s:o, s:o, s:s, s:s, s:s}",
-                           "tip_id", GNUNET_JSON_from_data_auto (&tip_id),
-                           "expiration", GNUNET_JSON_from_time_abs 
(expiration),
-                           "amount", TALER_JSON_from_amount (&tac->amount),
-                           "exchange_url", mi->tip_exchange,
-                           "next_url", tac->next_url,
-                           "pickup_url", tac->pickup_url);
-    tip_token_str = json_dumps (tip_token, JSON_COMPACT);
-    GNUNET_assert (NULL != tip_token_str);
-    tip_redirect_url = TALER_url_absolute_mhd (connection, 
"public/trigger-pay",
-                                               "tip_token", tip_token_str,
-                                               NULL);
-    GNUNET_assert (NULL != tip_redirect_url);
-    /* FIXME:  This is pretty redundant, but we want to support some older
-     * merchant implementations.  Newer ones should only get the
-     * tip_redirect_url. */
+    char *taler_tip_uri;
+    const char *host;
+    const char *forwarded_host;
+    const char *uri_path;
+    const char *uri_instance_id;
+    struct GNUNET_CRYPTO_HashAsciiEncoded hash_enc;
+
+    host = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "Host");
+    forwarded_host = MHD_lookup_connection_value (connection, MHD_HEADER_KIND,
+                                                  "X-Forwarded-Host");
+
+    uri_path = MHD_lookup_connection_value (connection, MHD_HEADER_KIND,
+                                        "X-Forwarded-Prefix");
+    if (NULL == uri_path)
+      uri_path = "-";
+
+    if (NULL != forwarded_host)
+      host = forwarded_host;
+
+    if (NULL == host)
+    {
+      /* Should never happen, at last the host header should be defined */
+      GNUNET_break (0);
+      return TMH_RESPONSE_reply_internal_error (connection, 0, "unable to 
identify backend host");
+    }
+
+    if (0 == strcmp (mi->id, "default"))
+      uri_instance_id = "-";
+    else
+      uri_instance_id = mi->id;
+
+    GNUNET_CRYPTO_hash_to_enc (&tip_id, &hash_enc);
+
+    GNUNET_assert (0 < GNUNET_asprintf (&taler_tip_uri,
+                                         "taler://tip/%s/%s/%s/%s",
+                                         host,
+                                         uri_path,
+                                         uri_instance_id,
+                                         hash_enc.encoding));
+
+
     res = TMH_RESPONSE_reply_json_pack (connection,
                                         MHD_HTTP_OK,
-                                        "{s:o, s:o, s:s, s:o, s:s}",
-                                        "tip_id", GNUNET_JSON_from_data_auto 
(&tip_id),
-                                        "expiration", 
GNUNET_JSON_from_time_abs (expiration),
-                                        "exchange_url", mi->tip_exchange,
-                                        "tip_token", tip_token,
-                                        "tip_redirect_url", tip_redirect_url);
-    GNUNET_free (tip_token_str);
-    GNUNET_free (tip_redirect_url);
+                                        "{s:s, s:s}",
+                                        "taler_tip_uri", taler_tip_uri,
+                                        "tip_id", hash_enc.encoding);
     return res;
   }
 }
diff --git a/src/backend/taler-merchant-httpd_tip-pickup.c 
b/src/backend/taler-merchant-httpd_tip-pickup.c
index 90f9c89..9d72b81 100644
--- a/src/backend/taler-merchant-httpd_tip-pickup.c
+++ b/src/backend/taler-merchant-httpd_tip-pickup.c
@@ -399,7 +399,7 @@ prepare_pickup (struct PickupContext *pc)
   qs = db->lookup_tip_by_id (db->cls,
                              &pc->tip_id,
                              &pc->exchange_url,
-                             NULL, NULL);
+                             NULL, NULL, NULL);
   if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
   {
     unsigned int response_code;
@@ -486,7 +486,7 @@ parse_planchet (struct MHD_Connection *connection,
 
 
 /**
- * Manages a /tip-pickup call, checking that the tip is authorized,
+ * Manages a POST /tip-pickup call, checking that the tip is authorized,
  * and if so, returning the withdrawal permissions.
  *
  * @param rh context of the handler
@@ -597,3 +597,114 @@ MH_handler_tip_pickup (struct TMH_RequestHandler *rh,
   json_decref (root);
   return res;
 }
+
+
+/**
+ * Manages a GET /tip-pickup call, checking that the tip is authorized,
+ * and if so, returning the withdrawal permissions.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param upload_data upload data
+ * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @return MHD result code
+ */
+int
+MH_handler_tip_pickup_get (struct TMH_RequestHandler *rh,
+                           struct MHD_Connection *connection,
+                           void **connection_cls,
+                           const char *upload_data,
+                           size_t *upload_data_size)
+{
+  struct MerchantInstance *mi;
+  const char *instance_str;
+  const char *tip_id_str;
+  char *exchange_url;
+  json_t *extra;
+  struct GNUNET_HashCode tip_id;
+  struct TALER_Amount tip_amount;
+  int ret;
+  int qs;
+
+  instance_str = MHD_lookup_connection_value (connection,
+                                              MHD_GET_ARGUMENT_KIND,
+                                              "instance");
+  if (NULL == instance_str)
+    instance_str = "default";
+  mi = TMH_lookup_instance (instance_str);
+  if (NULL == mi)
+    return TMH_RESPONSE_reply_bad_request (connection,
+                                           TALER_EC_TIP_INSTANCE_UNKNOWN,
+                                           "merchant instance unknown");
+
+  tip_id_str = MHD_lookup_connection_value (connection,
+                                            MHD_GET_ARGUMENT_KIND,
+                                            "tip_id");
+
+  if (NULL == tip_id_str)
+  {
+    /* tip_id is required but missing */
+    GNUNET_break_op (0);
+    return TMH_RESPONSE_reply_bad_request (connection,
+                                           TALER_EC_PARAMETER_MISSING,
+                                           "tip_id required");
+  }
+
+  if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (tip_id_str, &tip_id))
+  {
+    /* tip_id has wrong encoding */
+    GNUNET_break_op (0);
+    return TMH_RESPONSE_reply_bad_request (connection,
+                                           TALER_EC_PARAMETER_MALFORMED,
+                                           "tip_id malformed");
+  }
+
+  db->preflight (db->cls);
+  qs = db->lookup_tip_by_id (db->cls,
+                             &tip_id,
+                             &exchange_url,
+                             &extra,
+                             &tip_amount, NULL);
+
+  if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
+  {
+    unsigned int response_code;
+    enum TALER_ErrorCode ec;
+
+    switch (qs)
+    {
+    case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+      ec = TALER_EC_TIP_PICKUP_TIP_ID_UNKNOWN;
+      response_code = MHD_HTTP_NOT_FOUND;
+      break;
+    case GNUNET_DB_STATUS_SOFT_ERROR:
+      ec = TALER_EC_TIP_PICKUP_DB_ERROR_SOFT;
+      response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
+      break;
+    case GNUNET_DB_STATUS_HARD_ERROR:
+      ec = TALER_EC_TIP_PICKUP_DB_ERROR_HARD;
+      response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
+      break;
+    default:
+      GNUNET_break (0);
+      ec = TALER_EC_INTERNAL_LOGIC_ERROR;
+      response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
+      break;
+    }
+    return TMH_RESPONSE_reply_rc (connection,
+                                  response_code,
+                                  ec,
+                                  "Could not determine exchange URL for the 
given tip id");
+  }
+  ret = TMH_RESPONSE_reply_json_pack (connection,
+                                      MHD_HTTP_OK,
+                                      "{s:s, s:o}",
+                                      "exchange_url", exchange_url,
+                                      "amount", TALER_JSON_from_amount 
(&tip_amount),
+                                      "extra", extra);
+
+  GNUNET_free (exchange_url);
+  json_decref (extra);
+  return ret;
+}
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 28a79f6..2b2c016 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -242,6 +242,7 @@ postgres_initialize (void *cls)
                             ",tip_id BYTEA NOT NULL CHECK (LENGTH(tip_id)=64)"
                             ",exchange_url VARCHAR NOT NULL"
                             ",justification VARCHAR NOT NULL"
+                            ",extra BYTEA NOT NULL"
                             ",timestamp INT8 NOT NULL"
                             ",amount_val INT8 NOT NULL" /* overall tip amount 
*/
                             ",amount_frac INT4 NOT NULL"
@@ -608,6 +609,7 @@ postgres_initialize (void *cls)
                             " amount_val"
                             ",amount_frac"
                             ",justification"
+                            ",extra"
                             ",tip_id"
                             " FROM merchant_tips"
                             " WHERE reserve_priv=$1",
@@ -634,14 +636,15 @@ postgres_initialize (void *cls)
                             ",tip_id"
                             ",exchange_url"
                             ",justification"
+                            ",extra"
                             ",timestamp"
                             ",amount_val"
                             ",amount_frac"
                             ",left_val"
                             ",left_frac"
                             ") VALUES "
-                            "($1, $2, $3, $4, $5, $6, $7, $8, $9)",
-                            9),
+                            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
+                            10),
     GNUNET_PQ_make_prepare ("lookup_reserve_by_tip_id",
                             "SELECT"
                             " reserve_priv"
@@ -661,6 +664,7 @@ postgres_initialize (void *cls)
     GNUNET_PQ_make_prepare ("find_tip_by_id",
                             "SELECT"
                             " exchange_url"
+                            ",extra"
                             ",timestamp"
                             ",amount_val"
                             ",amount_frac"
@@ -1570,6 +1574,7 @@ find_tip_authorizations_cb (void *cls,
   {
     struct TALER_Amount amount;
     char *just;
+    json_t *extra;
     struct GNUNET_HashCode h;
     struct GNUNET_PQ_ResultSpec rs[] = {
       GNUNET_PQ_result_spec_string ("justification",
@@ -1578,6 +1583,8 @@ find_tip_authorizations_cb (void *cls,
                                             &h),
       TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
                                     &amount),
+      TALER_PQ_result_spec_json ("extra",
+                                 &extra),
       GNUNET_PQ_result_spec_end
     };
 
@@ -3186,6 +3193,7 @@ postgres_enable_tip_reserve_TR (void *cls,
  *
  * @param cls closure, typically a connection to the db
  * @param justification why was the tip approved
+ * @param extra extra data for the customer's wallet
  * @param amount how high is the tip (with fees)
  * @param reserve_priv which reserve is debited
  * @param exchange_url which exchange manages the tip
@@ -3202,6 +3210,7 @@ postgres_enable_tip_reserve_TR (void *cls,
 static enum TALER_ErrorCode
 postgres_authorize_tip_TR (void *cls,
                            const char *justification,
+                           const json_t *extra,
                            const struct TALER_Amount *amount,
                            const struct TALER_ReservePrivateKeyP *reserve_priv,
                            const char *exchange_url,
@@ -3298,6 +3307,7 @@ postgres_authorize_tip_TR (void *cls,
       GNUNET_PQ_query_param_auto_from_type (tip_id),
       GNUNET_PQ_query_param_string (exchange_url),
       GNUNET_PQ_query_param_string (justification),
+      TALER_PQ_query_param_json (extra),
       GNUNET_PQ_query_param_absolute_time (&now),
       TALER_PQ_query_param_amount (amount), /* overall amount */
       TALER_PQ_query_param_amount (amount), /* amount left */
@@ -3331,6 +3341,7 @@ postgres_authorize_tip_TR (void *cls,
  * @param cls closure, typically a connection to the d
  * @param tip_id the unique ID for the tip
  * @param[out] exchange_url set to the URL of the exchange (unless NULL)
+ * @param[out] extra extra data to pass to the wallet (unless NULL)
  * @param[out] amount set to the authorized amount (unless NULL)
  * @param[out] timestamp set to the timestamp of the tip authorization (unless 
NULL)
  * @return transaction status, usually
@@ -3341,11 +3352,13 @@ static enum GNUNET_DB_QueryStatus
 postgres_lookup_tip_by_id (void *cls,
                            const struct GNUNET_HashCode *tip_id,
                            char **exchange_url,
+                           json_t **extra,
                            struct TALER_Amount *amount,
                            struct GNUNET_TIME_Absolute *timestamp)
 {
   struct PostgresClosure *pg = cls;
   char *res_exchange_url;
+  json_t *res_extra;
   struct TALER_Amount res_amount;
   struct GNUNET_TIME_Absolute res_timestamp;
   struct GNUNET_PQ_QueryParam params[] = {
@@ -3357,6 +3370,8 @@ postgres_lookup_tip_by_id (void *cls,
                                   &res_exchange_url),
     GNUNET_PQ_result_spec_absolute_time ("timestamp",
                                          &res_timestamp),
+    TALER_PQ_result_spec_json ("extra",
+                               &res_extra),
     TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
                                  &res_amount),
     GNUNET_PQ_result_spec_end
@@ -3379,6 +3394,11 @@ postgres_lookup_tip_by_id (void *cls,
     *amount = res_amount;
   if (NULL != timestamp)
     *timestamp = res_timestamp;
+  if (NULL != extra)
+  {
+    json_incref (res_extra);
+    *extra = res_extra;
+  }
   GNUNET_PQ_cleanup_result (rs);
   return qs;
 }
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index b63cddc..89732f5 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -502,6 +502,7 @@ test_tipping ()
   if (TALER_EC_TIP_AUTHORIZE_INSUFFICIENT_FUNDS !=
       plugin->authorize_tip_TR (plugin->cls,
                                 "testing tips reserve unknown",
+                                json_object (),
                                 &amount,
                                 &tip_reserve_priv,
                                 "http://localhost:8081/";,
@@ -545,6 +546,7 @@ test_tipping ()
   if (TALER_EC_TIP_AUTHORIZE_RESERVE_EXPIRED !=
       plugin->authorize_tip_TR (plugin->cls,
                                 "testing tips too late",
+                                json_object (),
                                 &amount,
                                 &tip_reserve_priv,
                                 "http://localhost:8081/";,
@@ -591,6 +593,7 @@ test_tipping ()
   if (TALER_EC_NONE !=
       plugin->authorize_tip_TR (plugin->cls,
                                 "testing tips",
+                                json_object (),
                                 &amount,
                                 &tip_reserve_priv,
                                 "http://localhost:8081/";,
@@ -609,7 +612,7 @@ test_tipping ()
       plugin->lookup_tip_by_id (plugin->cls,
                                      &tip_id,
                                      &url,
-                                      NULL, NULL))
+                                      NULL, NULL, NULL))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -625,6 +628,7 @@ test_tipping ()
   if (TALER_EC_NONE !=
       plugin->authorize_tip_TR (plugin->cls,
                                 "testing tips more",
+                                json_object (),
                                 &amount,
                                 &tip_reserve_priv,
                                 "http://localhost:8081/";,
@@ -696,6 +700,7 @@ test_tipping ()
   if (TALER_EC_TIP_AUTHORIZE_INSUFFICIENT_FUNDS !=
       plugin->authorize_tip_TR (plugin->cls,
                                 "testing tips insufficient funds",
+                                json_object (),
                                 &amount,
                                 &tip_reserve_priv,
                                 "http://localhost:8081/";,
diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index a5a9e36..82ac716 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -829,17 +829,15 @@ struct TALER_MERCHANT_TipAuthorizeOperation;
  * @param cls closure
  * @param http_status HTTP status returned by the merchant backend
  * @param ec taler-specific error code
+ * @param taler_tip_uri tip URI
  * @param tip_id which tip ID should be used to pickup the tip
- * @param tip_expiration when does the tip expire (needs to be picked up 
before this time)
- * @param exchange_url at what exchange can the tip be picked up
  */
 typedef void
 (*TALER_MERCHANT_TipAuthorizeCallback) (void *cls,
                                         unsigned int http_status,
                                         enum TALER_ErrorCode ec,
-                                        const struct GNUNET_HashCode *tip_id,
-                                        struct GNUNET_TIME_Absolute 
tip_expiration,
-                                        const char *exchange_url);
+                                        const char *taler_tip_uri,
+                                        struct GNUNET_HashCode *tip_id);
 
 
 /**
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index a1e3b0e..c7009ad 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -704,6 +704,7 @@ struct TALER_MERCHANTDB_Plugin
    *
    * @param cls closure, typically a connection to the db
    * @param justification why was the tip approved
+   * @param extra extra data that will be given to the customer's wallet
    * @param amount how high is the tip (with fees)
    * @param reserve_priv which reserve is debited
    * @param exchange_url which exchange manages the tip
@@ -720,6 +721,7 @@ struct TALER_MERCHANTDB_Plugin
   enum TALER_ErrorCode
   (*authorize_tip_TR)(void *cls,
                       const char *justification,
+                      const json_t *extra,
                       const struct TALER_Amount *amount,
                       const struct TALER_ReservePrivateKeyP *reserve_priv,
                       const char *exchange_url,
@@ -749,6 +751,7 @@ struct TALER_MERCHANTDB_Plugin
    * @param cls closure, typically a connection to the d
    * @param tip_id the unique ID for the tip
    * @param[out] exchange_url set to the URL of the exchange (unless NULL)
+   * @param[out] extra extra data to pass to the wallet
    * @param[out] amount set to the authorized amount (unless NULL)
    * @param[out] timestamp set to the timestamp of the tip authorization 
(unless NULL)
    * @return transaction status, usually
@@ -759,6 +762,7 @@ struct TALER_MERCHANTDB_Plugin
   (*lookup_tip_by_id)(void *cls,
                       const struct GNUNET_HashCode *tip_id,
                       char **exchange_url,
+                      json_t **extra,
                       struct TALER_Amount *amount,
                       struct GNUNET_TIME_Absolute *timestamp);
 
diff --git a/src/lib/merchant_api_tip_authorize.c 
b/src/lib/merchant_api_tip_authorize.c
index 88b499f..d77041c 100644
--- a/src/lib/merchant_api_tip_authorize.c
+++ b/src/lib/merchant_api_tip_authorize.c
@@ -83,13 +83,11 @@ static int
 check_ok (struct TALER_MERCHANT_TipAuthorizeOperation *tao,
           const json_t *json)
 {
+  const char *taler_tip_uri;
   struct GNUNET_HashCode tip_id;
-  struct GNUNET_TIME_Absolute tip_expiration;
-  const char *exchange_url;
   struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_absolute_time ("expiration", &tip_expiration),
+    GNUNET_JSON_spec_string ("taler_tip_uri", &taler_tip_uri),
     GNUNET_JSON_spec_fixed_auto ("tip_id", &tip_id),
-    GNUNET_JSON_spec_string ("exchange_url", &exchange_url),
     GNUNET_JSON_spec_end()
   };
 
@@ -99,14 +97,14 @@ check_ok (struct TALER_MERCHANT_TipAuthorizeOperation *tao,
                          NULL, NULL))
   {
     GNUNET_break_op (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "JSON %s\n", json_dumps (json, 0));
     return GNUNET_SYSERR;
   }
   tao->cb (tao->cb_cls,
            MHD_HTTP_OK,
            TALER_JSON_get_error_code (json),
-           &tip_id,
-           tip_expiration,
-           exchange_url);
+           taler_tip_uri,
+           &tip_id);
   tao->cb = NULL; /* do not call twice */
   GNUNET_JSON_parse_free (spec);
   return GNUNET_OK;
@@ -163,9 +161,7 @@ handle_tip_authorize_finished (void *cls,
     tao->cb (tao->cb_cls,
              response_code,
              TALER_JSON_get_error_code (json),
-             NULL,
-             GNUNET_TIME_UNIT_ZERO_ABS,
-             NULL);
+             NULL, NULL);
   TALER_MERCHANT_tip_authorize_cancel (tao);
 }
 
diff --git a/src/lib/testing_api_cmd_tip.c b/src/lib/testing_api_cmd_tip.c
index 6e1f529..652bd95 100644
--- a/src/lib/testing_api_cmd_tip.c
+++ b/src/lib/testing_api_cmd_tip.c
@@ -209,9 +209,9 @@ struct TipAuthorizeState
   enum TALER_ErrorCode expected_ec;
 
   /**
-   * Base URL of the involved exchange.
+   * Tip taler:// URI.
    */
-  const char *exchange_url;
+  const char *tip_uri;
 
   /**
    * The tip id; set when the CMD succeeds.
@@ -242,18 +242,15 @@ struct TipAuthorizeState
  * @param cls closure
  * @param http_status HTTP status returned by the merchant backend
  * @param ec taler-specific error code
- * @param tip_id which tip ID should be used to pickup the tip
- * @param tip_expiration when does the tip expire (needs to be
- *        picked up before this time)
- * @param exchange_url at what exchange can the tip be picked up
+ * @param taler_tip_uri URI to let the wallet know about the tip
+ * @param tip_id unique identifier for the tip
  */
 static void
 tip_authorize_cb (void *cls,
                   unsigned int http_status,
                   enum TALER_ErrorCode ec,
-                  const struct GNUNET_HashCode *tip_id,
-                  struct GNUNET_TIME_Absolute tip_expiration,
-                  const char *exchange_url)
+                  const char *taler_tip_uri,
+                  struct GNUNET_HashCode *tip_id)
 {
   struct TipAuthorizeState *tas = cls;
 
@@ -286,19 +283,8 @@ tip_authorize_cb (void *cls,
   if ( (MHD_HTTP_OK == http_status) &&
        (TALER_EC_NONE == ec) )
   {
-    if (0 != strcmp (exchange_url,
-                     tas->exchange_url))
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "Unexpected exchange URL %s to command %s\n",
-                  exchange_url,
-                  TALER_TESTING_interpreter_get_current_label
-                    (tas->is));
-      TALER_TESTING_interpreter_fail (tas->is);
-      return;
-    }
+    tas->tip_uri = strdup (taler_tip_uri);
     tas->tip_id = *tip_id;
-    tas->tip_expiration = tip_expiration;
   }
 
   TALER_TESTING_interpreter_next (tas->is);
@@ -446,7 +432,6 @@ TALER_TESTING_cmd_tip_authorize_with_ec
 
   tas = GNUNET_new (struct TipAuthorizeState);
   tas->merchant_url = merchant_url;
-  tas->exchange_url = exchange_url;
   tas->instance = instance;
   tas->justification = justification;
   tas->amount = amount;
@@ -494,7 +479,6 @@ TALER_TESTING_cmd_tip_authorize (const char *label,
 
   tas = GNUNET_new (struct TipAuthorizeState);
   tas->merchant_url = merchant_url;
-  tas->exchange_url = exchange_url;
   tas->instance = instance;
   tas->justification = justification;
   tas->amount = amount;

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



reply via email to

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