summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_merchant_get_order.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-07-11 15:16:15 +0200
committerChristian Grothoff <christian@grothoff.org>2022-07-11 15:16:15 +0200
commit962f9e5f6494da301f491623c289d7fd2c16d1d6 (patch)
tree74d16483081d91772a8e16bd3303f8186b062f11 /src/testing/testing_api_cmd_merchant_get_order.c
parent6741a252e5f69cae36a2119fd183b26539863784 (diff)
downloadmerchant-962f9e5f6494da301f491623c289d7fd2c16d1d6.tar.gz
merchant-962f9e5f6494da301f491623c289d7fd2c16d1d6.tar.bz2
merchant-962f9e5f6494da301f491623c289d7fd2c16d1d6.zip
improve C API
Diffstat (limited to 'src/testing/testing_api_cmd_merchant_get_order.c')
-rw-r--r--src/testing/testing_api_cmd_merchant_get_order.c87
1 files changed, 43 insertions, 44 deletions
diff --git a/src/testing/testing_api_cmd_merchant_get_order.c b/src/testing/testing_api_cmd_merchant_get_order.c
index 85ba174f..8001ac43 100644
--- a/src/testing/testing_api_cmd_merchant_get_order.c
+++ b/src/testing/testing_api_cmd_merchant_get_order.c
@@ -130,45 +130,40 @@ apply_forget (void *cls,
* Callback to process a GET /orders/$ID request
*
* @param cls closure
- * @param hr HTTP response details
- * @param osr order status response details (on success)
+ * @param osr order status response details
*/
static void
merchant_get_order_cb (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
const struct TALER_MERCHANT_OrderStatusResponse *osr)
{
- /* FIXME, deeper checks should be implemented here. */
struct MerchantGetOrderState *gos = cls;
gos->ogh = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"GET /private/orders/$ID completed with status %u\n",
- hr->http_status);
- if (gos->http_status != hr->http_status)
+ osr->hr.http_status);
+ if (gos->http_status != osr->hr.http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u (%d) to command %s\n",
- hr->http_status,
- (int) hr->ec,
+ osr->hr.http_status,
+ (int) osr->hr.ec,
TALER_TESTING_interpreter_get_current_label (gos->is));
TALER_TESTING_interpreter_fail (gos->is);
return;
}
- switch (hr->http_status)
+ switch (osr->hr.http_status)
{
case MHD_HTTP_OK:
- // FIXME: use gts->tip_reference here to
- // check if the data returned matches that from the POST / PATCH
- if (gos->osc != osr->status)
+ if (gos->osc != osr->details.success.status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Order paid does not match\n");
TALER_TESTING_interpreter_fail (gos->is);
return;
}
- switch (osr->status)
+ switch (osr->details.success.status)
{
case TALER_MERCHANT_OSC_PAID:
{
@@ -241,7 +236,7 @@ merchant_get_order_cb (
}
if (1 != json_equal (ct,
- osr->details.paid.contract_terms))
+ osr->details.success.details.paid.contract_terms))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Order contract terms do not match\n");
@@ -251,14 +246,14 @@ merchant_get_order_cb (
json_decref (ct);
}
- if (gos->wired != osr->details.paid.wired)
+ if (gos->wired != osr->details.success.details.paid.wired)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Order wired does not match\n");
TALER_TESTING_interpreter_fail (gos->is);
return;
}
- if (gos->transfers_length != osr->details.paid.wts_len)
+ if (gos->transfers_length != osr->details.success.details.paid.wts_len)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Number of transfers found does not match\n");
@@ -285,7 +280,8 @@ merchant_get_order_cb (
return;
}
if (0 != GNUNET_memcmp (wtid,
- &osr->details.paid.wts[i].wtid))
+ &osr->details.success.details.paid.wts[i].
+ wtid))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Wire transfer id does not match\n");
@@ -306,7 +302,8 @@ merchant_get_order_cb (
return;
}
if (0 != strcmp (*exchange_url,
- osr->details.paid.wts[i].exchange_url))
+ osr->details.success.details.paid.wts[i].
+ exchange_url))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Wire transfer exchange url does not match\n");
@@ -340,12 +337,13 @@ merchant_get_order_cb (
TALER_TESTING_interpreter_fail (gos->is);
return;
}
- if ((GNUNET_OK != TALER_amount_cmp_currency (&transfer_total,
- &osr->details.paid.wts[
- i]
- .total_amount)) ||
- (0 != TALER_amount_cmp (&transfer_total,
- &osr->details.paid.wts[i].total_amount)))
+ if ((GNUNET_OK !=
+ TALER_amount_cmp_currency (
+ &transfer_total,
+ &osr->details.success.details.paid.wts[i].total_amount)) ||
+ (0 != TALER_amount_cmp (
+ &transfer_total,
+ &osr->details.success.details.paid.wts[i].total_amount)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Wire transfer total does not match\n");
@@ -354,14 +352,15 @@ merchant_get_order_cb (
}
}
}
- if (gos->refunded != osr->details.paid.refunded)
+ if (gos->refunded != osr->details.success.details.paid.refunded)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Order refunded does not match\n");
TALER_TESTING_interpreter_fail (gos->is);
return;
}
- if (gos->refunds_length != osr->details.paid.refunds_len)
+ if (gos->refunds_length !=
+ osr->details.success.details.paid.refunds_len)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Number of refunds found does not match\n");
@@ -369,10 +368,11 @@ merchant_get_order_cb (
return;
}
if (0 < gos->refunds_length)
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (
- osr->details.paid.refund_amount.currency,
- &refunded_total));
+ GNUNET_assert (
+ GNUNET_OK ==
+ TALER_amount_set_zero (
+ osr->details.success.details.paid.refund_amount.currency,
+ &refunded_total));
for (unsigned int i = 0; i < gos->refunds_length; ++i)
{
const struct TALER_TESTING_Command *refund_cmd;
@@ -383,7 +383,7 @@ merchant_get_order_cb (
{
const struct TALER_Amount *expected_amount;
struct TALER_Amount *amount_found =
- &osr->details.paid.refunds[i].refund_amount;
+ &osr->details.success.details.paid.refunds[i].refund_amount;
if (GNUNET_OK !=
TALER_TESTING_get_trait_amount (refund_cmd,
@@ -421,8 +421,9 @@ merchant_get_order_cb (
TALER_TESTING_interpreter_fail (gos->is);
return;
}
- if (0 != strcmp (*expected_reason,
- osr->details.paid.refunds[i].reason))
+ if (0 != strcmp (
+ *expected_reason,
+ osr->details.success.details.paid.refunds[i].reason))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Refund reason does not match\n");
@@ -432,7 +433,7 @@ merchant_get_order_cb (
}
}
- if (gos->wired != osr->details.paid.wired)
+ if (gos->wired != osr->details.success.details.paid.wired)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Order wired does not match\n");
@@ -446,19 +447,19 @@ merchant_get_order_cb (
break;
case TALER_MERCHANT_OSC_UNPAID:
{
- /* FIXME: Check all of the members of `pud` */
struct TALER_MERCHANT_PayUriData pud;
const struct TALER_TESTING_Command *order_cmd;
const char **order_id;
const struct TALER_ClaimTokenP *claim_token;
if (GNUNET_OK !=
- TALER_MERCHANT_parse_pay_uri (osr->details.unpaid.taler_pay_uri,
- &pud))
+ TALER_MERCHANT_parse_pay_uri (
+ osr->details.success.details.unpaid.taler_pay_uri,
+ &pud))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Taler pay uri `%s' is malformed\n",
- osr->details.unpaid.taler_pay_uri);
+ osr->details.success.details.unpaid.taler_pay_uri);
TALER_TESTING_interpreter_fail (gos->is);
return;
}
@@ -511,7 +512,7 @@ merchant_get_order_cb (
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Order pay uri `%s' does not match, wanted %s/%s\n",
- osr->details.unpaid.taler_pay_uri,
+ osr->details.success.details.unpaid.taler_pay_uri,
host,
*order_id);
TALER_TESTING_interpreter_fail (gos->is);
@@ -541,8 +542,8 @@ merchant_get_order_cb (
return;
}
TALER_MERCHANT_parse_pay_uri_free (&pud);
+ break;
}
- break;
}
break;
default:
@@ -860,17 +861,15 @@ conclude_task (void *cls)
* Callback to process a GET /private/orders/$ID request
*
* @param cls closure
- * @param hr HTTP response details
- * @param osr order status response details (on success)
+ * @param osr order status response details
*/
static void
merchant_poll_order_cb (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
const struct TALER_MERCHANT_OrderStatusResponse *osr)
{
- /* FIXME, deeper checks should be implemented here. */
struct MerchantPollOrderStartState *pos = cls;
+ const struct TALER_MERCHANT_HttpResponse *hr = &osr->hr;
pos->ogh = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,