GoCardless/Mandate.pm

filter: Statementstmt 100% 32 / 32 Branchbran n/a Conditioncond 50.0% 5 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 23 / 23 Podpod 15.0% 3 / 20 totaltotal 70.0% 63 / 90 CC 6 SCAR 3.4
CC
6
Cov
88%
is_bank_debit
2.1
is_instant
2.1
is_recurring
2.1
CRAP 1.4
« GoCardless.pm ↑ Summary GoCardless/Webhook/Event.pm »
1 package Business::GoCardless::Mandate;
2  
3 =head1 NAME
4  
5 Business::GoCardless::Mandate
6  
7 =head1 DESCRIPTION
8  
9 A class for a gocardless mandate, extends L<Business::GoCardless::Resource>
10  
11 =cut
12  
13 55 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 55 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 55 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 55 extends 'Business::GoCardless::Resource';
18  
19 =head1 ATTRIBUTES
20  
21 authorisation_source
22 created_at
23 consent_parameters
24 consent_type
25 funds_settlement
26 id
27 links
28 mandate_type
29 metadata
30 next_possible_charge_date
31 next_possible_standard_ach_charge_date
32 payments_require_approval
33 reference
34 scheme
35 status
36 verified_at
37  
38 =cut
39  
40 55 has [ qw/
41 authorisation_source
42 created_at
43 consent_parameters
44 consent_type
45 funds_settlement
46 id
47 links
48 mandate_type
49 metadata
50 next_possible_charge_date
51 next_possible_standard_ach_charge_date
52 payments_require_approval
53 reference
54 scheme
55 status
56 verified_at
57 / ] => (
58 is => 'rw',
59 );
60  
61  
62 =head1 Operations on a mandate
63  
64 =head2 cancel
65  
66 $Mandate->cancel;
67  
68 # optionally with metadata
69 $Mandate->cancel( metadata => { ... } );
70  
71 =head2 reinstate
72  
73 Reinstate a cancelled or expired mandate:
74  
75 $Mandate->reinstate;
76  
77 # optionally with metadata
78 $Mandate->reinstate( metadata => { ... } );
79  
80 =head2 update
81  
82 $Mandate = $Mandate->update( %params );
83  
84 Returns the (updated) Mandate object. note that you can only update the metadata on a mandate, so you must pass the params
85 hash as something that looks like:
86  
87 %params = ( metadata => { ... } );
88  
89 =cut
90  
91 1 ▶sub cancel { shift->_action( 'cancel',@_ ); }
Subroutine cancel: called CC=1 SCAR=0.0
Pod documented
92 1 ▶sub reinstate { shift->_action( 'reinstate',@_ ); }
Subroutine reinstate: called CC=1 SCAR=0.0
Pod documented
93 2 ▶sub update { shift->_update( @_ ); }
Subroutine update: called CC=1 SCAR=0.0
Pod documented
94  
95 =head1 Status checks on a mandate
96  
97 pending_customer_approval
98 pending_submission
99 submitted
100 active
101 failed
102 cancelled
103 expired
104 consumed
105 blocked
106 suspended_by_payer
107  
108 if ( $Mandate->failed ) {
109 ...
110 }
111  
112 =cut
113  
114 1 ▶sub pending_customer_approval { return shift->status eq 'pending_customer_approval' }
Subroutine pending_customer_approval: called CC=1 SCAR=0.0
Pod undocumented
115 1 ▶sub pending_submission { return shift->status eq 'pending_submission' }
Subroutine pending_submission: called CC=1 SCAR=0.0
Pod undocumented
116 1 ▶sub submitted { return shift->status eq 'submitted' }
Subroutine submitted: called CC=1 SCAR=0.0
Pod undocumented
117 1 ▶sub active { return shift->status eq 'active' }
Subroutine active: called CC=1 SCAR=0.0
Pod undocumented
118 1 ▶sub failed { return shift->status eq 'failed' }
Subroutine failed: called CC=1 SCAR=0.0
Pod undocumented
119 1 ▶sub cancelled { return shift->status eq 'cancelled' }
Subroutine cancelled: called CC=1 SCAR=0.0
Pod undocumented
120 1 ▶sub expired { return shift->status eq 'expired' }
Subroutine expired: called CC=1 SCAR=0.0
Pod undocumented
121 1 ▶sub consumed { return shift->status eq 'consumed' }
Subroutine consumed: called CC=1 SCAR=0.0
Pod undocumented
122 1 ▶sub blocked { return shift->status eq 'blocked' }
Subroutine blocked: called CC=1 SCAR=0.0
Pod undocumented
123 1 ▶sub suspended_by_payer { return shift->status eq 'suspended_by_payer' }
Subroutine suspended_by_payer: called CC=1 SCAR=0.0
Pod undocumented
124  
125 =head1 Funds settlement checks on a mandate
126  
127 is_managed
128 is_direct
129  
130 =cut
131  
132 1 ▶sub is_managed { return shift->funds_settlement eq 'managed' }
Subroutine is_managed: called CC=1 SCAR=0.0
Pod undocumented
133 1 ▶sub is_direct { return shift->funds_settlement eq 'direct' }
Subroutine is_direct: called CC=1 SCAR=0.0
Pod undocumented
134  
135 =head1 Mandate type checks on a mandate
136  
137 is_bank_debit
138 is_instant
139 is_recurring
140 is_vrp_commercial
141 is_vrp_sweeping
142  
143 if ( $Mandate->is_instant ) {
144 ...
145 }
146  
147 =cut
148  
149 2 ▶sub is_bank_debit { return ( shift->mandate_type // '' ) eq 'bank_debit' }
Subroutine is_bank_debit: called CC=2 SCAR=7.6
Pod undocumented
Condition50%1/2
(shift())->mandate_type // ""
l!l
20
MC/DC0%0/1
(shift())->mandate_type // ""
(shift())->mandate_type
Truth table50%1/2
A
A= (shift())->mandate_type
Aresult
11
00
150 2 ▶sub is_instant { return ( shift->mandate_type // '' ) eq 'instant' }
Subroutine is_instant: called CC=2 SCAR=7.6
Pod undocumented
Condition50%1/2
(shift())->mandate_type // ""
l!l
20
MC/DC0%0/1
(shift())->mandate_type // ""
(shift())->mandate_type
Truth table50%1/2
A
A= (shift())->mandate_type
Aresult
11
00
151 1 ▶sub is_recurring { return ( shift->mandate_type // '' ) eq 'recurring' }
Subroutine is_recurring: called CC=2 SCAR=7.6
Pod undocumented
Condition50%1/2
(shift())->mandate_type // ""
l!l
10
MC/DC0%0/1
(shift())->mandate_type // ""
(shift())->mandate_type
Truth table50%1/2
A
A= (shift())->mandate_type
Aresult
11
00
152 1 ▶sub is_vrp_commercial { return ( shift->mandate_type // '' ) eq 'vrp_commercial' }
Subroutine is_vrp_commercial: called CC=2 SCAR=7.6
Pod undocumented
Condition50%1/2
(shift())->mandate_type // ""
l!l
10
MC/DC0%0/1
(shift())->mandate_type // ""
(shift())->mandate_type
Truth table50%1/2
A
A= (shift())->mandate_type
Aresult
11
00
153 1 ▶sub is_vrp_sweeping { return ( shift->mandate_type // '' ) eq 'vrp_sweeping' }
Subroutine is_vrp_sweeping: called CC=2 SCAR=7.6
Pod undocumented
Condition50%1/2
(shift())->mandate_type // ""
l!l
10
MC/DC0%0/1
(shift())->mandate_type // ""
(shift())->mandate_type
Truth table50%1/2
A
A= (shift())->mandate_type
Aresult
11
00
154  
155 =head1 AUTHOR
156  
157 Lee Johnson - C<lee@payprop.com>
158  
159 This library is free software; you can redistribute it and/or modify it under
160 the same terms as Perl itself. If you would like to contribute documentation,
161 features, bug fixes, or anything else then please raise an issue / pull request:
162  
163 https://github.com/payprop/business-gocardless
164  
165 =cut
166  
167 55 1;
168  
169 # vim: ts=4:sw=4:et
« GoCardless.pm ↑ Summary GoCardless/Webhook/Event.pm »