Codebase list libbusiness-onlinepayment-transactioncentral-perl / upstream/latest
Imported Upstream version 0.06 Xavier Guimard 11 years ago
20 changed file(s) with 892 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 Revision history for Perl extension Business::OnlinePayment::TransactionCentral.
1
2 0.06 Wed Feb 27 16:49:17 PST 2008
3 - update tests with new regkey for TC test account
4
5 0.05 Wed Nov 14 13:26:38 PST 2007
6 - add email->Email mapping
7
8 0.04 Wed May 30 11:53:00 PDT 2007
9 - depend on B:OP v3
10 - fix a "false success" problem caused by discrepancy between test and
11 live systems: "Auth" field comes back as "Declined" rather than empty
12
13 0.03 Sat May 19 15:03:43 PDT 2007
14 - add/finish ECHECK support (google of TCInterfaceGuide indicated
15 s/processcheck.asp/processcheckonline.asp/)
16 - fix another problem with transactions going through but coming back
17 denied: Returned "Auth" field can have trailing whitespace, wtf!
18 - trim "<html><body> </body></html>" tags off of return info. This
19 was preventing TransID (B:OP order_number) from being returned.
20 - add tests: order_number, check, bad_check
21
22 0.02 Thu Apr 19 17:48:09 PDT 2007
23 - updated example in manpage s/Capstone/TransactionCentral/
24 - add debugging methods response_page, response_code, response_headers
25 - Make sure expiration date has a leading zero
26 - fix problem with transactions going through but coming back denied:
27 Returned "Auth" field can have letters as well as numbers! sheesh
28
29 0.01 Wed Nov 23 05:14:43 2005
30 - original version; created by h2xs 1.23 with options
31 -X -b 5.5.0 -n Business::OnlinePayment::TransactionCentral -v 0.01
32
0 Changes
1 Makefile.PL
2 MANIFEST
3 README
4 lib/Business/OnlinePayment/TransactionCentral.pm
5 t/Business-OnlinePayment-TransactionCentral.t
6 t/load.t
7 t/bad_card.t
8 t/bad_check.t
9 t/bop.t
10 t/check.t
11 t/credit_card.t
12 t/crypt_bad_card.t
13 t/crypt_credit_card.t
14 t/crypt_load.t
15 t/credit_card_fs.t
16 t/credit_card_onedigitmonth.t
17 t/order_number.t
0 use 5.005;
1 use ExtUtils::MakeMaker;
2 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
3 # the contents of the Makefile that is written.
4 WriteMakefile(
5 NAME => 'Business::OnlinePayment::TransactionCentral',
6 VERSION_FROM => 'lib/Business/OnlinePayment/TransactionCentral.pm', # finds $VERSION
7 PREREQ_PM => {
8 'Business::OnlinePayment' => 3,
9
10 # for HTTPS (maybe it should be a separate dist?)
11 'URI::Escape' => 0,
12 'Tie::IxHash' => 0,
13
14 # 'Net::SSLeay' => 0,
15 # or 'Crypt::SSLeay' => 0,
16 # 'URI
17 },
18 ($] >= 5.005 ? ## Add these new keywords supported since 5.005
19 (ABSTRACT_FROM => 'lib/Business/OnlinePayment/TransactionCentral.pm', # retrieve abstract from module
20 AUTHOR => 'Ivan Kohler <ivan-transactioncentral@420.am>') : ()),
21 );
0 Copyright (c) 2006 Ivan Kohler
1 Copyright (c) 2007 Freeside Internet Services, Inc.
2 All rights reserved. This program is free software; you can redistribute it
3 and/or modify it under the same terms as Perl itself.
4
5 This is Business::OnlinePayment::TransactionCentral, a Business::OnlinePayment
6 backend module for the MerchantAnywhere Transaction Central gateway. It is
7 only useful if you have a merchant account with MerchantAnywhere:
8 http://www.merchantanywhere.com/
9 http://www.merchantanywhere.com/ecshop/TC_elink.htm
10 http://www.merchantanywhere.com/ecshop/TC%20Interface%20NEW.pdf
11
12 Business::OnlinePayment is a generic interface for processing payments through
13 online credit card processors, online check acceptance houses, etc. (If you
14 like buzzwords, call it an "multiplatform ecommerce-enabling middleware
15 solution").
16
0 package Business::OnlinePayment::TransactionCentral;
1
2 use 5.005;
3 use strict;
4 use Carp;
5 use Business::OnlinePayment 3;
6 use Business::OnlinePayment::HTTPS 0.02;
7 use vars qw($VERSION @ISA $DEBUG);
8
9 @ISA = qw(Business::OnlinePayment::HTTPS);
10 $VERSION = '0.06';
11 $DEBUG = 0;
12
13 sub set_defaults {
14 my $self = shift;
15
16 $self->server('webservices.primerchants.com');
17 $self->port('443');
18 $self->path('/billing/TransactionCentral/');
19
20 $self->build_subs(qw( order_number avs_code cvv2_response
21 response_page response_code response_headers
22 ));
23 }
24
25 sub submit {
26 my($self) = @_;
27
28 $self->revmap_fields(
29 'MerchantID' => 'login',
30 'RegKey' => 'password',
31 'Amount' => 'amount',
32 # 'CreditAmount' => 'amount',
33 'AccountNo' => 'card_number',
34 'NameonAccount' => 'name',
35 'AVSADDR' => 'address',
36 'AVSZIP' => 'zip',
37 'Email' => 'email',
38 'CCRURL' => \'',
39 'CVV2' => 'cvv2',
40 'TransID' => 'order_number',
41 'TRANSROUTE' => 'routing_code',
42 );
43
44 #XXX also set required fields here...
45
46 my @required_fields = qw(login password);
47 my %content = $self->content();
48 my $action = $content{'action'};
49 my $url = $self->path;
50 if (
51 $content{'type'} =~ /^(cc|visa|mastercard|american express|discover)$/i
52 ) {
53
54 if ( $action =~ /^\s*normal\s*authorization\s*$/i ) {
55 $url .= 'processCC.asp';
56
57 #REFID
58 $content{'REFID'} = int(rand(2**31));
59
60 #CCMonth & CCYear
61 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
62 or croak "unparsable expiration ". $content{'expiration'};
63 my( $month, $year ) = ( $1, $2 );
64 $month = '0'. $month if $month =~ /^\d$/;
65 $content{'CCMonth'} = $month;
66 $content{'CCYear'} = $year;
67
68 push @required_fields, qw( amount card_number expiration
69 name address zip
70 );
71
72 } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) {
73 croak "Authorizaiton Only is not supported by Transaction Central";
74 } elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) {
75 croak "Post Authorizaiton is not supported by Transaction Central";
76 } elsif ( $action =~ /^\s*(void|credit)\s*$/i ) {
77 $url .= 'voidcreditcconline.asp';
78
79 $content{'CreditAmount'} = delete $content{'Amount'};
80
81 } else {
82 croak "Unknown action $action";
83 }
84
85 } elsif ( $content{'type'} =~ /^e?check$/i ) {
86
87 if ( $action =~ /^\s*normal\s*authorization\s*$/i ) {
88 $url .= 'processcheckonline.asp';
89 $content{'AccountNo'} = $content{'account_number'};
90 $content{'TRANSTYPE'} =
91 ( exists($content{account_type}) && $content{account_type} =~ /^s/i )
92 ? 'SA'
93 : 'CK';
94
95 push @required_fields, qw( amount account_number routing_code
96 name
97 );
98
99 } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) {
100 croak "Authorizaiton Only is not supported by Transaction Central";
101 } elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) {
102 croak "Post Authorizaiton is not supported by Transaction Central";
103 } elsif ( $action =~ /^\s*(void|credit)\s*$/i ) {
104 $url .= 'addckcreditupdtonline.asp';
105 } else {
106 croak "Unknown action $action";
107 }
108
109 } else {
110 croak 'Unknown type: '. $content{'type'};
111 }
112 $self->path($url);
113 $self->content(%content);
114
115 $self->required_fields(@required_fields);
116
117 my @fields = qw(
118 MerchantID RegKey Amount REFID AccountNo CCMonth CCYear NameonAccount
119 AVSADDR AVSZIP CCRURL CVV2 USER1 USER2 USER3 USER4 TrackData
120 TransID CreditAmount
121 DESCRIPTION DESCDATE TRANSTYPE TRANSROUTE
122 );
123
124 my( $page, $response, %reply_headers ) =
125 $self->https_post( $self->get_fields( @fields ) );
126
127 $self->response_code( $response );
128 $self->response_page( $page );
129 $self->response_headers( \%reply_headers );
130
131 #trim off <html><body> </body></html> around the response we want
132 $page =~ s/^[\s\n]*<html>[\s\n]*<body>[\s\n]*//;
133 $page =~ s/[\s\n]*<\/body>[\s\n]*<\/html>[\s\n]*$//;
134
135 my %return = map { /^(\w+)=(.*)$/ ? ( $1 => $2 ) : () } split(/&/, $page);
136
137 if ( $DEBUG ) { warn "$_ => $return{$_}\n" foreach keys %return; }
138
139 #$self->result_code( $return{'AVSCode'} );
140 $self->avs_code( $return{'AVSCode'} );
141 $self->cvv2_response( $return{'CVV2ResponseMsg'} );
142
143 if ( $return{'Auth'} =~ /^\s*(\w+)\s*$/ && lc($1) ne 'declined' ) {
144
145 $self->is_success(1);
146 $self->authorization( $return{'Auth'} );
147 $self->order_number( $return{'TransID'} );
148
149 } else {
150
151 $self->is_success(0);
152 $self->error_message( $return{'Notes'} );
153
154 }
155
156 }
157
158 sub revmap_fields {
159 my($self, %map) = @_;
160 my %content = $self->content();
161 foreach(keys %map) {
162 # warn "$_ = ". ( ref($map{$_})
163 # ? ${ $map{$_} }
164 # : $content{$map{$_}} ). "\n";
165 $content{$_} = ref($map{$_})
166 ? ${ $map{$_} }
167 : $content{$map{$_}};
168 }
169 $self->content(%content);
170 }
171
172 1;
173
174 __END__
175
176 =head1 NAME
177
178 Business::OnlinePayment::TransactionCentral - Transaction Central backend module for Business::OnlinePayment
179
180 =head1 SYNOPSIS
181
182 use Business::OnlinePayment;
183
184 ####
185 # One step transaction, the simple case.
186 ####
187
188 my $tx = new Business::OnlinePayment("TransactionCentral");
189 $tx->content(
190 type => 'CC',
191 login => '10011', #MerchantID
192 password => 'KK48NPYEJHMAH6DK', #Regkey
193 action => 'Normal Authorization',
194 description => 'Business::OnlinePayment test',
195 amount => '49.95',
196 name => 'Tofu Beast',
197 address => '123 Anystreet',
198 city => 'Anywhere',
199 state => 'UT',
200 zip => '84058',
201 phone => '420-867-5309',
202 email => 'tofu.beast@example.com',
203 card_number => '4012000000001',
204 expiration => '08/06',
205 cvv2 => '1234', #optional
206 );
207 $tx->submit();
208
209 if($tx->is_success()) {
210 print "Card processed successfully: ".$tx->authorization."\n";
211 } else {
212 print "Card was rejected: ".$tx->error_message."\n";
213 }
214 =head1 DESCRIPTION
215
216 This is a Business::OnlinePayment backend module for the Transaction Central
217 (MerchantAnywhere, PRIMerchants) gateway. It is only useful if you have a
218 merchant account with MerchantAnywhere / PRIMerchants:
219
220 http://www.merchantanywhere.com/
221 http://www.merchantanywhere.com/ecshop/TC_elink.htm
222
223 http://www.primerchants.com/
224 http://www.primerchants.com/info/transactioncentral.asp
225
226 =head1 SUPPORTED TRANSACTION TYPES
227
228 =head2 CC, Visa, MasterCard, American Express, Discover
229
230 Content required: type, login, password, action, amount, card_number, expiration, name, address, zip.
231
232 =head2 ECHECK
233
234 Content required: type, login, password, action, amount, account_number, routing_code, name
235
236 =head1 PREREQUISITES
237
238 URI::Escape
239
240 Net::SSLeay _or_ ( Crypt::SSLeay and LWP )
241
242 =head1 DESCRIPTION
243
244 For detailed information see L<Business::OnlinePayment>.
245
246 =head1 NOTE
247
248 The newest publicly available documentation is available at:
249
250 http://www.merchantanywhere.com/ecshop/TC%20Interface%20NEW.pdf
251
252 It is somewhat out-of-date and contains a few discrepancies. Google
253 "TCInterfaceGuide" for current documentation.
254
255 =head1 AUTHOR
256
257 Ivan Kohler <ivan-transactioncentral@420.am>
258
259 =head1 COPYRIGHT AND LICENSE
260
261 Copyright (C) 2006 by Ivan Kohler
262 Copyright (C) 2007 Freeside Internet Services, Inc.
263
264 This library is free software; you can redistribute it and/or modify
265 it under the same terms as Perl itself.
266
267 =head1 SEE ALSO
268
269 perl(1). L<Business::OnlinePayment>.
270
271 =cut
0 # Before `make install' is performed this script should be runnable with
1 # `make test'. After `make install' it should work as `perl Business-OnlinePayment-TransactionCentral.t'
2
3 #########################
4
5 # change 'tests => 1' to 'tests => last_test_to_print';
6
7 use Test;
8 BEGIN { plan tests => 1 };
9 use Business::OnlinePayment::TransactionCentral;
10 ok(1); # If we made it this far, we're ok.
11
12 #########################
13
14 # Insert your test code below, the Test::More module is use()ed here so read
15 # its man page ( perldoc Test::More ) for help writing this test script.
16
0 BEGIN {$| = 1; print "1..1\n"; }
1
2 print "ok 1 # Skipped: No way to get a decline response out of test account";
3 exit;
4
5 eval "use Net::SSLeay;";
6 if ( $@ ) {
7 print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit;
8 }
9
10 use Business::OnlinePayment;
11
12 require "t/lib/test_account.pl";
13 my($login, $regkey) = test_account_or_skip();
14
15 my $tx = new Business::OnlinePayment("TransactionCentral");
16
17 #$Business::OnlinePayment::HTTPS::DEBUG = 1;
18 #$Business::OnlinePayment::HTTPS::DEBUG = 1;
19 $Business::OnlinePayment::TransactionCentral::DEBUG = 1;
20 $Business::OnlinePayment::TransactionCentral::DEBUG = 1;
21
22 $tx->content(
23 type => 'VISA',
24 login => $login,
25 password => $regkey,
26 action => 'Normal Authorization',
27 amount => '32.32',
28 #card_number => '4012000000001',
29 #card_number => '4342424242424242',
30 card_number => '1',
31 expiration => '08/06',
32 cvv2 => '420',
33 name => 'Tofu Beast',
34 address => '123 Anystreet',
35 city => 'Anywhere',
36 state => 'UT',
37 zip => '84058',
38 country => 'US',
39 email => 'ivan-transactioncentral-test@420.am',
40 );
41 $tx->test_transaction(1); # test, dont really charge
42 $tx->submit();
43
44 if($tx->is_success()) {
45 print "not ok 1\n";
46 } else {
47 #warn $tx->server_response."\n";
48 #warn $tx->error_message. "\n";
49 print "ok 1\n";
50 }
0 BEGIN { $| = 1; print "1..1\n"; }
1
2 #print "ok 1 # Skipped: testing account won't accept ACH transactions\n"; exit;
3
4 #eval "use Net::SSLeay;";
5 #if ( $@ ) {
6 # print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit;
7 #}
8
9 use Business::OnlinePayment;
10
11 require "t/lib/test_account.pl";
12 my($login, $regkey) = test_account_or_skip();
13
14 my $ctx = new Business::OnlinePayment("TransactionCentral");
15
16 $ctx->content(
17 type => 'ECHECK',
18 login => $login,
19 password => $regkey,
20 action => 'Normal Authorization',
21 amount => '49.95',
22 invoice_number => '100100',
23 customer_id => 'jsk',
24 name => 'Tofu Beast',
25 account_number => '12345',
26 #routing_code => '026009593',
27 routing_code => 'bad_routing_code',
28 bank_name => 'First National Test Bank',
29 phone => '420-420-5454',
30 #payee => 'Tofu Heavy Enterprises, GmbH',
31 check_number => '420',
32 );
33 $ctx->test_transaction(1); # test, dont really charge
34 $ctx->submit();
35
36 #print $ctx->is_success()."\n";
37
38 if($ctx->is_success()) {
39 #warn $ctx->error_message();
40 print "not ok 1 (".$ctx->error_message().")\n";
41 } else {
42 print "ok 1\n";
43 }
0 BEGIN { $| = 1; print "1..1\n"; }
1 END {print "not ok 1\n" unless $loaded;}
2 use Business::OnlinePayment;
3 $loaded = 1;
4 print "ok 1\n";
0 BEGIN { $| = 1; print "1..1\n"; }
1
2 use Business::OnlinePayment;
3
4 require "t/lib/test_account.pl";
5 my($login, $regkey) = test_account_or_skip();
6
7 my $ctx = Business::OnlinePayment->new("TransactionCentral");
8
9 #$Business::OnlinePayment::TransactionCentral::DEBUG = 1;
10 #$Business::OnlinePayment::TransactionCentral::DEBUG = 1;
11
12 $ctx->content(
13 type => 'CHECK',
14 login => $login,
15 password => $regkey,
16 action => 'Normal Authorization',
17 amount => '49.95',
18 invoice_number => '100100',
19 customer_id => 'jsk',
20 name => 'Tofu Beast',
21 account_number => '12345',
22 routing_code => '111000025', # BoA in Texas taken from Wikipedia
23 bank_name => 'First National Test Bank',
24 account_type => 'Checking',
25 license_num => '12345678',
26 license_state => 'OR',
27 license_dob => '1975-05-21',
28 );
29 $ctx->test_transaction(1); # test, dont really charge
30 $ctx->submit();
31
32 if($ctx->is_success()) {
33 print "ok 1\n";
34 } else {
35 warn "error message : ". $ctx->error_message(). "\n";
36 warn "response code : ". $ctx->response_code(). "\n";
37 warn "response page : ". $ctx->response_page(). "\n";
38
39 print "not ok 1 (".$ctx->error_message().")\n";
40 }
0 BEGIN { $| = 1; print "1..1\n"; }
1
2 eval "use Net::SSLeay;";
3 if ( $@ ) {
4 print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit;
5 }
6
7 use Business::OnlinePayment;
8
9 require "t/lib/test_account.pl";
10 my($login, $regkey) = test_account_or_skip();
11
12 my $tx = new Business::OnlinePayment("TransactionCentral");
13
14 #$Business::OnlinePayment::HTTPS::DEBUG = 1;
15 #$Business::OnlinePayment::HTTPS::DEBUG = 1;
16 #$Business::OnlinePayment::TransactionCentral::DEBUG = 1;
17 #$Business::OnlinePayment::TransactionCentral::DEBUG = 1;
18
19 $tx->content(
20 type => 'VISA',
21 login => $login,
22 password => $regkey,
23 action => 'Normal Authorization',
24 description => 'Business::OnlinePayment::TransactionCentral test',
25 amount => '32',
26 card_number => '4012000000001',
27 expiration => '01/06',
28 cvv2 => '420',
29 name => 'Tofu Beast',
30 address => '123 Anystreet',
31 city => 'Anywhere',
32 state => 'UT',
33 zip => '84058',
34 country => 'US',
35 email => 'ivan-transactioncentral-test@420.am',
36 );
37 $tx->test_transaction(1); # test, dont really charge
38 $tx->submit();
39
40 if($tx->is_success()) {
41 print "ok 1\n";
42 } else {
43 #warn $tx->server_response."\n";
44 warn $tx->error_message. "\n";
45 print "not ok 1\n";
46 }
47
0 BEGIN { $| = 1; print "1..1\n"; }
1
2 eval "use Net::SSLeay;";
3 if ( $@ ) {
4 print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit;
5 }
6
7 use Business::OnlinePayment;
8
9 require "t/lib/test_account.pl";
10 my($login, $regkey) = test_account_or_skip();
11
12 my $tx = new Business::OnlinePayment("TransactionCentral");
13
14 #$Business::OnlinePayment::HTTPS::DEBUG = 1;
15 #$Business::OnlinePayment::HTTPS::DEBUG = 1;
16 #$Business::OnlinePayment::TransactionCentral::DEBUG = 1;
17 #$Business::OnlinePayment::TransactionCentral::DEBUG = 1;
18
19 $tx->content(
20 type => 'VISA',
21 login => $login,
22 password => $regkey,
23 action => 'Normal Authorization',
24 description => 'Business::OnlinePayment::TransactionCentral test',
25 amount => '32',
26
27 customer_id => '54',
28 last_name => 'Beast',
29 first_name => 'Tofu',
30 name => 'Tofu Beast',
31 address => '123 Anystreet',
32 city => 'Anywhere',
33 state => 'UT',
34 zip => '84058',
35 country => 'US',
36
37 referer => 'http://cleanwhisker.420.am/',
38 email => 'ivan-transactioncentral-test@420.am',
39 #email => 'tofubeast@example.com',
40 phone => '530-555-3300',
41
42 'customer_ip' => '5.4.3.2',
43 #invoice_number => '420',
44 card_number => '4012000000001',
45 expiration => '01/06',
46 cvv2 => '420',
47 );
48 $tx->test_transaction(1); # test, dont really charge
49 $tx->submit();
50
51 if($tx->is_success()) {
52 print "ok 1\n";
53 } else {
54 #warn $tx->server_response."\n";
55 warn $tx->error_message. "\n";
56 print "not ok 1\n";
57 }
58
0 BEGIN { $| = 1; print "1..1\n"; }
1
2 eval "use Net::SSLeay;";
3 if ( $@ ) {
4 print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit;
5 }
6
7 use Business::OnlinePayment;
8
9 require "t/lib/test_account.pl";
10 my($login, $regkey) = test_account_or_skip();
11
12 my $tx = new Business::OnlinePayment("TransactionCentral");
13
14 #$Business::OnlinePayment::HTTPS::DEBUG = 1;
15 #$Business::OnlinePayment::HTTPS::DEBUG = 1;
16 #$Business::OnlinePayment::TransactionCentral::DEBUG = 1;
17 #$Business::OnlinePayment::TransactionCentral::DEBUG = 1;
18
19 $tx->content(
20 type => 'VISA',
21 login => $login,
22 password => $regkey,
23 action => 'Normal Authorization',
24 description => 'Business::OnlinePayment::TransactionCentral test',
25 amount => '32',
26 card_number => '4012000000001',
27 expiration => '1/12',
28 cvv2 => '420',
29 name => 'Tofu Beast',
30 address => '123 Anystreet',
31 city => 'Anywhere',
32 state => 'UT',
33 zip => '84058',
34 country => 'US',
35 email => 'ivan-transactioncentral-test@420.am',
36 );
37 $tx->test_transaction(1); # test, dont really charge
38 $tx->submit();
39
40 if($tx->is_success()) {
41 print "ok 1\n";
42 } else {
43 #warn $tx->server_response."\n";
44 warn $tx->error_message. "\n";
45 print "not ok 1\n";
46 }
47
0 BEGIN {
1 $| = 1; print "1..1\n";
2 $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
3 $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
4 }
5
6 print "ok 1 # Skipped: No way to get a decline response out of test account";
7 exit;
8
9 eval "use Crypt::SSLeay;";
10 if ( $@ ) {
11 print "ok 1 # Skipped: Crypt::SSLeay is not installed\n"; exit;
12 }
13
14 use Business::OnlinePayment;
15
16 require "t/lib/test_account.pl";
17 my($login, $regkey) = test_account_or_skip();
18
19 my $tx = new Business::OnlinePayment("TransactionCentral");
20
21 $tx->content(
22 type => 'VISA',
23 login => $login,
24 password => $regkey,
25 action => 'Normal Authorization',
26 amount => '32.32',
27 #card_number => '4012000000001',
28 card_number => '4342424242424242',
29 expiration => '08/06',
30 cvv2 => '420',
31 name => 'Tofu Beast',
32 address => '123 Anystreet',
33 city => 'Anywhere',
34 state => 'UT',
35 zip => '84058',
36 country => 'US',
37 email => 'ivan-transactioncentral-test@420.am',
38 );
39 $tx->test_transaction(1); # test, dont really charge
40 $tx->submit();
41
42 if($tx->is_success()) {
43 print "not ok 1\n";
44 } else {
45 #warn $tx->server_response."\n";
46 #warn $tx->error_message. "\n";
47 print "ok 1\n";
48 }
49
0 BEGIN {
1 $| = 1; print "1..1\n";
2 $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
3 $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
4 }
5
6 eval "use Crypt::SSLeay;";
7 if ( $@ ) {
8 print "ok 1 # Skipped: Crypt::SSLeay is not installed\n"; exit;
9 }
10
11 use Business::OnlinePayment;
12
13 require "t/lib/test_account.pl";
14 my($login, $regkey) = test_account_or_skip();
15
16 my $tx = new Business::OnlinePayment("TransactionCentral");
17
18 #$Business::OnlinePayment::HTTPS::DEBUG = 1;
19 #$Business::OnlinePayment::HTTPS::DEBUG = 1;
20 #$Business::OnlinePayment::TransactionCentral::DEBUG = 1;
21 #$Business::OnlinePayment::TransactionCentral::DEBUG = 1;
22
23 $tx->content(
24 type => 'VISA',
25 login => $login,
26 password => $regkey,
27 action => 'Normal Authorization',
28 description => 'Business::OnlinePayment::TransactionCentral test',
29 amount => '54.01',
30 card_number => '4012000000001',
31 expiration => '08/06',
32 cvv2 => '420',
33 name => 'Tofu Beast',
34 address => '123 Anystreet',
35 city => 'Anywhere',
36 state => 'UT',
37 zip => '84058',
38 country => 'US',
39 email => 'ivan-transactioncentral-test@420.am',
40 );
41 $tx->test_transaction(1); # test, dont really charge
42 $tx->submit();
43
44 if($tx->is_success()) {
45 print "ok 1\n";
46 } else {
47 #warn $tx->server_response."\n";
48 warn $tx->error_message. "\n";
49 print "not ok 1\n";
50 }
51
0 BEGIN {
1 $| = 1; print "1..1\n";
2 eval "use Crypt::SSLeay;";
3 if ( $@ ) {
4 print "ok 1 # Skipped: Crypt::SSLeay is not installed\n"; exit;
5 }
6 $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
7 $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
8 }
9 END {print "not ok 1\n" unless $loaded;}
10 use Business::OnlinePayment::TransactionCentral;
11 $loaded = 1;
12 print "ok 1\n";
0 sub test_account_or_skip {
1 my $suffix = shift;
2 my($login, $password) = test_account($suffix);
3
4 unless( defined $login ) {
5 #plan skip_all => "No test account";
6 #not (yet?) using Test::More
7 print "ok 1 # Skipped: No test account\n";
8 exit;
9 }
10
11 return($login, $password);
12 }
13
14 sub test_account {
15 my $suffix = shift || '';
16 $suffix = "_$suffix" if $suffix;
17 open TEST_ACCOUNT, "t/test_account$suffix" or return;
18 my($login, $password) = <TEST_ACCOUNT>;
19 chomp $login;
20 chomp $password;
21
22 return($login, $password);
23 }
24
25 sub expiration_date {
26 my($month, $year) = (localtime)[4,5];
27 $month += 1;
28 $year++; # So we expire next year.
29 $year %= 100; # y2k? What's that?
30
31 return sprintf("%02d/%02d", $month, $year);
32 }
33
34 sub tomorrow {
35 my($day, $month, $year) = (localtime(time+86400))[3..5];
36 return sprintf("%04d-%02d-%02d", $year+1900, ++$month, $day);
37 }
38
39 1;
0 BEGIN {
1 $| = 1; print "1..1\n";
2 eval "use Net::SSLeay;";
3 if ( $@ ) {
4 print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit;
5 }
6
7 }
8 END {print "not ok 1\n" unless $loaded;}
9 use Business::OnlinePayment::TransactionCentral;
10 $loaded = 1;
11 print "ok 1\n";
0 BEGIN { $| = 1; print "1..1\n"; }
1
2 eval "use Net::SSLeay;";
3 if ( $@ ) {
4 print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit;
5 }
6
7 use Business::OnlinePayment;
8
9 require "t/lib/test_account.pl";
10 my($login, $regkey) = test_account_or_skip();
11
12 my $tx = new Business::OnlinePayment("TransactionCentral");
13
14 #$Business::OnlinePayment::HTTPS::DEBUG = 1;
15 #$Business::OnlinePayment::HTTPS::DEBUG = 1;
16 #$Business::OnlinePayment::TransactionCentral::DEBUG = 1;
17 #$Business::OnlinePayment::TransactionCentral::DEBUG = 1;
18
19 $tx->content(
20 type => 'VISA',
21 login => $login,
22 password => $regkey,
23 action => 'Normal Authorization',
24 description => 'Business::OnlinePayment::TransactionCentral test',
25 amount => '32',
26 card_number => '4012000000001',
27 expiration => '01/06',
28 cvv2 => '420',
29 name => 'Tofu Beast',
30 address => '123 Anystreet',
31 city => 'Anywhere',
32 state => 'UT',
33 zip => '84058',
34 country => 'US',
35 email => 'ivan-transactioncentral-test@420.am',
36 );
37 $tx->test_transaction(1); # test, dont really charge
38 $tx->submit();
39
40 if($tx->is_success() && $tx->order_number =~ /^(\w+)$/ ) {
41 print "ok 1\n";
42 } else {
43 warn "order number: ". $tx->order_number."\n";
44 #warn $tx->error_message. "\n";
45 print "not ok 1\n";
46 }
47
0 10011
1 6BK9JNNR6MQY578Y