line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
871
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
3
|
|
|
|
|
|
|
package iTransact::Lite; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
438
|
use XML::Hash::LX; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Digest::HMAC_SHA1; |
7
|
|
|
|
|
|
|
use LWP::UserAgent; |
8
|
|
|
|
|
|
|
use Any::Moose; |
9
|
|
|
|
|
|
|
use Ouch; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has gateway_id => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
required=> 1, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has api_key => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
required=> 1, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has api_username => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
required=> 1, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub submit { |
27
|
|
|
|
|
|
|
my ($self, $payload) = @_; |
28
|
|
|
|
|
|
|
my $xml = hash2xml $payload; |
29
|
|
|
|
|
|
|
$xml = (split(/\n/, $xml))[1]; # strip the tag before calculating the PayloadSignature |
30
|
|
|
|
|
|
|
my $hmac = Digest::HMAC_SHA1->new($self->api_key); |
31
|
|
|
|
|
|
|
$hmac->add($xml); |
32
|
|
|
|
|
|
|
my %request = ( |
33
|
|
|
|
|
|
|
GatewayInterface => { |
34
|
|
|
|
|
|
|
APICredentials => { |
35
|
|
|
|
|
|
|
Username => $self->api_username, |
36
|
|
|
|
|
|
|
TargetGateway => $self->gateway_id, |
37
|
|
|
|
|
|
|
PayloadSignature => $hmac->b64digest . '=', |
38
|
|
|
|
|
|
|
}, |
39
|
|
|
|
|
|
|
%{$payload}, |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
$xml = hash2xml \%request; |
43
|
|
|
|
|
|
|
my $response = LWP::UserAgent->new->post( |
44
|
|
|
|
|
|
|
'https://secure.itransact.com/cgi-bin/rc/xmltrans2.cgi', |
45
|
|
|
|
|
|
|
Content_Type => 'text/xml', |
46
|
|
|
|
|
|
|
Content => $xml, |
47
|
|
|
|
|
|
|
Accept => 'text/xml', |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
if ($response->is_success) { |
50
|
|
|
|
|
|
|
return xml2hash $response->decoded_content; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
else { |
53
|
|
|
|
|
|
|
ouch 504, 'Could not connect to the credit card processor.', \%request; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
no Any::Moose; |
59
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
iTransact::Lite - A simple interface to the iTransact payment gateway. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use iTransact::Lite; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $itransact = iTransact::Lite->new( |
70
|
|
|
|
|
|
|
gateway_id => 99999, |
71
|
|
|
|
|
|
|
api_key => 'xxxxxxx', |
72
|
|
|
|
|
|
|
api_username => 'mycoolsite', |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $response = $itransact->submit({ |
76
|
|
|
|
|
|
|
AuthTransaction => { |
77
|
|
|
|
|
|
|
CustomerData => { |
78
|
|
|
|
|
|
|
Email => 'user@example.com', |
79
|
|
|
|
|
|
|
BillingAddress => { |
80
|
|
|
|
|
|
|
Address1 => '123 Main St', |
81
|
|
|
|
|
|
|
FirstName => 'John', |
82
|
|
|
|
|
|
|
LastName => 'Doe', |
83
|
|
|
|
|
|
|
City => 'Anytown', |
84
|
|
|
|
|
|
|
State => 'WI', |
85
|
|
|
|
|
|
|
Zip => '00000', |
86
|
|
|
|
|
|
|
Country => 'US', |
87
|
|
|
|
|
|
|
Phone => '608-555-1212', |
88
|
|
|
|
|
|
|
}, |
89
|
|
|
|
|
|
|
CustId => $customer_id, |
90
|
|
|
|
|
|
|
}, |
91
|
|
|
|
|
|
|
Total => sprintf('%.2f', $amount), |
92
|
|
|
|
|
|
|
Description => 'Space Sneakers', |
93
|
|
|
|
|
|
|
AccountInfo => { |
94
|
|
|
|
|
|
|
CardAccount => { |
95
|
|
|
|
|
|
|
AccountNumber => $credit_card_number, |
96
|
|
|
|
|
|
|
ExpirationMonth => '07', |
97
|
|
|
|
|
|
|
ExpirationYear => '2019', |
98
|
|
|
|
|
|
|
CVVNumber => '999', |
99
|
|
|
|
|
|
|
}, |
100
|
|
|
|
|
|
|
}, |
101
|
|
|
|
|
|
|
TransactionControl => { |
102
|
|
|
|
|
|
|
SendCustomerEmail => 'FALSE', |
103
|
|
|
|
|
|
|
SendMerchantEmail => 'FALSE', |
104
|
|
|
|
|
|
|
TestMode => 'TRUE', |
105
|
|
|
|
|
|
|
}, |
106
|
|
|
|
|
|
|
}, |
107
|
|
|
|
|
|
|
}); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
if ($response->{GatewayInterface}{TransactionResponse}{TransactionResult}{Status} eq 'ok') { |
110
|
|
|
|
|
|
|
say "Success! Transaction ID: ". $response->{GatewayInterface}{TransactionResponse}{TransactionResult}{XID}; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
else { |
113
|
|
|
|
|
|
|
die $response->{GatewayInterface}{TransactionResponse}{TransactionResult}{ErrorMessage}; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 DESCRIPTION |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This module provides a simple wrapper around the iTransact XML Connection API (L). It does the hard work of signing, serializing, and submitting the request for you, but you still have to give it the data the web service API is expecting. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 METHODS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 new |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Constructor. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item gateway_id |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
The gateway id number supplied by iTransact for your account. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item api_key |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
The API Key supplied by iTransact for your account after you enable web services. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item api_username |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The API Username suppplied by iTransact for your account after you enable web services. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 submit |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Use this method to submit your requests. You may use this method multipled times on the same object with new payloads each time. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=over |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item payload |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
A hash reference of the data you wish to submit. This should not include the outer C wrapper or the C section as those will be auto generated. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=back |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 EXCEPTIONS |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
If this module is unable to connect to iTransact for any reason it will throw an L exception with the exception code of C<504>. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 PREREQS |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
The following modules are required: |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
L |
163
|
|
|
|
|
|
|
L |
164
|
|
|
|
|
|
|
L |
165
|
|
|
|
|
|
|
L |
166
|
|
|
|
|
|
|
L |
167
|
|
|
|
|
|
|
L |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 TODO |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Someday I should probably make a full featured version of this module that hides all of the web service's data structures, and does some more advanced response handling. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 SUPPORT |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item Repository |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
L |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item Bug Reports |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
L |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=back |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 AUTHOR |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
JT Smith |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 LEGAL |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
iTransact::Lite is Copyright 2012 Plain Black Corporation (L) and is licensed under the same terms as Perl itself. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
196
|
|
|
|
|
|
|
|