From 32073e637db2c5c91b726072f891c36ebd8b3d10 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 7 Nov 2005 11:10:08 +0000 Subject: - Switch from GET to POST, as per old 1.5 prerelease from Michael Lehmkuhl - Don't check expiration for ECHECK and refunds - For the unsupported "void" action, return is_success 0 and error msg suggesting "credit" action, instead of croaking. This way the "try void first, if it fails, try credit" idiom will work. - tests: enable check.t and add crypt_check.t and {crypt_}bad_check.t - update with new test account --- OpenECHO.pm | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'OpenECHO.pm') diff --git a/OpenECHO.pm b/OpenECHO.pm index fdf3a56..a9eed3a 100644 --- a/OpenECHO.pm +++ b/OpenECHO.pm @@ -56,10 +56,11 @@ use strict; use Carp; use Business::OnlinePayment 3; use Business::OnlinePayment::HTTPS; -use vars qw($VERSION @ISA); +use vars qw($VERSION @ISA $DEBUG); @ISA = qw(Business::OnlinePayment::HTTPS); $VERSION = '0.03'; +$DEBUG = 0; sub set_defaults { my $self = shift; @@ -96,6 +97,14 @@ sub map_fields { my %content = $self->content(); + if ( lc($content{'action'}) eq 'void' ) { + $self->is_success(0); + $self->error_message( 'OpenECHO gateway does not support voids; '. + 'try action => "Credit" ' + ); + return; + } + my $avs = $self->require_avs; $avs = 1 unless defined($avs) && length($avs); #default AVS on unless explicitly turned off @@ -214,6 +223,8 @@ sub submit { license_num => 'ec_id_number', license_state => 'ec_id_state', #license_dob => + payee => 'ec_payee', + check_number => 'ec_serial_number', #recurring_billing => 'cnp_recurring', ); @@ -224,14 +235,16 @@ sub submit { #XXX counter field shouldn't be just a random integer (but it does need a #default this way i guess... $self->{_content}{counter} = int(rand(2**31)); - - #ccexp_month & ccexp_year - $self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/ - or croak "unparsable expiration ". $self->{_content}{expiration}; - my( $month, $year ) = ( $1, $2 ); - $month = '0'. $month if $month =~ /^\d$/; - $self->{_content}{ccexp_month} = $month; - $self->{_content}{ccexp_year} = $year; + + if ( $self->transaction_type =~ /^[EA][VS]$/ ) { + #ccexp_month & ccexp_year + $self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/ + or croak "unparsable expiration ". $self->{_content}{expiration}; + my( $month, $year ) = ( $1, $2 ); + $month = '0'. $month if $month =~ /^\d$/; + $self->{_content}{ccexp_month} = $month; + $self->{_content}{ccexp_year} = $year; + } $self->{_content}{cnp_recurring} = 'Y' if exists($self->{_content}{recurring_billing}) @@ -244,7 +257,9 @@ sub submit { $self->required_fields(); my( $page, $response, %reply_headers) = - $self->https_get( $self->get_fields( $self->fields ) ); + $self->https_post( $self->get_fields( $self->fields ) ); + + warn "raw echo response: $page" if $DEBUG; #XXX check $response and die if not 200? -- cgit v1.2.1