1 package Business::OnlinePayment::PaymentsGateway;
5 use Business::OnlinePayment
6 use Net::SSLeay qw(sslcat);
7 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG);
11 @ISA - qw( Exporter AutoLoader Business::OnlinePayment);
21 $self->port( 5050 + 1000 * $self->test_transaction() );
27 my %content = $self->content();
31 'normal authorization' => 0,
32 'authorization only' => 1,
33 'post authorization' => 2,
40 'american express' => 10,
46 #pg_type/action = action + type
48 $self->transaction_type( $actions{ lc($content{'action'}) }
49 + $types{ lc($content{'type' }) } );
51 #$self->content(%content);
56 my %content = $self->content();
58 $content{$_} = ref($map{$_})
62 $self->content(%content);
69 my %content = $self->content();
72 'pg_merchant_id' => 'login',
73 'pg_password' => 'password',
74 'pg_transaction_type' => \($self->transaction_type()),
78 'pg_total_amount' => 'amount',
79 #'pg_sales_tax_amount'
80 'pg_consumer_id' => 'customer_id',
81 'ecom_consumerorderid' => 'invoice_number', #???
83 'pg_billto_postal_name_company' => 'company', #????
84 'ecom_billto_postal_name_first' => 'first_name', #????
85 'ecom_billto_postal_name_last' => 'last_name', # ????
86 'ecom_billto_postal_street_line1' => 'address',
87 #'ecom_billto_postal_street_line2'
88 'ecom_billto_postal_city' => 'city',
89 'ecom_billto_postal_stateprov' => 'state',
90 'ecom_billto_postal_postalcode' => 'zip',
91 'ecom_billto_postal_countrycode' => 'country',
92 'ecom_billto_telecom_phone_number' => 'phone',
93 'ecom_billto_online_email' => 'email',
95 #'pg_billto_dl_number'
97 'ecom_payment_check_trn' => 'routing_code',
98 'ecom_payment_check_account' => 'account_number',
99 'ecom_payment_check_account_type' => \'C', #checking
100 #'ecom_payment_check_checkno' =>
103 # name (first_name & last_name ) ?
106 # card_number exp_date
108 #account_number routing_code bank_name
110 my @fields = qw( pg_merchant_id pg_password pg_transaction_type ),
111 ( map { "pg_merchant_$_" } (1..9) ),
112 qw( pg_total_amount pg_sales_tax_amount pg_consumer_id
113 ecom_consumerorderid ecom_walletid
114 pg_billto_postal_name_company
115 ecom_billto_postal_name_first ecom_billto_postal_name_last
116 ecom_billto_postal_street_line1
117 ecom_billto_postal_street_line2
118 ecom_billto_postal_city ecom_billto_postal_stateprov
119 ecom_billto_postal_postalcode ecom_billto_postal_countrycode
120 ecom_billto_telecom_phone_number ecom_billto_online_email
121 pg_billto_ssn pg_billto_dl_number pg_billto_dl_state
124 if ( $content{'type'} =~ /^check$/i ) {
125 push @fields, qw( ecom_payment_check_trn
126 ecom_payment_check_account
127 ecom_payment_check_account_type );
129 croak $content{$type}. ' not (yet) supported';
132 my $request = join("\n", map { "$_=$content{$_}" } @fields ). "\n";
134 my $reply = sslcat( $self->server(), $self->port(), $request );
136 my %response = map { /^(\w+)=(.*)$/
137 or warn "can't parse response line: $_";
139 } split(/\n/, $reply);
141 if ( $response{'pg_response_type'} eq 'A' ) {
142 $self->is_success(1);
143 $self->response_code($response{'pg_response_code'});
144 $self->authorization($response{'pg_authorization_code'});
146 $self->is_success(0);
147 $self->response_code($response{'pg_response_code'});
148 $self->error_message($response{'pg_response_description'});