Zend certified PHP/Magento developer

Magento is losing customer session when returning from payment gateway

We have developed a payment plugin for Magento 2. The plugin is working correctly in our test environments and in some merchant environments but it’s failing in some merchants stores due to not being able to recover the session data.

The merchant is using Magento Commerce 2.3.2 and it’s using Fastly as a cache solution.

Basically, the plugin stores some data in the session before redirecting the user to the payment gateway. When the user is redirected back (the redirection is made using a location.href), an action of a plugin controller is triggered, but when executing that action, the content of the session variables is empty.

We suspect that the issue might be related to the cache configuration. But unfortunately, we can’t properly debug the issue because we don’t have access to the merchant environment and also Magento Commerce and Fastly are paid products.

Has anyone come across an issue like this before and can provide some solution?