From 5ac448738dfe213bf27d89abe253455ce0a38acf Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 1 May 2020 19:22:32 +0200 Subject: fix status code --- src/testing/testing_api_cmd_refund.c | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'src/testing/testing_api_cmd_refund.c') diff --git a/src/testing/testing_api_cmd_refund.c b/src/testing/testing_api_cmd_refund.c index 47f5a060..c27311fb 100644 --- a/src/testing/testing_api_cmd_refund.c +++ b/src/testing/testing_api_cmd_refund.c @@ -43,11 +43,6 @@ struct RefundState */ const char *refund_amount; - /** - * Expected refund fee. - */ - const char *refund_fee; - /** * Reference to any command that can provide a coin to refund. */ @@ -133,7 +128,6 @@ refund_run (void *cls, struct TALER_CoinSpendPublicKeyP coin; const json_t *contract_terms; struct GNUNET_HashCode h_contract_terms; - struct TALER_Amount refund_fee; struct TALER_Amount refund_amount; const struct TALER_MerchantPrivateKeyP *merchant_priv; const struct TALER_TESTING_Command *coin_cmd; @@ -153,19 +147,6 @@ refund_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - if (GNUNET_OK != - TALER_string_to_amount (rs->refund_fee, - &refund_fee)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to parse amount `%s' at %u/%s\n", - rs->refund_fee, - is->ip, - cmd->label); - TALER_TESTING_interpreter_fail (is); - return; - } - coin_cmd = TALER_TESTING_interpreter_lookup_command (is, rs->coin_reference); if (NULL == coin_cmd) @@ -211,7 +192,6 @@ refund_run (void *cls, } rs->rh = TALER_EXCHANGE_refund (rs->exchange, &refund_amount, - &refund_fee, &h_contract_terms, &coin, rs->refund_transaction_id, @@ -254,7 +234,6 @@ refund_cleanup (void *cls, * @param label command label. * @param expected_response_code expected HTTP status code. * @param refund_amount the amount to ask a refund for. - * @param refund_fee expected refund fee. * @param coin_reference reference to a command that can * provide a coin to be refunded. * @@ -264,7 +243,6 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_refund (const char *label, unsigned int expected_response_code, const char *refund_amount, - const char *refund_fee, const char *coin_reference) { struct RefundState *rs; @@ -273,7 +251,6 @@ TALER_TESTING_cmd_refund (const char *label, rs->expected_response_code = expected_response_code; rs->refund_amount = refund_amount; - rs->refund_fee = refund_fee; rs->coin_reference = coin_reference; { struct TALER_TESTING_Command cmd = { @@ -295,7 +272,6 @@ TALER_TESTING_cmd_refund (const char *label, * @param label command label. * @param expected_response_code expected HTTP status code. * @param refund_amount the amount to ask a refund for. - * @param refund_fee expected refund fee. * @param coin_reference reference to a command that can * provide a coin to be refunded. * @param refund_transaction_id transaction id to use @@ -308,7 +284,6 @@ TALER_TESTING_cmd_refund_with_id (const char *label, unsigned int expected_response_code, const char *refund_amount, - const char *refund_fee, const char *coin_reference, uint64_t refund_transaction_id) { @@ -317,7 +292,6 @@ TALER_TESTING_cmd_refund_with_id rs = GNUNET_new (struct RefundState); rs->expected_response_code = expected_response_code; rs->refund_amount = refund_amount; - rs->refund_fee = refund_fee; rs->coin_reference = coin_reference; rs->refund_transaction_id = refund_transaction_id; { -- cgit v1.2.3 From 727b7b04f3ae23fd49da7479fe4b4258513aef83 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 5 May 2020 22:17:16 +0200 Subject: return fee as well --- src/include/taler_error_codes.h | 19 +++++++++++++++++++ src/include/taler_exchange_service.h | 2 ++ src/lib/exchange_api_refund.c | 4 +++- src/testing/testing_api_cmd_refund.c | 3 +++ 4 files changed, 27 insertions(+), 1 deletion(-) (limited to 'src/testing/testing_api_cmd_refund.c') diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h index f75464c3..74660303 100644 --- a/src/include/taler_error_codes.h +++ b/src/include/taler_error_codes.h @@ -2198,6 +2198,25 @@ enum TALER_ErrorCode */ TALER_EC_TIP_PICKUP_UNBLIND_FAILURE = 2812, + /** + * We failed to fetch contract terms from our merchant database. The + * response is provided with HTTP status code + * #MHD_HTTP_INTERNAL_SERVER_ERROR. + */ + TALER_EC_GET_ORDERS_DB_LOOKUP_ERROR = 2900, + + /** + * We failed to find the contract terms from our merchant database. + * The response is provided with HTTP status code #MHD_HTTP_NOT_FOUND. + */ + TALER_EC_GET_ORDERS_ID_UNKNOWN = 2901, + + /** + * The contract hash provided by the wallet does not match the order. + * The response is provided with HTTP status code #MHD_HTTP_FORBIDDEN. + */ + TALER_EC_GET_ORDERS_WRONG_CONTRACT = 2902, + /** * We failed to contract terms from our merchant database. The * response is provided with HTTP status code diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index f94b8253..82b9b83d 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -851,6 +851,7 @@ struct TALER_EXCHANGE_RefundHandle; * * @param cls closure * @param hr HTTP response data + * @param refund_fee the refund fee the exchange charged us * @param sign_key exchange key used to sign @a obj, or NULL * @param signature the actual signature, or NULL on error */ @@ -858,6 +859,7 @@ typedef void (*TALER_EXCHANGE_RefundCallback) ( void *cls, const struct TALER_EXCHANGE_HttpResponse *hr, + const struct TALER_Amount *refund_fee, const struct TALER_ExchangePublicKeyP *sign_key, const struct TALER_ExchangeSignatureP *signature); diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index 9cb8794d..b1ea176b 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c @@ -92,7 +92,6 @@ verify_refund_signature_ok (struct TALER_EXCHANGE_RefundHandle *rh, const json_t *json, struct TALER_ExchangePublicKeyP *exchange_pub, struct TALER_ExchangeSignatureP *exchange_sig) - { const struct TALER_EXCHANGE_Keys *key_state; struct GNUNET_JSON_Specification spec[] = { @@ -149,6 +148,7 @@ handle_refund_finished (void *cls, struct TALER_ExchangeSignatureP exchange_sig; struct TALER_ExchangePublicKeyP *ep = NULL; struct TALER_ExchangeSignatureP *es = NULL; + struct TALER_Amount *rf = NULL; const json_t *j = response; struct TALER_EXCHANGE_HttpResponse hr = { .reply = j, @@ -176,6 +176,7 @@ handle_refund_finished (void *cls, { ep = &exchange_pub; es = &exchange_sig; + rf = &rh->depconf.refund_fee; } break; case MHD_HTTP_BAD_REQUEST: @@ -234,6 +235,7 @@ handle_refund_finished (void *cls, } rh->cb (rh->cb_cls, &hr, + rf, ep, es); TALER_EXCHANGE_refund_cancel (rh); diff --git a/src/testing/testing_api_cmd_refund.c b/src/testing/testing_api_cmd_refund.c index c27311fb..e662ace2 100644 --- a/src/testing/testing_api_cmd_refund.c +++ b/src/testing/testing_api_cmd_refund.c @@ -76,6 +76,7 @@ struct RefundState * * @param cls closure * @param hr HTTP response details + * @param refund_fee the refund fee the exchange charged * @param exchange_pub public key the exchange * used for signing @a obj. * @param exchange_sig actual signature confirming the refund @@ -83,6 +84,7 @@ struct RefundState static void refund_cb (void *cls, const struct TALER_EXCHANGE_HttpResponse *hr, + const struct TALER_Amount *refund_fee, const struct TALER_ExchangePublicKeyP *exchange_pub, const struct TALER_ExchangeSignatureP *exchange_sig) { @@ -90,6 +92,7 @@ refund_cb (void *cls, struct RefundState *rs = cls; struct TALER_TESTING_Command *refund_cmd; + (void) refund_fee; refund_cmd = &rs->is->commands[rs->is->ip]; rs->rh = NULL; if (rs->expected_response_code != hr->http_status) -- cgit v1.2.3