Skip Menu |

This queue is for tickets about the Business-OnlinePayment-Vanco CPAN distribution.

Report information
The Basics
Id: 37732
Status: new
Priority: 0/
Queue: Business-OnlinePayment-Vanco

People
Owner: Nobody in particular
Requestors: bradoaks [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 0.01
  • 0.02
Fixed in: (no value)



Subject: a patch to add support for funds information
Hello, Plus Three learned that we needed to utilize the Funds feature of Vanco's services. This patch adds a couple tests and the plumbing to pass the fund information through to them for processing. Feedback welcome, as this is the first payment processor code that I've touched. Thank you, --bradoaks
Subject: bop-Vanco.patch
diff -ru --new-file --exclude=test_account --exclude=attic /tmp/2/Business-OnlinePayment-Vanco-0.01/t/card_once.t ./t/card_once.t --- /tmp/2/Business-OnlinePayment-Vanco-0.01/t/card_once.t 2008-03-21 10:36:50.000000000 -0400 +++ ./t/card_once.t 2008-07-07 15:17:49.000000000 -0400 @@ -16,7 +16,7 @@ action => 'Normal Authorization', description => 'Business::OnlinePayment visa test', amount => '49.95', - customer_id => 'tfb', + customer_id => 'tfb'.time, name => 'Tofu Beast', address => '123 Anystreet', city => 'Anywhere', diff -ru --new-file --exclude=test_account --exclude=attic /tmp/2/Business-OnlinePayment-Vanco-0.01/t/card_recurring.t ./t/card_recurring.t --- /tmp/2/Business-OnlinePayment-Vanco-0.01/t/card_recurring.t 2008-03-18 15:18:35.000000000 -0400 +++ ./t/card_recurring.t 2008-07-07 15:17:45.000000000 -0400 @@ -16,7 +16,7 @@ action => 'Recurring Authorization', description => 'Business::OnlinePayment visa test', amount => '49.95', - customer_id => 'tofu', + customer_id => 'tofu'.time, name => 'Tofu Beast', address => '123 Anystreet', city => 'Anywhere', diff -ru --new-file --exclude=test_account --exclude=attic /tmp/2/Business-OnlinePayment-Vanco-0.01/t/check.t ./t/check.t --- /tmp/2/Business-OnlinePayment-Vanco-0.01/t/check.t 2008-03-21 10:14:35.000000000 -0400 +++ ./t/check.t 2008-07-07 15:17:39.000000000 -0400 @@ -15,7 +15,7 @@ password => $password, action => 'Normal Authorization', amount => '49.95', - customer_id => 'jsk', + customer_id => 'jsk'.time, name => 'Tofu Beast', account_number => '12345', routing_code => '111000025', # BoA in Texas taken from Wikipedia diff -ru --new-file --exclude=test_account --exclude=attic /tmp/2/Business-OnlinePayment-Vanco-0.01/t/one_fund.t ./t/one_fund.t --- /tmp/2/Business-OnlinePayment-Vanco-0.01/t/one_fund.t 1969-12-31 19:00:00.000000000 -0500 +++ ./t/one_fund.t 2008-07-07 15:17:28.000000000 -0400 @@ -0,0 +1,33 @@ +#!/usr/bin/perl -w + +use Test::More; +require "t/lib/test_account.pl"; + +my($login, $password, @opts) = test_account_or_skip(); +plan tests => 2; + +use_ok 'Business::OnlinePayment'; + +my $tx = Business::OnlinePayment->new("Vanco", @opts); +$tx->content( + type => 'VISA', + login => $login, + password => $password, + action => 'Normal Authorization', + amount => 0, + description => 'Business::OnlinePayment visa test', + funds => [ {fund_id => 1, fund_amount => 32.01} ], + customer_id => 'tfb-fund'.time, + name => 'Tofu Beast', + address => '123 Anystreet', + city => 'Anywhere', + state => 'UT', + zip => '84058', +# card_number => '4007000000027', + card_number => '4111111111111111', + expiration => expiration_date(), +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +ok($tx->is_success()) or diag $tx->error_message; diff -ru --new-file --exclude=test_account --exclude=attic /tmp/2/Business-OnlinePayment-Vanco-0.01/t/two_funds.t ./t/two_funds.t --- /tmp/2/Business-OnlinePayment-Vanco-0.01/t/two_funds.t 1969-12-31 19:00:00.000000000 -0500 +++ ./t/two_funds.t 2008-07-07 15:17:07.000000000 -0400 @@ -0,0 +1,36 @@ +#!/usr/bin/perl -w + +use Test::More; +require "t/lib/test_account.pl"; + +my($login, $password, @opts) = test_account_or_skip(); +plan tests => 2; + +use_ok 'Business::OnlinePayment'; + +my $tx = Business::OnlinePayment->new("Vanco", @opts); +$tx->content( + type => 'VISA', + login => $login, + password => $password, + action => 'Normal Authorization', + amount => 0, + description => 'Business::OnlinePayment visa test', + funds => [ + {fund_id => 5, fund_amount => 55}, + {fund_id => 'fund8', fund_amount => 88}, + ], + customer_id => 'tfb-2funds'.time, + name => 'Tofu Beast', + address => '123 Anystreet', + city => 'Anywhere', + state => 'UT', + zip => '84058', +# card_number => '4007000000027', + card_number => '4111111111111111', + expiration => expiration_date(), +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +ok($tx->is_success()) or diag $tx->error_message; diff -ru --new-file --exclude=test_account --exclude=attic /tmp/2/Business-OnlinePayment-Vanco-0.01/Vanco.pm ./Vanco.pm --- /tmp/2/Business-OnlinePayment-Vanco-0.01/Vanco.pm 2008-06-30 19:09:01.000000000 -0400 +++ ./Vanco.pm 2008-07-07 15:53:53.000000000 -0400 @@ -185,6 +185,19 @@ return $year; } +sub list_of_funds { + my ($self, $exp) = (shift, shift); + my @funds; + foreach my $fund_ref (@{$exp}) { + tie my(%fund), 'Tie::IxHash', ( + FundID => $fund_ref->{'fund_id'}, + FundAmount => $fund_ref->{'fund_amount'}, + ); + push @funds, { Fund => \%fund }; + } + return \@funds; +} + sub today { my @time = localtime($_[0] ? shift : time); $time[5] += 1900; @@ -200,6 +213,8 @@ my $value; if ( ref( $map{$_} ) eq 'HASH' ) { $value = $map{$_} if ( keys %{ $map{$_} } ); + }elsif ( ref( $map{$_} ) eq 'ARRAY' ) { + $value = $map{$_}; }elsif( ref( $map{$_} ) ) { $value = ${ $map{$_} }; }elsif( exists( $content{ $map{$_} } ) ) { @@ -297,6 +312,7 @@ ? $self->{_content}->{card_number} : $self->{_content}->{account_number} ; + my $funds = $self->list_of_funds($self->{_content}->{funds}); tie %requestvars, 'Tie::IxHash', $self->revmap_fields( @@ -320,6 +336,7 @@ CardBillingState => 'state', CardBillingZip => 'zip', Amount => 'amount', + Funds => $funds, StartDate => 'StartDate', EndDate => 'EndDate', FrequencyCode => 'FrequencyCode', @@ -422,15 +439,23 @@ sub _xmlwrite { my ($self, $writer, $item, $value) = @_; - $writer->startTag($item); + + # if empty list, suppress writing empty tags + return if ( ref( $value ) eq 'ARRAY' && scalar(@{$value}) == 0 ); + + $writer->startTag($item) if $item; if ( ref( $value ) eq 'HASH' ) { foreach ( keys ( %$value ) ) { - $self->_xmlwrite($writer, $_, $value->{$_}); + $self->_xmlwrite($writer, $_, $value->{$_}); + } + } elsif ( ref( $value ) eq 'ARRAY' ) { + foreach my $list_element (@{$value}) { + $self->_xmlwrite($writer, undef, $list_element); } }else{ $writer->characters($value); } - $writer->endTag($item); + $writer->endTag($item) if $item; } 1; @@ -539,6 +564,8 @@ Content required: type, login, password, action, amount, name, card_number, expiration. +Vanco also supports a funds listing for a transaction; if amount and funds are both specified, the funds data are used. + =head2 Check Content required: type, login, password, action, amount, name, account_number, routing_code, account_type. @@ -583,7 +610,7 @@ =head1 Setting Vanco parameters from content(%content) -The following rules are applied to map data to AuthorizeNet ARB parameters +The following rules are applied to map data to Vanco parameters from content(%content): # param => $content{<key>} @@ -611,6 +638,7 @@ CardBillingState => 'state', CardBillingZip => 'zip', Amount => 'amount', + Funds => \( $funds ), # list of funds with fund amounts and fund ids StartDate => 'start', EndDate => calculated_from start, periods, interval, FrequencyCode => [O,M,W,BW,Q, or A determined from interval],
From: bradoaks [...] gmail.com
On Wed Jul 16 11:52:44 2008, bradoaks wrote: Show quoted text
> Hello, > > Plus Three learned that we needed to utilize the Funds feature of > Vanco's services. This patch adds a couple tests and the plumbing to > pass the fund information through to them for processing. Feedback > welcome, as this is the first payment processor code that I've touched. > > Thank you, > --bradoaks
This patch also adds a timestamp to the customer_id -- Without it, their test environment was throwing duplicate_transaction errors on subsequent runs of the tests.
From: bradoaks [...] gmail.com
Show quoted text
> This patch also adds a timestamp to the customer_id -- Without it, their > test environment was throwing duplicate_transaction errors on subsequent > runs of the tests.
My patch to the test cases was causing the following error: # Customer ID Exceeds 15 Characters Instead of appending time(), I have replaced that with $$ instead. I was also getting an error from t/card_recurring.t using our test account: # Client Does Not Accept International Credit Cards I changed that account number to the same as is in t/card_once.t to get around this limitation of our account.