line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::OnlinePayment::PPIPayMover; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
102411
|
use strict; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
285
|
|
4
|
6
|
|
|
6
|
|
34
|
use vars qw($VERSION @ISA $DEBUG); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
452
|
|
5
|
6
|
|
|
6
|
|
49
|
use Carp; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
529
|
|
6
|
6
|
|
|
6
|
|
4561
|
use Business::OnlinePayment::PPIPayMover::constants; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
3078
|
|
7
|
6
|
|
|
6
|
|
3730
|
use Business::OnlinePayment::PPIPayMover::TransactionClient; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
195
|
|
8
|
6
|
|
|
6
|
|
43
|
use Business::OnlinePayment::PPIPayMover::CreditCardRequest; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
125
|
|
9
|
6
|
|
|
6
|
|
35
|
use Business::OnlinePayment::PPIPayMover::CountryCodes; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
398
|
|
10
|
6
|
|
|
6
|
|
32
|
use Business::OnlinePayment::PPIPayMover::CreditCardResponse; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
5782
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = '0.01'; |
13
|
|
|
|
|
|
|
@ISA = qw(Business::OnlinePayment); |
14
|
|
|
|
|
|
|
$DEBUG = 0; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $tranclient = new Business::OnlinePayment::PPIPayMover::TransactionClient; |
17
|
|
|
|
|
|
|
#my $ccreq = new Business::OnlinePayment::PPIPayMover::CreditCardRequest; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub set_defaults { |
20
|
4
|
|
|
4
|
0
|
167
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#$self->server('secure.linkpt.net'); |
23
|
|
|
|
|
|
|
#$self->port('1129'); |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
58
|
$self->build_subs(qw(order_number avs_code)); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub map_fields { |
30
|
4
|
|
|
4
|
0
|
8
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
20
|
my %content = $self->content(); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# ACTION MAP |
35
|
|
|
|
|
|
|
# target types: SALE, ADJUSTMENT, AUTH, CAPTURE, CREDIT, FORCE_AUTH, |
36
|
|
|
|
|
|
|
# FORCE_SALE, QUERY_CREDIT, QUERY_PAYMENT or VOID |
37
|
4
|
|
|
|
|
93
|
my %actions = ( |
38
|
|
|
|
|
|
|
'normal authorization' => 'SALE', |
39
|
|
|
|
|
|
|
'authorization only' => 'AUTH', |
40
|
|
|
|
|
|
|
'credit' => 'CREDIT', |
41
|
|
|
|
|
|
|
'post authorization' => 'CAPTURE', |
42
|
|
|
|
|
|
|
'void' => 'VOID', |
43
|
|
|
|
|
|
|
); |
44
|
4
|
|
33
|
|
|
26
|
$content{'action'} = $actions{lc($content{'action'})} || $content{'action'}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# TYPE MAP |
47
|
4
|
|
|
|
|
126
|
my %types = ( |
48
|
|
|
|
|
|
|
'visa' => 'CC', |
49
|
|
|
|
|
|
|
'mastercard' => 'CC', |
50
|
|
|
|
|
|
|
'american express' => 'CC', |
51
|
|
|
|
|
|
|
'discover' => 'CC', |
52
|
|
|
|
|
|
|
'cc' => 'CC', |
53
|
|
|
|
|
|
|
#'check' |
54
|
|
|
|
|
|
|
); |
55
|
4
|
|
33
|
|
|
17
|
$content{'type'} = $types{lc($content{'type'})} || $content{'type'}; |
56
|
4
|
|
|
|
|
102
|
$self->transaction_type($content{'type'}); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# stuff it back into %content |
59
|
4
|
|
|
|
|
42
|
$self->content(%content); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub submit { |
63
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#type => |
66
|
|
|
|
|
|
|
#login => |
67
|
|
|
|
|
|
|
#password => |
68
|
|
|
|
|
|
|
#authorization => |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#name |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#order_number |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#currency => |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
#check_type => |
77
|
|
|
|
|
|
|
#account_name => |
78
|
|
|
|
|
|
|
#account_number => |
79
|
|
|
|
|
|
|
#account_type => |
80
|
|
|
|
|
|
|
#bank_name => |
81
|
|
|
|
|
|
|
#routing_code => |
82
|
|
|
|
|
|
|
#customer_org => |
83
|
|
|
|
|
|
|
#customer_ssn => |
84
|
|
|
|
|
|
|
#license_num => |
85
|
|
|
|
|
|
|
#license_state => |
86
|
|
|
|
|
|
|
#license_dob => |
87
|
|
|
|
|
|
|
#get from new() args instead# payee => |
88
|
|
|
|
|
|
|
#check_number => |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
#recurring_billing => 'cnp_recurring', |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
$self->map_fields(); |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my %content = $self->content; |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my($month, $year); |
97
|
0
|
0
|
0
|
|
|
|
unless ( $content{action} eq 'CAPTURE' |
|
|
|
0
|
|
|
|
|
98
|
|
|
|
|
|
|
|| ( $content{'action'} =~ /^(CREDIT|VOID)$/ |
99
|
|
|
|
|
|
|
&& exists $content{'order_number'} ) |
100
|
|
|
|
|
|
|
) { |
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
if ( $self->transaction_type() =~ |
103
|
|
|
|
|
|
|
/^(cc|visa|mastercard|american express|discover)$/i |
104
|
|
|
|
|
|
|
) { |
105
|
|
|
|
|
|
|
} else { |
106
|
0
|
|
|
|
|
|
Carp::croak("PPIPayMover can't handle transaction type: ". |
107
|
|
|
|
|
|
|
$self->transaction_type()); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
$content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/ |
111
|
|
|
|
|
|
|
or croak "unparsable expiration $content{expiration}"; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
( $month, $year ) = ( $1, "20$2" ); |
114
|
0
|
0
|
|
|
|
|
$month = '0'. $month if $month =~ /^\d$/; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
my $ccreq = new Business::OnlinePayment::PPIPayMover::CreditCardRequest; |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
$self->revmap_fields( $ccreq, |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
'ChargeTotal' => 'amount', |
122
|
|
|
|
|
|
|
'ChargeType' => 'action', |
123
|
|
|
|
|
|
|
'CreditCardNumber' => 'card_number', |
124
|
|
|
|
|
|
|
'CreditCardVerificationNumber' => 'cvv2', |
125
|
|
|
|
|
|
|
'ExpireMonth' => \$month, |
126
|
|
|
|
|
|
|
'ExpireYear' => \$year, |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
'BillAddressOne' => 'address', |
129
|
|
|
|
|
|
|
#'BillAddressTwo' => '', |
130
|
|
|
|
|
|
|
'BillCity' => 'city', |
131
|
|
|
|
|
|
|
'BillCompany' => 'company', |
132
|
|
|
|
|
|
|
'BillCountryCode' => 'country', |
133
|
|
|
|
|
|
|
#'BillCustomerTitle' => '', |
134
|
|
|
|
|
|
|
'BillEmail', => 'email', |
135
|
|
|
|
|
|
|
'BillFax' => 'fax', |
136
|
|
|
|
|
|
|
'BillFirstName' => 'first_name', |
137
|
|
|
|
|
|
|
'BillLastName' => 'last_name', |
138
|
|
|
|
|
|
|
#'BillMiddleName' => '', |
139
|
|
|
|
|
|
|
'BillNote' => '', |
140
|
|
|
|
|
|
|
'BillPhone' => 'phone', |
141
|
|
|
|
|
|
|
'BillPostalCode' => 'zip', |
142
|
|
|
|
|
|
|
'BillStateOrProvince' => 'state', |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
'ShipAddressOne' => 'ship_address', |
145
|
|
|
|
|
|
|
#'ShipAddressTwo' => '', |
146
|
|
|
|
|
|
|
'ShipCity' => 'ship_city', |
147
|
|
|
|
|
|
|
'ShipCompany' => 'ship_company', |
148
|
|
|
|
|
|
|
'ShipCountryCode' => 'ship_country', |
149
|
|
|
|
|
|
|
#'ShipCustomerTitle' => '', |
150
|
|
|
|
|
|
|
'ShipEmail', => 'ship_email', |
151
|
|
|
|
|
|
|
'ShipFax' => 'ship_fax', |
152
|
|
|
|
|
|
|
'ShipFirstName' => 'ship_first_name', |
153
|
|
|
|
|
|
|
'ShipLastName' => 'ship_last_name', |
154
|
|
|
|
|
|
|
#'ShipMiddleName' => '', |
155
|
|
|
|
|
|
|
'ShipNote' => '', |
156
|
|
|
|
|
|
|
'ShipPhone' => 'ship_phone', |
157
|
|
|
|
|
|
|
'ShipPostalCode' => 'ship_zip', |
158
|
|
|
|
|
|
|
'ShipStateOrProvince' => 'ship_state', |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
#'OrderId' => 'order_number', |
161
|
|
|
|
|
|
|
'OrderId' => (int (rand 999999998) + 1 ), # XXX This can result in duplicate order ids. You should use your own sequence instead. |
162
|
|
|
|
|
|
|
'BuyerCode' => '83487235', |
163
|
|
|
|
|
|
|
'CustomerIPAddress' => 'customer_ip', |
164
|
|
|
|
|
|
|
'OrderCustomerId' => 'customer_id', |
165
|
|
|
|
|
|
|
'OrderDescription' => 'description', |
166
|
|
|
|
|
|
|
#'OrderUserId' => '', |
167
|
|
|
|
|
|
|
#'PurchaseOrderNumber' => '', |
168
|
|
|
|
|
|
|
'TransactionConditionCode' => \( TCC_CARDHOLDER_NOT_PRESENT_SECURE_ECOMMERCE ), |
169
|
|
|
|
|
|
|
#'ShippingCharge' => '', |
170
|
|
|
|
|
|
|
#'StateTax' => '', |
171
|
|
|
|
|
|
|
#'TaxAmount' => '', |
172
|
|
|
|
|
|
|
#'TaxExempt' => '', |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
'InvoiceNumber' => 'invoice_number', |
175
|
|
|
|
|
|
|
'Industry' => \( RETAIL ), |
176
|
|
|
|
|
|
|
#'FolioNumber' => '', |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
#'ChargeTotalIncludesRestaurant' |
179
|
|
|
|
|
|
|
#'ChargeTotalIncludesGiftshop' |
180
|
|
|
|
|
|
|
#'ChargeTotalIncludesMinibar' |
181
|
|
|
|
|
|
|
#'ChargeTotalIncludesPhone' |
182
|
|
|
|
|
|
|
#'ChargeTotalIncludesLaundry' |
183
|
|
|
|
|
|
|
#'ChargeTotalIncludesOther' |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
#'ServiceRate' |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
#'ServiceStartDay' |
188
|
|
|
|
|
|
|
#'ServiceStartMonth' |
189
|
|
|
|
|
|
|
#'ServiceStartYear' |
190
|
|
|
|
|
|
|
#'ServiceEndMonth' |
191
|
|
|
|
|
|
|
#'ServiceEndYear' |
192
|
|
|
|
|
|
|
#'ServiceEndDay' |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
#'ServiceNoShow' |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
#'ReferenceId' => '', # XXX Use reference ID for follow-on transactions (CAPTURE, VOID) |
197
|
|
|
|
|
|
|
#'CAVV' |
198
|
|
|
|
|
|
|
#'XID' |
199
|
|
|
|
|
|
|
#'Track1' |
200
|
|
|
|
|
|
|
#'Track2' |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
); |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# Send the transaction! (test token) |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
my $token = $content{'login'}; |
208
|
0
|
0
|
|
|
|
|
$token = "TEST$token" if $self->test_transaction(); |
209
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
my $ccresponse = $tranclient->doTransaction( |
211
|
|
|
|
|
|
|
"", # transaction key (?) |
212
|
|
|
|
|
|
|
$ccreq, #cc request |
213
|
|
|
|
|
|
|
$token, #token |
214
|
|
|
|
|
|
|
); |
215
|
|
|
|
|
|
|
|
216
|
0
|
0
|
|
|
|
|
die $tranclient->GetErrorString unless defined $ccresponse; |
217
|
|
|
|
|
|
|
|
218
|
0
|
|
|
|
|
|
$self->result_code($ccresponse->GetResponseCode); |
219
|
0
|
|
|
|
|
|
$self->avs_code($ccresponse->GetAVSCode); |
220
|
0
|
|
|
|
|
|
$self->order_number($ccresponse->GetOrderId); |
221
|
|
|
|
|
|
|
|
222
|
0
|
0
|
|
|
|
|
if ( $self->result_code == 1 ) { # eq '1' ? |
223
|
0
|
|
|
|
|
|
$self->is_success(1); |
224
|
|
|
|
|
|
|
#$self->authorization($ccresponse->GetBankApprovalCode); |
225
|
0
|
|
|
|
|
|
$self->authorization($ccresponse->GetReferenceId); #"Identifier for follow-on transactions" |
226
|
|
|
|
|
|
|
} else { |
227
|
0
|
|
|
|
|
|
$self->is_success(0); |
228
|
0
|
|
|
|
|
|
$self->error_message($ccresponse->GetResponseCodeText); |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
## print "ResponseCode : ", $ccresponse->GetResponseCode, "\n"; |
234
|
|
|
|
|
|
|
## print "ResponseCodeText : ", $ccresponse->GetResponseCodeText, "\n"; |
235
|
|
|
|
|
|
|
# print "Timestamp : ", $datetime, "\n"; |
236
|
|
|
|
|
|
|
# print "IsoCode : ", $ccresponse->GetIsoCode, "\n"; |
237
|
|
|
|
|
|
|
## print "OrderId : ", $ccresponse->GetOrderId, "\n"; |
238
|
|
|
|
|
|
|
## print "BankApprovalCode : ", $ccresponse->GetBankApprovalCode, "\n"; |
239
|
|
|
|
|
|
|
# print "State : ", $ccresponse->GetState, "\n"; |
240
|
|
|
|
|
|
|
# print "AuthorizedAmount : ", $ccresponse->GetAuthorizedAmount, "\n"; |
241
|
|
|
|
|
|
|
# print "OriginalAuthorizedAmount: ", $ccresponse->GetOriginalAuthorizedAmount, |
242
|
|
|
|
|
|
|
#"\n"; |
243
|
|
|
|
|
|
|
# print "CapturedAmount : ", $ccresponse->GetCapturedAmount, "\n"; |
244
|
|
|
|
|
|
|
# print "CreditedAmount : ", $ccresponse->GetCreditedAmount, "\n"; |
245
|
|
|
|
|
|
|
# print "TimeStampCreated : ", $ccresponse->GetTimeStampCreated, "\n"; |
246
|
|
|
|
|
|
|
## print "ReferenceId : ", $ccresponse->GetReferenceId, "\n"; |
247
|
|
|
|
|
|
|
# print "BankTransactionId : ", $ccresponse->GetBankTransactionId, "\n"; |
248
|
|
|
|
|
|
|
# print "BatchId : ", $ccresponse->GetBatchId, "\n"; |
249
|
|
|
|
|
|
|
# #print "AVS Code : ", $ccresponse->GetAVSCode, "\n"; |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
#this is different from a "normal" B:OP revmap, it sets things in $ccreq |
252
|
|
|
|
|
|
|
sub revmap_fields { |
253
|
4
|
|
|
4
|
0
|
102
|
my($self, $ccreq, %map) = @_; |
254
|
4
|
|
|
|
|
16
|
my %content = $self->content(); |
255
|
4
|
|
|
|
|
107
|
foreach(keys %map) { |
256
|
152
|
|
|
|
|
243
|
my $method = "Set$_"; |
257
|
152
|
100
|
|
|
|
416
|
my $content = ref($map{$_}) ? ${ $map{$_} } : $content{$map{$_}}; |
|
16
|
|
|
|
|
32
|
|
258
|
152
|
|
|
|
|
701
|
$ccreq->$method($content); |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
1; |
264
|
|
|
|
|
|
|
__END__ |