| 1 | package Business::OnlinePayment::iAuthorizer; | ||||||||||
| 2 | |||||||||||
| 3 | # $Id: iAuthorizer.pm,v 1.6 2003/09/11 05:30:38 db48x Exp $ | ||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Business::OnlinePayment; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Net::SSLeay qw/make_form post_https make_headers/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | require Exporter; | |||||||||
| 12 | |||||||||||
| 13 | 1 | @ISA = qw(Exporter AutoLoader Business::OnlinePayment); | |||||||||
| 14 | 1 | @EXPORT = qw(); | |||||||||
| 15 | 1 | @EXPORT_OK = qw(); | |||||||||
| 16 | 1 | $VERSION = '0.2'; | |||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub set_defaults { | ||||||||
|
Subroutine
set_defaults: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 19 | 0 | my $self = shift; | |||||||||
| 20 | |||||||||||
| 21 | 0 | $self->server('tran1.iAuthorizer.net'); | |||||||||
| 22 | 0 | $self->port('443'); | |||||||||
| 23 | 0 | $self->path('/trans/postto.asp'); | |||||||||
| 24 | |||||||||||
| 25 | 0 | $self->build_subs('action'); | |||||||||
| 26 | 0 | $self->build_subs('debug'); | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | sub map_fields { | ||||||||
|
Subroutine
map_fields: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 30 | 0 | my($self) = @_; | |||||||||
| 31 | |||||||||||
| 32 | 0 | my %content = $self->content(); | |||||||||
| 33 | |||||||||||
| 34 | # ACTION MAP | ||||||||||
| 35 | 0 | my %actions = ('normal authorization' => '5', | |||||||||
| 36 | 'authorization only' => '6', | ||||||||||
| 37 | 'credit' => '0', | ||||||||||
| 38 | 'post authorization' => '2', | ||||||||||
| 39 | 'void' => '1', | ||||||||||
| 40 | ); | ||||||||||
| 41 | 0 | $content{'action'} = $actions{lc($content{'action'})}; | |||||||||
| 42 | |||||||||||
| 43 | 0 | my %methods = ('manual' => '0', | |||||||||
| 44 | 'swipe' => '1', | ||||||||||
| 45 | 'swipe, track 1' => '1', | ||||||||||
| 46 | 'swipe, track 2' => '2', | ||||||||||
| 47 | ); | ||||||||||
| 48 | 0 | $content{'entry_method'} = $methods{lc($content{'entry_method'})}; | |||||||||
| 49 | |||||||||||
| 50 | 0 | ($content{'expMonth'}, $content{'expYear'}) = split('/', $content{'expiration'}); | |||||||||
| 51 | |||||||||||
| 52 | # stuff it back into %content | ||||||||||
| 53 | 0 | $self->content(%content); | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub remap_fields { | ||||||||
|
Subroutine
remap_fields: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 57 | 0 | my($self,%map) = @_; | |||||||||
| 58 | |||||||||||
| 59 | 0 | my %content = $self->content(); | |||||||||
| 60 | 0 | foreach(keys %map) { | |||||||||
| 61 | 0 | $content{$map{$_}} = $content{$_}; | |||||||||
| 62 | } | ||||||||||
| 63 | 0 | $self->content(%content); | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | sub get_fields { | ||||||||
|
Subroutine
get_fields: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 67 | 0 | my($self,@fields) = @_; | |||||||||
| 68 | |||||||||||
| 69 | 0 | my %content = $self->content(); | |||||||||
| 70 | 0 | my %new = (); | |||||||||
| 71 | 0 | foreach(grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; } | |||||||||
| 72 | |||||||||||
| 73 | 0 | return %new; | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | 0 | ▶ | sub transaction_type { | ||||||||
|
Subroutine
transaction_type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 77 | 0 | my $self = shift; | |||||||||
| 78 | 0 | return $self->content()->{'action'}; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 0 | ▶ | sub submit { | ||||||||
|
Subroutine
submit: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 82 | 0 | my($self) = @_; | |||||||||
| 83 | |||||||||||
| 84 | 0 | $self->map_fields(); | |||||||||
| 85 | 0 | $self->remap_fields( | |||||||||
| 86 | entry_method => 'EntryMethod', | ||||||||||
| 87 | login => 'MerchantCode', | ||||||||||
| 88 | password => 'MerchantPWD', | ||||||||||
| 89 | serial => 'MerchantSerial', | ||||||||||
| 90 | action => 'Trantype', | ||||||||||
| 91 | amount => 'amount', | ||||||||||
| 92 | invoice_number => 'invoicenum', | ||||||||||
| 93 | order_number => 'referencenum', | ||||||||||
| 94 | authorization => 'appcode', | ||||||||||
| 95 | customer_id => 'customer', | ||||||||||
| 96 | address => 'Address', | ||||||||||
| 97 | zip => 'ZipCode', | ||||||||||
| 98 | card_number => 'ccnumber', | ||||||||||
| 99 | cvv2 => 'CVV2', | ||||||||||
| 100 | ); | ||||||||||
| 101 | |||||||||||
| 102 | # if ($self->action() == 0 || $self->action() == 1) # void or force | ||||||||||
| 103 | # { | ||||||||||
| 104 | # $self->required_fields(qw/login password serial action card_number expiration amount authorization/); | ||||||||||
| 105 | # } | ||||||||||
| 106 | # else | ||||||||||
| 107 | # { | ||||||||||
| 108 | 0 | $self->required_fields(qw/login password serial action card_number expiration amount/); | |||||||||
| 109 | # } | ||||||||||
| 110 | |||||||||||
| 111 | 0 | my %post_data = $self->get_fields(qw/MerchantCode MerchantPWD MerchantSerial ccnumber | |||||||||
| 112 | expYear expMonth Trantype EntryMethod amount | ||||||||||
| 113 | invoicenum ordernum Zipcode Address CVV2 CF appcode/); | ||||||||||
| 114 | |||||||||||
| 115 | 0 | $post_data{'EntryMethod'} = 0; # hand entered, as opposed to swiped through a card reader | |||||||||
| 116 | 0 | $post_data{'CF'} = 'ON'; # return comma-delimited data | |||||||||
| 117 | |||||||||||
| 118 | 0 | my $pd = make_form(%post_data); | |||||||||
| 119 | 0 | my $s = $self->server(); | |||||||||
| 120 | 0 | my $p = $self->port(); | |||||||||
| 121 | 0 | my $t = $self->path(); | |||||||||
| 122 | 0 | my $r = $self->{_content}->{referer}; | |||||||||
| 123 | 0 | my($page,$server_response,%headers) = post_https($s,$p,$t,$r,$pd); | |||||||||
| 124 | |||||||||||
| 125 | 0 | my @col = split(',', $page); | |||||||||
| 126 | |||||||||||
| 127 | 0 | $self->server_response($page); | |||||||||
| 128 | 0 | ▶ | if($col[0] eq "0" ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 129 | 0 | $self->is_success(1); | |||||||||
| 130 | 0 | $self->result_code($col[1]); | |||||||||
| 131 | 0 | $self->authorization($col[1]); | |||||||||
| 132 | } else { | ||||||||||
| 133 | 0 | $self->is_success(0); | |||||||||
| 134 | 0 | $self->result_code($col[1]); | |||||||||
| 135 | 0 | $self->error_message($col[2]); | |||||||||
| 136 | } | ||||||||||
| 137 | |||||||||||
| 138 | $self->debug("<no response code, debug info follows>\n". | ||||||||||
| 139 | "HTTPS response:\n $server_response\n\n". | ||||||||||
| 140 | "HTTPS headers:\n ". | ||||||||||
| 141 | 0 | join("\n ", map { "$_ => ". $headers{$_} } keys %headers ). "\n\n". | |||||||||
| 142 | "POST Data:\n ". | ||||||||||
| 143 | 0 | join("\n ", map { "$_ => ". $post_data{$_} } keys %post_data ). "\n\n". | |||||||||
| 144 | "Raw HTTPS content:\n $page"); | ||||||||||
| 145 | } | ||||||||||
| 146 | |||||||||||
| 147 | 1 | 1; | |||||||||
| 148 | __END__ | ||||||||||