summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-06-03 23:42:39 +0200
committerChristian Grothoff <christian@grothoff.org>2023-06-03 23:42:39 +0200
commitc75ed08b4dbeb70959e10861a7eeb78c545a2fc8 (patch)
tree482ade5ae8da19c81710925c7025fd2b386b00dc
parent7f8c111f1383805d64ab7f754cb6456d3dfb7250 (diff)
downloadmerchant-c75ed08b4dbeb70959e10861a7eeb78c545a2fc8.tar.gz
merchant-c75ed08b4dbeb70959e10861a7eeb78c545a2fc8.tar.bz2
merchant-c75ed08b4dbeb70959e10861a7eeb78c545a2fc8.zip
address more FIXMEs
-rw-r--r--src/include/taler_merchant_service.h105
-rw-r--r--src/lib/merchant_api_get_reserves.c70
-rw-r--r--src/lib/merchant_api_tip_authorize.c69
-rw-r--r--src/testing/testing_api_cmd_get_reserves.c170
-rw-r--r--src/testing/testing_api_cmd_tip_authorize.c36
5 files changed, 255 insertions, 195 deletions
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index cb9edb29..e8d76263 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -3767,21 +3767,53 @@ struct TALER_MERCHANT_ReserveSummary
};
-// FIXME: change signature!
+/**
+ * Response to a GET /reserves request.
+ */
+struct TALER_MERCHANT_ReservesGetResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on status.
+ */
+ union
+ {
+
+ /**
+ * Details if status is #MHD_HTTP_OK.
+ */
+ struct
+ {
+ /**
+ * length of the @e reserves array
+ */
+ unsigned int reserves_length;
+
+ /**
+ * array with details about the reserves
+ */
+ const struct TALER_MERCHANT_ReserveSummary *reserves;
+
+ } ok;
+
+ } details;
+};
+
+
/**
* Callback to process a GET /reserves request
*
* @param cls closure
- * @param hr HTTP response details
- * @param reserves_length length of the @a reserves array
- * @param reserves array with details about the reserves, NULL on error
+ * @param rgr response details
*/
typedef void
(*TALER_MERCHANT_ReservesGetCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int reserves_length,
- const struct TALER_MERCHANT_ReserveSummary reserves[]);
+ const struct TALER_MERCHANT_ReservesGetResponse *rgr);
/**
@@ -3963,24 +3995,61 @@ TALER_MERCHANT_reserve_get_cancel (
struct TALER_MERCHANT_TipAuthorizeHandle;
-// FIXME: change signature!
/**
- * Callback for a /reserves/$RESERVE_PUB/tip-authorize request. Returns the result of
- * the operation.
+ * Response to a /tip-authorize request.
+ */
+struct TALER_MERCHANT_TipAuthorizeResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+
+ /**
+ * Details if status is #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * which tip ID should be used to pickup the tip
+ */
+ struct TALER_TipIdentifierP tip_id;
+
+ /**
+ * URI for the tip
+ */
+ const char *tip_uri;
+
+ /**
+ * when does the tip expire
+ */
+ struct GNUNET_TIME_Timestamp tip_expiration;
+
+ } ok;
+
+ } details;
+
+};
+
+
+/**
+ * Callback for a /reserves/$RESERVE_PUB/tip-authorize request. Returns the
+ * result of the operation.
*
* @param cls closure
- * @param hr HTTP response details
- * @param tip_id which tip ID should be used to pickup the tip
- * @param tip_uri URI for the tip
- * @param tip_expiration when does the tip expire
+ * @param tar response
*/
typedef void
(*TALER_MERCHANT_TipAuthorizeCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- struct TALER_TipIdentifierP *tip_id,
- const char *tip_uri,
- struct GNUNET_TIME_Timestamp tip_expiration);
+ const struct TALER_MERCHANT_TipAuthorizeResponse *tar);
/**
diff --git a/src/lib/merchant_api_get_reserves.c b/src/lib/merchant_api_get_reserves.c
index cf462cfb..b825b0d2 100644
--- a/src/lib/merchant_api_get_reserves.c
+++ b/src/lib/merchant_api_get_reserves.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2017, 2020 Taler Systems SA
+ Copyright (C) 2014-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free Software
@@ -81,23 +81,23 @@ handle_reserves_get_finished (void *cls,
{
struct TALER_MERCHANT_ReservesGetHandle *rgh = cls;
const json_t *json = response;
- struct TALER_MERCHANT_HttpResponse hr = {
- .http_status = (unsigned int) response_code,
- .reply = json
+ struct TALER_MERCHANT_ReservesGetResponse rgr = {
+ .hr.http_status = (unsigned int) response_code,
+ .hr.reply = json
};
rgh->job = NULL;
switch (response_code)
{
case 0:
- hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ rgr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
{
- json_t *reserves;
+ const json_t *reserves;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_json ("reserves",
- &reserves),
+ GNUNET_JSON_spec_array_const ("reserves",
+ &reserves),
GNUNET_JSON_spec_end ()
};
@@ -107,11 +107,10 @@ handle_reserves_get_finished (void *cls,
NULL, NULL))
{
GNUNET_break_op (0);
- hr.http_status = 0;
- hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ rgr.hr.http_status = 0;
+ rgr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
}
- else
{
size_t rds_length;
struct TALER_MERCHANT_ReserveSummary *rds;
@@ -119,14 +118,6 @@ handle_reserves_get_finished (void *cls,
unsigned int i;
bool ok;
- if (! json_is_array (reserves))
- {
- GNUNET_break_op (0);
- GNUNET_JSON_parse_free (spec);
- hr.http_status = 0;
- hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
- break;
- }
rds_length = json_array_size (reserves);
rds = GNUNET_new_array (rds_length,
struct TALER_MERCHANT_ReserveSummary);
@@ -169,14 +160,14 @@ handle_reserves_get_finished (void *cls,
GNUNET_break_op (0);
GNUNET_free (rds);
GNUNET_JSON_parse_free (spec);
- hr.http_status = 0;
- hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ rgr.hr.http_status = 0;
+ rgr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
}
+ rgr.details.ok.reserves = rds;
+ rgr.details.ok.reserves_length = rds_length;
rgh->cb (rgh->cb_cls,
- &hr,
- rds_length,
- rds);
+ &rgr);
GNUNET_free (rds);
GNUNET_JSON_parse_free (spec);
TALER_MERCHANT_reserves_get_cancel (rgh);
@@ -184,44 +175,43 @@ handle_reserves_get_finished (void *cls,
}
}
case MHD_HTTP_UNAUTHORIZED:
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
+ rgr.hr.ec = TALER_JSON_get_error_code (json);
+ rgr.hr.hint = TALER_JSON_get_error_hint (json);
/* Nothing really to verify, merchant says we need to authenticate. */
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
+ rgr.hr.ec = TALER_JSON_get_error_code (json);
+ rgr.hr.hint = TALER_JSON_get_error_hint (json);
break;
default:
/* unexpected response code */
GNUNET_break_op (0);
TALER_MERCHANT_parse_error_details_ (json,
response_code,
- &hr);
+ &rgr.hr);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d\n",
(unsigned int) response_code,
- (int) hr.ec);
+ (int) rgr.hr.ec);
break;
}
rgh->cb (rgh->cb_cls,
- &hr,
- 0,
- NULL);
+ &rgr);
TALER_MERCHANT_reserves_get_cancel (rgh);
}
struct TALER_MERCHANT_ReservesGetHandle *
-TALER_MERCHANT_reserves_get (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- struct GNUNET_TIME_Timestamp after,
- enum TALER_EXCHANGE_YesNoAll active,
- enum TALER_EXCHANGE_YesNoAll failures,
- TALER_MERCHANT_ReservesGetCallback cb,
- void *cb_cls)
+TALER_MERCHANT_reserves_get (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ struct GNUNET_TIME_Timestamp after,
+ enum TALER_EXCHANGE_YesNoAll active,
+ enum TALER_EXCHANGE_YesNoAll failures,
+ TALER_MERCHANT_ReservesGetCallback cb,
+ void *cb_cls)
{
struct TALER_MERCHANT_ReservesGetHandle *rgh;
CURL *eh;
diff --git a/src/lib/merchant_api_tip_authorize.c b/src/lib/merchant_api_tip_authorize.c
index 036d40af..317023ac 100644
--- a/src/lib/merchant_api_tip_authorize.c
+++ b/src/lib/merchant_api_tip_authorize.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2017, 2020, 2021 Taler Systems SA
+ Copyright (C) 2014-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free Software
@@ -81,25 +81,26 @@ struct TALER_MERCHANT_TipAuthorizeHandle
* @param json cryptographic proof returned by the exchange/merchant
* @return #GNUNET_OK if response is valid
*/
-static int
+static enum GNUNET_GenericReturnValue
check_ok (struct TALER_MERCHANT_TipAuthorizeHandle *tao,
const json_t *json)
{
const char *tip_status_url;
- const char *taler_tip_uri;
- struct TALER_TipIdentifierP tip_id;
- struct GNUNET_TIME_Timestamp expiration_time;
+ struct TALER_MERCHANT_TipAuthorizeResponse tar = {
+ .hr.http_status = MHD_HTTP_OK,
+ .hr.reply = json
+ };
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_string ("tip_status_url", &tip_status_url),
- GNUNET_JSON_spec_string ("taler_tip_uri", &taler_tip_uri),
- GNUNET_JSON_spec_timestamp ("tip_expiration", &expiration_time),
- GNUNET_JSON_spec_fixed_auto ("tip_id", &tip_id),
+ GNUNET_JSON_spec_string ("tip_status_url",
+ &tip_status_url),
+ GNUNET_JSON_spec_string ("taler_tip_uri",
+ &tar.details.ok.tip_uri),
+ GNUNET_JSON_spec_timestamp ("tip_expiration",
+ &tar.details.ok.tip_expiration),
+ GNUNET_JSON_spec_fixed_auto ("tip_id",
+ &tar.details.ok.tip_id),
GNUNET_JSON_spec_end ()
};
- struct TALER_MERCHANT_HttpResponse hr = {
- .http_status = MHD_HTTP_OK,
- .reply = json
- };
if (GNUNET_OK !=
GNUNET_JSON_parse (json,
@@ -118,10 +119,7 @@ check_ok (struct TALER_MERCHANT_TipAuthorizeHandle *tao,
return GNUNET_SYSERR;
}
tao->cb (tao->cb_cls,
- &hr,
- &tip_id,
- taler_tip_uri,
- expiration_time);
+ &tar);
tao->cb = NULL; /* do not call twice */
GNUNET_JSON_parse_free (spec);
return GNUNET_OK;
@@ -143,9 +141,9 @@ handle_tip_authorize_finished (void *cls,
{
struct TALER_MERCHANT_TipAuthorizeHandle *tao = cls;
const json_t *json = response;
- struct TALER_MERCHANT_HttpResponse hr = {
- .http_status = (unsigned int) response_code,
- .reply = json
+ struct TALER_MERCHANT_TipAuthorizeResponse tar = {
+ .hr.http_status = (unsigned int) response_code,
+ .hr.reply = json
};
tao->job = NULL;
@@ -160,55 +158,52 @@ handle_tip_authorize_finished (void *cls,
return;
}
GNUNET_break_op (0);
- hr.http_status = 0;
- hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ tar.hr.http_status = 0;
+ tar.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
case MHD_HTTP_UNAUTHORIZED:
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
+ tar.hr.ec = TALER_JSON_get_error_code (json);
+ tar.hr.hint = TALER_JSON_get_error_hint (json);
/* Nothing really to verify, merchant says we need to authenticate. */
break;
case MHD_HTTP_NOT_FOUND:
/* Well-defined status code, pass on to application! */
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
+ tar.hr.ec = TALER_JSON_get_error_code (json);
+ tar.hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_PRECONDITION_FAILED:
/* Well-defined status code, pass on to application! */
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
+ tar.hr.ec = TALER_JSON_get_error_code (json);
+ tar.hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
+ tar.hr.ec = TALER_JSON_get_error_code (json);
+ tar.hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_SERVICE_UNAVAILABLE:
/* Server had an unclear (internal or external) issue; we should retry,
but this API leaves this to the application */
TALER_MERCHANT_parse_error_details_ (json,
response_code,
- &hr);
+ &tar.hr);
break;
default:
/* unexpected response code */
GNUNET_break_op (0);
TALER_MERCHANT_parse_error_details_ (json,
response_code,
- &hr);
+ &tar.hr);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d\n",
(unsigned int) response_code,
- (int) hr.ec);
+ (int) tar.hr.ec);
break;
}
if (NULL != tao->cb)
tao->cb (tao->cb_cls,
- &hr,
- NULL,
- NULL,
- GNUNET_TIME_UNIT_ZERO_TS);
+ &tar);
TALER_MERCHANT_tip_authorize_cancel (tao);
}
diff --git a/src/testing/testing_api_cmd_get_reserves.c b/src/testing/testing_api_cmd_get_reserves.c
index ea860c27..309a7881 100644
--- a/src/testing/testing_api_cmd_get_reserves.c
+++ b/src/testing/testing_api_cmd_get_reserves.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2020 Taler Systems SA
+ Copyright (C) 2020-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -68,112 +68,124 @@ struct GetReservesState
static void
get_reserves_cb (void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int reserves_length,
- const struct TALER_MERCHANT_ReserveSummary reserves[])
+ const struct TALER_MERCHANT_ReservesGetResponse *rgr)
{
struct GetReservesState *grs = cls;
- bool matched[reserves_length];
- bool fail = false;
grs->rgh = NULL;
- if (grs->http_status != hr->http_status)
+ if (grs->http_status != rgr->hr.http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u (%d) to command %s\n",
- hr->http_status,
- (int) hr->ec,
+ rgr->hr.http_status,
+ (int) rgr->hr.ec,
TALER_TESTING_interpreter_get_current_label (grs->is));
TALER_TESTING_interpreter_fail (grs->is);
return;
}
- switch (hr->http_status)
+ switch (rgr->hr.http_status)
{
case MHD_HTTP_OK:
- if (reserves_length != grs->reserves_length)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Length of reserves found does not match\n");
- TALER_TESTING_interpreter_fail (grs->is);
- return;
- }
- /* check if the data returned matches that from the POST / PATCH */
- memset (matched, 0, sizeof (matched));
- for (unsigned int i = 0; i < reserves_length; ++i)
- for (unsigned int j = 0; j < reserves_length; ++j)
+ bool matched[GNUNET_NZL (rgr->details.ok.reserves_length)];
+ bool fail = false;
+
+ if (rgr->details.ok.reserves_length != grs->reserves_length)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Length of reserves found does not match\n");
+ TALER_TESTING_interpreter_fail (grs->is);
+ return;
+ }
+ /* check if the data returned matches that from the POST / PATCH */
+ memset (matched,
+ 0,
+ sizeof (matched));
+ for (unsigned int i = 0; i < rgr->details.ok.reserves_length; ++i)
{
- const struct TALER_TESTING_Command *reserve_cmd;
- bool match = true;
+ const struct TALER_MERCHANT_ReserveSummary *reserve
+ = &rgr->details.ok.reserves[i];
- reserve_cmd = TALER_TESTING_interpreter_lookup_command (
- grs->is,
- grs->reserves[j]);
+ for (unsigned int j = 0; j < grs->reserves_length; ++j)
{
- const struct TALER_ReservePublicKeyP *reserve_pub;
+ const struct TALER_TESTING_Command *reserve_cmd;
+ bool match = true;
- if (GNUNET_OK !=
- TALER_TESTING_get_trait_reserve_pub (reserve_cmd,
- &reserve_pub))
+ reserve_cmd = TALER_TESTING_interpreter_lookup_command (
+ grs->is,
+ grs->reserves[j]);
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not fetch reserve public key\n");
- TALER_TESTING_interpreter_fail (grs->is);
- return;
- }
- if (0 != GNUNET_memcmp (&reserves[i].reserve_pub,
- reserve_pub))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Reserve public key does not match, got %s\n",
- TALER_B2S (&reserves[i].reserve_pub));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Reserve public key does not match, expected %s\n",
- TALER_B2S (reserve_pub));
- match = false;
- }
- }
- {
- const struct TALER_Amount *initial;
+ const struct TALER_ReservePublicKeyP *reserve_pub;
- if (GNUNET_OK !=
- TALER_TESTING_get_trait_amount (reserve_cmd,
- &initial))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not fetch reserve initial balance\n");
- TALER_TESTING_interpreter_fail (grs->is);
- return;
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_reserve_pub (reserve_cmd,
+ &reserve_pub))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not fetch reserve public key\n");
+ TALER_TESTING_interpreter_fail (grs->is);
+ return;
+ }
+ if (0 != GNUNET_memcmp (&reserve->reserve_pub,
+ reserve_pub))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Reserve public key does not match, got %s\n",
+ TALER_B2S (&reserve->reserve_pub));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Reserve public key does not match, expected %s\n",
+ TALER_B2S (reserve_pub));
+ match = false;
+ }
}
- if ((GNUNET_OK !=
- TALER_amount_cmp_currency (&reserves[i].merchant_initial_amount,
- initial)) ||
- (0 != TALER_amount_cmp (&reserves[i].merchant_initial_amount,
- initial)))
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Reserve initial amount does not match, got %s\n",
- TALER_amount2s (&reserves[i].merchant_initial_amount));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Reserve initial amount does not match, wanted %s\n",
- TALER_amount2s (initial));
- match = false;
+ const struct TALER_Amount *initial;
+
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_amount (reserve_cmd,
+ &initial))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not fetch reserve initial balance\n");
+ TALER_TESTING_interpreter_fail (grs->is);
+ return;
+ }
+ if ((GNUNET_OK !=
+ TALER_amount_cmp_currency (
+ &reserve->merchant_initial_amount,
+ initial)) ||
+ (0 != TALER_amount_cmp (&reserve->merchant_initial_amount,
+ initial)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Reserve initial amount does not match, got %s\n",
+ TALER_amount2s (
+ &reserve->merchant_initial_amount));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Reserve initial amount does not match, wanted %s\n",
+ TALER_amount2s (initial));
+ match = false;
+ }
}
+ if (match)
+ matched[i] = true;
}
- if (match)
- matched[i] = true;
}
- for (unsigned int i = 0; i < reserves_length; ++i)
- if (! matched[i])
- fail = true;
- if (fail)
- {
- TALER_TESTING_interpreter_fail (grs->is);
- return;
+ for (unsigned int i = 0; i < rgr->details.ok.reserves_length; ++i)
+ if (! matched[i])
+ fail = true;
+ if (fail)
+ {
+ TALER_TESTING_interpreter_fail (grs->is);
+ return;
+ }
+ break;
}
- break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unhandled HTTP status.\n");
+ "Unhandled HTTP status %u.\n",
+ rgr->hr.http_status);
+ break;
}
TALER_TESTING_interpreter_next (grs->is);
}
diff --git a/src/testing/testing_api_cmd_tip_authorize.c b/src/testing/testing_api_cmd_tip_authorize.c
index 3d6893d9..07f98411 100644
--- a/src/testing/testing_api_cmd_tip_authorize.c
+++ b/src/testing/testing_api_cmd_tip_authorize.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2020 Taler Systems SA
+ Copyright (C) 2014-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -126,24 +126,18 @@ do_retry (void *cls);
* tip_expiration).
*
* @param cls closure
- * @param hr HTTP response we got
- * @param tip_id unique identifier for the tip
- * @param taler_tip_uri URI to let the wallet know about the tip
- * @param expiration when the tip expires
+ * @param tar response we got
*/
static void
tip_authorize_cb (void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- struct TALER_TipIdentifierP *tip_id,
- const char *taler_tip_uri,
- struct GNUNET_TIME_Timestamp expiration)
+ const struct TALER_MERCHANT_TipAuthorizeResponse *tar)
{
struct TipAuthorizeState *tas = cls;
tas->tao = NULL;
- if (tas->http_status != hr->http_status)
+ if (tas->http_status != tar->hr.http_status)
{
- if ( (MHD_HTTP_NOT_FOUND == hr->http_status) &&
+ if ( (MHD_HTTP_NOT_FOUND == tar->hr.http_status) &&
(0 < tas->retries_left) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -160,29 +154,29 @@ tip_authorize_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u (%d) to command %s\n",
- hr->http_status,
- hr->ec,
+ tar->hr.http_status,
+ tar->hr.ec,
TALER_TESTING_interpreter_get_current_label (tas->is));
TALER_TESTING_interpreter_fail (tas->is);
return;
}
- if (tas->expected_ec != hr->ec)
+ if (tas->expected_ec != tar->hr.ec)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected error code %d (%u) to command %s\n",
- (int) hr->ec,
- hr->http_status,
+ (int) tar->hr.ec,
+ tar->hr.http_status,
TALER_TESTING_interpreter_get_current_label (tas->is));
TALER_TESTING_interpreter_fail (tas->is);
return;
}
- if ( (MHD_HTTP_OK == hr->http_status) &&
- (TALER_EC_NONE == hr->ec) )
+ if ( (MHD_HTTP_OK == tar->hr.http_status) &&
+ (TALER_EC_NONE == tar->hr.ec) )
{
- tas->tip_uri = strdup (taler_tip_uri);
- tas->tip_id = *tip_id;
- tas->tip_expiration = expiration;
+ tas->tip_uri = GNUNET_strdup (tar->details.ok.tip_uri);
+ tas->tip_id = tar->details.ok.tip_id;
+ tas->tip_expiration = tar->details.ok.tip_expiration;
}
TALER_TESTING_interpreter_next (tas->is);
}