line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::CyberSource::Report::SingleTransaction; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
35430
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
282
|
|
4
|
5
|
|
|
5
|
|
31
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
159
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
30
|
use base 'Business::CyberSource::Report'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
2186
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
58
|
use Carp; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
388
|
|
9
|
5
|
|
|
5
|
|
201402
|
use HTTP::Request::Common qw(); |
|
5
|
|
|
|
|
405866
|
|
|
5
|
|
|
|
|
147
|
|
10
|
5
|
|
|
5
|
|
106950
|
use LWP::UserAgent qw(); |
|
5
|
|
|
|
|
148135
|
|
|
5
|
|
|
|
|
3095
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Business::CyberSource::Report::SingleTransaction - Interface to CyberSource's Single Transaction 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/Query'; |
27
|
|
|
|
|
|
|
our $PRODUCTION_URL = 'https://ebc.cybersource.com/ebc/Query'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SYNOPSIS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This module is an interface to the Single Transaction 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::SingleTransaction object. |
44
|
|
|
|
|
|
|
my $single_transaction_report = $report_factory->build( 'SingleTransaction' ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Retrieve a Single Transaction report by Request ID. |
47
|
|
|
|
|
|
|
$single_transaction_report->retrieve( |
48
|
|
|
|
|
|
|
request_id => $request_id, |
49
|
|
|
|
|
|
|
include_extended_detail => $include_extended_detail, |
50
|
|
|
|
|
|
|
version => $version, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Retrieve a Single Transaction report using a combination of merchant |
54
|
|
|
|
|
|
|
# reference number and |
55
|
|
|
|
|
|
|
$single_transaction_report->retrieve( |
56
|
|
|
|
|
|
|
merchant_reference_number => $merchant_reference_number, |
57
|
|
|
|
|
|
|
target_date => $target_date, |
58
|
|
|
|
|
|
|
include_extended_detail => $include_extended_detail, |
59
|
|
|
|
|
|
|
version => $version, |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 retrieve() |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Build and send the request to CyberSource. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Retrieve a Single Transaction report by Request ID. |
70
|
|
|
|
|
|
|
$single_transaction_report->retrieve( |
71
|
|
|
|
|
|
|
request_id => $request_id, |
72
|
|
|
|
|
|
|
include_extended_detail => $include_extended_detail, |
73
|
|
|
|
|
|
|
version => $version, |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Retrieve a Single Transaction report using a combination of merchant |
77
|
|
|
|
|
|
|
# reference number and target date. |
78
|
|
|
|
|
|
|
$single_transaction_report->retrieve( |
79
|
|
|
|
|
|
|
merchant_reference_number => $merchant_reference_number, |
80
|
|
|
|
|
|
|
target_date => $target_date, |
81
|
|
|
|
|
|
|
include_extended_detail => $include_extended_detail, |
82
|
|
|
|
|
|
|
version => $version, |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Parameters: |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=over |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * request_id (mandatory, if no merchant_reference_number/target_date) |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
A request ID from CyberSource. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item * merchant_reference_number/target_date (mandatory, if no request_id) |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
The reference number you sent with the original transaction. This is not a |
96
|
|
|
|
|
|
|
number generated by CyberSource. This must be used in conjunction with a target |
97
|
|
|
|
|
|
|
date, with the format YYYYMMDD. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * include_extended_detail (optional) |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Can be set to 'Predecessor' or 'Related' to retrieve more information about the |
102
|
|
|
|
|
|
|
transactions found. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * version (default: 1.7) |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
CyberSource offers multiple versions of the resulting XML. Available versions |
107
|
|
|
|
|
|
|
are 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
See L |
110
|
|
|
|
|
|
|
for more details about the differences. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * user_agent (optional) |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
By default, C. This is useful for tests, see the documentation |
115
|
|
|
|
|
|
|
for L in particular. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub retrieve |
122
|
|
|
|
|
|
|
{ |
123
|
12
|
|
|
12
|
1
|
19845
|
my ( $self, %args ) = @_; |
124
|
12
|
|
|
|
|
30
|
my $request_id = delete( $args{'request_id'} ); |
125
|
12
|
|
|
|
|
30
|
my $merchant_reference_number = delete( $args{'merchant_reference_number'} ); |
126
|
12
|
|
|
|
|
26
|
my $target_date = delete( $args{'target_date'} ); |
127
|
12
|
|
33
|
|
|
97
|
my $user_agent = delete( $args{'user_agent'} ) || LWP::UserAgent->new(); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# Defaults. |
130
|
12
|
|
|
|
|
31
|
my $include_extended_detail = delete( $args{'include_extended_detail'} ); |
131
|
12
|
|
50
|
|
|
38
|
my $version = delete( $args{'version'} ) || '1.7'; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# Verify the version number. |
134
|
12
|
100
|
|
|
|
80
|
croak 'The version number can only be 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 or 1.7' |
135
|
|
|
|
|
|
|
unless $version =~ m/^1\.[1-7]$/; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# Verify the value of $include_extended_detail. |
138
|
11
|
100
|
|
|
|
36
|
if ( defined( $include_extended_detail ) ) |
139
|
|
|
|
|
|
|
{ |
140
|
10
|
100
|
|
|
|
78
|
croak "The value of 'include_extended_detail' needs to be either 'Predecessor' or 'Related'" |
141
|
|
|
|
|
|
|
if $include_extended_detail !~ m/^(?:Predecessor|Related)$/; |
142
|
9
|
100
|
|
|
|
62
|
croak "'include_extended_detail' is only available for versions >= 1.3" |
143
|
|
|
|
|
|
|
if $version < 1.3; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# Prepare the request parameters. |
147
|
9
|
|
|
|
|
81
|
my $request_parameters = |
148
|
|
|
|
|
|
|
{ |
149
|
|
|
|
|
|
|
versionNumber => $version, |
150
|
|
|
|
|
|
|
merchantID => $self->get_merchant_id(), |
151
|
|
|
|
|
|
|
username => $self->get_username(), |
152
|
|
|
|
|
|
|
password => $self->get_password(), |
153
|
|
|
|
|
|
|
type => 'transaction', |
154
|
|
|
|
|
|
|
subtype => 'transactionDetail', |
155
|
|
|
|
|
|
|
}; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# Add the request_id or merchant_reference_number/target_date. |
158
|
9
|
100
|
66
|
|
|
105
|
if ( defined( $request_id ) && !defined( $merchant_reference_number ) && !defined( $target_date ) ) |
|
|
100
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
159
|
|
|
|
|
|
|
{ |
160
|
4
|
|
|
|
|
13
|
$request_parameters->{'requestID'} = $request_id; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
elsif ( !defined( $request_id ) && defined( $merchant_reference_number ) && defined( $target_date ) ) |
163
|
|
|
|
|
|
|
{ |
164
|
2
|
100
|
|
|
|
24
|
croak 'The target_date format must be YYYYMMDD' |
165
|
|
|
|
|
|
|
unless $target_date =~ m/^\d{8}$/; |
166
|
|
|
|
|
|
|
|
167
|
1
|
|
|
|
|
3
|
$request_parameters->{'merchantReferenceNumber'} = $merchant_reference_number; |
168
|
1
|
|
|
|
|
4
|
$request_parameters->{'targetDate'} = $target_date; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
else |
171
|
|
|
|
|
|
|
{ |
172
|
3
|
|
|
|
|
62
|
croak 'Please provide either a request_id or the combination of a ' |
173
|
|
|
|
|
|
|
. 'merchant_reference_number and target_date parameters'; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# Add option to get extended details. |
177
|
5
|
100
|
|
|
|
28
|
$request_parameters->{'includeExtendedDetail'} = $include_extended_detail |
178
|
|
|
|
|
|
|
if defined( $include_extended_detail ); |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# Send the query. |
181
|
5
|
50
|
|
|
|
36
|
my $request = HTTP::Request::Common::POST( |
182
|
|
|
|
|
|
|
$self->use_production_system() ? $PRODUCTION_URL : $TEST_URL, |
183
|
|
|
|
|
|
|
Content => $request_parameters, |
184
|
|
|
|
|
|
|
); |
185
|
5
|
|
|
|
|
14688
|
$request->authorization_basic( |
186
|
|
|
|
|
|
|
$self->get_username(), |
187
|
|
|
|
|
|
|
$self->get_password(), |
188
|
|
|
|
|
|
|
); |
189
|
|
|
|
|
|
|
|
190
|
5
|
|
|
|
|
2445
|
my $response = $user_agent->request( $request ); |
191
|
5
|
50
|
|
|
|
6437
|
croak "Could not get a response from CyberSource" |
192
|
|
|
|
|
|
|
unless defined $response; |
193
|
5
|
50
|
|
|
|
25
|
croak "CyberSource returned the following error: " . $response->status_line() |
194
|
|
|
|
|
|
|
unless $response->is_success(); |
195
|
|
|
|
|
|
|
|
196
|
5
|
|
|
|
|
68
|
return $response->content(); |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 BUGS |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Please report any bugs or feature requests through the web interface at |
203
|
|
|
|
|
|
|
L. |
204
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
205
|
|
|
|
|
|
|
your bug as I make changes. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 SUPPORT |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
perldoc Business::CyberSource::Report::SingleTransaction |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
You can also look for information at: |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=over 4 |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=item * |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
GitHub's request tracker |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
L |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item * |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
AnnoCPAN: Annotated CPAN documentation |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
L |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=item * |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
CPAN Ratings |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
L |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item * |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
MetaCPAN |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
L |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=back |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 AUTHOR |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
L, C<< >>. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
I originally developed this project for ThinkGeek |
254
|
|
|
|
|
|
|
(L). Thanks for allowing me to open-source it! |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
Copyright 2011-2014 Guillaume Aubert. |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it under |
262
|
|
|
|
|
|
|
the terms of the GNU General Public License version 3 as published by the Free |
263
|
|
|
|
|
|
|
Software Foundation. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
266
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
267
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
270
|
|
|
|
|
|
|
this program. If not, see http://www.gnu.org/licenses/ |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=cut |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
1; |