1 package Business::OnlinePayment::SecureHostingUPG;
\r
5 use Business::OnlinePayment 3;
\r
6 use Business::OnlinePayment::HTTPS;
\r
7 use vars qw($VERSION $DEBUG @ISA);
\r
9 @ISA = qw(Business::OnlinePayment::HTTPS);
\r
16 $self->server('www.secure-server-hosting.com');
\r
18 $self->path('/secutran/transactionjs1.php');
\r
20 $self->build_subs(qw(
\r
21 order_number avs_code
\r
24 # md5 cvv2_response cavv_response
\r
31 #$self->map_fields();
\r
32 $self->remap_fields(
\r
34 # => 'transaction_type',
\r
35 login => 'shreference',
\r
36 password => 'checkcode',
\r
39 name => 'cardholdersname',
\r
43 address => 'cardholderaddr1',
\r
44 # => 'cardholderaddr2',
\r
45 city => 'cardholdercity',
\r
46 state => 'cardholderstate',
\r
47 zip => 'cardholderpostcode',
\r
49 phone => 'cardholdertelephonenumber',
\r
51 email => 'cardholdersemail',
\r
52 card_number => 'cardnumber',
\r
53 # => 'cardexpiremonth',
\r
54 # => 'cardexpireyear',
\r
56 'amount' => 'transactionamount',
\r
61 currency => 'transactioncurrency',
\r
65 issue_number => 'switchnumber',
\r
68 die "only Normal Authorization is currently supported"
\r
69 unless $self->{_content}{'action'} =~ /^\s*normal\s*authorization\s*$/i;
\r
71 #cardexpiremonth & cardexpireyear
\r
72 $self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
\r
73 or croak "unparsable expiration ". $self->{_content}{expiration};
\r
74 my( $month, $year ) = ( $1, $2 );
\r
75 $month = '0'. $month if $month =~ /^\d$/;
\r
76 $self->{_content}{cardexpiremonth} = $month;
\r
77 $self->{_content}{cardexpireyear} = $year;
\r
79 #cardstartmonth & cardstartyear
\r
80 $self->{_content}{'card_start'} =~ /^(\d+)\D+\d*(\d{2})$/
\r
81 or croak "unparsable card_start ". $self->{_content}{expiration};
\r
82 my( $smonth, $syear ) = ( $1, $2 );
\r
83 $smonth = '0'. $smonth if $smonth =~ /^\d$/;
\r
84 $self->{_content}{cardstartmonth} = $smonth;
\r
85 $self->{_content}{cardstartyear} = $syear;
\r
87 $self->required_fields(qw(
\r
88 shreference checkcode transactionamount transactioncurrency
\r
89 cardexpireyear cardexpiremonth cardstartyear cardstartmonth
\r
90 switchnumber cv2 cardnumber cardholdersname cardholdersemail
\r
93 my( $page, $response, @reply_headers) =
\r
94 $self->https_post( $self->get_fields( $self->fields ) );
\r
95 #my( $page, $response, @reply_headers) =
\r
96 # $self->https_get( $self->get_fields( $self->fields ) );
\r
98 #my %reply_headers = @reply_headers;
\r
99 #warn join('', map { " $_ => $reply_headers{$_}\n" } keys %reply_headers )
\r
102 #XXX check $response and die if not 200?
\r
108 #md5 cvv2_response cavv_response ...?
\r
110 $self->server_response($page);
\r
112 my $result = $self->GetXMLProp($page, 'result');
\r
114 if ( defined($result) && $result eq 'success' ) {
\r
115 $self->is_success(1);
\r
116 $self->avs_code( $self->GetXMLProp($page, 'cv2asvresult') );
\r
117 } elsif ( defined($result) && $result eq 'failed' ) {
\r
118 $self->is_success(0);
\r
120 my $tranerrdesc = $self->GetXMLProp($page, 'tranerrdesc');
\r
121 my $tranerrdetail = $self->GetXMLProp($page, 'tranerrdetail');
\r
122 $error = $tranerrdesc if defined $tranerrdesc;
\r
123 $error .= " - $tranerrdetail"
\r
124 if defined $tranerrdetail && length $tranerrdetail;
\r
125 $self->error_message($error);
\r
127 die "unparsable response received from gateway".
\r
128 ( $DEBUG ? ": $page" : '' );
\r
141 transactioncurrency
\r
156 cardholdertelephonenumber
\r
161 my( $self, $raw, $prop ) = @_;
\r
165 ($data) = $raw =~ m"<$prop>(.*?)</$prop>"gsi;
\r
166 #$data =~ s/<.*?>/ /gs;
\r
177 Business::OnlinePayment::SecureHostingUPG - SecureHosting UPG backend module for Business::OnlinePayment
\r
181 use Business::OnlinePayment;
\r
184 # One step transaction, the simple case.
\r
187 my $tx = new Business::OnlinePayment("SecureHostingUPG");
\r
190 login => 'SecureHosting Reference',
\r
191 password => 'SecureHosting Checkcode value',
\r
192 action => 'Normal Authorization',
\r
193 description => 'Business::OnlinePayment test',
\r
196 name => 'Tofu Beast',
\r
197 address => '123 Anystreet',
\r
198 city => 'Anywhere',
\r
201 phone => '420-867-5309',
\r
202 email => 'tofu.beast@example.com',
\r
203 card_number => '4005550000000019',
\r
204 expiration => '08/06',
\r
205 card_start => '05/04',
\r
206 cvv2 => '1234', #optional
\r
207 issue_number => '5678',
\r
211 if($tx->is_success()) {
\r
212 print "Card processed successfully: ".$tx->authorization."\n";
\r
214 print "Card was rejected: ".$tx->error_message."\n";
\r
217 =head1 SUPPORTED TRANSACTION TYPES
\r
219 =head2 CC, Visa, MasterCard, American Express, Discover
\r
221 Content required: type, login, password, action, amount, first_name, last_name, card_number, expiration.
\r
223 =head1 PREREQUISITES
\r
228 Net::SSLeay _or_ ( Crypt::SSLeay and LWP )
\r
230 The included htmlgood.html and htmlbad.html files must be uploaded to your
\r
231 Secure Hosting account (Settings | File Manager).
\r
235 For detailed information see L<Business::OnlinePayment>.
\r
239 Only "Normal Authorization" is supported by the gateway.
\r
243 Ivan Kohler <ivan-securehostingupg@420.am>
\r
247 perl(1). L<Business::OnlinePayment>.
\r