merchant

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

commit 5bdbbd68c4e11a322fe5c1b92c5ccc962863dbb1
parent 26085c8712c509d1384d1de99fec1bc9d3d15386
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
Date:   Wed, 29 Jul 2020 21:38:21 -0400

revert to use pointers for claim token client lib

Diffstat:
Msrc/include/taler_merchant_service.h | 8++++----
Msrc/lib/merchant_api_post_order_claim.c | 6+++---
Msrc/lib/merchant_api_post_orders.c | 2+-
Msrc/testing/testing_api_cmd_claim_order.c | 6++----
Msrc/testing/testing_api_cmd_post_orders.c | 7++++---
5 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h @@ -1114,7 +1114,7 @@ struct TALER_MERCHANT_PostOrdersOperation; * @param cls closure * @param hr HTTP response details * @param order_id order id of the newly created order - * @param token the claim token generated by the merchant (zeroed if + * @param token the claim token generated by the merchant (NULL if * it wasn't generated). */ typedef void @@ -1122,7 +1122,7 @@ typedef void void *cls, const struct TALER_MERCHANT_HttpResponse *hr, const char *order_id, - struct TALER_ClaimTokenP token); + const struct TALER_ClaimTokenP *token); /** @@ -1814,7 +1814,7 @@ typedef void * @param backend_url base URL of the merchant backend * @param order_id order id used to perform the lookup * @param nonce nonce to use to claim the proposal - * @param claim_token the token used to verify the claim + * @param claim_token the token used to verify the claim (NULL for none) * @param cb callback which will work the response gotten from the backend * @param cb_cls closure to pass to @a cb * @return handle for this handle, NULL upon errors @@ -1824,7 +1824,7 @@ TALER_MERCHANT_order_claim (struct GNUNET_CURL_Context *ctx, const char *backend_url, const char *order_id, const struct GNUNET_CRYPTO_EddsaPublicKey *nonce, - const struct TALER_ClaimTokenP claim_token, + const struct TALER_ClaimTokenP *claim_token, TALER_MERCHANT_OrderClaimCallback cb, void *cb_cls); diff --git a/src/lib/merchant_api_post_order_claim.c b/src/lib/merchant_api_post_order_claim.c @@ -185,7 +185,7 @@ TALER_MERCHANT_order_claim (struct GNUNET_CURL_Context *ctx, const char *backend_url, const char *order_id, const struct GNUNET_CRYPTO_EddsaPublicKey *nonce, - const struct TALER_ClaimTokenP claim_token, + const struct TALER_ClaimTokenP *claim_token, TALER_MERCHANT_OrderClaimCallback cb, void *cb_cls) { @@ -200,12 +200,12 @@ TALER_MERCHANT_order_claim (struct GNUNET_CURL_Context *ctx, GNUNET_break (0); return NULL; } - if (0 != GNUNET_is_zero (&claim_token)) + if (NULL != claim_token) { GNUNET_assert (0 == json_object_set_new (req_obj, "token", - GNUNET_JSON_from_data_auto (&claim_token))); + GNUNET_JSON_from_data_auto (claim_token))); } och = GNUNET_new (struct TALER_MERCHANT_OrderClaimHandle); och->ctx = ctx; diff --git a/src/lib/merchant_api_post_orders.c b/src/lib/merchant_api_post_orders.c @@ -173,7 +173,7 @@ handle_post_order_finished (void *cls, po->cb (po->cb_cls, &hr, order_id, - token); + has_token ? &token : NULL); if (MHD_HTTP_OK == response_code) GNUNET_JSON_parse_free (spec); TALER_MERCHANT_orders_post_cancel (po); diff --git a/src/testing/testing_api_cmd_claim_order.c b/src/testing/testing_api_cmd_claim_order.c @@ -189,7 +189,7 @@ order_claim_run (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *nonce; /* Only used if we do NOT use the nonce/token from traits. */ struct GNUNET_CRYPTO_EddsaPublicKey dummy_nonce; - struct TALER_ClaimTokenP claim_token = {0}; + const struct TALER_ClaimTokenP *claim_token; pls->is = is; if (NULL != pls->order_id) @@ -203,7 +203,6 @@ order_claim_run (void *cls, else { const struct TALER_TESTING_Command *order_cmd; - const struct TALER_ClaimTokenP *ct; order_cmd = TALER_TESTING_interpreter_lookup_command (is, @@ -223,11 +222,10 @@ order_claim_run (void *cls, if (GNUNET_OK != TALER_TESTING_get_trait_claim_token (order_cmd, 0, - &ct)) + &claim_token)) { TALER_TESTING_FAIL (is); } - claim_token = *ct; if (GNUNET_OK != TALER_TESTING_get_trait_order_id (order_cmd, diff --git a/src/testing/testing_api_cmd_post_orders.c b/src/testing/testing_api_cmd_post_orders.c @@ -232,12 +232,13 @@ static void order_cb (void *cls, const struct TALER_MERCHANT_HttpResponse *hr, const char *order_id, - struct TALER_ClaimTokenP claim_token) + const struct TALER_ClaimTokenP *claim_token) { struct OrdersState *ps = cls; ps->po = NULL; - ps->claim_token = claim_token; + if (NULL != claim_token) + ps->claim_token = *claim_token; if (ps->http_status != hr->http_status) { TALER_LOG_ERROR ("Given vs expected: %u(%d) vs %u\n", @@ -287,7 +288,7 @@ order_cb (void *cls, ps->merchant_url, ps->order_id, &ps->nonce, - ps->claim_token, + &ps->claim_token, &orders_claim_cb, ps))) TALER_TESTING_FAIL (ps->is);