1 package Business::OnlinePayment::PXPost;
6 use Business::OnlinePayment 3;
7 use Business::OnlinePayment::HTTPS 0.03;
8 use vars qw($VERSION $DEBUG @ISA);
10 @ISA = qw(Business::OnlinePayment::HTTPS);
17 $self->server('www.paymentexpress.com');
19 $self->path('/pxpost.asp');
21 $self->build_subs(qw( order_number ));
22 #avs_code order_type md5 cvv2_response cavv_response
29 'login' => 'PostUsername',
30 'password' => 'PostPassword',
31 'name' => 'CardHolderName',
32 'card_number' => 'CardNumber',
33 #'expiration' => 'DateExpiry',
36 'action' => 'TxnType',
37 'currency' => 'InputCurrency',
39 #'' => 'MerchantReference',
43 #'' => 'DpsTxnRef', #XXX
44 #'' => 'DpsBillingId',
46 #'' => 'EnableAddBillCard',
49 my $action = $self->{_content}{'TxnType'};
50 if ( $action =~ /^\s*normal\s*authorization\s*$/i ) {
52 } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) {
54 } elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) {
56 } elsif ( $action =~ /^\s*void\s*$/i ) {
57 die "DPS PXPost does not support void transactions\n";
58 } elsif ( $action =~ /^\s*credit\s*$/i ) {
61 $self->{_content}{'TxnType'} = $action;
63 if ( $action =~ /^(Purchase|Auth)$/ ) {
65 $self->required_fields(
66 qw( login password name card_number expiration amount )
70 $self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
71 or croak "unparsable expiration ". $self->{_content}{expiration};
72 my( $month, $year ) = ( $1, $2 );
73 $month = '0'. $month if $month =~ /^\d$/;
74 $self->{_content}{'DateExpiry'} = $month.$year;
76 } elsif ( $action eq 'Complete' || $action eq 'Refund' ) {
78 $self->required_fields(
79 qw( login password name order_number amount )
85 tie my %fields, 'Tie::IxHash', $self->get_fields( $self->fields );
86 my $post_data = join("\n",
88 ( map "<$_>$fields{$_}</$_>", keys %fields ),
92 warn $post_data if $DEBUG > 1;
94 my( $page, $response, @reply_headers ) = $self->https_post( $post_data );
96 $self->server_response($page);
98 my $result = $self->GetXMLProp($page, 'Authorized');
100 if ( $result =~ /^\s*1\s*$/ ) {
101 $self->is_success(1);
102 $self->result_code( $self->GetXMLProp( $page, 'ReCo' ) );
103 $self->authorization( $self->GetXMLProp( $page, 'AuthCode' ) );
104 $self->order_number( $self->GetXMLProp( $page, 'DpsTxnRef' ) );
105 } elsif ( $result =~ /^\s*0\s*$/ ) {
106 $self->is_success(0);
107 $self->result_code( $self->GetXMLProp( $page, 'ReCo' ) );
108 $self->error_message( $self->GetXMLProp( $page, 'ResponseText' ). ': '.
109 $self->GetXMLProp( $page, 'HelpText' )
112 die "unparsable response received from gateway (response $result)".
113 ( $DEBUG ? ": $page" : '' );
121 #order is important to this processor
145 my( $self, $raw, $prop ) = @_;
149 ($data) = $raw =~ m"<$prop>(.*?)</$prop>"gsi;
150 #$data =~ s/<.*?>/ /gs;
161 Business::OnlinePayment::PXPost - Direct Payment Solutions PX Post backend module for Business::OnlinePayment
165 use Business::OnlinePayment;
168 # One step transaction, the simple case.
171 my $tx = new Business::OnlinePayment("PXPost");
174 login => 'PXPost Username',
175 password => 'PXPost Password',
176 action => 'Normal Authorization',
177 #description => 'Business::OnlinePayment test',
179 name => 'Tofu Beast',
180 card_number => '4005550000000019',
181 expiration => '08/06',
182 cvv2 => '1234', #optional
186 if($tx->is_success()) {
187 print "Card processed successfully: ".$tx->authorization."\n";
189 print "Card was rejected: ".$tx->error_message."\n";
192 =head1 SUPPORTED TRANSACTION TYPES
194 =head2 CC, Visa, MasterCard, American Express, Discover
196 Content required: type, login, password, action, amount, card_number, expiration, name.
203 Net::SSLeay _or_ ( Crypt::SSLeay and LWP )
207 For detailed information see L<Business::OnlinePayment>.
213 Ivan Kohler <ivan-pxpost@420.am>
217 perl(1). L<Business::OnlinePayment>.