Fayland 林 > Business-Eway > Business::Eway

Download:
Business-Eway-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Business::Eway - eWAY - eCommerce the SAFE and EASY way

SYNOPSIS ^

    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";
        }
    }

DESCRIPTION ^

eWAY - eCommerce the SAFE and EASY way http://www.eway.co.uk/

new

    my $eway = Business::Eway->new(
        CustomerID => 87654321,
        UserName => 'TestAccount',
    );

Arguments

All those arguments can be passed into Business::Eway->new() or pass into $eway->request later

request

    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).

result

    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.

TIPS

I need params in ReturnUrl

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}

EXAMPLES ^

There is 'examples' directory in the .tar.gz in case you want to have a check.

SEE ALSO ^

AUTHOR ^

eWAY Europe Ltd, <support at eway.co.uk>

COPYRIGHT & LICENSE ^

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.

syntax highlighting: