Friday, January 16, 2015

eWay Shared Rapid Payment Using PHP

First, create an api from eway api setup page for online hosted rapid payment



Then download source code.


Browse http://localhost/ewayHosted/index.php and fill up Api Key & Password field and following by other fields and click 'Pay...' button. 
If all details are correct you would get data like below from eway:


stdClass Object
(
    [SharedPaymentUrl] => https://secure-au.sandbox.ewaypayments.com/sharedpage/sharedpayment?AccessCode=F9802jxD7ElfeXKsdljElP1OKxSJyKZHJuaRB8qf97fzPPiDGFS-JmlfVug7kAvkctMALC0cSrVtKdomIp0DPlJv0CdRAl4apAHgJNzFMo5TXfQ804a8-5BP80gWFSmOLsLgeXOGFrjiuBvfYPjjs8F1zBw==
    [AccessCode] => F9802jxD7ElfeXKsdljElP1OKxSJyKZHJuaRB8qf97fzPPiDGFS-JmlfVug7kAvkctMALC0cSrVtKdomIp0DPlJv0CdRAl4apAHgJNzFMo5TXfQ804a8-5BP80gWFSmOLsLgeXOGFrjiuBvfYPjjs8F1zBw==
    [Customer] => stdClass Object
        (
            [CardNumber] => 
            [CardStartMonth] => 
            [CardStartYear] => 
            [CardIssueNumber] => 
            [CardName] => 
            [CardExpiryMonth] => 
            [CardExpiryYear] => 
            [IsActive] => 
            [TokenCustomerID] => 
            [Reference] => KU060238
            [Title] => Mr.
            [FirstName] => Pritom
            [LastName] => Kumar
            [CompanyName] => WEB ACTIVE
            [JobDescription] => Developer
            [Street1] => 15 Smith St
            [Street2] => 
            [City] => Phillip
            [State] => ACT
            [PostalCode] => 2602
            [Country] => au
            [Email] => 
            [Phone] => 1800 10 10 65
            [Mobile] => 1800 10 10 65
            [Comments] => Some comments here
            [Fax] => 02 9852 2244
            [Url] => http://www.yoursite.com
        )

    [Payment] => stdClass Object
        (
            [TotalAmount] => 100
            [InvoiceNumber] => INVOICE1001
            [InvoiceDescription] => Individual Invoice Description
            [InvoiceReference] => 513456
            [CurrencyCode] => AUD
        )

    [FormActionURL] => https://secure-au.sandbox.ewaypayments.com/AccessCode/F9802jxD7ElfeXKsdljElP1OKxSJyKZHJuaRB8qf97fzPPiDGFS-JmlfVug7kAvkctMALC0cSrVtKdomIp0DPlJv0CdRAl4apAHgJNzFMo5TXfQ804a8-5BP80gWFSmOLsLgeXOGFrjiuBvfYPjjs8F1zBw==
    [CompleteCheckoutURL] => 
    [Errors] => 
)

Then collect 'AccessCode' from data returned and redirect to 'SharedPaymentUrl' where your original payment would process.




Need to fill up all fields and click on 'PAY NOW' button above.



Now click on 'FINALIZE TRANSACTION' button to redirect back to your original site from where you went.



And finally your transaction in eWay portal:



Php & MySql oAuth2 Server & Client Example

Download source code and install


Add a new client secret pair to server side:


Start authorize from client side:



Authorize application from server side, add your login functionality by own to make the page restricted.


Now, you are getting your data from server using the access token. After expire access token, program automatically can collect new access token using refresh token.