Business-GoCardless
view release on metacpan or search on metacpan
lib/Business/GoCardless/Mandate.pm view on Meta::CPAN
has [ qw/
authorisation_source
created_at
consent_parameters
consent_type
funds_settlement
id
links
mandate_type
metadata
next_possible_charge_date
next_possible_standard_ach_charge_date
payments_require_approval
reference
scheme
status
verified_at
/ ] => (
is => 'rw',
);
=head1 Operations on a mandate
=head2 cancel
$Mandate->cancel;
=head2 update
$Mandate->update( %params );
note that you can only update the metadata on a mandate, so you must pass the params
hash as something that looks like:
%params = ( metadata => { ... } );
=cut
sub cancel { shift->_operation( undef,'api_post',undef,'actions/cancel' ); }
sub update {
my ( $self,%params ) = @_;
return $self->client->api_put(
sprintf( $self->endpoint,$self->id ),
{ mandates => { %params } },
);
}
=head1 Status checks on a mandate
pending_customer_approval
pending_submission
submitted
active
failed
cancelled
expired
consumed
blocked
suspended_by_payer
if ( $Mandate->failed ) {
...
}
=cut
sub pending_customer_approval { return shift->status eq 'pending_customer_approval' }
sub pending_submission { return shift->status eq 'pending_submission' }
sub submitted { return shift->status eq 'submitted' }
sub active { return shift->status eq 'active' }
sub failed { return shift->status eq 'failed' }
sub cancelled { return shift->status eq 'cancelled' }
sub expired { return shift->status eq 'expired' }
sub consumed { return shift->status eq 'consumed' }
sub blocked { return shift->status eq 'blocked' }
sub suspended_by_payer { return shift->status eq 'suspended_by_payer' }
=head1 Funds settlement checks on a mandate
is_managed
is_direct
=cut
sub is_managed { return shift->funds_settlement eq 'managed' }
sub is_direct { return shift->funds_settlement eq 'direct' }
=head1 Mandate type checks on a mandate
is_bank_debit
is_instant
is_recurring
is_vrp_commercial
is_vrp_sweeping
if ( $Mandate->is_instant ) {
...
}
=cut
sub is_bank_debit { return ( shift->mandate_type // '' ) eq 'bank_debit' }
sub is_instant { return ( shift->mandate_type // '' ) eq 'instant' }
sub is_recurring { return ( shift->mandate_type // '' ) eq 'recurring' }
sub is_vrp_commercial { return ( shift->mandate_type // '' ) eq 'vrp_commercial' }
sub is_vrp_sweeping { return ( shift->mandate_type // '' ) eq 'vrp_sweeping' }
=head1 AUTHOR
Lee Johnson - C<leejo@cpan.org>
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:
https://github.com/Humanstate/business-gocardless
=cut
1;
# vim: ts=4:sw=4:et
( run in 0.667 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )