view release on metacpan or search on metacpan
- Add count, app_fee, retry_if_possible,
earliest_charge_date_after_resume, and parent_plan_paused
attributes to Business::GoCardless::Subscription
- Add pending_customer_approval, customer_approval_denied, finished,
and paused status checks to Business::GoCardless::Subscription
- Fix Pro->customer( $id ), which returned an unpopulated object due
to using the wrong response key
- Fix pagination in the Pro (v2) API: the Paginator now uses the
cursors in the response meta data, previously only the first page
of results was ever returned
- Payment->refund now creates a refund via the /refunds endpoint and
returns a new Business::GoCardless::Refund object (it previously
always returned 0). The amount to refund must be passed explicitly
- Mandate->update now returns the updated Mandate object rather than
the raw response data (BREAKING CHANGE if you used the return value)
- Webhook::Event->resources now supports refunds and customers events,
add is_customer method
- Webhook::V2 objects from Pro->webhooks now have the webhook delivery
attributes (id, url, response_code, successful, is_test, etc)
- Decode API responses as UTF-8, previously strings containing non
ASCII characters were returned as UTF-8 encoded bytes rather than
lib/Business/GoCardless/BankAccountDetail.pm view on Meta::CPAN
=head1 NAME
Business::GoCardless::BankAccountDetail
=head1 DESCRIPTION
A class for a gocardless bank account detail, extends L<Business::GoCardless::Resource>
The encrypted bank account details of a customer bank account, as a flattened
JWE (RFC 7516). You will need to decrypt this with your private key, see
L<https://developer.gocardless.com/api-reference/#core-endpoints-bank-account-details>
=cut
use strict;
use warnings;
use Moo;
extends 'Business::GoCardless::Resource';
=head1 ATTRIBUTES
lib/Business/GoCardless/BillingRequest.pm view on Meta::CPAN
return Business::GoCardless::BillingRequestFlow->new(
client => $self->client,
%{ $data->{billing_request_flows} },
);
}
sub institutions {
my ( $self,%filters ) = @_;
my $uri = sprintf( $self->endpoint,$self->id ) . '/institutions';
$uri .= '?' . $self->client->normalize_params( \%filters ) if keys %filters;
my $data = $self->client->api_get( $uri );
return map {
Business::GoCardless::Institution->new( client => $self->client,%{ $_ } )
} @{ $data->{institutions} // [] };
}
sub customer_id { return shift->_link( 'customer' ) }
lib/Business/GoCardless/Client.pm view on Meta::CPAN
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
lib/Business/GoCardless/MandateImportEntry.pm view on Meta::CPAN
has [ qw/
created_at
links
processing_errors
record_identifier
/ ] => (
is => 'rw',
);
has '+endpoint' => (
default => sub { '/mandate_import_entries/%s' },
);
=head1 Links
Shortcut methods to get the IDs of the linked resources
mandate_import_id
mandate_id
customer_id
lib/Business/GoCardless/Merchant.pm view on Meta::CPAN
pending_balance
sub_resource_uris
uri
/ ] => (
is => 'rw',
);
sub BUILD {
my ( $self ) = @_;
my $data = $self->client->api_get( sprintf( $self->endpoint,$self->id ) );
foreach my $attr ( keys( %{ $data } ) ) {
eval { $self->$attr( $data->{$attr} ); };
$@ && do {
carp( "Couldn't set $attr on @{[ ref( $self ) ]}: $@" );
};
}
return $self;
}
lib/Business/GoCardless/Merchant.pm view on Meta::CPAN
=cut
sub bills { shift->_list( 'bills',shift ) }
sub pre_authorizations { shift->_list( 'pre_authorizations',shift )}
sub subscriptions { shift->_list( 'subscriptions',shift ) }
sub payouts { shift->_list( 'payouts',shift ) }
sub users { shift->_list( 'users',shift ) }
sub _list {
my ( $self,$endpoint,$filters ) = @_;
my $class = {
bills => 'Bill',
pre_authorizations => 'PreAuthorization',
subscriptions => 'Subscription',
payouts => 'Payout',
users => 'User',
}->{ $endpoint };
$filters //= {};
$filters->{per_page} ||= 100;
$filters->{page} ||= 1;
my $uri = sprintf( $self->endpoint,$self->id ) . "/$endpoint";
if ( keys( %{ $filters } ) ) {
$uri .= '?' . $self->client->normalize_params( $filters );
}
my ( $data,$links,$info ) = $self->client->api_get( $uri );
$class = "Business::GoCardless::$class";
my @objects = map { $class->new( client => $self->client,%{ $_ } ) }
@{ $data };
lib/Business/GoCardless/OutboundPaymentImportEntry.pm view on Meta::CPAN
metadata
processed_at
reference
scheme
validation_errors
verification_result
/ ] => (
is => 'rw',
);
has '+endpoint' => (
default => sub { '/outbound_payment_import_entries/%s' },
);
=head1 AUTHOR
Lee Johnson - C<lee@payprop.com>
This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself. If you would like to contribute documentation,
features, bug fixes, or anything else then please raise an issue / pull request:
lib/Business/GoCardless/Pro.pm view on Meta::CPAN
L</Setting up a mandate with a Billing Request>.
Also note this class also currently inherits from L<Business::GoCardless>
so has all attributes and methods available on that class (some of which may not
make sense from the context of the Pro API).
=head1 SYNOPSIS
The following examples show instantiating the object and getting a resource
(Payment in this case) to manipulate. For more examples see the t/004_end_to_end_pro.t
script, which can be run against the gocardless sandbox (or even live) endpoint
when given the necessary ENV variables.
my $GoCardless = Business::GoCardless::Pro->new(
token => $your_gocardless_token
client_details => {
base_url => $gocardless_url, # defaults to https://api.gocardless.com
webhook_secret => $secret,
},
);
lib/Business/GoCardless/Pro.pm view on Meta::CPAN
# get a list of resources (pager), %filters are optional
my @billing_requests = $GoCardless->billing_requests( %filters );
# create a resource, returns a Business::GoCardless::BillingRequest
my $BillingRequest = $GoCardless->create_billing_request( %params );
Operations on a resource (cancel, update, etc) are methods on the resource
objects, see the documentation of each resource class for these. The parameters
and filters are as documented in the GoCardless API reference. Note that some of
the endpoints are restricted, for example to GoCardless Embed customers or to
those with custom payment pages enabled, see the GoCardless API reference for
details.
=head2 Setting up a mandate with a Billing Request
Billing Requests have replaced Redirect Flows, for example to set up a mandate
using the GoCardless hosted payment pages:
my $BillingRequest = $GoCardless->create_billing_request(
mandate_request => { scheme => 'bacs' },
lib/Business/GoCardless/Pro.pm view on Meta::CPAN
my @payment_accounts = $GoCardless->payment_accounts( %filters );
=head2 Payment Account Transactions
See L<Business::GoCardless::PaymentAccountTransaction>
my $PaymentAccountTransaction = $GoCardless->payment_account_transaction( $id );
=cut
# the class for each of the resources (keyed on the API endpoint), and the
# path for the resource if it isn't the same as the endpoint
my %RESOURCE_CLASS = (
payments => 'Payment',
redirect_flows => 'RedirectFlow',
customers => 'Customer',
subscriptions => 'Subscription',
webhooks => 'Webhook::V2',
payouts => 'Payout',
);
my %RESOURCE_PATH;
# most of the resources follow the same pattern in the API, so we generate the
# methods for them from the following. for each resource the operations are:
#
# get => $Pro->$singular( $id )
# list => $Pro->$endpoint( %filters ) (pager)
# create => $Pro->create_$singular( %params )
#
my @RESOURCES = (
# endpoint class singular operations
[ mandates => 'Mandate' => mandate => qw/ list create / ],
[ subscriptions => 'Subscription' => subscription => qw/ create / ],
[ customers => 'Customer' => customer => qw/ create / ],
[ refunds => 'Refund' => refund => qw/ get list create / ],
[ events => 'Webhook::Event' => event => qw/ get list / ],
[ billing_requests => 'BillingRequest' => billing_request => qw/ get list create / ],
[ billing_request_flows => 'BillingRequestFlow' => billing_request_flow => qw/ create / ],
[ billing_request_templates => 'BillingRequestTemplate' => billing_request_template => qw/ get list create / ],
[ bank_authorisations => 'BankAuthorisation' => bank_authorisation => qw/ get create / ],
[ institutions => 'Institution' => institution => qw/ list / ],
lib/Business/GoCardless/Pro.pm view on Meta::CPAN
[ payment_account_transactions => 'PaymentAccountTransaction' => payment_account_transaction => qw/ get / ],
[ bank_account_details => 'BankAccountDetail' => bank_account_detail => qw// ],
[ customer_notifications => 'CustomerNotification' => customer_notification => qw// ],
);
$RESOURCE_PATH{logos} = '/branding/logos';
$RESOURCE_PATH{payer_themes} = '/branding/payer_themes';
foreach my $resource ( @RESOURCES ) {
my ( $endpoint,$class,$singular,@operations ) = @{ $resource };
$RESOURCE_CLASS{$endpoint} = $class;
my %methods = (
get => [ $singular => sub {
my ( $self,$id ) = @_;
return $self->_get( $endpoint,$id );
} ],
list => [ $endpoint => sub {
my ( $self,%filters ) = @_;
return $self->_list( $endpoint,\%filters );
} ],
create => [ "create_$singular" => sub {
my ( $self,%params ) = @_;
return $self->_create( $endpoint,\%params );
} ],
);
foreach my $operation ( @operations ) {
my ( $method,$code ) = @{ $methods{$operation} };
# make sure we don't clobber any explicitly defined methods
confess( "$method is already defined" )
if __PACKAGE__->can( $method );
lib/Business/GoCardless/Pro.pm view on Meta::CPAN
no strict 'refs';
*{ __PACKAGE__ . "::$method" } = $code;
}
}
# load all of the resource classes
eval "require Business::GoCardless::$_; 1" || die $@
for sort values( %RESOURCE_CLASS );
sub _new_resource {
my ( $self,$endpoint,$data ) = @_;
my $class = "Business::GoCardless::$RESOURCE_CLASS{$endpoint}";
return $endpoint eq 'webhooks'
? $class->_new_from_api( $self->client,$data )
: $class->new( client => $self->client,%{ $data // {} } );
}
sub _get {
my ( $self,$endpoint,$id,$headers ) = @_;
my $path = $RESOURCE_PATH{$endpoint} // "/$endpoint";
my $data = $self->client->api_get( "$path/$id",undef,$headers );
return $self->_new_resource( $endpoint,$data->{$endpoint} );
}
sub _create {
my ( $self,$endpoint,$params,%opts ) = @_;
my $data = $self->_create_request( $endpoint,$params,%opts );
return $self->_new_resource( $endpoint,$data->{$endpoint} );
}
sub _create_request {
my ( $self,$endpoint,$params,%opts ) = @_;
my %params = %{ $params // {} };
my %headers = %{ $opts{headers} // {} };
# not part of the request body, see IDEMPOTENCY KEYS
my $key = delete( $params{idempotency_key} );
$headers{'Idempotency-Key'} = $key if defined $key;
my $path = $opts{path} // $RESOURCE_PATH{$endpoint} // "/$endpoint";
return $self->client->api_post(
$path,{ $endpoint => \%params },\%headers
);
}
sub _list {
my ( $self,$endpoint,$filters,$path ) = @_;
$filters //= {};
$path //= $RESOURCE_PATH{$endpoint} // "/$endpoint";
my $class = "Business::GoCardless::$RESOURCE_CLASS{$endpoint}";
my $uri_for = sub {
my ( %cursor ) = @_;
# cursor params replace any passed in the original filters
my %params = ( %{ $filters },%cursor );
delete( @params{ grep { ! defined $params{$_} } keys %params } );
return keys( %params )
? "$path?" . $self->client->normalize_params( \%params )
lib/Business/GoCardless/Pro.pm view on Meta::CPAN
};
# the v2 API uses cursor based pagination, so we construct the links for
# next / previous / first from the meta data in each page of results
my $page_loader = sub {
my ( $uri ) = @_;
my ( $data ) = $self->client->api_get( $uri );
my $cursors = $data->{meta}{cursors} // {};
my @objects = map { $self->_new_resource( $endpoint,$_ ) }
@{ $data->{$endpoint} // [] };
my $links = {
first => $uri_for->( before => undef,after => undef ),
( $cursors->{after} ? ( next => $uri_for->( after => $cursors->{after},before => undef ) ) : () ),
( $cursors->{before} ? ( previous => $uri_for->( before => $cursors->{before},after => undef ) ) : () ),
};
return ( \@objects,$links,$data->{meta} // {} );
};
lib/Business/GoCardless/Pro.pm view on Meta::CPAN
client => $self->client,
links => $links,
info => $info,
objects => $objects,
page_loader => $page_loader,
);
}
=head1 OTHER RESOURCE METHODS
The following methods are for API endpoints that don't follow the standard
pattern of the L</RESOURCE METHODS>.
=head2 create_billing_request_with_actions
Create a billing request and perform actions on it in a single request (this
is restricted to custom payment pages, and doesn't support ACH/PAD). Returns a
L<Business::GoCardless::BillingRequest> object, and in list context also the
L<Business::GoCardless::BankAuthorisation> if one was created:
my ( $BillingRequest,$BankAuthorisation )
lib/Business/GoCardless/Resource.pm view on Meta::CPAN
use strict;
use warnings;
use Moo;
use Carp qw/ carp confess /;
use JSON ();
=head1 ATTRIBUTES
=head2 endpoint
The gocardless API endpoint that corresponds to the resource, for example a
L<Business::GoCardless::Bill> object will have an endpoint of "bills". This
is handled automatically, you do not need to pass this unless the name of the
resource differs significantly from the endpoint.
=head2 client
The client object, defaults to L<Business::GoCardless::Client>.
=cut
has endpoint => (
is => 'ro',
default => sub {
my ( $self ) = @_;
my ( $class ) = ( split( ':',ref( $self ) ) )[-1];
confess( "You must subclass Business::GoCardless::Resource" )
if $class eq 'Resource';
$class =~ s/([a-z])([A-Z])/$1 . '_' . lc( $2 )/eg;
$class = lc( $class );
lib/Business/GoCardless/Resource.pm view on Meta::CPAN
Calls the gocardless API and populates the resource object with the data.
my $Bill = Business::GoCardless::Bill->new( client => $self->client );
$Bill->find_with_client;
=cut
sub find_with_client {
my ( $self,$sub_key ) = @_;
my $path = sprintf( $self->endpoint,( $self->id // '' ) );
my $data = $self->client->api_get( $path );
$data = $data->{$sub_key} if $sub_key;
foreach my $attr ( keys( %{ $data } ) ) {
# as per https://developer.gocardless.com/api-reference/#overview-backwards-compatibility
#
# The following changes are considered backwards compatible
# "Adding new properties to the responses from existing API endpoints"
#
# so we need to be able to handle attributes we don't know about yet, hence the eval
eval { $self->$attr( $data->{$attr} ); };
$@ && do {
carp( "Couldn't set $attr on @{[ ref( $self ) ]}: $@" );
};
}
return $self;
}
sub _operation {
my ( $self,$operation,$method,$params,$suffix ) = @_;
$method //= 'api_post',
my $uri = $operation
? sprintf( $self->endpoint,$self->id ) . "/$operation"
: sprintf( $self->endpoint,$self->id );
$uri .= "/$suffix" if $suffix;
my $data = $self->client->$method( $uri,$params );
if ( $self->client->api_version > 1 ) {
# v2 responses wrap the resource in a key, e.g. { payments => { ... } }
my $key = $self->_resource_key;
$data = $data->{$key} if ref( $data->{$key} ) eq 'HASH';
}
lib/Business/GoCardless/Resource.pm view on Meta::CPAN
};
}
return $self;
}
# the following are for the v2 API, and used by the resource classes to
# implement their operations (cancel, update, etc)
# the key the resource is wrapped in for requests and responses, which is the
# first part of the endpoint, e.g. /billing_requests/%s -> billing_requests
sub _resource_key {
my ( $self ) = @_;
my ( $key ) = $self->endpoint =~ m!^/([^/]+)!;
return $key;
}
# POST to an action, e.g. /payments/PM123/actions/cancel, any params for the
# action are sent wrapped in a data key as required by the API
sub _action {
my ( $self,$action,%params ) = @_;
return $self->_operation(
undef,'api_post',
lib/Business/GoCardless/Resource.pm view on Meta::CPAN
# DELETE the resource
sub _delete {
my ( $self ) = @_;
return $self->_operation( undef,'api_delete' );
}
sub uri {
my ( $self ) = @_;
my $endpoint = sprintf( $self->endpoint,$self->id );
return $self->client->api_version > 1
? join( '/',$self->client->base_url . $self->client->api_path . $endpoint )
: join( '/',$self->client->base_url . $endpoint );
}
=head2 to_hash
Returns a hash representation of the object.
my %data = $Bill->to_hash;
=head2 to_json
lib/Business/GoCardless/Webhook/Event.pm view on Meta::CPAN
action
resource_type
links
details
metadata
resource_metadata
customer_notifications
source
This class is used for events in webhooks, and for events from the events API
endpoints (see L<Business::GoCardless::Pro/events>).
=cut
has [ qw/
id
created_at
action
resource_type
links
/ ] => (
lib/Business/GoCardless/Webhook/V2.pm view on Meta::CPAN
use Business::GoCardless::Exception;
use Business::GoCardless::Webhook::Event;
=head1 ATTRIBUTES
json
signature
has_legacy_data
The following attributes are only populated when the object comes from the
webhooks list endpoint (i.e. L<Business::GoCardless::Pro/webhooks>), and contain
details of the webhook delivery itself:
id
created_at
url
request_headers
response_code
response_body
response_body_truncated
response_headers
lib/Business/GoCardless/Webhook/V2.pm view on Meta::CPAN
...
}
=cut
sub is_legacy { 0 }
=head2 retry
Retry the delivery of a webhook, only for webhooks from the webhooks list
endpoint (see L<Business::GoCardless::Pro/webhooks>). Returns a new
Webhook::V2 object for the new delivery:
my $Retried = $Webhook->retry if ! $Webhook->successful;
=cut
sub retry {
my ( $self ) = @_;
my $data = $self->client->api_post(
t/business/gocardless.t view on Meta::CPAN
);
cmp_deeply(
$GoCardless->client_details,
{ api_version => 1 },
'client_details'
);
isa_ok( $GoCardless->client,'Business::GoCardless::Client' );
# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {} );
*LWP::UserAgent::request = sub { $mock };
test_bill( $GoCardless,$mock );
test_merchant( $GoCardless,$mock );
test_payout( $GoCardless,$mock );
t/business/gocardless.t view on Meta::CPAN
} }
}
sub _user_obj {
return bless( {
'client' => ignore(),
'created_at' => '2011-11-18T17:06:15Z',
'email' => 'customer40@gocardless.com',
'endpoint' => '/users/%s',
'first_name' => 'Frank',
'id' => 'JKH8HGKL9H',
'last_name' => 'Smith'
}, 'Business::GoCardless::User' );
}
sub _subscription_json {
my ( $status ) = @_;
t/business/gocardless.t view on Meta::CPAN
my ( $status ) = @_;
$status //= 'active';
return bless( {
'amount' => '7.50',
'client' => ignore(),
'created_at' => '2014-08-20T21:41:25Z',
'currency' => 'GBP',
'description' => 'GoCardless magazine',
'endpoint' => '/subscriptions/%s',
'expires_at' => '2016-08-20T21:41:25Z',
'id' => '0NZ71WBMVF',
'interval_length' => '1',
'interval_unit' => 'month',
'merchant_id' => '06Z06JWQW1',
'name' => 'Membership subscription',
'next_interval_start' => '2014-09-20T00:00:00Z',
'setup_fee' => '0.00',
'start_at' => '2014-12-31T00:00:00Z',
'status' => $status,
t/business/gocardless.t view on Meta::CPAN
my ( $status ) = @_;
$status //= 'active';
return bless( {
'client' => ignore(),
'created_at' => '2014-08-20T21:41:25Z',
'currency' => 'GBP',
'description' => 'GoCardless magazine',
'endpoint' => '/pre_authorizations/%s',
'expires_at' => '2016-08-20T21:41:25Z',
'id' => '1234ABCD',
'interval_length' => '1',
'interval_unit' => 'month',
'max_amount' => '750.00',
'merchant_id' => '06Z06JWQW1',
'name' => 'Computer support invoices',
'next_interval_start' => '2014-09-20T00:00:00Z',
'remaining_amount' => '750.00',
'setup_fee' => '10.00',
t/business/gocardless.t view on Meta::CPAN
my ( $extra ) = @_;
$extra //= {};
return bless( {
%{ $extra },
'amount' => '12.37',
'bank_reference' => 'JOHNSMITH-Z5DRM',
'client' => ignore(),
'created_at' => '2013-05-10T16:34:34Z',
'endpoint' => '/payouts/%s',
'id' => '0BKR1AZNJF',
'paid_at' => '2013-05-10T17:00:26Z',
'transaction_fees' => '0.13'
}, 'Business::GoCardless::Payout' );
}
sub _merchant_json {
return qq{{
"id":"06Z06JWQW1",
t/business/gocardless.t view on Meta::CPAN
sub _merchant_obj {
return bless(
{
'balance' => '0.0',
'client' => ignore(),
'created_at' => '2014-01-22T10:27:42Z',
'description' => 'We do stuff.',
'email' => 'lee@foo.com',
'endpoint' => '/merchants/%s',
'eur_balance' => '0.0',
'eur_pending_balance' => '0.0',
'first_name' => 'Lee',
'gbp_balance' => '0.0',
'gbp_pending_balance' => '0.0',
'hide_variable_amount' => JSON::false,
'id' => '06Z06JWQW1',
'last_name' => 'Johnson',
'name' => 'Company Ltd',
'next_payout_amount' => undef,
t/business/gocardless.t view on Meta::CPAN
$status //= 'pending';
return bless({
'amount' => '44.0',
'can_be_retried' => JSON::false,
'charge_customer_at' => '2014-09-01',
'client' => ignore(),
'created_at' => '2014-08-20T21:41:25Z',
'currency' => 'GBP',
'description' => 'Month 2 payment',
'endpoint' => '/bills/%s',
'gocardless_fees' => '0.44',
'id' => '123ABCD',
'is_setup_fee' => JSON::false,
'merchant_id' => '06Z06JWQW1',
'name' => 'Bill 2 for Subscription description',
'paid_at' => undef,
'partner_fees' => '0',
'payout_id' => undef,
'source_id' => 'YH1VEVQHYVB1UT',
'source_type' => 'ad_hoc_authorization',
t/business/gocardless/balance.t view on Meta::CPAN
api_version => 2,
base_url => 'https://api.gocardless.com',
),
),
'Business::GoCardless::Balance'
);
can_ok(
$Balance,
qw/
endpoint
amount
balance_type
currency
last_updated_at
links
/,
);
is( $Balance->endpoint,'/balances/%s','endpoint' );
done_testing();
# vim: ts=4:sw=4:et
t/business/gocardless/bankaccountdetail.t view on Meta::CPAN
base_url => 'https://api.gocardless.com',
),
id => 'ID123',
),
'Business::GoCardless::BankAccountDetail'
);
can_ok(
$Detail,
qw/
endpoint
ciphertext
encrypted_key
id
iv
protected
tag
/,
);
is( $Detail->endpoint,'/bank_account_details/%s','endpoint' );
is( $Detail->uri,'https://api.gocardless.com/bank_account_details/ID123','->uri' );
done_testing();
# vim: ts=4:sw=4:et
t/business/gocardless/bankaccountholderverification.t view on Meta::CPAN
base_url => 'https://api.gocardless.com',
),
id => 'ID123',
),
'Business::GoCardless::BankAccountHolderVerification'
);
can_ok(
$Verification,
qw/
endpoint
actual_account_name
id
result
status
type
pending
completed
/,
);
is( $Verification->endpoint,'/bank_account_holder_verifications/%s','endpoint' );
is( $Verification->uri,'https://api.gocardless.com/bank_account_holder_verifications/ID123','->uri' );
note( "status checks" );
ok( ! $Verification->pending,'! ->pending when no status' );
my @statuses = qw/ pending completed /;
foreach my $status ( @statuses ) {
$Verification->status( $status );
t/business/gocardless/bankauthorisation.t view on Meta::CPAN
base_url => 'https://api.gocardless.com',
),
id => 'ID123',
),
'Business::GoCardless::BankAuthorisation'
);
can_ok(
$BankAuthorisation,
qw/
endpoint
authorisation_type
authorised_at
created_at
expires_at
id
last_visited_at
links
qr_code_url
redirect_uri
url
/,
);
is( $BankAuthorisation->endpoint,'/bank_authorisations/%s','endpoint' );
is( $BankAuthorisation->uri,'https://api.gocardless.com/bank_authorisations/ID123','->uri' );
done_testing();
# vim: ts=4:sw=4:et
t/business/gocardless/bankdetailslookup.t view on Meta::CPAN
api_version => 2,
base_url => 'https://api.gocardless.com',
),
),
'Business::GoCardless::BankDetailsLookup'
);
can_ok(
$Lookup,
qw/
endpoint
available_debit_schemes
bank_name
bic
payer_name_verification_result
/,
);
is( $Lookup->endpoint,'/bank_details_lookups/%s','endpoint' );
done_testing();
# vim: ts=4:sw=4:et
t/business/gocardless/bill.t view on Meta::CPAN
app_secret => 'baz',
merchant_id => 'boz',
),
),
'Business::GoCardless::Bill'
);
can_ok(
$Bill,
qw/
endpoint
amount
gocardless_fees
partner_fees
amount_minus_fees
currency
description
name
status
can_be_retried
can_be_cancelled
t/business/gocardless/bill.t view on Meta::CPAN
pending
paid
failed
chargedback
cancelled
withdrawn
refunded
/,
);
is( $Bill->endpoint,'/bills/%s','endpoint' );
$Bill->status( 'unknown' );
ok( ! $Bill->pending,'pending' );
ok( ! $Bill->paid,'paid' );
ok( ! $Bill->failed,'failed' );
ok( ! $Bill->chargedback,'chargedback' );
ok( ! $Bill->cancelled,'cancelled' );
ok( ! $Bill->withdrawn,'withdrawn' );
ok( ! $Bill->refunded,'refunded' );
t/business/gocardless/billingrequest.t view on Meta::CPAN
payment_request_payment => 'PM123',
subscription_request_subscription => 'SB123',
},
),
'Business::GoCardless::BillingRequest'
);
can_ok(
$BillingRequest,
qw/
endpoint
actions
auto_fulfil
created_at
creditor_address
creditor_identifier
creditor_name
creditor_scheme_identifier
experimentation
fallback_enabled
fallback_occurred
t/business/gocardless/billingrequest.t view on Meta::CPAN
instalment_schedule_id
mandate_id
payment_id
subscription_id
create_flow
institutions
/,
);
is( $BillingRequest->endpoint,'/billing_requests/%s','endpoint' );
is( $BillingRequest->uri,'https://api.gocardless.com/billing_requests/BRQ123','->uri' );
note( "status checks" );
ok( ! $BillingRequest->pending,'! ->pending when no status' );
my @statuses = qw/ pending ready_to_fulfil fulfilling fulfilled cancelled /;
foreach my $status ( @statuses ) {
$BillingRequest->status( $status );
t/business/gocardless/billingrequest.t view on Meta::CPAN
is( $BillingRequest->mandate_id,'MD123','->mandate_id' );
is( $BillingRequest->payment_id,'PM123','->payment_id' );
is( $BillingRequest->subscription_id,'SB123','->subscription_id' );
$BillingRequest->links( undef );
ok( ! $BillingRequest->customer_id,'! ->customer_id when no links' );
note( "operations" );
# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
my $request;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {} );
*LWP::UserAgent::request = sub { $request = $_[1]; $mock };
$mock->mock( 'content',sub { '{"billing_requests":{"id":"BRQ123","status":"after collect_customer_details"}}' } );
t/business/gocardless/billingrequestflow.t view on Meta::CPAN
base_url => 'https://api.gocardless.com',
),
id => 'ID123',
),
'Business::GoCardless::BillingRequestFlow'
);
can_ok(
$Flow,
qw/
endpoint
authorisation_url
auto_fulfil
created_at
customer_details_captured
exit_uri
expires_at
id
language
links
lock_bank_account
t/business/gocardless/billingrequestflow.t view on Meta::CPAN
redirect_uri
session_token
show_redirect_buttons
show_success_redirect_button
skip_success_screen
initialise
/,
);
is( $Flow->endpoint,'/billing_request_flows/%s','endpoint' );
is( $Flow->uri,'https://api.gocardless.com/billing_request_flows/ID123','->uri' );
note( "operations" );
# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
my $request;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {} );
*LWP::UserAgent::request = sub { $request = $_[1]; $mock };
$mock->mock( 'content',sub { '{"billing_request_flows":{"id":"ID123","session_token":"after initialise"}}' } );
t/business/gocardless/billingrequesttemplate.t view on Meta::CPAN
base_url => 'https://api.gocardless.com',
),
id => 'ID123',
),
'Business::GoCardless::BillingRequestTemplate'
);
can_ok(
$Template,
qw/
endpoint
authorisation_url
created_at
id
mandate_request_constraints
mandate_request_currency
mandate_request_description
mandate_request_metadata
mandate_request_scheme
mandate_request_verify
metadata
t/business/gocardless/billingrequesttemplate.t view on Meta::CPAN
payment_request_description
payment_request_metadata
payment_request_scheme
redirect_uri
updated_at
update
/,
);
is( $Template->endpoint,'/billing_request_templates/%s','endpoint' );
is( $Template->uri,'https://api.gocardless.com/billing_request_templates/ID123','->uri' );
note( "operations" );
# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
my $request;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {} );
*LWP::UserAgent::request = sub { $request = $_[1]; $mock };
$mock->mock( 'content',sub { '{"billing_request_templates":{"id":"ID123","name":"after update"}}' } );
t/business/gocardless/block.t view on Meta::CPAN
base_url => 'https://api.gocardless.com',
),
id => 'ID123',
),
'Business::GoCardless::Block'
);
can_ok(
$Block,
qw/
endpoint
active
block_type
created_at
id
reason_description
reason_type
resource_reference
updated_at
disable
enable
/,
);
is( $Block->endpoint,'/blocks/%s','endpoint' );
is( $Block->uri,'https://api.gocardless.com/blocks/ID123','->uri' );
note( "operations" );
# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
my $request;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {} );
*LWP::UserAgent::request = sub { $request = $_[1]; $mock };
$mock->mock( 'content',sub { '{"blocks":{"id":"ID123","active":"after disable"}}' } );
t/business/gocardless/client.t view on Meta::CPAN
api_delete
/,
);
is( $Client->max_retries,3,'max_retries default' );
is( $Client->max_retry_wait,60,'max_retry_wait default' );
ok( ! $Client->raise_on_idempotency_conflict,'raise_on_idempotency_conflict default' );
ok( ! $Client->rate_limit,'no rate_limit before any requests' );
# monkey patching LWP here to make this test work without having to actually
# hit the endpoints - each request gets the next response in @responses
no warnings 'redefine';
no warnings 'once';
my ( @responses,@requests,@sleeps );
*LWP::UserAgent::request = sub {
my ( $ua,$req ) = @_;
push( @requests,$req );
return shift( @responses ) // die "No more responses";
};
t/business/gocardless/creditor.t view on Meta::CPAN
base_url => 'https://api.gocardless.com',
),
id => 'ID123',
),
'Business::GoCardless::Creditor'
);
can_ok(
$Creditor,
qw/
endpoint
address_line1
address_line2
address_line3
bank_reference_prefix
can_create_refunds
city
country_code
created_at
creditor_type
custom_payment_pages_enabled
t/business/gocardless/creditor.t view on Meta::CPAN
name
postal_code
region
scheme_identifiers
verification_status
update
/,
);
is( $Creditor->endpoint,'/creditors/%s','endpoint' );
is( $Creditor->uri,'https://api.gocardless.com/creditors/ID123','->uri' );
note( "operations" );
# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
my $request;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {} );
*LWP::UserAgent::request = sub { $request = $_[1]; $mock };
$mock->mock( 'content',sub { '{"creditors":{"id":"ID123","name":"after update"}}' } );
t/business/gocardless/creditorbankaccount.t view on Meta::CPAN
links => {
creditor => 'CR123',
},
),
'Business::GoCardless::CreditorBankAccount'
);
can_ok(
$BankAccount,
qw/
endpoint
account_holder_name
account_number_ending
account_type
bank_name
country_code
created_at
currency
enabled
id
links
metadata
verification_status
disable
creditor_id
/,
);
is( $BankAccount->endpoint,'/creditor_bank_accounts/%s','endpoint' );
is( $BankAccount->uri,'https://api.gocardless.com/creditor_bank_accounts/ID123','->uri' );
note( "links" );
is( $BankAccount->creditor_id,'CR123','->creditor_id' );
$BankAccount->links( undef );
ok( ! $BankAccount->creditor_id,'! ->creditor_id when no links' );
note( "operations" );
# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
my $request;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {} );
*LWP::UserAgent::request = sub { $request = $_[1]; $mock };
$mock->mock( 'content',sub { '{"creditor_bank_accounts":{"id":"ID123","enabled":"after disable"}}' } );
t/business/gocardless/currencyexchangerate.t view on Meta::CPAN
api_version => 2,
base_url => 'https://api.gocardless.com',
),
),
'Business::GoCardless::CurrencyExchangeRate'
);
can_ok(
$Rate,
qw/
endpoint
rate
source
target
time
/,
);
is( $Rate->endpoint,'/currency_exchange_rates/%s','endpoint' );
done_testing();
# vim: ts=4:sw=4:et
t/business/gocardless/customer.t view on Meta::CPAN
email
first_name
id
last_name
company_name
phone_number
danish_identity_number
/,
);
is( $Customer->endpoint,'/customers/%s','endpoint' );
is( $Customer->first_name,$Customer->given_name,'->first_name' );
is( $Customer->last_name,$Customer->family_name,'->last_name' );
ok( ! $Customer->company_name,'company_name' );
ok( ! $Customer->phone_number,'phone_number' );
ok( ! $Customer->danish_identity_number,'danish_identity_number' );
done_testing();
# vim: ts=4:sw=4:et
t/business/gocardless/customerbankaccount.t view on Meta::CPAN
links => {
customer => 'CU123',
},
),
'Business::GoCardless::CustomerBankAccount'
);
can_ok(
$BankAccount,
qw/
endpoint
account_holder_name
account_number_ending
account_type
bank_account_token
bank_name
country_code
created_at
currency
enabled
id
t/business/gocardless/customerbankaccount.t view on Meta::CPAN
payer_name_verification_result
trusted_recipient
update
disable
customer_id
/,
);
is( $BankAccount->endpoint,'/customer_bank_accounts/%s','endpoint' );
is( $BankAccount->uri,'https://api.gocardless.com/customer_bank_accounts/ID123','->uri' );
note( "links" );
is( $BankAccount->customer_id,'CU123','->customer_id' );
$BankAccount->links( undef );
ok( ! $BankAccount->customer_id,'! ->customer_id when no links' );
note( "operations" );
# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
my $request;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {} );
*LWP::UserAgent::request = sub { $request = $_[1]; $mock };
$mock->mock( 'content',sub { '{"customer_bank_accounts":{"id":"ID123","enabled":"after update"}}' } );
t/business/gocardless/customernotification.t view on Meta::CPAN
base_url => 'https://api.gocardless.com',
),
id => 'ID123',
),
'Business::GoCardless::CustomerNotification'
);
can_ok(
$Notification,
qw/
endpoint
action_taken
action_taken_at
action_taken_by
id
links
type
handle
/,
);
is( $Notification->endpoint,'/customer_notifications/%s','endpoint' );
is( $Notification->uri,'https://api.gocardless.com/customer_notifications/ID123','->uri' );
note( "operations" );
# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
my $request;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {} );
*LWP::UserAgent::request = sub { $request = $_[1]; $mock };
$mock->mock( 'content',sub { '{"customer_notifications":{"id":"ID123","action_taken":"after handle"}}' } );
t/business/gocardless/export.t view on Meta::CPAN
base_url => 'https://api.gocardless.com',
),
id => 'ID123',
),
'Business::GoCardless::Export'
);
can_ok(
$Export,
qw/
endpoint
created_at
currency
download_url
error_message
export_type
id
/,
);
is( $Export->endpoint,'/exports/%s','endpoint' );
is( $Export->uri,'https://api.gocardless.com/exports/ID123','->uri' );
done_testing();
# vim: ts=4:sw=4:et