diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_post-orders-ID-refund.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_post-orders-ID-refund.c | 88 |
1 files changed, 36 insertions, 52 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c index 40c89712..134cd2ee 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c @@ -28,7 +28,6 @@ #include <taler/taler_json_lib.h> #include <taler/taler_exchange_service.h> #include "taler-merchant-httpd.h" -#include "taler-merchant-httpd_auditors.h" #include "taler-merchant-httpd_exchanges.h" #include "taler-merchant-httpd_post-orders-ID-refund.h" @@ -52,7 +51,7 @@ struct CoinRefund /** * Request to connect to the target exchange. */ - struct TMH_EXCHANGES_FindOperation *fo; + struct TMH_EXCHANGES_KeysOperation *fo; /** * Handle for the refund operation with the exchange. @@ -279,7 +278,7 @@ refund_cleanup (void *ctx) GNUNET_free (cr->exchange_url); if (NULL != cr->fo) { - TMH_EXCHANGES_find_exchange_cancel (cr->fo); + TMH_EXCHANGES_keys4exchange_cancel (cr->fo); cr->fo = NULL; } if (NULL != cr->rh) @@ -386,17 +385,14 @@ notify_refund_obtained (struct PostRefundData *prd) * refund request to an exchange. * * @param cls a `struct CoinRefund` - * @param hr HTTP response data - * @param exchange_pub exchange key used to sign refund confirmation - * @param exchange_sig exchange's signature over refund + * @param rr response data */ static void refund_cb (void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr, - const struct TALER_ExchangePublicKeyP *exchange_pub, - const struct TALER_ExchangeSignatureP *exchange_sig) + const struct TALER_EXCHANGE_RefundResponse *rr) { struct CoinRefund *cr = cls; + const struct TALER_EXCHANGE_HttpResponse *hr = &rr->hr; cr->rh = NULL; cr->exchange_status = hr->http_status; @@ -413,12 +409,12 @@ refund_cb (void *cls, { enum GNUNET_DB_QueryStatus qs; - cr->exchange_pub = *exchange_pub; - cr->exchange_sig = *exchange_sig; + cr->exchange_pub = rr->details.ok.exchange_pub; + cr->exchange_sig = rr->details.ok.exchange_sig; qs = TMH_db->insert_refund_proof (TMH_db->cls, cr->refund_serial, - exchange_sig, - exchange_pub); + &rr->details.ok.exchange_sig, + &rr->details.ok.exchange_pub); if (0 >= qs) { /* generally, this is relatively harmless for the merchant, but let's at @@ -437,53 +433,42 @@ refund_cb (void *cls, /** - * Function called with the result of a #TMH_EXCHANGES_find_exchange() + * Function called with the result of a + * #TMH_EXCHANGES_keys4exchange() * operation. * * @param cls a `struct CoinRefund *` - * @param hr HTTP response details - * @param eh handle to the exchange context - * @param payto_uri payto://-URI of the exchange - * @param wire_fee current applicable wire fee for dealing with @a eh, NULL if not available - * @param exchange_trusted true if this exchange is trusted by config + * @param keys keys of exchange, NULL on error + * @param exchange representation of the exchange */ static void exchange_found_cb (void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr, - struct TALER_EXCHANGE_Handle *eh, - const char *payto_uri, - const struct TALER_Amount *wire_fee, - bool exchange_trusted) + struct TALER_EXCHANGE_Keys *keys, + struct TMH_Exchange *exchange) { struct CoinRefund *cr = cls; struct PostRefundData *prd = cr->prd; - (void) payto_uri; - (void) wire_fee; - (void) exchange_trusted; + (void) exchange; cr->fo = NULL; - if (NULL == hr) + if (NULL == keys) { prd->http_status = MHD_HTTP_GATEWAY_TIMEOUT; prd->ec = TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT; check_resume_prd (prd); return; } - if (NULL == eh) - { - prd->http_status = MHD_HTTP_BAD_GATEWAY; - prd->ec = TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE; - check_resume_prd (prd); - return; - } - cr->rh = TALER_EXCHANGE_refund (eh, - &cr->refund_amount, - &prd->h_contract_terms, - &cr->coin_pub, - cr->rtransaction_id, - &prd->hc->instance->merchant_priv, - &refund_cb, - cr); + cr->rh = TALER_EXCHANGE_refund ( + TMH_curl_ctx, + cr->exchange_url, + keys, + &cr->refund_amount, + &prd->h_contract_terms, + &cr->coin_pub, + cr->rtransaction_id, + &prd->hc->instance->merchant_priv, + &refund_cb, + cr); } @@ -580,7 +565,8 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, enum GNUNET_GenericReturnValue res; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_fixed_auto ("h_contract", &prd->h_contract_terms), + GNUNET_JSON_spec_fixed_auto ("h_contract", + &prd->h_contract_terms), GNUNET_JSON_spec_end () }; res = TALER_MHD_parse_json_data (connection, @@ -596,14 +582,12 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, { json_t *contract_terms; uint64_t order_serial; - bool paid; qs = TMH_db->lookup_contract_terms (TMH_db->cls, hc->instance->settings.id, hc->infix, &contract_terms, &order_serial, - &paid, NULL); if (0 > qs) { @@ -667,7 +651,7 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, { if (NULL != cr->fo) { - TMH_EXCHANGES_find_exchange_cancel (cr->fo); + TMH_EXCHANGES_keys4exchange_cancel (cr->fo); cr->fo = NULL; } if (NULL != cr->rh) @@ -683,8 +667,9 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, } { - GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TMH_currency, - &prd->refund_amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TMH_currency, + &prd->refund_amount)); qs = TMH_db->lookup_refunds_detailed (TMH_db->cls, hc->instance->settings.id, &prd->h_contract_terms, @@ -724,9 +709,8 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, if (NULL == cr->exchange_reply) { /* We need to talk to the exchange */ - cr->fo = TMH_EXCHANGES_find_exchange (cr->exchange_url, - NULL, - GNUNET_NO, + cr->fo = TMH_EXCHANGES_keys4exchange (cr->exchange_url, + false, &exchange_found_cb, cr); } |