summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-01-06 20:24:05 +0100
committerChristian Grothoff <christian@grothoff.org>2024-01-06 20:24:05 +0100
commitb1ccf194316920ff1898cca8c1a34169470dc164 (patch)
tree9fc065452e83b7bfa2718dfba2d1f4c2aea17faf /src
parent4d920a818432ba757189f9b03a0886a37901dbb2 (diff)
downloadmerchant-b1ccf194316920ff1898cca8c1a34169470dc164.tar.gz
merchant-b1ccf194316920ff1898cca8c1a34169470dc164.tar.bz2
merchant-b1ccf194316920ff1898cca8c1a34169470dc164.zip
updating logic to use new depositcheck tooling (not yet working)
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_private-get-orders-ID.c464
-rw-r--r--src/include/taler_merchant_service.h24
-rw-r--r--src/include/taler_merchant_testing_lib.h11
-rw-r--r--src/lib/Makefile.am2
-rw-r--r--src/lib/merchant_api_merchant_get_order.c45
-rw-r--r--src/testing/Makefile.am1
-rw-r--r--src/testing/test_kyc_api.c23
-rw-r--r--src/testing/testing_api_cmd_depositcheck.c162
-rw-r--r--src/testing/testing_api_cmd_merchant_get_order.c4
9 files changed, 204 insertions, 532 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 4f7959bd..fb8b9dd5 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -31,13 +31,6 @@
/**
- * How long do we wait on the exchange?
- */
-#define EXCHANGE_TIMEOUT GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_SECONDS, 30)
-
-
-/**
* Data structure we keep for a check payment request.
*/
struct GetOrderRequestContext;
@@ -66,16 +59,6 @@ struct TransferQuery
char *exchange_url;
/**
- * Handle to query exchange about deposit status.
- */
- struct TALER_EXCHANGE_DepositGetHandle *dgh;
-
- /**
- * Handle for ongoing exchange operation.
- */
- struct TMH_EXCHANGES_KeysOperation *fo;
-
- /**
* Overall request this TQ belongs with.
*/
struct GetOrderRequestContext *gorc;
@@ -153,48 +136,41 @@ enum GetOrderPhase
GOP_CHECK_REFUNDS = 6,
/**
- * Check if the exchange transferred the funds to
- * the merchant.
+ * Load all deposits associated with the order.
*/
- GOP_CHECK_EXCHANGE_TRANSFERS = 7,
-
- /**
- * We are suspended awaiting a response from the
- * exchange.
- */
- GOP_SUSPENDED_ON_EXCHANGE = 8,
+ GOP_CHECK_DEPOSITS = 7,
/**
* Check local records for transfers of funds to
* the merchant.
*/
- GOP_CHECK_LOCAL_TRANSFERS = 9,
+ GOP_CHECK_LOCAL_TRANSFERS = 8,
/**
* Generate final comprehensive result.
*/
- GOP_REPLY_RESULT = 10,
+ GOP_REPLY_RESULT = 9,
/**
* End with the HTTP status and error code in
* wire_hc and wire_ec.
*/
- GOP_ERROR = 11,
+ GOP_ERROR = 10,
/**
* We are suspended awaiting payment.
*/
- GOP_SUSPENDED_ON_UNPAID = 12,
+ GOP_SUSPENDED_ON_UNPAID = 11,
/**
* Processing is done, return #MHD_YES.
*/
- GOP_END_YES = 13,
+ GOP_END_YES = 12,
/**
* Processing is done, return #MHD_NO.
*/
- GOP_END_NO = 14
+ GOP_END_NO = 13
};
@@ -298,12 +274,6 @@ struct GetOrderRequestContext
json_t *wire_details;
/**
- * Problems we encountered when looking up Wire details
- * for the payment, to be returned. NULL if not available.
- */
- json_t *wire_reports;
-
- /**
* Details about refunds, NULL if there are no refunds.
*/
json_t *refund_details;
@@ -413,12 +383,6 @@ struct GetOrderRequestContext
bool refund_pending;
/**
- * Did the client request us to fetch the wire transfer status?
- * If false, we may still return it if it is available.
- */
- bool transfer_status_requested;
-
- /**
* Set to true if our database (incorrectly) has refunds
* in a different currency than the currency of the
* original payment for the order.
@@ -463,65 +427,6 @@ TMH_force_gorc_resume (void)
/**
- * Resume processing the request, cancelling all pending asynchronous
- * operations.
- *
- * @param gorc request to resume
- */
-static void
-gorc_resume (struct GetOrderRequestContext *gorc)
-{
- struct TransferQuery *tq;
-
- if (NULL != gorc->tt)
- {
- GNUNET_SCHEDULER_cancel (gorc->tt);
- gorc->tt = NULL;
- }
- while (NULL != (tq = gorc->tq_head))
- {
- if (NULL != tq->fo)
- {
- TMH_EXCHANGES_keys4exchange_cancel (tq->fo);
- tq->fo = NULL;
- }
- if (NULL != tq->dgh)
- {
- TALER_EXCHANGE_deposits_get_cancel (tq->dgh);
- tq->dgh = NULL;
- }
- }
- GNUNET_assert (GNUNET_YES == gorc->suspended);
- GNUNET_CONTAINER_DLL_remove (gorc_head,
- gorc_tail,
- gorc);
- gorc->suspended = GNUNET_NO;
- MHD_resume_connection (gorc->sc.con);
- TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
-}
-
-
-/**
- * Resume processing the request, cancelling all pending asynchronous
- * operations.
- *
- * @param gorc request to resume
- * @param http_status HTTP status to return, 0 to continue with success
- * @param ec error code for the request, #TALER_EC_NONE on success
- */
-static void
-gorc_resume_error (struct GetOrderRequestContext *gorc,
- unsigned int http_status,
- enum TALER_ErrorCode ec)
-{
- gorc->wire_hc = http_status;
- gorc->wire_ec = ec;
- gorc->phase = GOP_ERROR;
- gorc_resume (gorc);
-}
-
-
-/**
* We have received a trigger from the database
* that we should (possibly) resume the request.
*
@@ -554,58 +459,6 @@ resume_by_event (void *cls,
/**
- * Add a report about trouble obtaining wire transfer data to the reply.
- *
- * @param gorc request to add wire report to
- * @param ec error code to add
- * @param coin_pub public key of the affected coin
- * @param exchange_hr details from exchange, NULL if exchange is blameless
- */
-static void
-gorc_report (struct GetOrderRequestContext *gorc,
- enum TALER_ErrorCode ec,
- struct TALER_CoinSpendPublicKeyP *coin_pub,
- const struct TALER_EXCHANGE_HttpResponse *exchange_hr)
-{
- if (NULL != exchange_hr)
- GNUNET_assert (0 ==
- json_array_append_new (
- gorc->wire_reports,
- GNUNET_JSON_PACK (
- TALER_JSON_pack_ec (ec),
- TMH_pack_exchange_reply (exchange_hr),
- GNUNET_JSON_pack_data_auto ("coin_pub",
- coin_pub))));
- else
- GNUNET_assert (0 ==
- json_array_append_new (
- gorc->wire_reports,
- GNUNET_JSON_PACK (
- TALER_JSON_pack_ec (ec),
- GNUNET_JSON_pack_data_auto ("coin_pub",
- coin_pub))));
-}
-
-
-/**
- * Timeout trying to get current wire transfer data from the exchange.
- * Clean up and continue.
- *
- * @param cls closure, must be a `struct GetOrderRequestContext *`
- */
-static void
-exchange_timeout_cb (void *cls)
-{
- struct GetOrderRequestContext *gorc = cls;
-
- gorc->tt = NULL;
- gorc_resume_error (gorc,
- MHD_HTTP_REQUEST_TIMEOUT,
- TALER_EC_GENERIC_TIMEOUT);
-}
-
-
-/**
* Clean up the session state for a GET /private/order/ID request.
*
* @param cls closure, must be a `struct GetOrderRequestContext *`
@@ -621,8 +474,6 @@ gorc_cleanup (void *cls)
json_decref (gorc->wire_details);
if (NULL != gorc->refund_details)
json_decref (gorc->refund_details);
- if (NULL != gorc->wire_reports)
- json_decref (gorc->wire_reports);
if (NULL != gorc->tt)
{
GNUNET_SCHEDULER_cancel (gorc->tt);
@@ -1245,243 +1096,6 @@ phase_check_refunds (struct GetOrderRequestContext *gorc)
/**
- * Function called with detailed wire transfer data.
- *
- * @param cls closure with a `struct TransferQuery *`
- * @param dr HTTP response data
- */
-static void
-deposit_get_cb (void *cls,
- const struct TALER_EXCHANGE_GetDepositResponse *dr)
-{
- struct TransferQuery *tq = cls;
- struct GetOrderRequestContext *gorc = tq->gorc;
-
- GNUNET_CONTAINER_DLL_remove (gorc->tq_head,
- gorc->tq_tail,
- tq);
- switch (dr->hr.http_status)
- {
- case MHD_HTTP_OK:
- {
- enum GNUNET_DB_QueryStatus qs;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Exchange returned wire transfer over %s for deposited coin %s\n",
- TALER_amount2s (&dr->details.ok.coin_contribution),
- TALER_B2S (&tq->coin_pub));
- qs = TMH_db->insert_deposit_to_transfer (TMH_db->cls,
- tq->deposit_serial,
- &dr->details.ok);
- 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->phase++;
- gorc_resume (gorc);
- }
- return;
- }
- /* Compute total amount *wired* */
- if ( (GNUNET_OK !=
- TALER_amount_cmp_currency (
- &gorc->deposits_total,
- &dr->details.ok.coin_contribution)) ||
- (GNUNET_OK !=
- TALER_amount_cmp_currency (
- &gorc->deposit_fees_total,
- &tq->deposit_fee)) )
- {
- /* something very wrong in our database ... */
- GNUNET_break (0);
- gorc_report (gorc,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- &tq->coin_pub,
- NULL);
- GNUNET_free (tq->exchange_url);
- GNUNET_free (tq);
- if (NULL == gorc->tq_head)
- {
- gorc->phase++;
- gorc_resume (gorc);
- }
- return;
- }
- if (0 >
- TALER_amount_add (&gorc->deposits_total,
- &gorc->deposits_total,
- &dr->details.ok.coin_contribution))
- {
- gorc_report (gorc,
- 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->phase++;
- gorc_resume (gorc);
- }
- 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->exchange_url);
- GNUNET_free (tq);
- if (NULL == gorc->tq_head)
- {
- gorc->phase++;
- gorc_resume (gorc);
- }
- return;
- }
- break;
- }
- case MHD_HTTP_ACCEPTED:
- {
- /* got a 'preliminary' reply from the exchange,
- remember our target UUID */
- enum GNUNET_DB_QueryStatus qs;
- struct GNUNET_TIME_Timestamp now;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Exchange returned KYC requirement (%d/%d) for deposited coin %s\n",
- dr->details.accepted.kyc_ok,
- dr->details.accepted.aml_decision,
- TALER_B2S (&tq->coin_pub));
- now = GNUNET_TIME_timestamp_get ();
- qs = TMH_db->account_kyc_set_status (
- TMH_db->cls,
- gorc->hc->instance->settings.id,
- &tq->h_wire,
- tq->exchange_url,
- dr->details.accepted.requirement_row,
- NULL,
- NULL,
- now,
- dr->details.accepted.kyc_ok,
- dr->details.accepted.aml_decision);
- 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->phase++;
- gorc_resume (gorc);
- }
- return;
- }
- gorc_report (gorc,
- TALER_EC_NONE,
- &tq->coin_pub,
- &dr->hr);
- break;
- }
- default:
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Exchange returned tracking failure for deposited coin %s\n",
- TALER_B2S (&tq->coin_pub));
- 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->phase++;
- gorc_resume (gorc);
- }
- return;
- }
- } /* end switch */
- GNUNET_free (tq->exchange_url);
- GNUNET_free (tq);
- if (NULL != gorc->tq_head)
- return;
- /* *all* are done, resume! */
- gorc->phase++;
- gorc_resume (gorc);
-}
-
-
-/**
- * Function called with the result of a #TMH_EXCHANGES_keys4exchange()
- * operation.
- *
- * @param cls closure with a `struct GetOrderRequestContext *`
- * @param keys keys of the exchange
- * @param exchange representation of the exchange
- */
-static void
-exchange_found_cb (void *cls,
- struct TALER_EXCHANGE_Keys *keys,
- struct TMH_Exchange *exchange)
-{
- struct TransferQuery *tq = cls;
- struct GetOrderRequestContext *gorc = tq->gorc;
-
- (void) exchange;
- tq->fo = NULL;
- if (NULL == keys)
- {
- /* failed */
- GNUNET_CONTAINER_DLL_remove (gorc->tq_head,
- gorc->tq_tail,
- tq);
- GNUNET_free (tq->exchange_url);
- GNUNET_free (tq);
- gorc_resume_error (gorc,
- MHD_HTTP_GATEWAY_TIMEOUT,
- TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT);
- return;
- }
- tq->dgh = TALER_EXCHANGE_deposits_get (
- TMH_curl_ctx,
- tq->exchange_url,
- keys,
- &gorc->hc->instance->merchant_priv,
- &tq->h_wire,
- &gorc->h_contract_terms,
- &tq->coin_pub,
- GNUNET_TIME_UNIT_ZERO,
- &deposit_get_cb,
- tq);
- if (NULL == tq->dgh)
- {
- GNUNET_CONTAINER_DLL_remove (gorc->tq_head,
- gorc->tq_tail,
- tq);
- GNUNET_free (tq->exchange_url);
- GNUNET_free (tq);
- gorc_resume_error (gorc,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_MERCHANT_GET_ORDERS_ID_EXCHANGE_REQUEST_FAILURE);
- }
-}
-
-
-/**
* Function called with each @a coin_pub that was deposited into the
* @a h_wire account of the merchant for the @a deposit_serial as part
* of the payment for the order identified by @a cls.
@@ -1524,16 +1138,6 @@ deposit_cb (void *cls,
tq->h_wire = *h_wire;
tq->amount_with_fee = *amount_with_fee;
tq->deposit_fee = *deposit_fee;
- tq->fo = TMH_EXCHANGES_keys4exchange (exchange_url,
- false,
- &exchange_found_cb,
- tq);
- if (NULL == tq->fo)
- {
- gorc_resume_error (gorc,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_MERCHANT_GET_ORDERS_ID_EXCHANGE_LOOKUP_START_FAILURE);
- }
}
@@ -1543,16 +1147,8 @@ deposit_cb (void *cls,
* @param[in,out] gorc order context to update
*/
static void
-phase_check_exchange_transfers (struct GetOrderRequestContext *gorc)
+phase_check_deposits (struct GetOrderRequestContext *gorc)
{
- if (gorc->wired ||
- (! gorc->transfer_status_requested) )
- {
- gorc->phase = GOP_CHECK_LOCAL_TRANSFERS;
- return;
- }
- /* suspend connection, wait for exchange to check wire transfer status there */
- gorc->transfer_status_requested = false; /* only try ONCE */
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (gorc->contract_amount.currency,
&gorc->deposits_total));
@@ -1563,22 +1159,7 @@ phase_check_exchange_transfers (struct GetOrderRequestContext *gorc)
gorc->order_serial,
&deposit_cb,
gorc);
- if (NULL == gorc->tq_head)
- {
- /* No deposits found for paid order. This is strange... */
- GNUNET_break (0);
- gorc->phase = GOP_CHECK_LOCAL_TRANSFERS;
- return;
- }
gorc->phase++;
- GNUNET_CONTAINER_DLL_insert (gorc_head,
- gorc_tail,
- gorc);
- gorc->suspended = GNUNET_YES;
- MHD_suspend_connection (gorc->sc.con);
- gorc->tt = GNUNET_SCHEDULER_add_delayed (EXCHANGE_TIMEOUT,
- &exchange_timeout_cb,
- gorc);
}
@@ -1784,8 +1365,9 @@ phase_reply_result (struct GetOrderRequestContext *gorc)
ret = TALER_MHD_REPLY_JSON_PACK (
gorc->sc.con,
MHD_HTTP_OK,
+ // Deprecated in protocol v6.
GNUNET_JSON_pack_array_steal ("wire_reports",
- gorc->wire_reports),
+ json_array ()),
GNUNET_JSON_pack_uint64 ("exchange_code",
gorc->exchange_ec),
GNUNET_JSON_pack_uint64 ("exchange_http_status",
@@ -1818,7 +1400,6 @@ phase_reply_result (struct GetOrderRequestContext *gorc)
order_status_url));
GNUNET_free (order_status_url);
gorc->wire_details = NULL;
- gorc->wire_reports = NULL;
gorc->refund_details = NULL;
phase_end (gorc,
ret);
@@ -1862,24 +1443,9 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
GNUNET_assert (NULL != gorc->wire_details);
gorc->refund_details = json_array ();
GNUNET_assert (NULL != gorc->refund_details);
- gorc->wire_reports = json_array ();
- GNUNET_assert (NULL != gorc->wire_reports);
gorc->session_id = MHD_lookup_connection_value (connection,
MHD_GET_ARGUMENT_KIND,
"session_id");
- /* process 'transfer' argument */
- {
- const char *transfer_s;
-
- transfer_s = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "transfer");
- if ( (NULL != transfer_s) &&
- (0 == strcasecmp (transfer_s,
- "yes")) )
- gorc->transfer_status_requested = true;
- }
-
TALER_MHD_parse_request_timeout (connection,
&gorc->sc.long_poll_timeout);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1919,8 +1485,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
case GOP_CHECK_REFUNDS:
phase_check_refunds (gorc);
break;
- case GOP_CHECK_EXCHANGE_TRANSFERS:
- phase_check_exchange_transfers (gorc);
+ case GOP_CHECK_DEPOSITS:
+ phase_check_deposits (gorc);
break;
case GOP_CHECK_LOCAL_TRANSFERS:
phase_check_local_transfers (gorc);
@@ -1935,10 +1501,6 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Suspending order request awaiting payment\n");
return MHD_YES;
- case GOP_SUSPENDED_ON_EXCHANGE:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Suspending order request awaiting answer from exchange\n");
- return MHD_YES;
case GOP_END_YES:
return MHD_YES;
case GOP_END_NO:
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index aeddefc8..1de69e27 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -32,7 +32,7 @@
/**
* Library version (in hex) for compatibility tests.
*/
-#define TALER_MERCHANT_SERVICE_VERSION 0x00090400
+#define TALER_MERCHANT_SERVICE_VERSION 0x00090401
/**
@@ -329,7 +329,7 @@ struct TALER_MERCHANT_ExchangeConfigInfo
* Master public key of the exchange.
*/
struct TALER_MasterPublicKeyP master_pub;
-
+
};
/**
@@ -380,11 +380,11 @@ struct TALER_MERCHANT_ConfigResponse
unsigned int num_exchanges;
/**
- * Array details about exchanges trusted
+ * Array details about exchanges trusted
* by this merchant backend.
*/
const struct TALER_MERCHANT_ExchangeConfigInfo *exchanges;
-
+
} ok;
} details;
};
@@ -947,7 +947,7 @@ TALER_MERCHANT_instance_delete_cancel (
* @param arg request to cancel.
*/
#define TALER_MERCHANT_instance_purge_cancel(arg) \
- TALER_MERCHANT_instance_delete_cancel (arg)
+ TALER_MERCHANT_instance_delete_cancel (arg)
/* *************** Accounts **************** */
@@ -2574,17 +2574,6 @@ struct TALER_MERCHANT_OrderStatusResponse
unsigned int wts_len;
/**
- * Array of wire reports about problems tracking wire transfers.
- * Of length @e wrs_len.
- */
- struct TALER_MERCHANT_WireReport *wrs;
-
- /**
- * Length of the @e wrs array.
- */
- unsigned int wrs_len;
-
- /**
* Details returned by the merchant backend about refunds.
* Of length @e refunds_len.
*/
@@ -2704,8 +2693,6 @@ typedef void
* @param order_id order id to identify the payment
* @param session_id session id for the payment (or NULL if the check is not
* bound to a session)
- * @param transfer if true, obtain the wire transfer status from the exchange.
- * Otherwise, the wire transfer status MAY be returned if it is available.
* @param timeout timeout to use in long polling (how long may the server wait to reply
* before generating an unpaid response). Note that this is just provided to
* the server, we as client will block until the response comes back or until
@@ -2719,7 +2706,6 @@ TALER_MERCHANT_merchant_order_get (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const char *order_id,
const char *session_id,
- bool transfer,
struct GNUNET_TIME_Relative timeout,
TALER_MERCHANT_OrderMerchantGetCallback cb,
void *cb_cls);
diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h
index 0f2e1faa..54d7f888 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -1903,6 +1903,17 @@ TALER_TESTING_cmd_webhook (const char *label,
/**
+ * Command to run the 'taler-merchant-depositcheck' program.
+ *
+ * @param label command label.
+ * @param config_filename configuration file used by the deposit check helper.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_depositcheck (const char *label,
+ const char *config_filename);
+
+
+/**
* Command to run the 'taler-merchant-exchange' program.
*
* @param label command label.
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 41cd6674..5a6cda80 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -10,7 +10,7 @@ lib_LTLIBRARIES = \
libtalermerchant.la
libtalermerchant_la_LDFLAGS = \
- -version-info 3:0:0 \
+ -version-info 4:0:0 \
-no-undefined
libtalermerchant_la_SOURCES = \
diff --git a/src/lib/merchant_api_merchant_get_order.c b/src/lib/merchant_api_merchant_get_order.c
index 5e3a5ead..9f10c347 100644
--- a/src/lib/merchant_api_merchant_get_order.c
+++ b/src/lib/merchant_api_merchant_get_order.c
@@ -168,7 +168,6 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
{
uint32_t hc32;
const json_t *wire_details;
- const json_t *wire_reports;
const json_t *refund_details;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_bool ("refunded",
@@ -190,8 +189,6 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
&osr->details.ok.details.paid.contract_terms),
GNUNET_JSON_spec_array_const ("wire_details",
&wire_details),
- GNUNET_JSON_spec_array_const ("wire_reports",
- &wire_reports),
GNUNET_JSON_spec_array_const ("refund_details",
&refund_details),
GNUNET_JSON_spec_end ()
@@ -210,14 +207,12 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
return;
}
osr->details.ok.status = TALER_MERCHANT_OSC_PAID;
-
+
osr->details.ok.details.paid.exchange_hc = (unsigned int) hc32;
{
unsigned int wts_len = json_array_size (wire_details);
- unsigned int wrs_len = json_array_size (wire_reports);
unsigned int ref_len = json_array_size (refund_details);
struct TALER_MERCHANT_WireTransfer wts[GNUNET_NZL (wts_len)];
- struct TALER_MERCHANT_WireReport wrs[GNUNET_NZL (wrs_len)];
struct TALER_MERCHANT_RefundOrderDetail ref[GNUNET_NZL (ref_len)];
for (unsigned int i = 0; i<wts_len; i++)
@@ -253,40 +248,6 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
}
}
- for (unsigned int i = 0; i<wrs_len; i++)
- {
- struct TALER_MERCHANT_WireReport *wr = &wrs[i];
- const json_t *w = json_array_get (wire_reports, i);
- uint32_t ehs32;
- struct GNUNET_JSON_Specification ispec[] = {
- TALER_JSON_spec_ec ("code",
- &wr->code),
- GNUNET_JSON_spec_string ("hint",
- &wr->hint),
- TALER_JSON_spec_ec ("exchange_code",
- &wr->hr.ec),
- GNUNET_JSON_spec_uint32 ("exchange_http_status",
- &ehs32),
- GNUNET_JSON_spec_fixed_auto ("coin_pub",
- &wr->coin_pub),
- GNUNET_JSON_spec_end ()
- };
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (w,
- ispec,
- NULL, NULL))
- {
- GNUNET_break_op (0);
- osr->hr.http_status = 0;
- osr->hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
- omgh->cb (omgh->cb_cls,
- osr);
- return;
- }
- wr->hr.http_status = (unsigned int) ehs32;
- }
-
for (unsigned int i = 0; i<ref_len; i++)
{
struct TALER_MERCHANT_RefundOrderDetail *ro = &ref[i];
@@ -318,8 +279,6 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
osr->details.ok.details.paid.wts = wts;
osr->details.ok.details.paid.wts_len = wts_len;
- osr->details.ok.details.paid.wrs = wrs;
- osr->details.ok.details.paid.wrs_len = wrs_len;
osr->details.ok.details.paid.refunds = ref;
osr->details.ok.details.paid.refunds_len = ref_len;
omgh->cb (omgh->cb_cls,
@@ -445,7 +404,6 @@ TALER_MERCHANT_merchant_order_get (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const char *order_id,
const char *session_id,
- bool transfer,
struct GNUNET_TIME_Relative timeout,
TALER_MERCHANT_OrderMerchantGetCallback cb,
void *cb_cls)
@@ -480,7 +438,6 @@ TALER_MERCHANT_merchant_order_get (struct GNUNET_CURL_Context *ctx,
omgh->url = TALER_url_join (backend_url,
path,
"session_id", session_id,
- "transfer", transfer ? "YES" : "NO",
"timeout_ms", (0 != tms) ? timeout_ms : NULL,
NULL);
GNUNET_free (path);
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 341d6711..8a0afc9b 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -32,6 +32,7 @@ libtalermerchanttesting_la_SOURCES = \
testing_api_cmd_config.c \
testing_api_cmd_abort_order.c \
testing_api_cmd_claim_order.c \
+ testing_api_cmd_depositcheck.c \
testing_api_cmd_get_instance.c \
testing_api_cmd_get_instances.c \
testing_api_cmd_get_orders.c \
diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c
index c8b683d8..1bb9f472 100644
--- a/src/testing/test_kyc_api.c
+++ b/src/testing/test_kyc_api.c
@@ -207,21 +207,16 @@ run (void *cls,
/* KYC: hence nothing happened at the bank yet: */
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-2"),
/* KYC: we don't even know the legitimization UUID yet */
- TALER_TESTING_cmd_merchant_kyc_get ("kyc-pending",
+ TALER_TESTING_cmd_merchant_kyc_get ("kyc-pending-early",
merchant_url,
NULL,
NULL,
EXCHANGE_URL,
MHD_HTTP_NO_CONTENT,
TALER_AML_NORMAL),
- /* now we get the legi UUID */
- TALER_TESTING_cmd_merchant_get_order ("get-order-kyc",
- merchant_url,
- "create-proposal-1",
- TALER_MERCHANT_OSC_PAID,
- false,
- MHD_HTTP_OK,
- NULL),
+ /* now we get the legi UUID by running taler-merchant-depositcheck */
+ TALER_TESTING_cmd_depositcheck ("deposit-check",
+ CONFIG_FILE),
/* Now we should get a status of pending */
TALER_TESTING_cmd_merchant_kyc_get ("kyc-pending",
merchant_url,
@@ -397,11 +392,11 @@ run (void *cls,
"default",
MHD_HTTP_NO_CONTENT),
TALER_TESTING_cmd_merchant_post_account (
- "instance-create-default-account",
- merchant_url,
- merchant_payto,
- NULL, NULL,
- MHD_HTTP_OK),
+ "instance-create-default-account",
+ merchant_url,
+ merchant_payto,
+ NULL, NULL,
+ MHD_HTTP_OK),
TALER_TESTING_cmd_batch ("pay",
pay),
TALER_TESTING_cmd_batch ("aml",
diff --git a/src/testing/testing_api_cmd_depositcheck.c b/src/testing/testing_api_cmd_depositcheck.c
new file mode 100644
index 00000000..ad033d2e
--- /dev/null
+++ b/src/testing/testing_api_cmd_depositcheck.c
@@ -0,0 +1,162 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2024 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 3,
+ or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with TALER; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file testing/testing_api_cmd_depositcheck.c
+ * @brief run the taler-merchant-depositcheck command
+ * @author Priscilla HUANG
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "taler/taler_json_lib.h"
+#include <gnunet/gnunet_curl_lib.h>
+#include "taler/taler_signatures.h"
+#include "taler/taler_testing_lib.h"
+
+
+/**
+ * State for a "depositcheck" CMD.
+ */
+struct DepositcheckState
+{
+
+ /**
+ * Process for the depositcheck.
+ */
+ struct GNUNET_OS_Process *depositcheck_proc;
+
+ /**
+ * Configuration file used by the depositcheck.
+ */
+ const char *config_filename;
+};
+
+
+/**
+ * Run the command; use the `taler-merchant-depositcheck' program.
+ *
+ * @param cls closure.
+ * @param cmd command currently being executed.
+ * @param is interpreter state.
+ */
+static void
+depositcheck_run (void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
+{
+ struct DepositcheckState *ws = cls;
+
+ (void) cmd;
+ ws->depositcheck_proc
+ = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
+ NULL, NULL, NULL,
+ "taler-merchant-depositcheck",
+ "taler-merchant-depositcheck",
+ "-c", ws->config_filename,
+ "-t", /* exit when done */
+ "-L", "DEBUG",
+ NULL);
+ if (NULL == ws->depositcheck_proc)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
+ TALER_TESTING_wait_for_sigchld (is);
+}
+
+
+/**
+ * Free the state of a "depositcheck" CMD, and possibly
+ * kills its process if it did not terminate regularly.
+ *
+ * @param cls closure.
+ * @param cmd the command being freed.
+ */
+static void
+depositcheck_cleanup (void *cls,
+ const struct TALER_TESTING_Command *cmd)
+{
+ struct DepositcheckState *ws = cls;
+
+ (void) cmd;
+ if (NULL != ws->depositcheck_proc)
+ {
+ GNUNET_break (0 ==
+ GNUNET_OS_process_kill (ws->depositcheck_proc,
+ SIGKILL));
+ GNUNET_OS_process_wait (ws->depositcheck_proc);
+ GNUNET_OS_process_destroy (ws->depositcheck_proc);
+ ws->depositcheck_proc = NULL;
+ }
+ GNUNET_free (ws);
+}
+
+
+/**
+ * Offer "depositcheck" CMD internal data to other commands.
+ *
+ * @param cls closure.
+ * @param[out] ret result.
+ * @param trait name of the trait.
+ * @param index index number of the object to offer.
+ * @return #GNUNET_OK on success.
+ */
+static enum GNUNET_GenericReturnValue
+depositcheck_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
+{
+ struct DepositcheckState *ws = cls;
+ struct TALER_TESTING_Trait traits[] = {
+ TALER_TESTING_make_trait_process (&ws->depositcheck_proc),
+ TALER_TESTING_trait_end ()
+ };
+
+ return TALER_TESTING_get_trait (traits,
+ ret,
+ trait,
+ index);
+}
+
+
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_depositcheck (const char *label,
+ const char *config_filename)
+{
+ struct DepositcheckState *ws;
+
+ ws = GNUNET_new (struct DepositcheckState);
+ ws->config_filename = config_filename;
+
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = ws,
+ .label = label,
+ .run = &depositcheck_run,
+ .cleanup = &depositcheck_cleanup,
+ .traits = &depositcheck_traits
+ };
+
+ return cmd;
+ }
+}
+
+
+/* end of testing_api_cmd_depositcheck.c */
diff --git a/src/testing/testing_api_cmd_merchant_get_order.c b/src/testing/testing_api_cmd_merchant_get_order.c
index 642fbed6..f30c43ad 100644
--- a/src/testing/testing_api_cmd_merchant_get_order.c
+++ b/src/testing/testing_api_cmd_merchant_get_order.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2020 Taler Systems SA
+ Copyright (C) 2020-2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -536,7 +536,6 @@ merchant_get_order_run (void *cls,
gos->merchant_url,
order_id,
NULL,
- true,
GNUNET_TIME_UNIT_ZERO,
&merchant_get_order_cb,
gos);
@@ -858,7 +857,6 @@ merchant_poll_order_start_run (void *cls,
pos->merchant_url,
pos->order_id,
NULL,
- false,
pos->timeout,
&merchant_poll_order_cb,
pos);