diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/merchant_api_poll_payment.c | 7 | ||||
-rw-r--r-- | src/lib/test_merchant_api.c | 2 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_poll_payment.c | 22 |
3 files changed, 31 insertions, 0 deletions
diff --git a/src/lib/merchant_api_poll_payment.c b/src/lib/merchant_api_poll_payment.c index bef2aac8..6b0190af 100644 --- a/src/lib/merchant_api_poll_payment.c +++ b/src/lib/merchant_api_poll_payment.c @@ -205,6 +205,9 @@ handle_poll_payment_finished (void *cls, * before generating an unpaid response). Note that this is just provided to * the server, we as client will block until the response comes back or until * #TALER_MERCHANT_poll_payment_cancel() is called. + * @param min_refund long poll for the service to approve a refund exceeding this value; + * use NULL to not wait for any refund (only for payment). Only makes sense + * with a non-zero @a timeout. * @param poll_payment_cb callback which will work the response gotten from the backend * @param poll_payment_cb_cls closure to pass to @a poll_payment_cb * @return handle for this operation, NULL upon errors @@ -217,6 +220,7 @@ TALER_MERCHANT_poll_payment ( const struct GNUNET_HashCode *h_contract, const char *session_id, struct GNUNET_TIME_Relative timeout, + const struct TALER_Amount *min_refund, TALER_MERCHANT_PollPaymentCallback poll_payment_cb, void *poll_payment_cb_cls) { @@ -253,6 +257,9 @@ TALER_MERCHANT_poll_payment ( "h_contract", h_contract_s, (0 != ts) ? "timeout" : NULL, timeout_s, + (NULL != min_refund) ? "refund" : NULL, + (NULL != min_refund) ? TALER_amount2s ( + min_refund) : NULL, NULL); GNUNET_free (h_contract_s); GNUNET_free (timeout_s); diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c index f16cf5f0..1f3626ec 100644 --- a/src/lib/test_merchant_api.c +++ b/src/lib/test_merchant_api.c @@ -279,6 +279,7 @@ run (void *cls, TALER_TESTING_cmd_poll_payment_start ("poll-payment-1", merchant_url, "create-proposal-1", + NULL, GNUNET_TIME_UNIT_MILLISECONDS), TALER_TESTING_cmd_poll_payment_conclude ("poll-payment-conclude-1", MHD_HTTP_OK, @@ -287,6 +288,7 @@ run (void *cls, TALER_TESTING_cmd_poll_payment_start ("poll-payment-2", merchant_url, "create-proposal-1", + NULL, GNUNET_TIME_UNIT_MINUTES), TALER_TESTING_cmd_check_payment_start ("check-payment-2", merchant_url, diff --git a/src/lib/testing_api_cmd_poll_payment.c b/src/lib/testing_api_cmd_poll_payment.c index 6d8c37c4..32fcaddf 100644 --- a/src/lib/testing_api_cmd_poll_payment.c +++ b/src/lib/testing_api_cmd_poll_payment.c @@ -85,6 +85,11 @@ struct PollPaymentStartState struct TALER_Amount refund; /** + * Refund to wait for, set if @e wait_for_refund is #GNUNET_YES + */ + struct TALER_Amount min_refund; + + /** * Final HTTP response status code. */ unsigned int http_status; @@ -99,6 +104,11 @@ struct PollPaymentStartState */ int refunded; + /** + * #GNUNET_YES if we are waiting for a refund. + */ + int wait_for_refund; + }; @@ -325,6 +335,9 @@ poll_payment_start_run (void *cls, h_contract, NULL, /* session id */ cps->timeout, + (GNUNET_YES == cps->wait_for_refund) + ? &cps->min_refund + : NULL, &poll_payment_cb, cps); GNUNET_assert (NULL != cps->cpo); @@ -341,6 +354,7 @@ poll_payment_start_run (void *cls, * @param merchant_url merchant base url * @param proposal_reference the proposal whose payment status * is going to be checked. + * @param min_refund minimum refund to wait for * @param timeout which timeout to use * @return the command */ @@ -348,6 +362,7 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_poll_payment_start (const char *label, const char *merchant_url, const char *proposal_reference, + const char *min_refund, struct GNUNET_TIME_Relative timeout) { struct PollPaymentStartState *cps; @@ -356,6 +371,13 @@ TALER_TESTING_cmd_poll_payment_start (const char *label, cps->proposal_reference = proposal_reference; cps->merchant_url = merchant_url; cps->timeout = timeout; + if (NULL != min_refund) + { + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (min_refund, + &cps->min_refund)); + cps->wait_for_refund = GNUNET_YES; + } { struct TALER_TESTING_Command cmd = { .cls = cps, |