eWAY is the easiest way to accept payments in your app or on your website. Get integrated and start selling more, faster - in a range of languages using the eWAY SDKs, helpful documentation, and 24/7 support from real humans. eWAY - with you every step of the way.
Accept payments quickly and easily with eWAY using the eWAY Rapid PHP SDK. Using the PHP SDK provides convenient access to all the features of eWAY’s Rapid API, so you can create transactions, process refunds, query transactions, create token customers, and more!
The eWAY PHP SDK requires PHP version 5.4.0 or greater with the curl, json and openssl extensions. We recommend installing using the Composer Package Manager.
To make development and testing with eWAY easy, get a free partner account which provides access to the eWAY Sandbox. To find out more about activating Sandbox, check out the Success Community article here.
With ComposerIf you have Composer, adding the eWAY PHP SDK is as simple as running the following on the command line:
Once installed, the eWAY PHP SDK can be loaded in your project using Composer’s autoloader:
If you don’t have access to Composer, you can add the eWAY PHP SDK to your project by:
- Download the latest zip
- Unzip the zip into your project – for example into a lib directory
- Include the eWAY SDK:
Now you are all set to build your eWAY integration! You can find code samples for integrating various eWAY functions as part of the eWAY Rapid API reference.
To demonstrate using the eWAY PHP SDK, this example will show how to accept a payment with the Responsive Shared Page.
This example assumes that Composer is already installed and a new project is being started.
1. Add the eWAY PHP SDK
In the project directory, run the Composer command to install the eWAY PHP SDK.
Once completed, the directory should now have a “vendor” folder, along with a couple of composer files.
2. Load the eWAY PHP SDK
Now the eWAY client can be created with your Rapid API key & password. These can be found in Sandbox or Live MYeWAY – remember that different credentials are needed for Sandbox Live.
3. Create a Shared Payment URL
In order to send a customer to the Responsive Shared Page, a URL must be generated using the createTransaction function. This accepts a PaymentMethod and an array of transaction data.
The PaymentMethod determines how the card data will be accepted (in this case ResponsiveShared) while the transaction array contains customer and invoice details – more details of the variables that can be passed can be found in the Rapid API reference.
To make sure everything went well, check that the Errors list is empty. If it isn’t, UserDisplayMessage can be used to convert any error codes to human readable messages:
4. Redirect the Customer
Usually once the shared page URL has been created, the customer can be immediately redirected. For this example we’ll just display a link:
5. Fetch the Result
Once the customer has gone to the Responsive Shared Page and submitted their payment information, they will be redirected back to the RedirectUrl specified in the request. This was set to response.php – so now create that file and insert the following to fetch the transaction result:
Key information such as the success of the transaction and the transaction ID can be found in the TransactionStatus of the response. If the transaction wasn’t successful, the reason can be found in the ResponseMessage. An example of handling this information would be