| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Stancer::Refund; |
|
2
|
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
138292
|
use 5.020; |
|
|
13
|
|
|
|
|
47
|
|
|
4
|
13
|
|
|
13
|
|
85
|
use strict; |
|
|
13
|
|
|
|
|
26
|
|
|
|
13
|
|
|
|
|
340
|
|
|
5
|
13
|
|
|
13
|
|
56
|
use warnings; |
|
|
13
|
|
|
|
|
22
|
|
|
|
13
|
|
|
|
|
1137
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Representation of a refund |
|
8
|
|
|
|
|
|
|
our $VERSION = '1.0.3'; # VERSION |
|
9
|
|
|
|
|
|
|
|
|
10
|
13
|
|
|
13
|
|
474
|
use Stancer::Core::Types qw(coerce_datetime coerce_instance InstanceOf Maybe PaymentInstance Str); |
|
|
13
|
|
|
|
|
31
|
|
|
|
13
|
|
|
|
|
1600
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
13
|
|
|
13
|
|
2018
|
use Stancer::Payment; |
|
|
13
|
|
|
|
|
37
|
|
|
|
13
|
|
|
|
|
664
|
|
|
13
|
13
|
|
|
13
|
|
89
|
use Scalar::Util qw(blessed); |
|
|
13
|
|
|
|
|
45
|
|
|
|
13
|
|
|
|
|
829
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
13
|
|
|
13
|
|
87
|
use Moo; |
|
|
13
|
|
|
|
|
29
|
|
|
|
13
|
|
|
|
|
80
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
extends 'Stancer::Core::Object'; |
|
18
|
|
|
|
|
|
|
with 'Stancer::Role::Amount::Write'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
13
|
|
|
13
|
|
6647
|
use namespace::clean; |
|
|
13
|
|
|
|
|
32
|
|
|
|
13
|
|
|
|
|
103
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
13
|
|
|
13
|
|
10891
|
use Stancer::Refund::Status; |
|
|
13
|
|
|
|
|
42
|
|
|
|
13
|
|
|
|
|
4225
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has '+endpoint' => ( |
|
25
|
|
|
|
|
|
|
default => 'refunds', |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has date_bank => ( |
|
30
|
|
|
|
|
|
|
is => 'rwp', |
|
31
|
|
|
|
|
|
|
isa => Maybe[InstanceOf['DateTime']], |
|
32
|
1
|
|
|
1
|
|
79
|
builder => sub { $_[0]->_attribute_builder('date_bank') }, |
|
33
|
|
|
|
|
|
|
coerce => coerce_datetime(), |
|
34
|
|
|
|
|
|
|
lazy => 1, |
|
35
|
|
|
|
|
|
|
predicate => 1, |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has date_refund => ( |
|
40
|
|
|
|
|
|
|
is => 'rwp', |
|
41
|
|
|
|
|
|
|
isa => Maybe[InstanceOf['DateTime']], |
|
42
|
1
|
|
|
1
|
|
55
|
builder => sub { $_[0]->_attribute_builder('date_refund') }, |
|
43
|
|
|
|
|
|
|
coerce => coerce_datetime(), |
|
44
|
|
|
|
|
|
|
lazy => 1, |
|
45
|
|
|
|
|
|
|
predicate => 1, |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has payment => ( |
|
50
|
|
|
|
|
|
|
is => 'rw', |
|
51
|
|
|
|
|
|
|
isa => Maybe[PaymentInstance], |
|
52
|
1
|
|
|
1
|
|
36
|
builder => sub { $_[0]->_attribute_builder('payment') }, |
|
53
|
|
|
|
|
|
|
coerce => coerce_instance('Stancer::Payment'), |
|
54
|
|
|
|
|
|
|
lazy => 1, |
|
55
|
|
|
|
|
|
|
predicate => 1, |
|
56
|
|
|
|
|
|
|
trigger => sub { $_[0]->_add_modified('payment') }, |
|
57
|
|
|
|
|
|
|
); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has status => ( |
|
61
|
|
|
|
|
|
|
is => 'rwp', |
|
62
|
|
|
|
|
|
|
isa => Maybe[Str], |
|
63
|
5
|
|
|
5
|
|
164
|
builder => sub { $_[0]->_attribute_builder('status') }, |
|
64
|
|
|
|
|
|
|
lazy => 1, |
|
65
|
|
|
|
|
|
|
predicate => 1, |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding UTF-8 |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Stancer::Refund - Representation of a refund |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 VERSION |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
version 1.0.3 |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 C<amount> |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Read/Write integer, must be at least 50. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Refunded amount. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 C<currency> |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Read/Write string, must be one of "AUD", "CAD", "CHF", "DKK", "EUR", "GBP", "JPY", "NOK", "PLN", "SEK" or "USD". |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Refund currency. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 C<date_bank> |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Read-only instance of C<DateTime>. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Value date. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 C<date_refund> |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Read-only instance of C<DateTime>. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Date when the refund is sent to the bank. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 C<payment> |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Read/Write instance of C<Stancer::Payment>. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Related payment object. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 C<status> |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Read-only string. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Payment status. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 METHODS |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 C<< Stancer::Refund->new(I<$token>) : I<self> >> |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This method accept an optional string, it will be used as an entity ID for API calls. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Create a refund |
|
129
|
|
|
|
|
|
|
my $payment = Stancer::Payment->new($token); |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$payment->refund(); |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
my $refunds = $payment->refunds; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# Get an existing refund |
|
136
|
|
|
|
|
|
|
my $exist = Stancer::Refund->new($token); |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 USAGE |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 Logging |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
We use the L<Log::Any> framework for logging events. |
|
145
|
|
|
|
|
|
|
You may tell where it should log using any available L<Log::Any::Adapter> module. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
For example, to log everything to a file you just have to add a line to your script, like this: |
|
148
|
|
|
|
|
|
|
#! /usr/bin/env perl |
|
149
|
|
|
|
|
|
|
use Log::Any::Adapter (File => '/var/log/payment.log'); |
|
150
|
|
|
|
|
|
|
use Stancer::Refund; |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
You must import C<Log::Any::Adapter> before our libraries, to initialize the logger instance before use. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
You can choose your log level on import directly: |
|
155
|
|
|
|
|
|
|
use Log::Any::Adapter (File => '/var/log/payment.log', log_level => 'info'); |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Read the L<Log::Any> documentation to know what other options you have. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 SECURITY |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=over |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Never, never, NEVER register a card or a bank account number in your database. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Always uses HTTPS in card/SEPA in communication. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item * |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Our API will never give you a complete card/SEPA number, only the last four digits. |
|
176
|
|
|
|
|
|
|
If you need to keep track, use these last four digit. |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 BUGS |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
|
185
|
|
|
|
|
|
|
L<https://gitlab.com/wearestancer/library/lib-perl/-/issues> or by email to |
|
186
|
|
|
|
|
|
|
L<bug-stancer@rt.cpan.org|mailto:bug-stancer@rt.cpan.org>. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
|
189
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
|
190
|
|
|
|
|
|
|
feature. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 AUTHOR |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Joel Da Silva <jdasilva@cpan.org> |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This software is Copyright (c) 2018-2024 by Stancer / Iliad78. |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This is free software, licensed under: |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |