diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-08-30 13:45:00 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-08-30 13:45:00 +0200 |
commit | 5eab12fc24c3c4d1ef3879665ef3a87ba0d3f340 (patch) | |
tree | 97c803856f05b4af15da870f677d694226ed535c /src/lib | |
parent | 2a2a99d6e5463fe5a49fdd967caf36678df9d2e1 (diff) |
mobile-friendly tipping
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/merchant_api_tip_authorize.c | 16 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_tip.c | 30 |
2 files changed, 13 insertions, 33 deletions
diff --git a/src/lib/merchant_api_tip_authorize.c b/src/lib/merchant_api_tip_authorize.c index 88b499f9..d77041c7 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 6e1f5291..652bd95d 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; |