From dafab54d874265f576305d8ba44a6d90a142a7b1 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 11 Oct 2005 00:57:05 +0000 Subject: [PATCH] 0.02 fixes for postauth/refund/void --- Changes | 4 +++ lib/Business/OnlinePayment/Capstone.pm | 53 +++++++++++++++------------------- t/bad_card.t | 10 ++++++- t/crypt_bad_card.t | 10 ++++++- 4 files changed, 45 insertions(+), 32 deletions(-) diff --git a/Changes b/Changes index 7ab03fe..33c3c6a 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for Perl extension Business::OnlinePayment::Capstone. +0.02 Mon Oct 10 17:46:23 PDT 2005 + - fix required fields for postauth/void/return, + should fix "unparsable expiration" error on refunds + 0.01 Thu Aug 18 01:43:39 2005 - original version; created by h2xs 1.23 with options -X -b 5.5.0 -n Business::OnlinePayment::Capstone -v 0.01 diff --git a/lib/Business/OnlinePayment/Capstone.pm b/lib/Business/OnlinePayment/Capstone.pm index ed645bb..6302592 100644 --- a/lib/Business/OnlinePayment/Capstone.pm +++ b/lib/Business/OnlinePayment/Capstone.pm @@ -9,7 +9,7 @@ use Business::OnlinePayment::HTTPS 0.03; use vars qw($VERSION $DEBUG @ISA); @ISA = qw(Business::OnlinePayment::HTTPS); -$VERSION = '0.01'; +$VERSION = '0.02'; $DEBUG = 0; sub set_defaults { @@ -65,14 +65,12 @@ sub submit { custom0 => 'description', ); - # => 'order_type', # => 'transaction_type', #authorization => #company => - #country => #phone => #fax => @@ -80,45 +78,40 @@ sub submit { #customer_id => #authorization => 'txn_number' - # XXXfix check required fields! -# if ( $action =~ /^(purchase|preauth|ind_refund)$/ ) { -# -# $self->required_fields( -# qw( login password amount card_number expiration ) -# ); -# + if ( $action =~ /^auth(postauth)?$/ ) { + + $self->required_fields(qw( + login password action amount + name address city state zip + email + card_number expiration cvv2 + )); + $self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/ - or croak "unparsable expiration ". $self->{_content}{expiration}; + or croak "unparsable expiration: ". $self->{_content}{expiration}; my( $month, $year ) = ( $1, $2 ); $month = '0'. $month if $month =~ /^\d$/; $self->{_content}{card_exp} = $month.$year; if ( $self->{_content}{'card_start'} ) { $self->{_content}{'card_start'} =~ /^(\d+)\D+\d*(\d{2})$/ - or croak "unparsable expiration ". $self->{_content}{card_start}; + or croak "unparsable card_start ". $self->{_content}{card_start}; my( $month, $year ) = ( $1, $2 ); $month = '0'. $month if $month =~ /^\d$/; $self->{_content}{start_date} = $month.$year; } -# $self->generate_order_id; -# # $self->{_content}{amount} = sprintf('%.2f', $self->{_content}{amount} ); -# -# } elsif ( $action eq 'completion' || $action eq 'void' ) { -# -# $self->required_fields( qw( login password order_number authorization ) ); -# -# } elsif ( $action eq 'refund' ) { -# -# $self->required_fields( -# qw( login password order_number authorization ) -# ); -# -# } - - #warn $self->get_fields('zip'); - #warn $self->get_fields('postal'); + + } elsif ( $action =~ /^(postauth|void|return)$/ ) { + + $self->required_fields(qw( + login password action order_number + )); + + } else { + die "unknown action $action"; + } $self->{'_content'}{country} ||= 'US'; @@ -179,7 +172,7 @@ sub submit { if ( $result{'status'} eq 'good' ) { $self->is_success(1); $self->authorization( $result{'auth_code'} ); - $self->order_number( $result{'orderid'} ); + $self->order_number( $result{'orderid'} ); } elsif ( $result{'status'} =~ /^(bad|error|fraud)$/ ) { $self->is_success(0); $self->error_message("$1: ". $result{'status_msg'}); diff --git a/t/bad_card.t b/t/bad_card.t index f744c61..b41c71a 100644 --- a/t/bad_card.t +++ b/t/bad_card.t @@ -20,8 +20,16 @@ $tx->content( password => 'testing', action => 'Normal Authorization', amount => '32.32', - card_number => '4242424242424242', + card_number => '4342424242424242', expiration => '08/06', + cvv2 => '420', + name => 'Tofu Beast', + address => '123 Anystreet', + city => 'Anywhere', + state => 'UT', + zip => '84058', + country => 'US', + email => 'ivan-capstone-test@420.am', ); $tx->test_transaction(1); # test, dont really charge $tx->submit(); diff --git a/t/crypt_bad_card.t b/t/crypt_bad_card.t index cc36356..1072e2d 100644 --- a/t/crypt_bad_card.t +++ b/t/crypt_bad_card.t @@ -19,8 +19,16 @@ $tx->content( password => 'testing', action => 'Normal Authorization', amount => '32.32', - card_number => '4242424242424242', + card_number => '4342424242424242', expiration => '08/06', + cvv2 => '420', + name => 'Tofu Beast', + address => '123 Anystreet', + city => 'Anywhere', + state => 'UT', + zip => '84058', + country => 'US', + email => 'ivan-capstone-test@420.am', ); $tx->test_transaction(1); # test, dont really charge $tx->submit(); -- 2.11.0