From: jeff Date: Mon, 2 Mar 2009 23:46:12 +0000 (+0000) Subject: (no commit message) X-Git-Tag: import X-Git-Url: http://git.freeside.biz/gitweb/?p=Business-OnlineThirdPartyPayment-Interswitchng.git;a=commitdiff_plain;h=5f0a0938cc0f64c12f8ffcea379fd0b4b7ad39e7 --- 5f0a0938cc0f64c12f8ffcea379fd0b4b7ad39e7 diff --git a/Interswitchng.pm b/Interswitchng.pm new file mode 100644 index 0000000..c1c7fec --- /dev/null +++ b/Interswitchng.pm @@ -0,0 +1,106 @@ +package Business::OnlineThirdPartyPayment::Interswitchng; + +use strict; +use Carp; +use Business::OnlineThirdPartyPayment 3; +use Business::CreditCard; +use vars qw($VERSION @ISA $DEBUG); + +@ISA = qw(Business::OnlineThirdPartyPayment); +$VERSION = '0.01'; + +$DEBUG = 0; + +sub set_defaults { + my $self = shift; + + $self->server('webpay.interswitchng.com') unless $self->server; + $self->port('443') unless $self->port; + $self->path('/webpay_pilot/purchase.aspx') unless $self->path; + +} + +sub reference { + my ($self, $data) = @_; + $data->{TXNREF} || ''; +} + +sub submit { + my($self) = @_; + my %content = $self->content; + + my $action = lc($content{'action'}); + die 'Interswitchng only supports "Authorization Only" and '. + '"Post Authorization" transactions' + unless $action eq 'authorization only' || $action eq 'post authorization'; + + my @required = qw( login amount reference ); + unless ($self->transaction_type() eq 'CC' ) { + croak("Dummy can't handle transaction type: ". + $self->transaction_type()); + } + $self->required_fields(@required); + + $self->remap_fields ( + login => 'CADPID', + password => 'MERTID', + reference => 'TXNREF', + ); + %content = $self->content; + $content{AMT} = $content{amount} * 100; + + my $url = + "https://". $self->server(). ':'. $self->port(). $self->path(). '?'. + join( '&', map { "$_=$content{$_}" } qw( CADPID MERTID TXNREF AMT ) ); + $self->popup_url( $url ); + + $self->is_success(1); +} + +1; +__END__ + +=head1 NAME + +Business::OnlineThirdPartyPayment::Interswitchng - Interswitchng Webpay backend for Business::OnlineThirdPartyPayment + +=head1 SYNOPSIS + + use Business::OnlineThirdPartyPayment; + + my $tx = new Business::OnlineThirdPartyPayment("Interswitchng"); + $tx->content( + login => '87654321', + action => 'Normal Authorization', + description => 'Business::OnlinePayment test', + amount => '49.95', + invoice_number => '100100', + ); + $tx->submit(); + + if($tx->is_success()) { + print "Card processed successfully: ".$tx->authorization."\n"; + } else { + print "Card was rejected: ".$tx->error_message."\n"; + } + +=head1 DESCRIPTION + +For detailed information see L. + +=head1 NOTE + +=head1 COMPATIBILITY + +This module implements a payment gateway for Interswitchng's Webpay. + +=head1 AUTHOR + +Jeff Finucane + +=head1 SEE ALSO + +perl(1). L. + +=cut + diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..2d58242 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,5 @@ +Makefile.PL +MANIFEST +README +Interswitchng.pm +t/Interswitchng.t diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..22e645e --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,12 @@ +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile that is written. +WriteMakefile( + 'NAME' => 'Business::OnlineThirdPartyPayment::Interswitchng', + 'VERSION_FROM' => 'Interswitchng.pm', # finds $VERSION + 'AUTHOR' => 'Jeff Finucane ', + 'PREREQ_PM' => { + 'Business::OnlineThirdPartyPayment' => 3, + 'Business::CreditCard' => 0.27, + }, +); diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/t/Interswitchng.t b/t/Interswitchng.t new file mode 100644 index 0000000..615dd9e --- /dev/null +++ b/t/Interswitchng.t @@ -0,0 +1,25 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl eWay.t' + +use Test; +BEGIN { plan tests => 5 }; +use Business::OnlineThirdPartyPayment::Interswitchng; + +# a test transaction +my ($tx, $txnum, $res); +ok($tx = new Business::OnlineThirdPartyPayment("Interswitchng")); +ok( + $tx->content( + type => 'CC', + login => '87654321', + password => 'secret', + action => 'Authorization Only', + description => 'Business::OnlineThirdPartyPayment test', + amount => '49.95', + reference => '1349', + ) +); +ok($tx->test_transaction(1)); +ok($tx->submit()); +ok($tx->is_success()); +