Business-GoCardless
view release on metacpan or search on metacpan
lib/Business/GoCardless/Client.pm view on Meta::CPAN
This is a class for the lower level requests to the gocardless API. generally
there is nothing you should be doing with this.
=cut
use strict;
use warnings;
use feature qw/ say /;
use Moo;
with 'Business::GoCardless::Utils';
use Business::GoCardless::Exception;
use Business::GoCardless::Bill;
use Business::GoCardless::Merchant;
use Business::GoCardless::Payout;
use Business::GoCardless::RedirectFlow;
use Business::GoCardless::Subscription;
use Carp qw/ confess /;
use POSIX qw/ strftime /;
use MIME::Base64 qw/ encode_base64 /;
use LWP::UserAgent;
use HTTP::Date ();
use Time::HiRes ();
use UUID 0.34 ();
use JSON ();
=head1 ATTRIBUTES
=head2 token
Your gocardless API token, this attribute is required.
=head2 base_url
The gocardless API URL, defaults to $ENV{GOCARDLESS_URL} or
https://gocardless.com.
=head2 api_path
The gocardless API path, defaults to /api/v1.
=head2 app_id
Your gocardless app identifier, defaults to $ENV{GOCARDLESS_APP_ID} or will
exit if not set.
=head2 app_secret
Your gocardless app secret, defaults to $ENV{GOCARDLESS_APP_SECRET} or will
exit if not set.
=head2 webhook_secret
Your gocardless webhook secret, defaults to $ENV{GOCARDLESS_WEBHOOK_SECRET} or will
exit if not set.
This can also be an arrayref of secrets, in which case a webhook is valid if its
signature matches any of them. This allows you to rotate your webhook secret, or
receive webhooks from more than one webhook endpoint, without rejecting webhooks:
webhook_secret => [ $new_secret,$old_secret ],
=head2 merchant_id
Your gocardless merchant identifier, defaults to $ENV{GOCARDLESS_MERCHANT_ID}
or will exit if not set.
=head2 user_agent
The user agent string used in requests to the gocardless API, defaults to
business-gocardless/perl/v . $version_of_this_library . - . $api_version
The following attributes only apply to the Pro (v2) API:
=head2 max_retries
The number of times to retry a request that failed due to a network error, a
server error (500, 502, 503, 504), or being rate limited (429). Defaults to 3,
set to 0 to disable retries. Retry delays back off exponentially from 0.5s.
Requests are only retried if it is safe to do so: GET, PUT, and DELETE requests,
and POST requests that create a resource (as these have an idempotency key, see
L</IDEMPOTENCY KEYS>). POST requests to actions (e.g. cancelling a payment) are
only retried if they were rate limited, as the request will not have been
processed by GoCardless in that case.
=head2 max_retry_wait
When rate limited, requests are retried after the time given in the
C<ratelimit-reset> response header. If that is more than this many seconds away
the request is not retried and an exception is thrown. Defaults to 60.
=head2 raise_on_idempotency_conflict
If a create request gets an C<idempotent_creation_conflict> error, which means a
resource has already been created with the idempotency key, then by default the
existing resource is fetched and returned. Set this to true to throw an exception
instead, you can get the ID of the existing resource with the exception's
L<Business::GoCardless::Exception/conflicting_resource_id> method.
=head2 rate_limit
A hashref of the rate limit details from the most recent response from the API,
or undef if no request has been made yet:
my $rate_limit = $Client->rate_limit;
# {
# limit => 1000,
# remaining => 999,
# reset => 'Thu, 03 May 2018 16:00:00 GMT', # as sent by gocardless
# reset_at => 1525363200, # reset as epoch seconds
# }
=cut
has api_version => (
is => 'ro',
required => 0,
( run in 1.156 second using v1.01-cache-2.11-cpan-99fa8243a42 )