From 2ba0fedd391988610d6d18d9e5b61ac00c9f663e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 5 May 2020 22:17:07 +0200 Subject: updates --- src/backend/taler-merchant-httpd_get-orders-ID.c | 10 ++ .../taler-merchant-httpd_post-orders-ID-abort.c | 3 + .../taler-merchant-httpd_private-post-transfers.c | 106 ++++++++++----------- .../taler-merchant-httpd_private-post-transfers.h | 26 ++--- 4 files changed, 76 insertions(+), 69 deletions(-) (limited to 'src/backend') diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c index 0fae0a98..f22ac8a3 100644 --- a/src/backend/taler-merchant-httpd_get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_get-orders-ID.c @@ -74,6 +74,12 @@ struct CoinRefund */ json_t *exchange_reply; + /** + * When did the merchant grant the refund. To be used to group events + * in the wallet. + */ + struct GNUNET_TIME_Absolute execution_time; + /** * Coin to refund. */ @@ -435,12 +441,14 @@ check_resume_god (struct GetOrderData *god) * * @param cls a `struct CoinRefund` * @param hr HTTP response data + * @param refund_fee fee the exchange charged * @param exchange_pub exchange key used to sign refund confirmation * @param exchange_sig exchange's signature over refund */ 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) { @@ -465,6 +473,7 @@ refund_cb (void *cls, cr->exchange_sig = *exchange_sig; qs = TMH_db->insert_refund_proof (TMH_db->cls, cr->refund_serial, + refund_fee, exchange_sig, exchange_pub); if (0 >= qs) @@ -557,6 +566,7 @@ process_refunds_cb (void *cls, cr->coin_pub = *coin_pub; cr->rtransaction_id = rtransaction_id; cr->refund_amount = *refund_amount; + cr->execution_time = timestamp; GNUNET_CONTAINER_DLL_insert (god->cr_head, god->cr_tail, cr); diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c index 4c7960ef..564f0e3c 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c @@ -438,12 +438,14 @@ find_next_exchange (struct AbortContext *ac); * * @param cls closure * @param hr HTTP response data + * @param refund_fee fee the exchange charged * @param sign_key exchange key used to sign @a obj, or NULL * @param signature the actual signature, or NULL on error */ static void refund_cb (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) { @@ -452,6 +454,7 @@ refund_cb (void *cls, (void) sign_key; (void) signature; + (void) refund_fee; rd->rh = NULL; rd->http_status = hr->http_status; rd->exchange_reply = json_incref ((json_t*) hr->reply); diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c b/src/backend/taler-merchant-httpd_private-post-transfers.c index 6304761f..ce76a6f2 100644 --- a/src/backend/taler-merchant-httpd_private-post-transfers.c +++ b/src/backend/taler-merchant-httpd_private-post-transfers.c @@ -258,12 +258,12 @@ build_deposits_response (void *cls, json_t *contract_terms; json_t *order_id; - db->preflight (db->cls); + TMH_db->preflight (TMH_db->cls); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - db->find_contract_terms_from_hash (db->cls, - &contract_terms, - key, - &rctx->mi->pubkey)) + TMH_db->find_contract_terms_from_hash (TMH_db->cls, + &contract_terms, + key, + &rctx->mi->pubkey)) { GNUNET_break_op (0); return GNUNET_NO; @@ -541,16 +541,16 @@ check_wire_fee (struct TrackTransferContext *rctx, char *wire_method; wire_method = TALER_payto_get_method (rctx->payto_uri); - db->preflight (db->cls); - qs = db->lookup_wire_fee (db->cls, - &rctx->master_pub, - wire_method, - execution_time, - &expected_fee, - &closing_fee, - &start_date, - &end_date, - &master_sig); + TMH_db->preflight (TMH_db->cls); + qs = TMH_db->lookup_wire_fee (TMH_db->cls, + &rctx->master_pub, + wire_method, + execution_time, + &expected_fee, + &closing_fee, + &start_date, + &end_date, + &master_sig); if (0 >= qs) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -636,16 +636,16 @@ wire_transfer_cb (void *cls, "exchange_reply", hr->reply)); return; } - db->preflight (db->cls); - qs = db->insert_transfer_details (db->cls, - rctx->exchange_url, - rctx->payto_uri, - &rctx->wtid, - total_amount, - wire_fee, - execution_time, - details_length, - details); + TMH_db->preflight (TMH_db->cls); + qs = TMH_db->insert_transfer_details (TMH_db->cls, + rctx->exchange_url, + rctx->payto_uri, + &rctx->wtid, + total_amount, + wire_fee, + execution_time, + details_length, + details); if (0 > qs) { /* Special report if retries insufficient */ @@ -685,13 +685,13 @@ wire_transfer_cb (void *cls, rctx->current_detail = &details[i]; /* Set the coin as "never seen" before. */ rctx->check_transfer_result = GNUNET_NO; - db->preflight (db->cls); - qs = db->find_payments_by_hash_and_coin (db->cls, - &details[i].h_contract_terms, - &rctx->mi->pubkey, - &details[i].coin_pub, - &check_transfer, - rctx); + TMH_db->preflight (TMH_db->cls); + qs = TMH_db->find_payments_by_hash_and_coin (TMH_db->cls, + &details[i].h_contract_terms, + &rctx->mi->pubkey, + &details[i].coin_pub, + &check_transfer, + rctx); if (0 > qs) { /* single, read-only SQL statements should never cause @@ -752,11 +752,11 @@ wire_transfer_cb (void *cls, remember it for future reference */ for (unsigned int r = 0; rpreflight (db->cls); - qs = db->store_coin_to_transfer (db->cls, - &details[i].h_contract_terms, - &details[i].coin_pub, - &rctx->wtid); + TMH_db->preflight (TMH_db->cls); + qs = TMH_db->store_coin_to_transfer (TMH_db->cls, + &details[i].h_contract_terms, + &details[i].coin_pub, + &rctx->wtid); if (GNUNET_DB_STATUS_SOFT_ERROR != qs) break; } @@ -918,7 +918,7 @@ handle_track_transfer_timeout (void *cls) /** - * Manages a POST /private/transfers call. It calls the /track/wtid + * Manages a POST /private/transfers call. It calls the GET /transfers/$WTID * offered by the exchange in order to obtain the set of transfers * (of coins) associated with a given wire transfer. * @@ -1015,16 +1015,16 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, deposit_sums = json_array (); GNUNET_assert (NULL != deposit_sums); - db->preflight (db->cls); - qs = db->lookup_transfer_details (db->cls, - rctx->exchange_url, - rctx->payto_uri, - &rctx->wtid, - &total_amount, - &wire_fee, - &execution_time, - &transfer_details_cb, - deposit_sums); + TMH_db->preflight (TMH_db->cls); + qs = TMH_db->lookup_transfer_details (TMH_db->cls, + rctx->exchange_url, + rctx->payto_uri, + &rctx->wtid, + &total_amount, + &wire_fee, + &execution_time, + &transfer_details_cb, + deposit_sums); if (0 > qs) { /* Simple select queries should not cause serialization issues */ @@ -1053,11 +1053,11 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, /* reply not in database, ensure the POST is in the database, and start work to obtain the reply from the exchange */ - qs = db->insert_transfer (db->cls, - rctx->exchange_url, - &rctx->wtid, - &rctx->amount, - rctx->payto_uri); + qs = TMH_db->insert_transfer (TMH_db->cls, + rctx->exchange_url, + &rctx->wtid, + &rctx->amount, + rctx->payto_uri); if (0 > qs) { /* Simple select queries should not cause serialization issues */ diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.h b/src/backend/taler-merchant-httpd_private-post-transfers.h index 0463295e..2c548f77 100644 --- a/src/backend/taler-merchant-httpd_private-post-transfers.h +++ b/src/backend/taler-merchant-httpd_private-post-transfers.h @@ -14,36 +14,30 @@ TALER; see the file COPYING. If not, see */ /** - * @file backend/taler-merchant-httpd_track-transfer.h + * @file backend/taler-merchant-httpd_private-post-transfers.h * @brief headers for /track/transfer handler * @author Christian Grothoff * @author Marcello Stanisci */ -#ifndef TALER_MERCHANT_HTTPD_TRACK_TRANSFER_H -#define TALER_MERCHANT_HTTPD_TRACK_TRANSFER_H +#ifndef TALER_MERCHANT_HTTPD_PRIVATE_POST_TRANSFERS_H +#define TALER_MERCHANT_HTTPD_PRIVATE_POST_TRANSFERS_H #include #include "taler-merchant-httpd.h" /** - * Manages a /track/transfer call, thus it calls the /wire/transfer - * offered by the exchange in order to return the set of transfers - * (of coins) associated with a given wire transfer + * Manages a POST /private/transfers call. It calls the GET /transfers/$WTID + * offered by the exchange in order to obtain the set of transfers + * (of coins) associated with a given wire transfer. * * @param rh context of the handler * @param connection the MHD connection to handle - * @param[in,out] connection_cls the connection's closure (can be updated) - * @param upload_data upload data - * @param[in,out] upload_data_size number of bytes (left) in @a upload_data - * @param mi merchant backend instance, never NULL + * @param[in,out] hc context with further information about the request * @return MHD result code */ MHD_RESULT -MH_handler_track_transfer (struct TMH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - struct MerchantInstance *mi); +TMH_private_post_transfers (const struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + struct TMH_HandlerContext *hc); #endif -- cgit v1.2.3