From 807b6e0b125100b1dd8ec56521517522a0cbfd4f Mon Sep 17 00:00:00 2001 From: Jonathan Buchanan Date: Tue, 18 Aug 2020 21:36:50 -0400 Subject: expose refund_pending in merchant lib --- src/include/taler_merchant_service.h | 4 ++++ src/include/taler_merchant_testing_lib.h | 2 ++ src/lib/merchant_api_wallet_get_order.c | 8 +++++++- src/testing/test_merchant_api.c | 11 +++++++++++ src/testing/testing_api_cmd_wallet_get_order.c | 24 ++++++++++++++++++++---- 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index 2da5e03c..771cfbec 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -1465,6 +1465,9 @@ struct TALER_MERCHANT_OrderWalletGetHandle; * (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 refunded_amount amount that was refunded, NULL if there * was no refund * @param taler_pay_uri the URI that instructs the wallets to process @@ -1478,6 +1481,7 @@ typedef void 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); diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h index 5618b441..98751ce9 100644 --- a/src/include/taler_merchant_testing_lib.h +++ b/src/include/taler_merchant_testing_lib.h @@ -600,6 +600,7 @@ TALER_TESTING_cmd_poll_orders_conclude (const char *label, * @param order_reference reference to a command that created an order. * @param paid whether the order has been paid for or not. * @param refunded whether the order has been refunded. + * @param refund_pending whether the order has refunds that haven't been obtained. * @param http_status expected HTTP response code for the request. */ struct TALER_TESTING_Command @@ -608,6 +609,7 @@ TALER_TESTING_cmd_wallet_get_order (const char *label, const char *order_reference, bool paid, bool refunded, + bool refund_pending, unsigned int http_status); diff --git a/src/lib/merchant_api_wallet_get_order.c b/src/lib/merchant_api_wallet_get_order.c index f7ce538c..121b1850 100644 --- a/src/lib/merchant_api_wallet_get_order.c +++ b/src/lib/merchant_api_wallet_get_order.c @@ -87,6 +87,7 @@ cb_failure (struct TALER_MERCHANT_OrderWalletGetHandle *owgh, &hr, GNUNET_SYSERR, GNUNET_SYSERR, + GNUNET_SYSERR, NULL, NULL, NULL); @@ -113,12 +114,14 @@ handle_wallet_get_order_finished (void *cls, { case MHD_HTTP_OK: { - /* FIXME: do something with refund_pending */ struct TALER_Amount refund_amount; bool refunded; + bool refund_pending; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_bool ("refunded", &refunded), + GNUNET_JSON_spec_bool ("refund_pending", + &refund_pending), TALER_JSON_spec_amount ("refund_amount", &refund_amount), GNUNET_JSON_spec_end () @@ -145,6 +148,7 @@ handle_wallet_get_order_finished (void *cls, &hr, GNUNET_YES, refunded ? GNUNET_YES : GNUNET_NO, + refund_pending ? GNUNET_YES : GNUNET_NO, refunded ? &refund_amount : NULL, NULL, /* paid! */ NULL);/* paid! */ @@ -176,6 +180,7 @@ handle_wallet_get_order_finished (void *cls, &hr, GNUNET_NO, GNUNET_NO, + GNUNET_NO, NULL, taler_pay_uri, already_paid); @@ -198,6 +203,7 @@ handle_wallet_get_order_finished (void *cls, &hr, GNUNET_SYSERR, GNUNET_SYSERR, + GNUNET_SYSERR, NULL, NULL, NULL); diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 8e5903e1..d4348bff 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -329,6 +329,7 @@ run (void *cls, "create-proposal-1", false, false, + false, MHD_HTTP_OK), TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1", merchant_url, @@ -361,6 +362,7 @@ run (void *cls, "create-proposal-1", true, false, + false, MHD_HTTP_OK), TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1-2", merchant_url, @@ -681,6 +683,7 @@ run (void *cls, "create-proposal-1r", true, true, + true, MHD_HTTP_OK), TALER_TESTING_cmd_merchant_order_refund ("refund-increase-1r-2", merchant_url, @@ -693,6 +696,7 @@ run (void *cls, "create-proposal-1r", true, true, + true, MHD_HTTP_OK), TALER_TESTING_cmd_wallet_order_refund ("obtain-refund-1r", merchant_url, @@ -701,6 +705,13 @@ run (void *cls, "refund-increase-1r", "refund-increase-1r-2", NULL), + TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r-3", + merchant_url, + "create-proposal-1r", + true, + true, + false, + MHD_HTTP_OK), TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1r", merchant_url, "create-proposal-1r", diff --git a/src/testing/testing_api_cmd_wallet_get_order.c b/src/testing/testing_api_cmd_wallet_get_order.c index aeae42a5..04acf791 100644 --- a/src/testing/testing_api_cmd_wallet_get_order.c +++ b/src/testing/testing_api_cmd_wallet_get_order.c @@ -67,6 +67,11 @@ struct WalletGetOrderState * Whether the order was refunded or not. */ bool refunded; + + /** + * Whether the order has refunds pending. + */ + bool refund_pending; }; @@ -80,6 +85,9 @@ struct WalletGetOrderState * (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 refunded_amount amount that was refunded, NULL if there * was no refund * @param taler_pay_uri the URI that instructs the wallets to process @@ -93,6 +101,7 @@ wallet_get_order_cb ( 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) @@ -101,6 +110,7 @@ wallet_get_order_cb ( struct WalletGetOrderState *gos = cls; bool paid_b = (paid == GNUNET_YES); bool refunded_b = (refunded == GNUNET_YES); + bool refund_pending_b = (refund_pending == GNUNET_YES); gos->ogh = NULL; if (gos->http_status != hr->http_status) @@ -132,6 +142,13 @@ wallet_get_order_cb ( TALER_TESTING_interpreter_fail (gos->is); return; } + if (gos->refund_pending != refund_pending_b) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Order refund pending does not match\n"); + TALER_TESTING_interpreter_fail (gos->is); + return; + } if (!paid_b) { /* FIXME: Check all of the members of `pud` */ @@ -280,11 +297,8 @@ wallet_get_order_cleanup (void *cls, * @param order_reference reference to a command that created an order. * @param paid whether the order has been paid for or not. * @param refunded whether the order has been refunded. + * @param refund_pending whether the order has refunds that haven't been obtained. * @param http_status expected HTTP response code for the request. - * @param ... NULL-terminated list of labels (const char *) of - * refunds (commands) we expect to be aggregated in the transfer - * (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false, - * this parameter is ignored. */ struct TALER_TESTING_Command TALER_TESTING_cmd_wallet_get_order (const char *label, @@ -292,6 +306,7 @@ TALER_TESTING_cmd_wallet_get_order (const char *label, const char *order_reference, bool paid, bool refunded, + bool refund_pending, unsigned int http_status) { struct WalletGetOrderState *gos; @@ -302,6 +317,7 @@ TALER_TESTING_cmd_wallet_get_order (const char *label, gos->http_status = http_status; gos->paid = paid; gos->refunded = refunded; + gos->refund_pending = refund_pending; { struct TALER_TESTING_Command cmd = { .cls = gos, -- cgit v1.2.3