summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_private-get-orders-ID.c30
-rw-r--r--src/include/taler_merchant_testing_lib.h32
-rw-r--r--src/lib/merchant_api_merchant_get_order.c4
-rw-r--r--src/testing/test_merchant_api.c13
-rw-r--r--src/testing/testing_api_cmd_merchant_get_order.c96
5 files changed, 166 insertions, 9 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 d637f5cf..b6bdb139 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -332,17 +332,17 @@ gorc_report (struct GetOrderRequestContext *gorc,
GNUNET_assert (0 ==
json_array_append_new (
gorc->wire_reports,
- json_pack ("{s:I, s:s, s:o, s:I, s:I}",
+ json_pack ("{s:I, s:s, s:I, s:I, s:o}",
"code",
(json_int_t) ec,
"hint",
hint,
- "coin_pub",
- GNUNET_JSON_from_data_auto (coin_pub),
"exchange_ec",
(json_int_t) exchange_hr->ec,
"exchange_hc",
- (json_int_t) exchange_hr->http_status)));
+ (json_int_t) exchange_hr->http_status,
+ "coin_pub",
+ GNUNET_JSON_from_data_auto (coin_pub))));
else
GNUNET_assert (0 ==
json_array_append_new (
@@ -700,7 +700,19 @@ process_transfer_details (void *cls,
struct GetOrderRequestContext *gorc = cls;
json_t *wire_details = gorc->wire_details;
struct TALER_Amount wired;
-
+ struct GNUNET_TIME_Absolute execution_time_round = execution_time;
+
+ /* Compute total amount *wired* */
+ GNUNET_assert (0 <
+ TALER_amount_add (&gorc->deposits_total,
+ &gorc->deposits_total,
+ deposit_value));
+ GNUNET_assert (0 <
+ TALER_amount_add (&gorc->deposit_fees_total,
+ &gorc->deposit_fees_total,
+ deposit_fee));
+
+ GNUNET_TIME_round_abs (&execution_time_round);
GNUNET_assert
(0 <= TALER_amount_subtract (&wired,
deposit_value,
@@ -716,7 +728,7 @@ process_transfer_details (void *cls,
"amount",
TALER_JSON_from_amount (&wired),
"execution_time",
- GNUNET_JSON_from_time_abs (execution_time),
+ GNUNET_JSON_from_time_abs (execution_time_round),
"confirmed",
transfer_confirmed)));
}
@@ -956,6 +968,12 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
{
/* 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_get_zero (TMH_currency,
+ &gorc->deposits_total));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (TMH_currency,
+ &gorc->deposit_fees_total));
TMH_db->lookup_deposits_by_order (TMH_db->cls,
gorc->order_serial,
&deposit_cb,
diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h
index 07d572a9..83201005 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -544,6 +544,38 @@ TALER_TESTING_cmd_merchant_get_order (const char *label,
/**
+ * Define a GET /private/orders/$ORDER_ID CMD.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * serve the request.
+ * @param order_reference reference to a command that created an order.
+ * @param paid whether the order has been paid for or not.
+ * @param wired whether the order has been wired or not.
+ * @param transfers NULL-terminated list of labels (const char *) of
+ * wire transfers (commands) we expect to be aggregated in the order
+ * (assuming @a http_code is #MHD_HTTP_OK). If @e paid is fale, this
+ * parameter is ignored.
+ * @param refunded whether the order has been refunded.
+ * @param refunds NULL-terminated list of labels (const char *) of
+ * refunds (commands) we expect to be aggregated in the order
+ * (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false,
+ * this parameter is ignored.
+ * @param http_status expected HTTP response code for the request.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_order2 (const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ bool paid,
+ bool wired,
+ const char **transfers,
+ bool refunded,
+ const char **refunds,
+ unsigned int http_status);
+
+
+/**
* Start a long poll for GET /private/orders/$ORDER_ID.
*/
struct TALER_TESTING_Command
diff --git a/src/lib/merchant_api_merchant_get_order.c b/src/lib/merchant_api_merchant_get_order.c
index 53811ec1..b29823f4 100644
--- a/src/lib/merchant_api_merchant_get_order.c
+++ b/src/lib/merchant_api_merchant_get_order.c
@@ -233,12 +233,12 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
struct GNUNET_JSON_Specification ispec[] = {
GNUNET_JSON_spec_uint32 ("code",
&c32),
+ GNUNET_JSON_spec_string ("hint",
+ &wr->hint),
GNUNET_JSON_spec_uint32 ("exchange_ec",
&eec32),
GNUNET_JSON_spec_uint32 ("exchange_hc",
&ehs32),
- GNUNET_JSON_spec_string ("hint",
- &wr->hint),
GNUNET_JSON_spec_fixed_auto ("coin_pub",
&wr->coin_pub),
GNUNET_JSON_spec_end ()
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index d6630a69..eeaec917 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -231,6 +231,10 @@ static void
run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
+ const char *order_1_transfers[] = {
+ "post-transfer-1",
+ NULL
+ };
struct TALER_TESTING_Command pay[] = {
/**
* Move money to the exchange's bank account.
@@ -395,6 +399,15 @@ run (void *cls,
MHD_HTTP_OK,
"post-transfer-1",
NULL),
+ TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-2",
+ merchant_url,
+ "create-proposal-1",
+ true,
+ true,
+ order_1_transfers,
+ false,
+ NULL,
+ MHD_HTTP_OK),
TALER_TESTING_cmd_merchant_delete_order ("delete-order-1",
merchant_url,
"1",
diff --git a/src/testing/testing_api_cmd_merchant_get_order.c b/src/testing/testing_api_cmd_merchant_get_order.c
index 76bc75b8..cf0263ba 100644
--- a/src/testing/testing_api_cmd_merchant_get_order.c
+++ b/src/testing/testing_api_cmd_merchant_get_order.c
@@ -77,6 +77,21 @@ struct MerchantGetOrderState
* The length of @e refunds.
*/
unsigned int refunds_length;
+
+ /**
+ * Whether the order was wired or not.
+ */
+ bool wired;
+
+ /**
+ * A NULL-terminated list of transfers associated with this order.
+ */
+ const char **transfers;
+
+ /**
+ * The length of @e transfers.
+ */
+ unsigned int transfers_length;
};
@@ -230,6 +245,14 @@ merchant_get_order_cb (
}
}
}
+
+ if (gos->wired != osr->details.paid.wired)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Order wired does not match\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
}
break;
default:
@@ -278,7 +301,7 @@ merchant_get_order_run (void *cls,
gos->merchant_url,
order_id,
NULL,
- false,
+ true,
GNUNET_TIME_UNIT_ZERO,
&merchant_get_order_cb,
gos);
@@ -366,6 +389,77 @@ TALER_TESTING_cmd_merchant_get_order (const char *label,
}
+/**
+ * Define a GET /private/orders/$ORDER_ID CMD.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * serve the request.
+ * @param order_reference reference to a command that created an order.
+ * @param paid whether the order has been paid for or not.
+ * @param wired whether the order has been wired or not.
+ * @param transfers NULL-terminated list of labels (const char *) of
+ * wire transfers (commands) we expect to be aggregated in the order
+ * (assuming @a http_code is #MHD_HTTP_OK). If @e paid is fale, this
+ * parameter is ignored.
+ * @param refunded whether the order has been refunded.
+ * @param refunds NULL-terminated list of labels (const char *) of
+ * refunds (commands) we expect to be aggregated in the order
+ * (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false,
+ * this parameter is ignored.
+ * @param http_status expected HTTP response code for the request.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_order2 (const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ bool paid,
+ bool wired,
+ const char **transfers,
+ bool refunded,
+ const char **refunds,
+ unsigned int http_status)
+{
+ struct MerchantGetOrderState *gos;
+
+ gos = GNUNET_new (struct MerchantGetOrderState);
+ gos->merchant_url = merchant_url;
+ gos->order_reference = order_reference;
+ gos->paid = paid;
+ gos->wired = wired;
+ gos->refunded = refunded;
+ gos->http_status = http_status;
+ /*if (paid)
+ {
+ for (const char *clabel = transfers[0]; clabel != NULL; ++clabel)
+ {
+ GNUNET_array_append (gos->transfers,
+ gos->transfers_length,
+ clabel);
+ }
+ }
+ if (refunded)
+ {
+ for (const char *clabel = refunds[0]; clabel != NULL; ++clabel)
+ {
+ GNUNET_array_append (gos->refunds,
+ gos->refunds_length,
+ clabel);
+ }
+ }*/
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = gos,
+ .label = label,
+ .run = &merchant_get_order_run,
+ .cleanup = &merchant_get_order_cleanup
+ };
+
+ return cmd;
+ }
+}
+
+
struct MerchantPollOrderConcludeState
{
/**