File Coverage

blib/lib/Business/GoCardless/Bill.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 13 13 100.0
pod 0 10 0.0
total 32 42 76.1


line stmt bran cond sub pod time code
1             package Business::GoCardless::Bill;
2              
3             =head1 NAME
4              
5             Business::GoCardless::Bill
6              
7             =head1 DESCRIPTION
8              
9             A class for a gocardless bill, extends L
10              
11             =cut
12              
13 19     19   148 use strict;
  19         53  
  19         583  
14 19     19   120 use warnings;
  19         60  
  19         534  
15              
16 19     19   110 use Moo;
  19         64  
  19         141  
17              
18             extends 'Business::GoCardless::Resource';
19              
20             =head1 ATTRIBUTES
21              
22             amount
23             amount_minus_fees
24             can_be_cancelled
25             can_be_retried
26             charge_customer_at
27             created_at
28             currency
29             description
30             gocardless_fees
31             id
32             is_setup_fee
33             merchant_id
34             name
35             paid_at
36             partner_fees
37             payout_id
38             source_id
39             source_type
40             status
41             uri
42             user_id
43              
44             =cut
45              
46             has [ qw/
47             amount
48             amount_minus_fees
49             can_be_cancelled
50             can_be_retried
51             charge_customer_at
52             created_at
53             currency
54             description
55             gocardless_fees
56             id
57             is_setup_fee
58             merchant_id
59             name
60             paid_at
61             partner_fees
62             payout_id
63             source_id
64             source_type
65             status
66             uri
67             user_id
68             / ] => (
69             is => 'rw',
70             );
71              
72             =head1 Operations on a bill
73              
74             retry
75             cancel
76             refund
77              
78             $Bill->retry if $Bill->failed;
79              
80             =cut
81              
82 1     1 0 1953 sub retry { shift->_operation( 'retry' ); }
83 1     1 0 1938 sub cancel { shift->_operation( 'cancel','api_put' ); }
84 1     1 0 4 sub refund { shift->_operation( 'refund' ); }
85              
86             =head1 Status checks on a bill
87              
88             pending
89             paid
90             failed
91             chargedback
92             cancelled
93             withdrawn
94             refunded
95              
96             if ( $Bill->failed ) {
97             ...
98             }
99              
100             =cut
101              
102 1     1 0 2136 sub pending { return shift->status eq 'pending' }
103 1     1 0 8 sub paid { return shift->status eq 'paid' }
104 1     1 0 7 sub failed { return shift->status eq 'failed' }
105 1     1 0 10 sub chargedback { return shift->status eq 'chargedback' }
106 2     2 0 1912 sub cancelled { return shift->status eq 'cancelled' }
107 1     1 0 7 sub withdrawn { return shift->status eq 'withdrawn' }
108 2     2 0 2017 sub refunded { return shift->status eq 'refunded' }
109              
110             =head1 AUTHOR
111              
112             Lee Johnson - C
113              
114             This library is free software; you can redistribute it and/or modify it under
115             the same terms as Perl itself. If you would like to contribute documentation,
116             features, bug fixes, or anything else then please raise an issue / pull request:
117              
118             https://github.com/Humanstate/business-gocardless
119              
120             =cut
121              
122             1;
123              
124             # vim: ts=4:sw=4:et