Business::Eway - eWAY - eCommerce the SAFE and EASY way
use Business::Eway; my $eway = Business::Eway->new( CustomerID => 87654321, UserName => 'TestAccount', ); # when submit the cart order if ( $submit_order ) { my $rtn = $eway->request($args); # $args from CGI params if ( $rtn->{Result} eq 'True' ) { print $q->redirect( $rtn->{URI} ); } else { die $rtn->{Error}; } } # when user returns back from eway elsif ( $in_return_or_cancel_page or $params->{AccessPaymentCode} ) { my $rtn = $eway->result($AccessPaymentCode); if ( $rtn->{TrxnStatus} eq 'true' ) { print "Transaction Success!\n"; } else { print "Transaction Failed!\n"; } }
eWAY - eCommerce the SAFE and EASY way http://www.eway.co.uk/
my $eway = Business::Eway->new( CustomerID => 87654321, UserName => 'TestAccount', );
CustomerID (required)
CustomerID
UserName (required)
UserName
Your eWAY Customer ID and User Name.
ua
ua_args
By default, we use LWP::UserAgent->new as the UserAgent. you can pass ua or ua_args to use a different one.
All those arguments can be passed into Business::Eway->new() or pass into $eway->request later
Amount (required)
Amount
The amount of the transaction in dollar form
(ie $27.00 transaction would have a Amount value of "27.00")
Currency (required)
Currency
Three letter acronym of the currency code according to ISO 4217 (ie British Pound Sterling would be 'GBP')
Default: 'GBP'
ReturnUrl (required)
ReturnUrl
The web address to direct the customer with the result of the transaction.
CancelURL (required)
CancelURL
The web address to direct the customer when the transaction is cancelled.
PageTitle
This is value will be displayed as the title of the browser.
Default: eWAY Hosted Payment Page
PageDescription
This value will be displayed above the Transaction Details.
Default: Blank
PageFooter
This value will be displayed below the Transaction Details.
Language
The two letter acronym of the language code. supported languages now:
English EN Spanish ES French FR German DE Dutch NL
Default: EN
CompanyName
This will be displayed as the company the customer is purchasing from, including this is highly recommended.
CompanyLogo
The url of the image can be hosted on the merchants website and pass the secure https:// path of the image to be displayed at the top of the website. This is the top image block on the webpage and is restricted to 960px X 65px. A default secure image is used if none is supplied.
PageBanner
The url of the image can be hosted on the merchants website and pass the secure https:// path of the image to be displayed at the top of the website. This is the second image block on the webpage and is restricted to 960px X 65px. A default secure image is used if none is supplied.
CustomerFirstName
CustomerLastName
CustomerAddress
CustomerCity
CustomerState
CustomerPostCode
CustomerCountry
CustomerPhone
CustomerEmail
Customer Information
InvoiceDescription
This field is used to display to the user a description of the purchase they are about to make, usually product summary information.
MerchantReference
MerchantInvoice
This is a number created by the merchant for this transaction.
MerchantOption1
MerchantOption2
MerchantOption3
This field is not displayed to the customer but is returned in the result string. Anything can be used here, useful for tracking transactions
my $url = $eway->request_url($args); my $rtn = $eway->request($args); my ($status, $url_or_error) = $eway->request($args); # $status 1 - OK, 0 - ERROR
request a URL to https://payment.ewaygateway.com/Request and parse the XML into HASHREF. sample:
$VAR1 = \{ 'Error' => {}, 'URI' => 'https://payment.ewaygateway.com/UK1/PaymentPage.aspx?value=mwm4VNOrYxxxxxx', 'Result' => 'True' };
Usually you need redirect to the $rtn->{URI} when Result is True (or $url_or_error when $status is 1).
my $url = $eway->result_url($AccessPaymentCode); my $rtn = $eway->result($AccessPaymentCode); if ( $rtn->{TrxnStatus} eq 'true' ) { print "Transaction Success!\n"; } else { print "Transaction Failed!\n"; } foreach my $k ('TrxnStatus', 'AuthCode', 'ResponseCode', 'ReturnAmount', 'TrxnNumber', 'TrxnResponseMessage', 'MerchantOption1', 'MerchantOption2', 'MerchantOption3', 'MerchantInvoice', 'MerchantReference') { print "$k: $rtn->{$k}\n"; }
Eway will POST to your ReturnUrl (or CancelURL) when you finish the transaction (or click Cancel button). the POST would contain a param AccessPaymentCode which you can request to get the transaction status.
For example, you want your ReturnUrl to be 'http://mysite.com/cgi-bin/cart.cgi?cart_id=ABC'.
you need write the request like:
my $rtn = $eway->request( # others ReturnUrl => 'http://mysite.com/cgi-bin/cart.cgi', MerchantOption1 => 'ABC', );
and you can get the MerchantOption1 in
my $rtn = $eway->result($AccessPaymentCode); my $cart_id = $rtn->{MerchantOption1}
There is 'examples' directory in the .tar.gz in case you want to have a check.
Testing
http://www.eway.co.uk/Developer/Testing/Testing.aspx
Response Code
http://www.eway.co.uk/Developer/Downloads/ResponseCodes.aspx
Downloads
http://www.eway.co.uk/Developer/Downloads/SampleCode/eWAY-Sample-API-Code.aspx
eWAY Europe Ltd, <support at eway.co.uk>
<support at eway.co.uk>
Copyright 2009 eWAY Europe Ltd.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Business::Eway, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Business::Eway
CPAN shell
perl -MCPAN -e shell install Business::Eway
For more information on module installation, please visit the detailed CPAN module installation guide.