From f02a3a2055fc27a6a570d5d21af434b914881e01 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 13 Oct 2021 18:53:16 +0200 Subject: -migrate logic to match latest C API changes from the exchange --- .../taler-merchant-httpd_private-get-orders-ID.c | 129 +++++++++++---------- 1 file changed, 65 insertions(+), 64 deletions(-) (limited to 'src/backend/taler-merchant-httpd_private-get-orders-ID.c') diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c index b272e4c0..a981a7cf 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -424,8 +424,7 @@ exchange_timeout_cb (void *cls) */ static void deposit_get_cb (void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr, - const struct TALER_EXCHANGE_DepositData *dd) + const struct TALER_EXCHANGE_GetDepositResponse *dr) { struct TransferQuery *tq = cls; struct GetOrderRequestContext *gorc = tq->gorc; @@ -433,65 +432,75 @@ deposit_get_cb (void *cls, GNUNET_CONTAINER_DLL_remove (gorc->tq_head, gorc->tq_tail, tq); - if (NULL == dd) + switch (dr->hr.http_status) { - gorc_report (gorc, - TALER_EC_MERCHANT_GET_ORDERS_EXCHANGE_TRACKING_FAILURE, - &tq->coin_pub, - hr); - GNUNET_free (tq); - if (NULL == gorc->tq_head) - gorc_resume (gorc, - 0, - TALER_EC_NONE); - return; - } - else if (MHD_HTTP_OK == hr->http_status) - { - enum GNUNET_DB_QueryStatus qs; - - qs = TMH_db->insert_deposit_to_transfer (TMH_db->cls, - tq->deposit_serial, - dd); - if (qs < 0) + case MHD_HTTP_OK: { - gorc_report (gorc, - TALER_EC_GENERIC_DB_STORE_FAILED, - &tq->coin_pub, - NULL); - GNUNET_free (tq); - if (NULL == gorc->tq_head) - gorc_resume (gorc, - 0, - TALER_EC_NONE); - return; - } - /* Compute total amount *wired* */ - if (0 > - TALER_amount_add (&gorc->deposits_total, - &gorc->deposits_total, - &dd->coin_contribution)) - { - gorc_report (gorc, - TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_ID_AMOUNT_ARITHMETIC_FAILURE, - &tq->coin_pub, - NULL); - GNUNET_free (tq); - if (NULL == gorc->tq_head) - gorc_resume (gorc, - 0, - TALER_EC_NONE); - return; + enum GNUNET_DB_QueryStatus qs; + + qs = TMH_db->insert_deposit_to_transfer (TMH_db->cls, + tq->deposit_serial, + &dr->details.success); + if (qs < 0) + { + gorc_report (gorc, + TALER_EC_GENERIC_DB_STORE_FAILED, + &tq->coin_pub, + NULL); + GNUNET_free (tq); + if (NULL == gorc->tq_head) + gorc_resume (gorc, + 0, + TALER_EC_NONE); + return; + } + /* Compute total amount *wired* */ + if (0 > + TALER_amount_add (&gorc->deposits_total, + &gorc->deposits_total, + &dr->details.success.coin_contribution)) + { + gorc_report (gorc, + TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_ID_AMOUNT_ARITHMETIC_FAILURE, + &tq->coin_pub, + NULL); + GNUNET_free (tq); + if (NULL == gorc->tq_head) + gorc_resume (gorc, + 0, + TALER_EC_NONE); + return; + } + if (0 > + TALER_amount_add (&gorc->deposit_fees_total, + &gorc->deposit_fees_total, + &tq->deposit_fee)) + { + gorc_report (gorc, + TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_ID_AMOUNT_ARITHMETIC_FAILURE, + &tq->coin_pub, + NULL); + GNUNET_free (tq); + if (NULL == gorc->tq_head) + gorc_resume (gorc, + 0, + TALER_EC_NONE); + return; + } } - if (0 > - TALER_amount_add (&gorc->deposit_fees_total, - &gorc->deposit_fees_total, - &tq->deposit_fee)) + case MHD_HTTP_ACCEPTED: + /* got a 'preliminary' reply from the exchange, simply skip */ + // FIXME: store dr->details.accepted.payment_target_uuid! + gorc_report (gorc, + TALER_EC_NONE, + &tq->coin_pub, + &dr->hr); + default: { gorc_report (gorc, - TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_ID_AMOUNT_ARITHMETIC_FAILURE, + TALER_EC_MERCHANT_GET_ORDERS_EXCHANGE_TRACKING_FAILURE, &tq->coin_pub, - NULL); + &dr->hr); GNUNET_free (tq); if (NULL == gorc->tq_head) gorc_resume (gorc, @@ -499,15 +508,7 @@ deposit_get_cb (void *cls, TALER_EC_NONE); return; } - } - else - { - /* got a 'preliminary' reply from the exchange, simply skip */ - gorc_report (gorc, - TALER_EC_NONE, - &tq->coin_pub, - hr); - } + } /* end switch */ GNUNET_free (tq); if (NULL != gorc->tq_head) return; -- cgit v1.2.3