Tea Commerce Sagepay provider always submits to 'cancel' URL
Hi,
I wondered if the SagePay provider for Tea Commerce 2 had been tested with a SagePay simulator account? I'm sure I've filled out all of the keys correctly and have set up the simulator account to accept the correct currency and IP address etc, but when I get to the 'accept' cart step, the form to post to SagePay is always like this:
So it's always just pointing to the cancel page. There's nothing Tea Commerce related in the umbracoLog table, so I'm not sure how to find out where the problem is here. Does anyone have any pointers on how to find out why this is failing?
Try and look in the database umbracoLog tabel and see if you should have an entry about the SagePay provider - which you should when it always post you to the cancel url.
Ahhh!! Got it! There's nothing in the log table at all, but I just tried it now making sure I entered shipping details (every other time I've just used billing details in the customer information screen and not selected a different shipping address). With both billing and shipping details it posts to the correct URL.
Now I just have to figure out why it requires shipping details for SagePay because I don't think it should.
I did nothing settings-wise - no additional settings have been added to the provider through the Tea Commerce admin section. It's merely that I completed ALL of the fields in the 'information' cart step and that worked. If I leave the shipping details empty then it doesn't work - it posts to the cancel URL rather than the SagePay simulator URL.
By default Tea Commerce hides the shipping details and there's some logic in the Razor files that should populate the shipping details with the billing details if no shipping details are entered. There's an issue somewhere that must be preventing this from happening, therefore no shipping details are sent to SagePay if they're not explicitly entered into the second part of the 'information' form.
I should be looking into this today so I'll let you know if I find a solution (other than making every information field mandatory).
Did a quick fix like you say by just assigning all the shipping detail variables to the customer variables in the cshtml file and that worked. Would be nice to see that Razor logic working though.
I drew the same conclusion to be honest Matt - I had a quick look through the sagepay.cs file and it it seemed to be doing the right thing, but it definitely isn't working, so I'm not sure where exactly the problem is.
In the end I just altered the client-side logic to make the billing and shipping delivery details always visible and always required, and I added a 'use billing details for shipping details' checkbox to copy the billing to the shipping details so the customer doesn't have to type things twice if they're the same. It works fine for this project but I think it needs someone with better .NET skills to debug the provider as I couldn't spot the problem.
I did find another issue too. If you set the shop to use cookies, it doesn't seem to fall back to the cookies for the payment provider. So you put stuff in the cart, they're saved in a cookie, but if you leave your session idle the final post to the payment gateway fails because there's nothing in the session object and it's not reading the cookie values instead. At least I presume that's what's happening. Again, not a show-stopper but worth knowing - it means that using cookies for the cart isn't a stable option at the moment.
Billing information should always be present - so it depends on your Umbraco/Tea Commerce setup if you did it correct. For the shipping - if that is required in the 2.23 protocol of sagepay then we have a bug in the payment providers and should update them. Does any of you know if the information is required in protocol 2.23? And to send the shipping information you need to have the shipping settings for your payment method and also the order should have the info. So could you try and provide me with a screenshot of your payment provider. Just make black boxes of sensitive information. Then I can see what settings you have and maybe also a screenshot of the json/xml for you order and its properties when you are at the step just before clicking "Pay" in the cart.
@Dan - How do I recreate the cookie/session issue that you state? What did you set the cookie timeout to in the store settings?
Thanks for looking at this. Billing info is fine - it's required in the starter kit and also required by Sagepay, so no probs there. The issue I've had (and Matt too) is that if you don't enter shipping information in the 'information' cart step, the Sagepay post URL doesn't get constructed properly and always just posts to your fail URL. I didn't enter anything but the default payment provider credentials in Tea Commerce (no extra credentials - just the standard SagePay provider fields in the Starter Kit using a simulator account) so I don't think anything is wrong except for some reason the shipping provider code isn't using the billing details as the shipping details if no shipping details are provided.
I've just looked up and in the Sagepay protocol 2.23 documentation, page 18, it says that delivery information IS required for 2.23. Like I say, if you complete this during checkout of the Tea Commerce store it works fine, but if you don't supply both billing and shipping details it fails.
For me it works fine - I just have to ensure that client-side the user completes both billing and shipping details. It would be nice if they didn't have to, but it's not a show stopper for me in this implementation.
Regarding the cookie issue, I set the cookie expiry to 365. It works fine generally but if you add some items to basket, leave for an hour (or however long the server session timeout is) then the items are still in the cart when you refresh (as you'd expect) but you can't progress through to SagePay as it errors. It would seem that the payment provider is using the session info whereas the client-side cart is using the cookie. If you're not able to replicate this let me know and I'll document it thoroughly - just short on time this afternoon.
Just to reiterate what Dan has said, and I haven't had any further luck debugging it.
The site we are developing goes live on the 19th and whilst this functionality is not essential it would be preferrable. The cookie bug seems a bit more serious!
Thanks for the workaround options Dan, we will most likely by default copy the billing information into delivery information, and then have a checkbox below the billing information that reveals a new form if the shipping address is different (as in the starter kit), and have every field required.
The bug with SagePay provider and the shipping things I think I fixed. It was because of DeliveryCountry wasent always send as it should be. Anyone want to pull the latest code for the payment providers and test?
About the cookie part - I need a more detailed walkthrough to reproduce that. If you can reload the page and still see the order, then that order is also the one the payment provider works with. I cant see how this should happen. But if you learn me how to reproduce in a simple setup then i can try and reproduce.
Would be happy to, but I'm relatively new with Visual Studio/applying these changes to the Tea Commerce installation. Do I need to build the project and upload some dlls? If so which ones? Thanks for any help.
Are you referring to the umbracoLog table in the database? When I query the databse there is no mention of SagePay or Teacommerce (unless I am looking in the wrong place? This also happens on a vanilla Tea Commerce installation too.
It should always log when it goes to the cancel url - that is how the source code is written. And you use Tea Commerce 2 right? Did you sort the umbracoLog table descending using the date as the sort key?
Unless this is specific to my setup it definitely isn't logging - using TC2 and also did a fresh TC2 starter kit installation to double check and it does not log either. I have sorted by date, and also queried for teacommerce and sagepay and there are no entries.
Tea Commerce Sagepay provider always submits to 'cancel' URL
Hi,
I wondered if the SagePay provider for Tea Commerce 2 had been tested with a SagePay simulator account? I'm sure I've filled out all of the keys correctly and have set up the simulator account to accept the correct currency and IP address etc, but when I get to the 'accept' cart step, the form to post to SagePay is always like this:
So it's always just pointing to the cancel page. There's nothing Tea Commerce related in the umbracoLog table, so I'm not sure how to find out where the problem is here. Does anyone have any pointers on how to find out why this is failing?
Many thanks.
Hi Dan
Try and look in the database umbracoLog tabel and see if you should have an entry about the SagePay provider - which you should when it always post you to the cancel url.
Kind regards
Anders
Ahhh!! Got it! There's nothing in the log table at all, but I just tried it now making sure I entered shipping details (every other time I've just used billing details in the customer information screen and not selected a different shipping address). With both billing and shipping details it posts to the correct URL.
Now I just have to figure out why it requires shipping details for SagePay because I don't think it should.
Hi Dan,
I think they made billing and delivery addresses a requirement in one of the recent protocols.
How did you manage to to post to the correct URL? Did you have to add more settings to the payment provider in TC?
I'm currently using Sagepay for an ecommerce site and have the same problem.
Hi Matt,
I did nothing settings-wise - no additional settings have been added to the provider through the Tea Commerce admin section. It's merely that I completed ALL of the fields in the 'information' cart step and that worked. If I leave the shipping details empty then it doesn't work - it posts to the cancel URL rather than the SagePay simulator URL.
By default Tea Commerce hides the shipping details and there's some logic in the Razor files that should populate the shipping details with the billing details if no shipping details are entered. There's an issue somewhere that must be preventing this from happening, therefore no shipping details are sent to SagePay if they're not explicitly entered into the second part of the 'information' form.
I should be looking into this today so I'll let you know if I find a solution (other than making every information field mandatory).
Hi Dan, much appreciated!
Did a quick fix like you say by just assigning all the shipping detail variables to the customer variables in the cshtml file and that worked. Would be nice to see that Razor logic working though.
Hi Matt
That sounds weird - but you can see the source code here and let me know if you see what is wrong or you could even go ahead and correct it and make a pull request.
https://bitbucket.org/teasolutions/tea-commerce-tea-commerce-payment-providers
Kind regards
Anders
Hi again,
I've had a look and can't seem to find the solution for this.
I see the if statements in the Sagepay.cs that should copy the payment address to billing address if it doesn't exist, but it doesn't seem to work.
Dan did you have any luck?
Anders any chance you could take a look? The starter kit does not work out of the box with it.
The site we are using for it needs to go live in 2 weeks and we definitely need Sagepay.
I drew the same conclusion to be honest Matt - I had a quick look through the sagepay.cs file and it it seemed to be doing the right thing, but it definitely isn't working, so I'm not sure where exactly the problem is.
In the end I just altered the client-side logic to make the billing and shipping delivery details always visible and always required, and I added a 'use billing details for shipping details' checkbox to copy the billing to the shipping details so the customer doesn't have to type things twice if they're the same. It works fine for this project but I think it needs someone with better .NET skills to debug the provider as I couldn't spot the problem.
I did find another issue too. If you set the shop to use cookies, it doesn't seem to fall back to the cookies for the payment provider. So you put stuff in the cart, they're saved in a cookie, but if you leave your session idle the final post to the payment gateway fails because there's nothing in the session object and it's not reading the cookie values instead. At least I presume that's what's happening. Again, not a show-stopper but worth knowing - it means that using cookies for the cart isn't a stable option at the moment.
Billing information should always be present - so it depends on your Umbraco/Tea Commerce setup if you did it correct. For the shipping - if that is required in the 2.23 protocol of sagepay then we have a bug in the payment providers and should update them. Does any of you know if the information is required in protocol 2.23? And to send the shipping information you need to have the shipping settings for your payment method and also the order should have the info. So could you try and provide me with a screenshot of your payment provider. Just make black boxes of sensitive information. Then I can see what settings you have and maybe also a screenshot of the json/xml for you order and its properties when you are at the step just before clicking "Pay" in the cart.
@Dan - How do I recreate the cookie/session issue that you state? What did you set the cookie timeout to in the store settings?
Kind regards
Anders
Hi Anders,
Thanks for looking at this. Billing info is fine - it's required in the starter kit and also required by Sagepay, so no probs there. The issue I've had (and Matt too) is that if you don't enter shipping information in the 'information' cart step, the Sagepay post URL doesn't get constructed properly and always just posts to your fail URL. I didn't enter anything but the default payment provider credentials in Tea Commerce (no extra credentials - just the standard SagePay provider fields in the Starter Kit using a simulator account) so I don't think anything is wrong except for some reason the shipping provider code isn't using the billing details as the shipping details if no shipping details are provided.
I've just looked up and in the Sagepay protocol 2.23 documentation, page 18, it says that delivery information IS required for 2.23. Like I say, if you complete this during checkout of the Tea Commerce store it works fine, but if you don't supply both billing and shipping details it fails.
For me it works fine - I just have to ensure that client-side the user completes both billing and shipping details. It would be nice if they didn't have to, but it's not a show stopper for me in this implementation.
Regarding the cookie issue, I set the cookie expiry to 365. It works fine generally but if you add some items to basket, leave for an hour (or however long the server session timeout is) then the items are still in the cart when you refresh (as you'd expect) but you can't progress through to SagePay as it errors. It would seem that the payment provider is using the session info whereas the client-side cart is using the cookie. If you're not able to replicate this let me know and I'll document it thoroughly - just short on time this afternoon.
Hope this all helps anyhow...
Hi,
Just to reiterate what Dan has said, and I haven't had any further luck debugging it.
The site we are developing goes live on the 19th and whilst this functionality is not essential it would be preferrable. The cookie bug seems a bit more serious!
Thanks for the workaround options Dan, we will most likely by default copy the billing information into delivery information, and then have a checkbox below the billing information that reveals a new form if the shipping address is different (as in the starter kit), and have every field required.
The bug with SagePay provider and the shipping things I think I fixed. It was because of DeliveryCountry wasent always send as it should be. Anyone want to pull the latest code for the payment providers and test?
About the cookie part - I need a more detailed walkthrough to reproduce that. If you can reload the page and still see the order, then that order is also the one the payment provider works with. I cant see how this should happen. But if you learn me how to reproduce in a simple setup then i can try and reproduce.
Kind regards
Anders
Hi Anders, looks promising.
Would be happy to, but I'm relatively new with Visual Studio/applying these changes to the Tea Commerce installation. Do I need to build the project and upload some dlls? If so which ones? Thanks for any help.
Just build using Visual Studio in release mode and then overwrite the two dll files in your websites /bin folder.
Hi Anders,
It appears that has fixed the shipping address issue - will do some further testing.
However I cannot seem to debug errors with the Sagepay gateway (i.e. if it goes to the cancel URL), nothing is being posted to the UmbracoLog?
It should log in linie 154 - so you should see something that starts with "Sage Pay".
Kind regards
Anders
Are you referring to the umbracoLog table in the database? When I query the databse there is no mention of SagePay or Teacommerce (unless I am looking in the wrong place? This also happens on a vanilla Tea Commerce installation too.
Thanks,
Matt
It should always log when it goes to the cancel url - that is how the source code is written. And you use Tea Commerce 2 right? Did you sort the umbracoLog table descending using the date as the sort key?
Kind regards
Anders
Unless this is specific to my setup it definitely isn't logging - using TC2 and also did a fresh TC2 starter kit installation to double check and it does not log either. I have sorted by date, and also queried for teacommerce and sagepay and there are no entries.
Ahh just heard from the Umbraco team they moved the loggin to App_Data/Logs - try and look there.
Kind regards
Anders
is working on a reply...