Download the PHP package iammiloslukic/nestpay without Composer
On this page you can find all versions of the php package iammiloslukic/nestpay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iammiloslukic/nestpay
More information about iammiloslukic/nestpay
Files in iammiloslukic/nestpay
Package nestpay
Short Description Nestpay - Forked and modified by Milos Lukic
License MIT
Homepage https://github.com/readycmsio/nestpay
Informations about the package nestpay
Cubes Nestpay
Nestpay E-commerce integration, shipped with Laravel Package
Default usage
Installation
Require this package with composer.
For this package to work you need table nestpay_payments in database. This table is used to store information about payments.
You could create table by importing example SQL script:
*If you are using Laravel there is a ready to use migration (see documentation below)
Bootstrap & Configuration
Main class to use is \ReadyCMSIO\Nestpay\MerchantService
Instanciate the class and pass configuration parameters:
Setup the connection to the database by using existing PDO instance
If you want to have some other name for the nestpay_payments table, something you should pass another parameter
Configure \ReadyCMSIO\Nestpay\MerchantService what to do when successful payment occurres or what to do on failed payment:
IMPORTANT NOTICE!!! The onSuccessfulPayment and onFailedPayment could be triggered in 2 ways
- By calling \ReadyCMSIO\Nestpay\MerchantService::paymentProcess3DGateResponse when customer is redirected back to you page (see documentation below)
- By calling \ReadyCMSIO\Nestpay\MerchantService::paymentProcessOverNestpayApi from your cron job (see documentation below)
For that reason it is important to write your logic, like sending email or changing the order status, for successuful or failed payment IN THIS HANDLERS!!! (so you don't have to write it twice)
Usage
The confirmation page
You should have confirmation page from which customers are redirected to the bank card processor page.
That page should have form with lots of hidden paramters.
Use \ReadyCMSIO\Nestpay\MerchantService::paymentMakeRequestParameters method to generate necessary parameters (the HASH parameter and other necessary parameters)
After submitting this form customer is redirected to 3D gate bank card processing page where customer enters Card Number, CVC etc.
The result page
After entering Card details, customer is redirected back to your website on success or fail url.
You should call \ReadyCMSIO\Nestpay\MerchantService::paymentProcess3DGateResponse method to process $_POST parameters.
On success page:
On fail page:
Processing payment over API
When customer leaves the 3D Gate Page there is a possibility that he/she is NOT going to be redirected back to your website (internet connection broke, customer closes the browser etc.).
You should use \ReadyCMSIO\Nestpay\MerchantService::paymentProcessOverNestpayApi method to process payment over API in some cron job.
Capture payment (PostAuth) over API
For two step payment (PreAuth and PostAuth) you should use Nestpay API to capture reserved amount of successful payment.
Use \ReadyCMSIO\Nestpay\MerchantService::postAuthorizationOverNestpayApi
If you DO NOT want to capture entire amount, pass second parameter.
Void payment over API
To void payment use \ReadyCMSIO\Nestpay\MerchantService::voidOverNestpayApi
Get working payment
If you want to get the last processed payment use \ReadyCMSIO\Nestpay\MerchantService::getWorkingPayment
Customize saving payment information
If you prefer some other method to store payments, you should create "Data Access Object" class of your own. Your DAO class must implement \ReadyCMSIO\Nestpay\PaymentDao interface:
Make \ReadyCMSIO\Nestpay\MerchantService use your DAO class
Integration with Laravel Framework(>=5.4)
Package cubes-doo/nestpay
comes with built Laravel package.
Service provider class is \ReadyCMSIO\Nestpay\Laravel\NestpayServiceProvider.
If you are using Laravel version < 5.5 you must include service provider manually
Before using the \ReadyCMSIO\Nestpay\MerchantService class you should edit your .env file:
The package provides \ReadyCMSIO\Nestpay\MerchantService class which could be injected in controllers and other points in Laravel application:
Also \ReadyCMSIO\Nestpay\MerchantService could be obtained using facade or service container:
For unprocessed payments (when customer does not navigate back to your site after payment by accident) there is also available artisan command:
Laravel resources (config, controllers, views , etc)
Although you could integrate Nestpay service into your Laravel application manually, this Laravel package has all you need to integrate Nestpay system.
-
Publish package resources into your Laravel application:
-
Customize published config file config/nestpay.php to your production parameters (keep your testing parameters in .env)
-
Add Nestpay routes among others
-
Add published event subscriber into your \App\Providers\EventServiceProvider
-
Customize published migration for
nestpay_payment
table -
Customize published model \App\Models\NestpayPayment
- Customize controller \App\Http\Controllers\NestpayController
IMPORTANT NOTICE!!! You SHOULD NOT send emails to customer or have any logic which is related to the successful payment in this controller, because payment could be processed also over nestpay::handle-unprocessed-payments artisan command!
USE NestpayEventsSubscriber instead (see documentation below).
IMPORTANT NOTICE!!! Routes to actions NestpayController@success and NestpayController@fail MUST BE EXCLUDED FROM CSRF TOKEN VERIFICATION, exclude urls for that actions by editing VerifyCsrfTokent middleware
-
Customize view scripts
-
Schedule nestpay::handle-unprocessed-payments command to execute every five minutes, so unproccessed payments could be handled over Nestpay API in background
- Customize listener \App\Listeners\NestpayEventsSubscriber
IMPORTANT NOTICE!!!
THIS IS THE MOST IMPORTANT CUSTOMIZATION!!!
When payment is processed (eather over NestpayController or nestpay::handle-unprocessed-payments command) the following events are triggered:
- \ReadyCMSIO\Nestpay\Laravel\NestpayPaymentProcessedSuccessfullyEvent - for successful payments
- \ReadyCMSIO\Nestpay\Laravel\NestpayPaymentProcessedFailedEvent - for failed events
At this point you should have the published event subscriber \App\Listeners\NestpayEventsSubscriber which is configured to listen to those events.
The class has logic for sending necessary mail to the customer, all you have to do is add logic when payment has been successfull (when custmer HAS PAID)
All versions of nestpay with dependencies
ext-curl Version *