summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_private-get-orders-ID.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-10-13 18:53:16 +0200
committerChristian Grothoff <christian@grothoff.org>2021-10-13 18:53:16 +0200
commitf02a3a2055fc27a6a570d5d21af434b914881e01 (patch)
tree949d7f46d49b16ca367534059415daf8144178d5 /src/backend/taler-merchant-httpd_private-get-orders-ID.c
parent9d7abac6af174ac232096b63caa167df4fe348d2 (diff)
downloadmerchant-f02a3a2055fc27a6a570d5d21af434b914881e01.tar.gz
merchant-f02a3a2055fc27a6a570d5d21af434b914881e01.tar.bz2
merchant-f02a3a2055fc27a6a570d5d21af434b914881e01.zip
-migrate logic to match latest C API changes from the exchange
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-get-orders-ID.c')
-rw-r--r--src/backend/taler-merchant-httpd_private-get-orders-ID.c129
1 files changed, 65 insertions, 64 deletions
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;