merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 990f4d4d5192506aa4a5f6510449e0aa79a2e61f
parent 4089ebeec60159c438c0da04115f416d314713ef
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 31 May 2020 19:26:14 +0200

fix misc issues in client APIs

Diffstat:
Msrc/lib/merchant_api_tip_authorize.c | 8++++----
Msrc/lib/merchant_api_tip_pickup2.c | 27+++++++++++++++++++--------
Msrc/lib/merchant_api_tip_query.c | 39++++++++++++++++++++++++++++-----------
3 files changed, 51 insertions(+), 23 deletions(-)

diff --git a/src/lib/merchant_api_tip_authorize.c b/src/lib/merchant_api_tip_authorize.c @@ -239,8 +239,8 @@ TALER_MERCHANT_tip_authorize2 ( tao->cb_cls = authorize_cb_cls; { - char res_str[sizeof (struct GNUNET_HashCode) * 2]; - char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32]; + char res_str[sizeof (*reserve_pub) * 2]; + char arg_str[sizeof (res_str) + 48]; char *end; end = GNUNET_STRINGS_data_to_string (reserve_pub, @@ -250,7 +250,7 @@ TALER_MERCHANT_tip_authorize2 ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/reserves/%s/tip-authorize", + "/private/reserves/%s/tip-authorize", res_str); tao->url = TALER_url_join (backend_url, arg_str, @@ -341,7 +341,7 @@ TALER_MERCHANT_tip_authorize (struct GNUNET_CURL_Context *ctx, tao->cb_cls = authorize_cb_cls; tao->url = TALER_url_join (backend_url, - "/tips", + "/private/tips", NULL); if (NULL == tao->url) { diff --git a/src/lib/merchant_api_tip_pickup2.c b/src/lib/merchant_api_tip_pickup2.c @@ -283,11 +283,7 @@ TALER_MERCHANT_tip_pickup2 (struct GNUNET_CURL_Context *ctx, return NULL; } } - tp_obj = json_pack ("{" - " s:o," /* tip_id */ - " s:o," /* planchets */ - "}", - "tip_id", GNUNET_JSON_from_data_auto (tip_id), + tp_obj = json_pack ("{s:o}", "planchets", pa); if (NULL == tp_obj) { @@ -300,9 +296,24 @@ TALER_MERCHANT_tip_pickup2 (struct GNUNET_CURL_Context *ctx, tpo->cb = pickup_cb; tpo->cb_cls = pickup_cb_cls; - tpo->url = TALER_url_join (backend_url, - "tip-pickup", - NULL); + { + char tip_str[sizeof (*tip_id) * 2]; + char arg_str[sizeof (tip_str) + 32]; + char *end; + + end = GNUNET_STRINGS_data_to_string (tip_id, + sizeof (*tip_id), + tip_str, + sizeof (tip_str)); + *end = '\0'; + GNUNET_snprintf (arg_str, + sizeof (arg_str), + "/tips/%s/pickup", + tip_str); + tpo->url = TALER_url_join (backend_url, + arg_str, + NULL); + } if (NULL == tpo->url) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/lib/merchant_api_tip_query.c b/src/lib/merchant_api_tip_query.c @@ -16,7 +16,7 @@ */ /** * @file lib/merchant_api_tip_query.c => FIXME: rename! - * @brief Implementation of the /tip-query request of the merchant's HTTP API + * @brief Implementation of the GET /tips/$TIP_ID request of the merchant's HTTP API * @author Florian Dold */ #include "platform.h" @@ -92,15 +92,16 @@ handle_tip_get_finished (void *cls, { case MHD_HTTP_OK: { - struct GNUNET_TIME_Absolute reserve_expiration; const char *exchange_url; struct TALER_Amount amount_remaining; - struct TALER_ReservePublicKeyP reserve_pub; + struct GNUNET_TIME_Absolute expiration; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_fixed_auto ("reserve_pub", &reserve_pub), + GNUNET_JSON_spec_absolute_time ("expiration", + &expiration), GNUNET_JSON_spec_string ("exchange_url", &exchange_url), - TALER_JSON_spec_amount ("amount_remaining", &amount_remaining), + TALER_JSON_spec_amount ("tip_amount", + &amount_remaining), GNUNET_JSON_spec_end () }; @@ -116,7 +117,7 @@ handle_tip_get_finished (void *cls, } tqo->cb (tqo->cb_cls, &hr, - reserve_expiration, + expiration, exchange_url, &amount_remaining); TALER_MERCHANT_tip_get_cancel (tqo); @@ -155,7 +156,7 @@ handle_tip_get_finished (void *cls, /** - * Issue a /tip-get request to the backend. Informs the backend + * Issue a GET /tips/$TIP_ID request to the backend. Informs the backend * that a customer wants to pick up a tip. * * @param ctx execution context @@ -179,9 +180,25 @@ TALER_MERCHANT_tip_get (struct GNUNET_CURL_Context *ctx, tqo->ctx = ctx; tqo->cb = cb; tqo->cb_cls = cb_cls; - tqo->url = TALER_url_join (backend_url, - "tip-get", - NULL); + { + char res_str[sizeof (*tip_id) * 2]; + char arg_str[sizeof (res_str) + 48]; + char *end; + + end = GNUNET_STRINGS_data_to_string (tip_id, + sizeof (*tip_id), + res_str, + sizeof (res_str)); + *end = '\0'; + GNUNET_snprintf (arg_str, + sizeof (arg_str), + "/tips/%s", + res_str); + tqo->url = TALER_url_join (backend_url, + arg_str, + NULL); + } + if (NULL == tqo->url) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -210,7 +227,7 @@ TALER_MERCHANT_tip_get (struct GNUNET_CURL_Context *ctx, /** - * Cancel a /tip-get request. This function cannot be used + * Cancel a GET /tips/$TIP_ID request. This function cannot be used * on a request handle if a response is already served for it. * * @param tqo handle to the operation being cancelled