Adding Sage Pay to Tea Commerce.
Setup as instructions in Tea Commerce documentation.
I keep getting this error in the log file -
WARN TeaCommerce.PaymentProviders.Classic.SagePay - Sage Pay(CART-123) - Generate html form error - status: MALFORMED | status details: 3107 : The BillingSurname field is required.
So not sure why it's saying it malformed? Its not sending us thorugh to the Sage Pay payment, its failing back to the confirmation page as a faliure, i think it has something to do with this BillingSurname
Tried that, set it to firstName and lastName
But still getting the error:
2020-02-04 17:46:55,492 [P35280/D16/T383] WARN TeaCommerce.PaymentProviders.Classic.SagePay - Sage Pay(CART-134) - Generate html form error - status: MALFORMED | status details: 3107 : The BillingSurname field is required.
I can now see the info in the back office Carts showing populated now where it wasn't before:
Hmm, that is strange. It should definitely be the lastName property that the provider is looking for, and from the error, it's definitely not finding it.
Can you share the updated code for your customer info form?
Yea, it will be because your aren't public facing. The return URL / cancel URL in the settings aren't the actual ones that get sent to the payment providers, rather they are ones that are generated by TC as we need to do some other things when those requests come in so we send some specific TC URLs which do their thing and then they do the actual redirect to the configured URLs.
What this means though is that those URLs get generated based on the current domain so they will likely be for your .local domain and so this will be why it's failing.
The way I tend to test these things is using a tool such as ngrok https://ngrok.com/ which allows you to create temporary public URLs that can tunnel through to your local environment.
Oh man, that sucks. I hate it when it works local and then falls over on live.
RE VendorTxCode, this should be your orders cart number so you should be able to get that from the order table. The VPSTxId will become the order Transaction ID in the back office, but we don't know that till there has been a successful payment so I don't think you'll be able to know that given the payments are failing.
Hope this helps, but do let me know if I can help you further.
By the looks of it, I think it's possibly to do with HTTPS redirects.
In the first post it's showing the webhook is being sent to http://www.domainName.co.uk (I'm not sure if this is exactly correct as I'm assuming you anonymised the domain so not sure if you changed it to http instead of https) which is http, but then you are getting a 301 which I think could be from code doing a HTTPS redirect.
I do think it could potentially be a sort of mixture of a couple of issues though. I think the reason it could be going to http is because cloudflare proxies your site, but server to server it makes a http request, not https. The problem here is that TC uses the request object to detect the URL + protocol you are using to generate the webhook urls and so because the server to server requests are over http, I think it could be writing them as http urls.
Or you could implement a custom IPaymentProviderUriResolver replacing the default one found here, and force it to use HTTPs regardless. To do this, you'd create your own class and use a
I've added an SSL on the actual server. I think enabling Cloudflare to force al connection using HTTPS causes a 301 re-direct with SagePay pinging back to the site.
Adding the SSL to the server fixes it. I can now use End To End encryption on Cloudflare.
SagePay BillingSurname MALFORMED
Hi
Adding Sage Pay to Tea Commerce. Setup as instructions in Tea Commerce documentation.
I keep getting this error in the log file -
My AddOrUpdateOrderProperties are sett like this:
So not sure why it's saying it malformed? Its not sending us thorugh to the Sage Pay payment, its failing back to the confirmation page as a faliure, i think it has something to do with this BillingSurname
Form element is setup like this.
Hey Neil,
Just looking at the SagePay provider source here https://github.com/TeaCommerce/Tea-Commerce-Payment-Providers/blob/master/Source/TeaCommerce.PaymentProviders.SagePay/SagePay.cs and it looks like it expects the billing surname to be heald in the “lastName” property so because yours is “billingSurname” it’s not finding it.
If you store the first + last names of the billing contact in “firstName” and “lastName” properties, I think it should work.
Alternatively, you could recompile the payment provider source to look in another location.
HI Matt
Tried that, set it to firstName and lastName But still getting the error:
I can now see the info in the back office Carts showing populated now where it wasn't before:
Hmm, that is strange. It should definitely be the
lastName
property that the provider is looking for, and from the error, it's definitely not finding it.Can you share the updated code for your customer info form?
Hi Matt
Think I'm nearly there with it now. I've got it posting to Sage Pay now. I'm getting this from SagePay though:
I have set the SuccessURL and FailureURL in Tea Commerce SagePay settings.
Do these need to be absolute URL's, also I am testing this from my dev machine .local.
Hi Neil,
Glad to hear things are progressing.
Yea, it will be because your aren't public facing. The return URL / cancel URL in the settings aren't the actual ones that get sent to the payment providers, rather they are ones that are generated by TC as we need to do some other things when those requests come in so we send some specific TC URLs which do their thing and then they do the actual redirect to the configured URLs.
What this means though is that those URLs get generated based on the current domain so they will likely be for your .local domain and so this will be why it's failing.
The way I tend to test these things is using a tool such as ngrok https://ngrok.com/ which allows you to create temporary public URLs that can tunnel through to your local environment.
Matt
Ah yes, good shout - ngrok, I've used before to test WebHooks locally. I'll give that a whirl.
Thanks Matt!
Hi Matt
I got all this working with ngrok testing against the Sandbox.
Moved the site Live today, purchased a license, but now getting a 5006 error returned from Sage Pay?
I've spoken to Sage Pay and they said the 5006 is sometimes misleading. To look into it further I need - - either the VPSTxid or Vendor tx code?
Is there anywhere we can capture this? I've looked in the DB and can't see it stored anywhere?
Unsure why it would work fine locally using ngrok, and then as soon as it goes live we get the 5006 error.
Hi Neil,
Oh man, that sucks. I hate it when it works local and then falls over on live.
RE VendorTxCode, this should be your orders cart number so you should be able to get that from the order table. The VPSTxId will become the order Transaction ID in the back office, but we don't know that till there has been a successful payment so I don't think you'll be able to know that given the payments are failing.
Hope this helps, but do let me know if I can help you further.
Matt
Hi Matt
Ok got some more info from Sage Pay.
We are using Cloudflare for our HTTPS which I think maybe causing a problem.
SAGEPAY ran a test of a declined transaction to test everything is talking correctly.
This is Sage pay connecting to your Notification URL:
This is Sage Pay telling you the result of the transaction:
This is the response from the notification URL:
Could this be something to do with using Cloudflare?
By the looks of it, I think it's possibly to do with HTTPS redirects.
In the first post it's showing the webhook is being sent to
http://www.domainName.co.uk
(I'm not sure if this is exactly correct as I'm assuming you anonymised the domain so not sure if you changed it to http instead of https) which is http, but then you are getting a 301 which I think could be from code doing a HTTPS redirect.I do think it could potentially be a sort of mixture of a couple of issues though. I think the reason it could be going to http is because cloudflare proxies your site, but server to server it makes a http request, not https. The problem here is that TC uses the request object to detect the URL + protocol you are using to generate the webhook urls and so because the server to server requests are over http, I think it could be writing them as http urls.
I think if this is what is going on, you might need to have an SSL certificate on your server and tell cloudflare to run with end-to-end SSL https://support.cloudflare.com/hc/en-us/articles/200170416-End-to-end-HTTPS-with-Cloudflare-Part-3-SSL-options#h_845b3d60-9a03-4db0-8de6-20edc5b11057.
Or you could implement a custom
IPaymentProviderUriResolver
replacing the default one found here, and force it to use HTTPs regardless. To do this, you'd create your own class and use a[SuppressDependency( "TeaCommerce.Api.Web.PaymentProviders.IPaymentProviderUriResolver", "TeaCommerce.Api" )]
... on your class to tell it to replace the default (see here for more info on SupressDependency)
Matt
Thanks, Matt
I've added an SSL on the actual server. I think enabling Cloudflare to force al connection using HTTPS causes a 301 re-direct with SagePay pinging back to the site.
Adding the SSL to the server fixes it. I can now use End To End encryption on Cloudflare.
Thanks for your help, much appreciated as always.
Fantastic.
Glad to hear you got it all working, and glad I could help.
Matt
is working on a reply...