Download the PHP package kofikwarteng/laravel-sagepay without Composer
On this page you can find all versions of the php package kofikwarteng/laravel-sagepay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kofikwarteng/laravel-sagepay
More information about kofikwarteng/laravel-sagepay
Files in kofikwarteng/laravel-sagepay
Package laravel-sagepay
Short Description Laravel 5.x Sagepay Integration
License MIT
Informations about the package laravel-sagepay
Laravel 5.x Integration with SagePay
To my knowledge, Laravel lacks any SagePay Integration package. This was why I decided to write this package. The package integrates with the SagePay forms.
This Package is based on tolzhabayev's SagePay library. Credits goes to him for the development of such an awesome library for SagePay.
Requirements
PHP 5.4 and higher. PHP7/HHVM is fully supported too.
Laravel 5 (I have not tested it on Laravel 4 but it might work)
Installation
To install just use composer and run the command:
Alternatively, you can add ` to the require block in your file and run or
After, locate app.php file which can be found in the config folder of your Laravel installation. Add these two lines:
Add to the list of providers
Add to the list of aliases
After you are done, run this command in your root Laravel directory:
Now locate the file which can now be found in your config folder after running the command above. Edit the currency value and the Encryption password to your values. Make sure the Currency you enter is supported by SagePay.
SagePay has two types of Encryption Keys, the test keys and the live keys. For development, the test keys are used. The test keys, together with the Test URL, provides a sandbox where you can test their payment system with your application by using fake credit card numbers.
Here is a link to their test credit card numbers:
http://www.sagepay.co.uk/support/12/36/test-card-details-for-your-test-transactions
NB: The link may change without notice
Usage
To use this package in your controller, simply declare the SagePay class like this:
`
You can also simply use it in the ` file without declaring it.
You can then use the example below to create a simple payment:
I believe this is very straight forward and easy to use. What the library does is to get the information of your payment and encrypt it into a string that only SagePay can understand and decrypt.
To output the encrypted string simply call this method:
To submit the encryption code to SagePay, you can do something like this using blade:
return view ('pages.checkout', compact('encrypted_code' ));
On your view, you can use this form to place a booking:
Another way to use it is to return the encryption code as JSON, this way you can build a RestFul application based on the package. I personally used it to create a RestFul Application using AngularJS.
To check for success, sagepay attaches a url parameter called to the success and failure url which is an encrypted string which can be decrypted to provide a success response. With this success response, you can mark a payment as paid in your database, send an email, etc.
The method I personally use is to create a route with a order token parameter (the order token is just a token string I generate per order and store in the database). An example will be:
`
Mind you, this example is created with the intention that ` is your laravel installation folder. As you can see I set the success and failure URL to be the same url. There is no need creating separate routes. We then declare our routes like this:
`
For more advanced usage, please visit tolzhabayev's GitHub page as he is the original developer of the library. You can also contact me HERE.
I am working on various tests. They will be available soon once I'm done.
Thanks and happy coding.