aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_private-get-orders-ID.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-10-20 18:35:18 +0200
committerChristian Grothoff <christian@grothoff.org>2021-10-20 18:35:18 +0200
commit14c5d00ebd98fdb299fa16c9721588d55f8d3b35 (patch)
treec3954151b57234e84732e8cbda25eecc07ccb125 /src/backend/taler-merchant-httpd_private-get-orders-ID.c
parentf523d7c7fea88905b347aadf795aea27973a275e (diff)
add KYC handling to get-orders handler
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.c63
1 files changed, 57 insertions, 6 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 a981a7cf..c2fe759f 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -61,6 +61,11 @@ struct TransferQuery
struct TransferQuery *prev;
/**
+ * Base URL of the exchange.
+ */
+ char *exchange_url;
+
+ /**
* Handle to query exchange about deposit status.
*/
struct TALER_EXCHANGE_DepositGetHandle *dgh;
@@ -447,6 +452,7 @@ deposit_get_cb (void *cls,
TALER_EC_GENERIC_DB_STORE_FAILED,
&tq->coin_pub,
NULL);
+ GNUNET_free (tq->exchange_url);
GNUNET_free (tq);
if (NULL == gorc->tq_head)
gorc_resume (gorc,
@@ -464,6 +470,7 @@ deposit_get_cb (void *cls,
TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_ID_AMOUNT_ARITHMETIC_FAILURE,
&tq->coin_pub,
NULL);
+ GNUNET_free (tq->exchange_url);
GNUNET_free (tq);
if (NULL == gorc->tq_head)
gorc_resume (gorc,
@@ -480,6 +487,7 @@ deposit_get_cb (void *cls,
TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_ID_AMOUNT_ARITHMETIC_FAILURE,
&tq->coin_pub,
NULL);
+ GNUNET_free (tq->exchange_url);
GNUNET_free (tq);
if (NULL == gorc->tq_head)
gorc_resume (gorc,
@@ -489,18 +497,56 @@ deposit_get_cb (void *cls,
}
}
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);
+ {
+ /* got a 'preliminary' reply from the exchange,
+ remember our target UUID */
+ enum GNUNET_DB_QueryStatus qs;
+ struct GNUNET_TIME_Absolute now;
+ struct GNUNET_HashCode h_wire;
+
+ now = GNUNET_TIME_absolute_get ();
+ (void) GNUNET_TIME_round_abs (&now);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_JSON_merchant_wire_signature_hash (
+ gorc->wire_details,
+ &h_wire));
+ qs = TMH_db->account_kyc_set_status (
+ TMH_db->cls,
+ gorc->hc->instance->settings.id,
+ &h_wire,
+ tq->exchange_url,
+ dr->details.accepted.payment_target_uuid,
+ NULL,
+ NULL,
+ now,
+ false);
+ if (qs < 0)
+ {
+ gorc_report (gorc,
+ TALER_EC_GENERIC_DB_STORE_FAILED,
+ &tq->coin_pub,
+ NULL);
+ GNUNET_free (tq->exchange_url);
+ GNUNET_free (tq);
+ if (NULL == gorc->tq_head)
+ gorc_resume (gorc,
+ 0,
+ TALER_EC_NONE);
+ return;
+ }
+ gorc_report (gorc,
+ TALER_EC_NONE,
+ &tq->coin_pub,
+ &dr->hr);
+ break;
+ }
default:
{
gorc_report (gorc,
TALER_EC_MERCHANT_GET_ORDERS_EXCHANGE_TRACKING_FAILURE,
&tq->coin_pub,
&dr->hr);
+ GNUNET_free (tq->exchange_url);
GNUNET_free (tq);
if (NULL == gorc->tq_head)
gorc_resume (gorc,
@@ -509,6 +555,7 @@ deposit_get_cb (void *cls,
return;
}
} /* end switch */
+ GNUNET_free (tq->exchange_url);
GNUNET_free (tq);
if (NULL != gorc->tq_head)
return;
@@ -548,6 +595,7 @@ exchange_found_cb (void *cls,
GNUNET_CONTAINER_DLL_remove (gorc->tq_head,
gorc->tq_tail,
tq);
+ GNUNET_free (tq->exchange_url);
GNUNET_free (tq);
gorc_resume (gorc,
MHD_HTTP_GATEWAY_TIMEOUT,
@@ -560,6 +608,7 @@ exchange_found_cb (void *cls,
GNUNET_CONTAINER_DLL_remove (gorc->tq_head,
gorc->tq_tail,
tq);
+ GNUNET_free (tq->exchange_url);
GNUNET_free (tq);
gorc->exchange_hc = hr->http_status;
gorc->exchange_ec = hr->ec;
@@ -580,6 +629,7 @@ exchange_found_cb (void *cls,
GNUNET_CONTAINER_DLL_remove (gorc->tq_head,
gorc->tq_tail,
tq);
+ GNUNET_free (tq->exchange_url);
GNUNET_free (tq);
gorc_resume (gorc,
MHD_HTTP_INTERNAL_SERVER_ERROR,
@@ -618,6 +668,7 @@ deposit_cb (void *cls,
tq = GNUNET_new (struct TransferQuery);
tq->gorc = gorc;
+ tq->exchange_url = GNUNET_strdup (exchange_url);
tq->deposit_serial = deposit_serial;
GNUNET_CONTAINER_DLL_insert (gorc->tq_head,
gorc->tq_tail,