File Coverage

blib/lib/Business/GoCardless/Payment.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 15 15 100.0
pod 0 12 0.0
total 36 48 75.0


line stmt bran cond sub pod time code
1             package Business::GoCardless::Payment;
2              
3             =head1 NAME
4              
5             Business::GoCardless::Payment
6              
7             =head1 DESCRIPTION
8              
9             A class for a gocardless payment, extends L
10              
11             =cut
12              
13 5     5   578 use strict;
  5         10  
  5         121  
14 5     5   21 use warnings;
  5         11  
  5         96  
15              
16 5     5   19 use Moo;
  5         10  
  5         24  
17              
18             extends 'Business::GoCardless::Resource';
19              
20             =head1 ATTRIBUTES
21              
22             amount
23             amount_refunded
24             charge_date
25             created_at
26             currency
27             description
28             fx
29             id
30             links
31             metadata
32             reference
33             retry_if_possible
34             status
35              
36             =cut
37              
38             has [ qw/
39             amount
40             amount_refunded
41             charge_date
42             created_at
43             currency
44             description
45             fx
46             id
47             links
48             metadata
49             reference
50             retry_if_possible
51             status
52             / ] => (
53             is => 'rw',
54             );
55              
56             =head1 Operations on a payment
57              
58             retry
59             cancel
60             refund
61              
62             $Payment->retry if $Payment->failed;
63              
64             =cut
65              
66 1     1 0 3869 sub retry { shift->_operation( undef,'api_post',undef,'actions/retry' ); }
67 1     1 0 3942 sub cancel { shift->_operation( undef,'api_post',undef,'actions/cancel' ); }
68             sub refund {
69             # apparently this endpoint is restricted by default, so nuts to it for now
70 1     1 0 5 return 0;
71             }
72              
73             =head1 Status checks on a payment
74              
75             pending
76             paid
77             failed
78             chargedback
79             cancelled
80             withdrawn
81             refunded
82             submitted
83             confirmed
84              
85             if ( $Payment->failed ) {
86             ...
87             }
88              
89             =cut
90              
91 1     1 0 1610 sub pending { return shift->status =~ /pending/ }
92 1     1 0 7 sub paid { return shift->status eq 'paid_out' }
93 1     1 0 5 sub failed { return shift->status eq 'failed' }
94 1     1 0 6 sub chargedback { return shift->status eq 'charged_back' }
95 2     2 0 4192 sub cancelled { return shift->status eq 'cancelled' }
96 1     1 0 6 sub withdrawn { return shift->status eq 'customer_appoval_denied' }
97 1     1 0 5 sub refunded { return shift->status eq 'refunded' }
98 1     1 0 6 sub submitted { return shift->status eq 'submitted' }
99 1     1 0 6 sub confirmed { return shift->status eq 'confirmed' }
100              
101             =head1 AUTHOR
102              
103             Lee Johnson - C
104              
105             This library is free software; you can redistribute it and/or modify it under
106             the same terms as Perl itself. If you would like to contribute documentation,
107             features, bug fixes, or anything else then please raise an issue / pull request:
108              
109             https://github.com/Humanstate/business-gocardless
110              
111             =cut
112              
113             1;
114              
115             # vim: ts=4:sw=4:et