GoCardless/Subscription.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 15 / 15 Podpod 33.3% 4 / 12 totaltotal 85.7% 48 / 56 CC 2 SCAR 1.2
CC
2
Cov
100%
cancel
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« GoCardless/PreAuthorization.pm ↑ Summary GoCardless/Bill.pm »
1 package Business::GoCardless::Subscription;
2  
3 =head1 NAME
4  
5 Business::GoCardless::Subscription
6  
7 =head1 DESCRIPTION
8  
9 A class for a gocardless subscription, 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 amount
22 app_fee
23 created_at
24 count
25 currency
26 description
27 day_of_month
28 earliest_charge_date_after_resume
29 expires_at
30 end_date
31 id
32 interval_length
33 interval_unit
34 interval
35 links
36 merchant_id
37 metadata
38 month
39 name
40 next_interval_start
41 parent_plan_paused
42 payment_reference
43 retry_if_possible
44 setup_fee
45 start_at
46 start_date
47 status
48 sub_resource_uris
49 uri
50 user_id
51 upcoming_payments
52  
53 =cut
54  
55 55 has [ qw/
56 amount
57 app_fee
58 created_at
59 count
60 currency
61 description
62 day_of_month
63 earliest_charge_date_after_resume
64 expires_at
65 end_date
66 id
67 interval_length
68 interval_unit
69 interval
70 links
71 merchant_id
72 metadata
73 month
74 name
75 next_interval_start
76 parent_plan_paused
77 payment_reference
78 retry_if_possible
79 setup_fee
80 start_at
81 start_date
82 status
83 sub_resource_uris
84 uri
85 user_id
86 upcoming_payments
87 / ] => (
88 is => 'rw',
89 );
90  
91 =head1 Operations on a subscription
92  
93 =head2 cancel
94  
95 $Subscription->cancel
96  
97 Cancels a subscription. With the Pro (v2) API you can optionally pass metadata:
98  
99 $Subscription->cancel( metadata => { ... } );
100  
101 The following operations are only available with the Pro (v2) API:
102  
103 =head2 update
104  
105 Update the subscription, returns the updated Subscription object:
106  
107 $Subscription->update( amount => 1500,metadata => { ... } );
108  
109 =head2 pause
110  
111 Pause the subscription, optionally for a number of cycles:
112  
113 $Subscription->pause;
114 $Subscription->pause( pause_cycles => 2,metadata => { ... } );
115  
116 =head2 resume
117  
118 Resume a paused subscription:
119  
120 $Subscription->resume;
121  
122 =cut
123  
124 3 ▶sub cancel {
Subroutine cancel: called CC=2 SCAR=6.9
Pod documented
125 3 my ( $self,%params ) = @_;
126  
127 3 ▶ if ( $self->client->api_version > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->client->api_version > 1) { } 2 1 3
128 2 return $self->_action( 'cancel',%params );
129 } else {
130 1 return $self->_operation( 'cancel','api_put' );
131 }
132 }
133  
134 1 ▶sub update { shift->_update( @_ ); }
Subroutine update: called CC=1 SCAR=0.0
Pod documented
135 1 ▶sub pause { shift->_action( 'pause',@_ ); }
Subroutine pause: called CC=1 SCAR=0.0
Pod documented
136 1 ▶sub resume { shift->_action( 'resume',@_ ); }
Subroutine resume: called CC=1 SCAR=0.0
Pod documented
137  
138 =head1 Status checks on a subscription
139  
140 pending_customer_approval
141 customer_approval_denied
142 inactive
143 active
144 finished
145 cancelled
146 paused
147 expired
148  
149 if ( $Subscription->active ) {
150 ...
151 }
152  
153 =cut
154  
155 1 ▶sub pending_customer_approval { return shift->status eq 'pending_customer_approval' }
Subroutine pending_customer_approval: called CC=1 SCAR=0.0
Pod undocumented
156 1 ▶sub customer_approval_denied { return shift->status eq 'customer_approval_denied' }
Subroutine customer_approval_denied: called CC=1 SCAR=0.0
Pod undocumented
157 1 ▶sub inactive { return shift->status eq 'inactive' }
Subroutine inactive: called CC=1 SCAR=0.0
Pod undocumented
158 1 ▶sub active { return shift->status eq 'active' }
Subroutine active: called CC=1 SCAR=0.0
Pod undocumented
159 1 ▶sub finished { return shift->status eq 'finished' }
Subroutine finished: called CC=1 SCAR=0.0
Pod undocumented
160 3 ▶sub cancelled { return shift->status eq 'cancelled' }
Subroutine cancelled: called CC=1 SCAR=0.0
Pod undocumented
161 1 ▶sub paused { return shift->status eq 'paused' }
Subroutine paused: called CC=1 SCAR=0.0
Pod undocumented
162 1 ▶sub expired { return shift->status eq 'expired' }
Subroutine expired: called CC=1 SCAR=0.0
Pod undocumented
163  
164 =head1 AUTHOR
165  
166 Lee Johnson - C<lee@payprop.com>
167  
168 This library is free software; you can redistribute it and/or modify it under
169 the same terms as Perl itself. If you would like to contribute documentation,
170 features, bug fixes, or anything else then please raise an issue / pull request:
171  
172 https://github.com/payprop/business-gocardless
173  
174 =cut
175  
176 55 1;
177  
178 # vim: ts=4:sw=4:et
« GoCardless/PreAuthorization.pm ↑ Summary GoCardless/Bill.pm »