summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_wallet_get_order.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_wallet_get_order.c')
-rw-r--r--src/testing/testing_api_cmd_wallet_get_order.c95
1 files changed, 24 insertions, 71 deletions
diff --git a/src/testing/testing_api_cmd_wallet_get_order.c b/src/testing/testing_api_cmd_wallet_get_order.c
index f9e89d63..771dc6f8 100644
--- a/src/testing/testing_api_cmd_wallet_get_order.c
+++ b/src/testing/testing_api_cmd_wallet_get_order.c
@@ -79,37 +79,15 @@ struct WalletGetOrderState
* Callback to process a GET /orders/$ID request
*
* @param cls closure
- * @param hr HTTP response details
- * @param paid #GNUNET_YES if the payment is settled, #GNUNET_NO if not
- * settled, #GNUNET_SYSERR on error
- * (note that refunded payments are returned as paid!)
- * @param refunded #GNUNET_YES if there is at least on refund on this payment,
- * #GNUNET_NO if refunded, #GNUNET_SYSERR or error
- * @param refund_pending #GNUNET_YES if there are refunds waiting to be
- * obtained, #GNUNET_NO if all refunds have been obtained, #GNUNET_SYSERR
- * on error.
- * @param refund_amount amount that was refunded, NULL if there
- * was no refund
- * @param taler_pay_uri the URI that instructs the wallets to process
- * the payment
- * @param already_paid_order_id equivalent order that this customer
- * paid already, or NULL for none
+ * @param owgr response details
*/
static void
wallet_get_order_cb (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- enum GNUNET_GenericReturnValue paid,
- enum GNUNET_GenericReturnValue refunded,
- enum GNUNET_GenericReturnValue refund_pending,
- struct TALER_Amount *refund_amount,
- const char *taler_pay_uri,
- const char *already_paid_order_id)
+ const struct TALER_MERCHANT_OrderWalletGetResponse *owgr)
{
struct WalletGetOrderState *gos = cls;
- bool paid_b = (paid == GNUNET_YES);
- bool refunded_b = (refunded == GNUNET_YES);
- bool refund_pending_b = (refund_pending == GNUNET_YES);
+ const struct TALER_MERCHANT_HttpResponse *hr = &owgr->hr;
gos->ogh = NULL;
if (gos->http_status != hr->http_status)
@@ -125,44 +103,36 @@ wallet_get_order_cb (
switch (hr->http_status)
{
case MHD_HTTP_OK:
- // FIXME: use gos->order_reference here to
- // check if the data returned matches that from the POST / PATCH
- if (gos->paid != paid_b)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Order paid does not match\n");
- TALER_TESTING_interpreter_fail (gos->is);
- return;
- }
- if (gos->refunded != refunded_b)
+ if (gos->refunded != owgr->details.success.refunded)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Order refunded does not match\n");
TALER_TESTING_interpreter_fail (gos->is);
return;
}
- if (gos->refund_pending != refund_pending_b)
+ if (gos->refund_pending != owgr->details.success.refund_pending)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Order refund pending does not match\n");
TALER_TESTING_interpreter_fail (gos->is);
return;
}
- if (! paid_b)
+ break;
+ case MHD_HTTP_PAYMENT_REQUIRED:
{
- /* 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 (taler_pay_uri,
- &pud))
+ TALER_MERCHANT_parse_pay_uri (
+ owgr->details.payment_required.taler_pay_uri,
+ &pud))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Taler pay uri `%s' is malformed\n",
- taler_pay_uri);
+ owgr->details.payment_required.taler_pay_uri);
TALER_TESTING_interpreter_fail (gos->is);
return;
}
@@ -216,7 +186,7 @@ wallet_get_order_cb (
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Order pay uri `%s' does not match `%s'\n",
- taler_pay_uri,
+ owgr->details.payment_required.taler_pay_uri,
pud.order_id);
TALER_TESTING_interpreter_fail (gos->is);
TALER_MERCHANT_parse_pay_uri_free (&pud);
@@ -565,34 +535,15 @@ conclude_task (void *cls)
* Process response from a GET /orders/$ID request
*
* @param cls a `struct WalletPollOrderStartState *`
- * @param hr HTTP response details
- * @param paid #GNUNET_YES if the payment is settled, #GNUNET_NO if not
- * settled, #GNUNET_SYSERR on error
- * (note that refunded payments are returned as paid!)
- * @param refunded #GNUNET_YES if there is at least on refund on this payment,
- * #GNUNET_NO if refunded, #GNUNET_SYSERR or error
- * @param refund_pending #GNUNET_YES if there are refunds waiting to be
- * obtained, #GNUNET_NO if all refunds have been obtained, #GNUNET_SYSERR
- * on error.
- * @param refund_amount amount that was refunded, NULL if there
- * was no refund
- * @param taler_pay_uri the URI that instructs the wallets to process
- * the payment
- * @param already_paid_order_id equivalent order that this customer
- * paid already, or NULL for none
+ * @param owgr response details
*/
static void
wallet_poll_order_cb (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- enum GNUNET_GenericReturnValue paid,
- enum GNUNET_GenericReturnValue refunded,
- enum GNUNET_GenericReturnValue refund_pending,
- struct TALER_Amount *refund_amount,
- const char *taler_pay_uri,
- const char *already_paid_order_id)
+ const struct TALER_MERCHANT_OrderWalletGetResponse *owgr)
{
struct WalletPollOrderStartState *pos = cls;
+ const struct TALER_MERCHANT_HttpResponse *hr = &owgr->hr;
pos->ogh = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -602,13 +553,15 @@ wallet_poll_order_cb (
switch (hr->http_status)
{
case MHD_HTTP_OK:
- pos->paid = (GNUNET_YES == paid);
- pos->refunded = (GNUNET_YES == refunded);
- pos->refund_pending = (GNUNET_YES == refund_pending);
- if (NULL != refund_amount)
- pos->refund_available = *refund_amount;
- if (NULL != already_paid_order_id)
- pos->already_paid_order_id = GNUNET_strdup (already_paid_order_id);
+ pos->paid = true;
+ pos->refunded = owgr->details.success.refunded;
+ pos->refund_pending = owgr->details.success.refund_pending;
+ if (owgr->details.success.refunded)
+ pos->refund_available = owgr->details.success.refund_amount;
+ break;
+ case MHD_HTTP_PAYMENT_REQUIRED:
+ pos->already_paid_order_id = GNUNET_strdup (
+ owgr->details.payment_required.already_paid_order_id);
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,