line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::CyberSource::Report::PaymentEvents; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
31776
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
143
|
|
4
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
141
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
23
|
use base 'Business::CyberSource::Report'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1370
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
54
|
use Carp; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
329
|
|
9
|
4
|
|
|
4
|
|
3157
|
use HTTP::Request::Common qw(); |
|
4
|
|
|
|
|
75586
|
|
|
4
|
|
|
|
|
100
|
|
10
|
4
|
|
|
4
|
|
3425
|
use LWP::UserAgent qw(); |
|
4
|
|
|
|
|
89752
|
|
|
4
|
|
|
|
|
1712
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Business::CyberSource::Report::PaymentEvents - Interface to CyberSource's Payment Events report. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 VERSION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Version 1.1.8 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '1.1.8'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $TEST_URL = 'https://ebctest.cybersource.com/ebctest'; |
27
|
|
|
|
|
|
|
our $PRODUCTION_URL = 'https://ebc.cybersource.com/ebc'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SYNOPSIS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This module is an interface to the Payment Events report from CyberSource. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use Business::CyberSource::Report; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Generate a report factory. |
37
|
|
|
|
|
|
|
my $report_factory = Business::CyberSource::Report->new( |
38
|
|
|
|
|
|
|
merchant_id => $merchant_id, |
39
|
|
|
|
|
|
|
username => $username, |
40
|
|
|
|
|
|
|
password => $password, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Build a Business::CyberSource::Report::PaymentEvents object. |
44
|
|
|
|
|
|
|
my $payment_events_report = $report_factory->build( 'PaymentEvents' ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Retrieve the Payment Events report for a given date. |
47
|
|
|
|
|
|
|
$payment_events_report->retrieve( |
48
|
|
|
|
|
|
|
format => $format, |
49
|
|
|
|
|
|
|
date => $date, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 METHODS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 retrieve() |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Build and send the request to CyberSource. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Retrieve the Payment Events report for a given date. |
60
|
|
|
|
|
|
|
$payment_events_report->retrieve( |
61
|
|
|
|
|
|
|
format => $format, |
62
|
|
|
|
|
|
|
date => $date, |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Parameters: |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=over |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * format (mandatory) |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The desired format of the report, 'csv' or 'xml'. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * date (mandatory) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
The date of the transactions to include in the report, using the format |
76
|
|
|
|
|
|
|
YYYY/MM/DD. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * user_agent (optional) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
By default, C. This is useful for tests, see the documentation |
81
|
|
|
|
|
|
|
for L in particular. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=back |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub retrieve |
88
|
|
|
|
|
|
|
{ |
89
|
7
|
|
|
7
|
1
|
13223
|
my ( $self, %args ) = @_; |
90
|
7
|
|
|
|
|
18
|
my $format = delete( $args{'format'} ); |
91
|
7
|
|
|
|
|
16
|
my $date = delete( $args{'date'} ); |
92
|
7
|
|
33
|
|
|
34
|
my $user_agent = delete( $args{'user_agent'} ) || LWP::UserAgent->new(); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Verify the format. |
95
|
7
|
100
|
100
|
|
|
115
|
croak "The format needs to be 'csv' or 'xml'" |
96
|
|
|
|
|
|
|
unless defined( $format ) && ( $format =~ m/^(csv|xml)$/ ); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Verify the date. |
99
|
5
|
100
|
|
|
|
32
|
croak 'You need to specify a date for the transactions to retrieve' |
100
|
|
|
|
|
|
|
unless defined( $date ); |
101
|
4
|
100
|
|
|
|
36
|
croak 'The format for the date of the transactions to retrieve is YYYY/MM/DD' |
102
|
|
|
|
|
|
|
unless $date =~ m/^\d{4}\/\d{2}\/\d{2}$/; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Prepare the URL to hit. |
105
|
3
|
50
|
|
|
|
30
|
my $url = ( $self->use_production_system() ? $PRODUCTION_URL : $TEST_URL ) |
106
|
|
|
|
|
|
|
. '/DownloadReport/' . $date . '/' . $self->get_merchant_id() |
107
|
|
|
|
|
|
|
. '/PaymentEventsReport.' . $format; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Send the query. |
110
|
3
|
|
|
|
|
16
|
my $request = HTTP::Request::Common::GET( $url ); |
111
|
3
|
|
|
|
|
11383
|
$request->authorization_basic( |
112
|
|
|
|
|
|
|
$self->get_username(), |
113
|
|
|
|
|
|
|
$self->get_password(), |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
3
|
|
|
|
|
2082
|
my $response = $user_agent->request( $request ); |
117
|
3
|
50
|
|
|
|
3820
|
croak "Could not get a response from CyberSource" |
118
|
|
|
|
|
|
|
unless defined $response; |
119
|
3
|
50
|
|
|
|
15
|
croak "CyberSource returned the following error: " . $response->status_line() |
120
|
|
|
|
|
|
|
unless $response->is_success(); |
121
|
|
|
|
|
|
|
|
122
|
3
|
|
|
|
|
44
|
return $response->content(); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 BUGS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Please report any bugs or feature requests through the web interface at |
129
|
|
|
|
|
|
|
L. |
130
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
131
|
|
|
|
|
|
|
your bug as I make changes. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SUPPORT |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
perldoc Business::CyberSource::Report::PaymentEvents |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
You can also look for information at: |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=over 4 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
GitHub's request tracker |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
L |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
AnnoCPAN: Annotated CPAN documentation |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
CPAN Ratings |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
L |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
MetaCPAN |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=back |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 AUTHOR |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
L, C<< >>. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
I originally developed this project for ThinkGeek |
180
|
|
|
|
|
|
|
(L). Thanks for allowing me to open-source it! |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Copyright 2011-2014 Guillaume Aubert. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it under |
188
|
|
|
|
|
|
|
the terms of the GNU General Public License version 3 as published by the Free |
189
|
|
|
|
|
|
|
Software Foundation. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
192
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
193
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
196
|
|
|
|
|
|
|
this program. If not, see http://www.gnu.org/licenses/ |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
1; |