Payment_handler -> payment_validate does not load previous settings in saved session

I have added a new offsite payment gateway called PayHere (www.payhere.lk) to ip via omnipay. When a purchase request is returned to ‘payment_return’ in turn it calls ‘payment_validate’. In payment_validate prevoius sent request data is retrieved via a saved session.


// Load previous settings
   $params = $this->session->userdata($invoice->invoice_url_key . '_online_payment');

//Added by me to check if session is retrived..                
   if (empty($params)) {
            		log_message('error', $invoice->invoice_url_key . '_online_payment' . 'session data not found. Payment Handler-payment_validate');
        	}
        		
   $response = $gateway->completePurchase($params)->send();

In my case this session is not retrieved and empty array is passed to the ‘completePurchase’.
( I have checked the session is created in makePayment - see log file)

DEBUG - 2018-02-17 12:51:02 --> 7PsAmk62pnFwvNKuBZWRxqgdY4D3JS8y_online_paymentsession data Found. Payment Handler-make_payment

Log File is as below

DEBUG - 2018-02-17 12:50:59 --> UTF-8 Support Enabled
DEBUG - 2018-02-17 12:50:59 --> Global POST, GET and COOKIE data sanitized
DEBUG - 2018-02-17 12:50:59 --> Payment_Information MX_Controller Initialized
DEBUG - 2018-02-17 12:50:59 --> Config file loaded: /home3/danesha/public_html/billing/application/config/invoice_plane.php
DEBUG - 2018-02-17 12:50:59 --> Encryption: Auto-configured driver 'openssl'.
DEBUG - 2018-02-17 12:50:59 --> File loaded: /home3/danesha/public_html/billing/application/modules/settings/models/Mdl_settings.php
DEBUG - 2018-02-17 12:50:59 --> File loaded: /home3/danesha/public_html/billing/application/controllers/../modules/layout/controllers/Layout.php
DEBUG - 2018-02-17 12:50:59 --> Layout MX_Controller Initialized
DEBUG - 2018-02-17 12:50:59 --> File loaded: /home3/danesha/public_html/billing/application/modules/invoices/models/Mdl_invoices.php
DEBUG - 2018-02-17 12:50:59 --> File loaded: /home3/danesha/public_html/billing/application/modules/payment_methods/models/Mdl_payment_methods.php
DEBUG - 2018-02-17 12:50:59 --> Config file loaded: /home3/danesha/public_html/billing/application/config/payment_gateways.php
DEBUG - 2018-02-17 12:50:59 --> File loaded: /home3/danesha/public_html/billing/application/modules/layout/views/alerts.php
DEBUG - 2018-02-17 12:50:59 --> File loaded: /home3/danesha/public_html/billing/application/modules/clients/views/partial_client_address.php
DEBUG - 2018-02-17 12:50:59 --> File loaded: /home3/danesha/public_html/billing/application/modules/layout/views/includes/fullpage-loader.php
DEBUG - 2018-02-17 12:50:59 --> File loaded: /home3/danesha/public_html/billing/application/modules/guest/views/payment_information.php
DEBUG - 2018-02-17 12:50:59 --> Total execution time: 0.0791
DEBUG - 2018-02-17 12:51:02 --> UTF-8 Support Enabled
DEBUG - 2018-02-17 12:51:02 --> Global POST, GET and COOKIE data sanitized
DEBUG - 2018-02-17 12:51:02 --> Payment_Handler MX_Controller Initialized
DEBUG - 2018-02-17 12:51:02 --> Config file loaded: /home3/danesha/public_html/billing/application/config/invoice_plane.php
DEBUG - 2018-02-17 12:51:02 --> Encryption: Auto-configured driver 'openssl'.
DEBUG - 2018-02-17 12:51:02 --> File loaded: /home3/danesha/public_html/billing/application/modules/settings/models/Mdl_settings.php
DEBUG - 2018-02-17 12:51:02 --> File loaded: /home3/danesha/public_html/billing/application/controllers/../modules/layout/controllers/Layout.php
DEBUG - 2018-02-17 12:51:02 --> Layout MX_Controller Initialized
DEBUG - 2018-02-17 12:51:02 --> File loaded: /home3/danesha/public_html/billing/application/modules/invoices/models/Mdl_invoices.php
DEBUG - 2018-02-17 12:51:02 --> Config file loaded: /home3/danesha/public_html/billing/application/config/payment_gateways.php
DEBUG - 2018-02-17 12:51:02 --> 7PsAmk62pnFwvNKuBZWRxqgdY4D3JS8y_online_paymentsession data Found. Payment Handler-make_payment
DEBUG - 2018-02-17 12:51:27 --> UTF-8 Support Enabled
DEBUG - 2018-02-17 12:51:27 --> Global POST, GET and COOKIE data sanitized
DEBUG - 2018-02-17 12:51:27 --> Payment_Handler MX_Controller Initialized
DEBUG - 2018-02-17 12:51:27 --> Config file loaded: /home3/danesha/public_html/billing/application/config/invoice_plane.php
DEBUG - 2018-02-17 12:51:27 --> Encryption: Auto-configured driver 'openssl'.
DEBUG - 2018-02-17 12:51:27 --> File loaded: /home3/danesha/public_html/billing/application/modules/settings/models/Mdl_settings.php
DEBUG - 2018-02-17 12:51:27 --> File loaded: /home3/danesha/public_html/billing/application/controllers/../modules/layout/controllers/Layout.php
DEBUG - 2018-02-17 12:51:27 --> Layout MX_Controller Initialized
DEBUG - 2018-02-17 12:51:27 --> File loaded: /home3/danesha/public_html/billing/application/modules/invoices/models/Mdl_invoices.php
DEBUG - 2018-02-17 12:51:27 --> Config file loaded: /home3/danesha/public_html/billing/application/config/payment_gateways.php
ERROR - 2018-02-17 12:51:27 --> 7PsAmk62pnFwvNKuBZWRxqgdY4D3JS8y_online_paymentsession data not found. Payment Handler-payment_validate
ERROR - 2018-02-17 12:51:27 --> Severity: 4096 --> Argument 1 passed to Omnipay\PayHere\Gateway::completePurchase() must be of the type array, null given, called in /home3/danesha/public_html/billing/application/modules/guest/controllers/Payment_handler.php on line 271 and defined /home3/danesha/public_html/billing/vendor/omnipay/PayHere/src/Gateway.php 99
ERROR - 2018-02-17 12:51:27 --> Severity: 4096 --> Argument 2 passed to Omnipay\Common\AbstractGateway::createRequest() must be of the type array, null given, called in /home3/danesha/public_html/billing/vendor/omnipay/PayHere/src/Gateway.php on line 101 and defined /home3/danesha/public_html/billing/vendor/omnipay/common/src/Omnipay/Common/AbstractGateway.php 270
ERROR - 2018-02-17 12:51:27 --> Severity: Warning --> array_replace(): Argument #2 is not an array /home3/danesha/public_html/billing/vendor/omnipay/common/src/Omnipay/Common/AbstractGateway.php 274
ERROR - 2018-02-17 12:51:27 --> Severity: 4096 --> Argument 1 passed to Omnipay\Common\Message\AbstractRequest::initialize() must be of the type array, null given, called in /home3/danesha/public_html/billing/vendor/omnipay/common/src/Omnipay/Common/AbstractGateway.php on line 274 and defined /home3/danesha/public_html/billing/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractRequest.php 114
ERROR - 2018-02-17 12:51:27 --> Severity: error --> Exception: Post data from PayHere NOT Found-CompletePurchaseRequest-getData /home3/danesha/public_html/billing/vendor/omnipay/PayHere/src/Message/CompletePurchaseRequest.php 34
ERROR - 2018-02-17 12:51:27 --> Severity: Warning --> Cannot modify header information - headers already sent by (output started at /home3/danesha/public_html/billing/vendor/codeigniter/framework/system/core/Exceptions.php:271) /home3/danesha/public_html/billing/vendor/codeigniter/framework/system/core/Common.php 564
DEBUG - 2018-02-17 12:51:30 --> UTF-8 Support Enabled
DEBUG - 2018-02-17 12:51:30 --> Global POST, GET and COOKIE data sanitized
DEBUG - 2018-02-17 12:51:30 --> View MX_Controller Initialized
DEBUG - 2018-02-17 12:51:30 --> Config file loaded: /home3/danesha/public_html/billing/application/config/invoice_plane.php
DEBUG - 2018-02-17 12:51:30 --> Encryption: Auto-configured driver 'openssl'.
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/modules/settings/models/Mdl_settings.php
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/controllers/../modules/layout/controllers/Layout.php
DEBUG - 2018-02-17 12:51:30 --> Layout MX_Controller Initialized
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/modules/invoices/models/Mdl_invoices.php
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/modules/invoices/models/Mdl_items.php
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/modules/invoices/models/Mdl_invoice_tax_rates.php
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/modules/payment_methods/models/Mdl_payment_methods.php
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/modules/custom_fields/models/Mdl_custom_fields.php
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/modules/custom_fields/models/Mdl_invoice_custom.php
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/modules/custom_values/models/Mdl_custom_values.php
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/modules/custom_fields/models/Mdl_client_custom.php
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/modules/custom_fields/models/Mdl_user_custom.php
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/modules/layout/views/alerts.php
DEBUG - 2018-02-17 12:51:30 --> File loaded: /home3/danesha/public_html/billing/application/views/invoice_templates/public/InvoicePlane_Web.php
DEBUG - 2018-02-17 12:51:30 --> Total execution time: 0.0754

Using ip 1.5.6 on Cent_os

Can anyone help please help me on this.
@Kovah