You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
Hi Nick
Can you give me any pointers with an issue I have with a new payment gateway.
New gateway is similar to the Sagepay/Protx form I currently use.
I have got it working almost perfect with Apple/Google pay transaction all being processed correctly.
Only issue is that I seem to temporarily loose some cookies when the success/fail response is returned.
I get the correct response in the URL(similar to sagepay) and the order is always processed correctly(Pending Shipment, emails sent, etc).
However, around 1 in 10 test transactions, the shopping cart isn't emptied even though the order has processed.
On virtually every test transaction, the cookie acceptance banner is displayed when returned to site, even though the kcookieinfo is there.
On some occassions, if i checkout as a logged in user, I can get both kusertoken cookie and a new ksesstoken cookie on return.
It seems that site doesn't acknowledge existing cookies on return from payment provider, even though all the cookies are available.
Single refresh restores account login status and cookie banner is hidden, so the cookies are definitely there but the original cart has been emptied.
This only happens on new gateway, not the original sagepay gateway.
I have tried altering the cookies but that hasn't helped.
Any ideas where to look.
Thanks
Rob
Offline
Looks like the issue is related to samesite cookie attribute and new gateway post response, not get as used by sagepay.
I can overcome issue by setting cookie samesite to none, unless you have any better ideas.
Offline
Is the new gateway posting back to K9 behind the scenes and outputting the content returned for the confirm page on their site/URL? A few gateways used to work that way and they all had issues so all of them changed. Just asking as your symptoms are similar. The solution was always to change the confirm page over to a redirect that pushed the customer to the confirm page on the site.
Offline
When payment is processed this url is hit: /utilities/ecomrelay.php?CARDNETtrans=20260305134&CARDNETresp=OK
(exactly the same as Sagepay form)..
OrderConfirmation page is then hit, order is processed. Everything work perfect with cookie attribute samesite='None' set which has something to do with POST responses and cross site cookies.
Gateway does post back lots of information about transaction via $_POST in ecomrelay.php, including reason for failure, etc.
Alternative option is to add the following at the start of ecomrelay.php:
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
'domain' => '.domainname.co.uk',
'secure' => true,
'httponly' => true,
'samesite' => 'None'
]);
session_start();
This also resolves all issues.
Last edited by zanart (03-06-2026 02:53:56)
Offline
That's the issue. There is a POST back, but they are scraping the response and presenting it to the customer on their site. As such, the cookies are not being picked up. To handle this situation, instead of targeting /utilities/ecomrelay.php on the return, target /utilities/ecomrelaymeta.php. You'll make that change in your payment method setup in K9. The ecomrelaymeta.php script does a meta-refresh over to the confirm page rather than trying to do any processing when it is accessed. This basically jumps the customer over to a confirm page that is served by your site. I'm not sure if any other payment methods actually use this type of method any more as it always was problematic from a return/confirm standpoint.
Offline
Sorry Nick - forgot to reply.
Everything is working perfectly with new gateway.
Offline