summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_wallet_get_order.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-02-24 17:28:29 +0100
committerChristian Grothoff <christian@grothoff.org>2024-02-24 17:28:29 +0100
commit1a695f06eaf4fa635f0235a28dac5dcdea5fd448 (patch)
tree92b9d51b07510f5183ebd23cc441e536ae39b44f /src/testing/testing_api_cmd_wallet_get_order.c
parent70a44acf8458cfed17191950cb41e69b6f06e64d (diff)
downloadmerchant-1a695f06eaf4fa635f0235a28dac5dcdea5fd448.tar.gz
merchant-1a695f06eaf4fa635f0235a28dac5dcdea5fd448.tar.bz2
merchant-1a695f06eaf4fa635f0235a28dac5dcdea5fd448.zip
major refactoring of taler-merchant-httpd_get-orders-ID.c --- no semantic change
Diffstat (limited to 'src/testing/testing_api_cmd_wallet_get_order.c')
-rw-r--r--src/testing/testing_api_cmd_wallet_get_order.c90
1 files changed, 82 insertions, 8 deletions
diff --git a/src/testing/testing_api_cmd_wallet_get_order.c b/src/testing/testing_api_cmd_wallet_get_order.c
index fd4a914d..d55ff0a7 100644
--- a/src/testing/testing_api_cmd_wallet_get_order.c
+++ b/src/testing/testing_api_cmd_wallet_get_order.c
@@ -59,6 +59,18 @@ struct WalletGetOrderState
const char *order_reference;
/**
+ * Reference to a command that created a paid
+ * equivalent order that we expect to be referred
+ * to during repurchase detection, or NULL.
+ */
+ const char *repurchase_order_ref;
+
+ /**
+ * Session Id the order needs to be bound to.
+ */
+ const char *session_id;
+
+ /**
* Whether the order was paid or not.
*/
bool paid;
@@ -125,6 +137,31 @@ wallet_get_order_cb (
const char *order_id;
const struct TALER_ClaimTokenP *claim_token;
+ if (NULL != gos->repurchase_order_ref)
+ {
+ const struct TALER_TESTING_Command *rep_cmd;
+ const char *rep_id;
+ const char *ri;
+
+ rep_cmd = TALER_TESTING_interpreter_lookup_command (
+ gos->is,
+ gos->repurchase_order_ref);
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_order_id (rep_cmd,
+ &rep_id))
+ {
+ TALER_TESTING_FAIL (gos->is);
+ }
+ ri = owgr->details.payment_required.already_paid_order_id;
+ if ( (NULL == ri) ||
+ (0 !=
+ strcmp (ri,
+ rep_id)) )
+ {
+ TALER_TESTING_FAIL (gos->is);
+ }
+ }
+
if (GNUNET_OK !=
TALER_MERCHANT_parse_pay_uri (
owgr->details.payment_required.taler_pay_uri,
@@ -243,7 +280,7 @@ wallet_get_order_run (void *cls,
order_id,
h_contract,
GNUNET_TIME_UNIT_ZERO,
- NULL,
+ gos->session_id,
NULL,
false,
&wallet_get_order_cb,
@@ -274,13 +311,48 @@ wallet_get_order_cleanup (void *cls,
struct TALER_TESTING_Command
-TALER_TESTING_cmd_wallet_get_order (const char *label,
- const char *merchant_url,
- const char *order_reference,
- bool paid,
- bool refunded,
- bool refund_pending,
- unsigned int http_status)
+TALER_TESTING_cmd_wallet_get_order (
+ const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ bool paid,
+ bool refunded,
+ bool refund_pending,
+ unsigned int http_status)
+{
+ struct WalletGetOrderState *gos;
+
+ gos = GNUNET_new (struct WalletGetOrderState);
+ gos->merchant_url = merchant_url;
+ gos->order_reference = order_reference;
+ gos->http_status = http_status;
+ gos->paid = paid;
+ gos->refunded = refunded;
+ gos->refund_pending = refund_pending;
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = gos,
+ .label = label,
+ .run = &wallet_get_order_run,
+ .cleanup = &wallet_get_order_cleanup
+ };
+
+ return cmd;
+ }
+}
+
+
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_wallet_get_order2 (
+ const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ const char *session_id,
+ bool paid,
+ bool refunded,
+ bool refund_pending,
+ const char *repurchase_order_ref,
+ unsigned int http_status)
{
struct WalletGetOrderState *gos;
@@ -289,8 +361,10 @@ TALER_TESTING_cmd_wallet_get_order (const char *label,
gos->order_reference = order_reference;
gos->http_status = http_status;
gos->paid = paid;
+ gos->session_id = session_id;
gos->refunded = refunded;
gos->refund_pending = refund_pending;
+ gos->repurchase_order_ref = repurchase_order_ref;
{
struct TALER_TESTING_Command cmd = {
.cls = gos,