From 8446e3d316a469f22403f8767e48aac04c8ab79a Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Fri, 4 May 2012 15:18:35 -0700 Subject: [PATCH] add Reverse Authorization support, patch from dougforpres --- Changes | 3 +++ IPPay.pm | 15 ++++++++++++--- t/card.t | 30 +++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/Changes b/Changes index c027dc0..586eb89 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Perl extension Business::OnlinePayment::IPPay. +0.07 unreleased + - add Reverse Authorization support, patch from dougforpres + 0.06 Wed Jan 26 13:15:21 PST 2011 - fix january bug in tests diff --git a/IPPay.pm b/IPPay.pm index 59c3e78..963ba5b 100644 --- a/IPPay.pm +++ b/IPPay.pm @@ -11,7 +11,7 @@ use Business::OnlinePayment::HTTPS; use vars qw($VERSION $DEBUG @ISA $me); @ISA = qw(Business::OnlinePayment::HTTPS); -$VERSION = '0.06'; +$VERSION = '0.07_01'; $VERSION = eval $VERSION; # modperlstyle: convert the string into a number $DEBUG = 0; @@ -28,6 +28,7 @@ sub _info { 'Post Authorization', 'Void', 'Credit', + 'Reverse Authorization', ], 'ECHECK' => [ 'Normal Authorization', @@ -89,6 +90,7 @@ sub map_fields { ( 'normal authorization' => 'SALE', 'authorization only' => 'AUTHONLY', 'post authorization' => 'CAPT', + 'reverse authorization' => 'REVERSEAUTH', 'void' => 'VOID', 'credit' => 'CREDIT', ); @@ -189,6 +191,8 @@ sub submit { }elsif ( $action eq 'post authorization' && $type eq 'CC') { push @required_fields, qw( order_number ); + }elsif ( $action eq 'reverse authorization' && $type eq 'CC') { + push @required_fields, qw( order_number card_number expiration amount ); }elsif ( $action eq 'void') { push @required_fields, qw( order_number amount ); @@ -521,6 +525,7 @@ The following actions are valid normal authorization authorization only + reverse authorization post authorization credit void @@ -593,9 +598,13 @@ Business::OnlinePayment::IPPay uses IPPay XML Product Specifications version See http://www.ippay.com/ for more information. -=head1 AUTHOR +=head1 AUTHORS -Jeff Finucane, ippay@weasellips.com +Original author: Jeff Finucane + +Current maintainer: Ivan Kohler + +Reverse Authorization patch from dougforpres =head1 SEE ALSO diff --git a/t/card.t b/t/card.t index e68be0d..dc1d38d 100644 --- a/t/card.t +++ b/t/card.t @@ -4,7 +4,7 @@ use Test::More; require "t/lib/test_account.pl"; my($login, $password, %opt) = test_account_or_skip('card'); -plan tests => 43; +plan tests => 50; use_ok 'Business::OnlinePayment'; @@ -89,6 +89,34 @@ my $voidable_amount = 0; $postable_amount = $content{amount} if $tx->is_success; } +# authorization void test +{ + my $tx = Business::OnlinePayment->new("IPPay", @opts); + $tx->content(%content, action => 'authorization only', amount => '3.00' ); + $tx->test_transaction(1); + $tx->submit; + + if ($tx->is_success) { + my $void_tx = Business::OnlinePayment->new("IPPay", @opts); + + $tx->content(%content, action => 'reverse authorization', + order_number => $tx->order_number ); + tx_check( + $tx, + desc => "reverse authorization", + is_success => 1, + result_code => '000', + error_message => 'APPROVED', + authorization => qr/TEST\d{2}/, + avs_code => '', # so rather pointless :\ + cvv2_response => '', # ... + ); + } + else { + + } +} + # post authorization test SKIP: { my $tx = new Business::OnlinePayment( "IPPay", %opt ); -- 2.11.0