eWay Payment Gateway Integration Tutorial

Web Design Blog - eWay Responsive Shared Page API

During a recent website design project, I was asked to implement the eWay Responsive Shared Page, payment gateway into a website to handle payments for a clients products within their online store. Today, in this tutorial, I’d like to share with you, just how easy it is to integrate into your website and how this was done using PHP.

eWay Responsive Shared Page API Tutorial

The eWay Responsive Shared Page API  is useful for people who do not have SSL encryption within their website and need a 3rd party payment processor. A few of the features, such as sending a transaction and requesting the payment status via access code apply to other payment types within the eWay API so may also be useful for people trying to get to grips with their API in general.

How the API works

The API is essentially made up of three parts:

  1. Create a Transaction and send it to the API with the order details, including final price then acquire a unique eWay gateway URL.
  2. Send the user to the unique eWay Responsive Shared Page to make their payment.
  3. On payment completion, user is returned to website. Check the status of the transaction using the Access Code returned from eWay.

Creating a Transaction

Once we have the total amount for the user’s order, we build the transaction data and send it to the API. You can view the complete set of transaction parameters available to send on the eWay Responsive Shared Page API page.

Please Note: The payment Total Amount must be in Cents.

Sending the User to the Payment Gateway

Once we have the response and check for errors, if there are no errors, we use the URL returned from the transaction response to send the user to the payment gateway. The URL will be returned as $response->SharedPaymentUrl

Confirming Payments

When the customer completes their payment, they will be sent back to the web page you specified when creating the transaction i.e the RedirectUrl or to the CancelUrl if they cancelled their order. When the user is sent back to your website, an access code will be available as a GET parameter $_GET['AccessCode']. We use this access code to check the status of the payment and make sure the payment completed.

Important: eWay, by default, does not automatically redirect users once a payment is completed.

Automatically Redirecting Users on Completed Payment

Once the payment has been completed, by default, instead of being automatically redirected back to your website, the user is offered the option to return to your website via a button. This may be fine in some cases, however, in most cases this will pose a problem. The problem here would be that if the customer doesn’t click the button, the functionality on your RedirectUrl will never be triggered and thus, you can’t save the order as successful as soon as the order completes.

Luckily though, eWay has a way to enable this functionality. If you sign into your eWay account, along the top nav bar you will find Settings. Within the settings drop down menu, you will find Shared Page. On the Shared Page settings page, there are a range of options to customise the look and functionality of your payment gateway page.

To set your payment gateway to redirect to your RedirectUrl as soon as the user has made the payment, do the following:

  1. Navigate down to Redirect After Payment Processing
  2. Check the Redirect to merchant website check box.
  3. Set the Delay to zero and click Save Settings

Cosmic Solutions - Web Design & development Example of the eWay Shared Page redirect settings.

Now the user will be returned to your specified RedirectUrl automatically, right after the payment has completed. This means you can now use the access code to ensure the payment completed and finalise the order.

Need a website? Get in touch with us today for a free quote. Get a Free Quote