From d91e7701e032d91c79ee46b3d62d1726c1f27d4c Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 21 Dec 2010 09:33:08 +0000 Subject: [PATCH 1/1] initial release --- Changes | 5 +++ MANIFEST | 5 +++ Makefile.PL | 12 ++++++ README | 28 ++++++++++++ eWayShared.pm | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 184 insertions(+) create mode 100644 Changes create mode 100644 MANIFEST create mode 100644 Makefile.PL create mode 100644 README create mode 100644 eWayShared.pm diff --git a/Changes b/Changes new file mode 100644 index 0000000..9ec0269 --- /dev/null +++ b/Changes @@ -0,0 +1,5 @@ +Revision history for Business-OnlineThirdPartyPayment-eWayShared + +0.01 Tue Dec 21 01:14:11 PST 2010 + - Initial release + diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..df90bf4 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,5 @@ +Makefile.PL +MANIFEST +README +eWayShared.pm +Changes diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..7fe3793 --- /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::eWayShared', + 'VERSION_FROM' => 'eWayShared.pm', # finds $VERSION + 'AUTHOR' => 'Mark Wells ', + 'PREREQ_PM' => { + 'Business::OnlineThirdPartyPayment' => 3, + 'Business::CreditCard' => 0.27, + }, +); diff --git a/README b/README new file mode 100644 index 0000000..bd11834 --- /dev/null +++ b/README @@ -0,0 +1,28 @@ +Business-OnlineThirdPartyPayment-eWayShared is a +Business::OnlineThirdPartyPayment module for interfacing with +the eWay Shared Payments Gateway for credit card payment. + +INSTALLATION + +To install this module, run the following commands: + + perl Makefile.PL + make + make test + make install + +SUPPORT AND DOCUMENTATION + +After installing, you can find documentation for this module with the +perldoc command. + + perldoc Business::OnlineThirdPartyPayment::eWayShared + +COPYRIGHT AND LICENCE + +Copyright (C) 2009-2010 Mark Wells +Copyright (C) 2009-2010 Freeside Internet Services, Inc. + +This program is free software; you can redistribute it and/or modify it +under the same terms as Perl itself. + diff --git a/eWayShared.pm b/eWayShared.pm new file mode 100644 index 0000000..658f5dc --- /dev/null +++ b/eWayShared.pm @@ -0,0 +1,134 @@ +package Business::OnlineThirdPartyPayment::eWayShared; + +use strict; +use Business::OnlineThirdPartyPayment 3; +use vars qw($VERSION @ISA $DEBUG); + +@ISA = qw(Business::OnlineThirdPartyPayment); +$VERSION = '0.01'; + +$DEBUG = 0; + +sub set_defaults { + my $self = shift; + + $self->server('www.eway.com.au') unless $self->server; + $self->port('443') unless $self->port; + $self->path('/gateway/payment.asp') unless $self->path; + $self->build_subs(qw(authorization order_number result_code error_message)); +} + +sub use_3dsecure { + my $self = shift; + $self->{'use_3dsecure'} = shift if ( @_ ); + $self->path('/gateway_3d/payment.asp') if $self->{'use_3dsecure'}; + return $self->{'use_3dsecure'}; +} + +sub reference { + # Situation: We've been POSTed back from the gateway's web site. The + # POST data is in the argument. We need to set the state of the object + # and then return the reference number. + my ($self, $data) = @_; + my $status = $data->{'ewayTrxnStatus'}; + $self->order_number($data->{'ewayTrxnReference'}); + if ( lc($status) eq 'true' ) { + $self->is_success(1); + $self->authorization($data->{'eWAYAuthCode'}); + # not spelled like this in the spec + } + else { + $self->is_success(0); + $self->result_code($data->{'eWAYresponsecode'}); + $self->error_message($data->{'eWAYresponseText'}); + } + return $data->{'ewayTrxnNumber'}; +} + +sub submit { + # One of two situations: + # "authorization only": We haven't sent anything yet and are just + # creating a pending transaction locally. Set popup_url and remap + # transaction fields into collectitems. + # OR + # "post authorization: We've already called reference() with the + # callback data. + my($self) = @_; + my %content = $self->content; + + my $action = lc($content{'action'}); + die 'Third Party Payment supports "Authorization Only" and '. + '"Post Authorization" transactions' + if !($action eq 'authorization only' || $action eq 'post authorization'); + die 'eWay only supports credit card transactions' + if $self->transaction_type() ne 'CC'; + + my @required = qw( amount reference ); + $self->required_fields(@required); + + if ( $action eq 'authorization only' ) { + $self->is_success(1); + my $url = + "https://". $self->server(). + ($self->port != 443 ? ':'. $self->port() : ''). $self->path(); + $self->popup_url( $url ); + + my %fields = ( + 'login' => 'ewayCustomerID', + 'amount' => 'ewayTotalAmount', + 'first_name' => 'ewayCustomerFirstName', + 'last_name' => 'ewayCustomerLastName', + 'email' => 'ewayCustomerEmail', + 'address' => 'ewayCustomerAddress', + 'zip' => 'ewayCustomerPostcode', + 'description' => 'ewayCustomerInvoiceDescription', + 'invoice_number' => 'ewayCustomerInvoiceRef', + 'reference' => 'ewayTrxnNumber', + 'callback_url' => 'eWAYURL', + ); + $self->required_fields(qw(login amount first_name last_name)); + $self->remap_fields(%fields); + my %content = $self->content; + $content{'ewayTotalAmount'} *= 100; + $self->collectitems([ map { $_ => $content{$_} } values(%fields) ]); + $self->is_success(1); + return; + } + elsif ( $action eq 'post authorization' ) { + return; # everything has been set up already + } +} + +1; +__END__ + +=head1 NAME + +Business::OnlineThirdPartyPayment::eWayShared - eWay backend for Business::OnlineThirdPartyPayment + +=head1 DESCRIPTION + +For detailed information see L. + +Call "$transaction->use_3dsecure(1)" (or pass "'use_3dsecure' => 1" +to I) to enable the 3D-Secure gateway. + +=head1 NOTE + +=head1 COMPATIBILITY + +eWay Shared Payments and 3D-Secure API, as of December 2010. + +=head1 AUTHOR + +Mark Wells + +Based on Business::OnlineThirdPartyPayment::Interswitchng by +Jeff Finucane + +=head1 SEE ALSO + +perl(1). L. + +=cut + -- 2.11.0