Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Neil Hodges 338 posts 987 karma points
    Feb 04, 2020 @ 16:22
    Neil Hodges
    0

    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 -

    WARN  TeaCommerce.PaymentProviders.Classic.SagePay - Sage Pay(CART-123) - Generate html form error - status: MALFORMED | status details: 3107 : The BillingSurname field is required.
    

    My AddOrUpdateOrderProperties are sett like this:

     <input name="AddOrUpdateOrderProperties" type="hidden" value="properties" />
    <input name="properties" type="hidden" value="
           email, 
           phone, 
           billingCompany, 
           billingFirstName, 
           billingSurname, 
           billingAddress1, 
           billingAddress2, 
           billingCity, 
           billingCounty, 
           billingZipCode, 
           shippingCompany, 
           shipping_FirstName, 
           shipping_LastName, 
           shipping_Address1, 
           shipping_Address2, 
           shipping_City, 
           shipping_County, 
           shipping_ZipCode" />
    

    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

    <div class="form-group">
                    <div class="col-sm-12">
                        @Html.TextBoxFor(model => model.billingSurname, new { @id = "BillingSurname", @name = "BillingSurname", @placeholder = "LAST NAME", value = Model.billingSurname, @required = true })
                    </div>
                </div>
    

    Form element is setup like this.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Feb 04, 2020 @ 16:40
    Matt Brailsford
    0

    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.

  • Neil Hodges 338 posts 987 karma points
    Feb 04, 2020 @ 17:51
    Neil Hodges
    0

    HI Matt

    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:

    enter image description here

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Feb 04, 2020 @ 18:35
    Matt Brailsford
    0

    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?

  • Neil Hodges 338 posts 987 karma points
    Feb 04, 2020 @ 19:41
    Neil Hodges
    0

    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:

    ErrorCode : 5006    Unable to redirect to Vendor's web site. The Vendor failed to provide a RedirectionURL.
    

    enter image description here

    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.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Feb 04, 2020 @ 20:23
    Matt Brailsford
    0

    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

  • Neil Hodges 338 posts 987 karma points
    Feb 04, 2020 @ 20:25
    Neil Hodges
    0

    Ah yes, good shout - ngrok, I've used before to test WebHooks locally. I'll give that a whirl.

    Thanks Matt!

  • Neil Hodges 338 posts 987 karma points
    Feb 11, 2020 @ 15:42
    Neil Hodges
    0

    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.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Feb 11, 2020 @ 16:03
    Matt Brailsford
    0

    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

  • Neil Hodges 338 posts 987 karma points
    Feb 11, 2020 @ 16:38
    Neil Hodges
    0

    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:

    11/02/2020
    16:21:33.286 +0000  INFO [tomcat-http--58] [00761DE0-5A8C-40D8-E5B4-3CE3914F2DCD] 11 02 2020 16:21:33,286 (AdaptiveHttpMessageDispatcher.java:147) - Adaptive connection attempt 1 to http://www.domainName.co.uk/base/TC/PaymentCallback/1/SagePay/47229783-0eb0-4a92-b15b-fc3b92d45fd3/65c814884d28b895a6ac99fd4b1107f90d8a0b73f714ee54ac0b297bc5e655a5.aspx
    Host:
    
    HEXVGWA01
    

    This is Sage Pay telling you the result of the transaction:

    11/02/2020
    16:21:33.286 +0000  INFO [tomcat-http--58] [00761DE0-5A8C-40D8-E5B4-3CE3914F2DCD] 11 02 2020 16:21:33,286 (AdaptiveHttpMessageDispatcher.java:129) - Message content: {VPSProtocol=2.23, TxType=PAYMENT, VendorTxCode=CART-197, VPSTxId={00761DE0-5A8C-40D8-E5B4-3CE3914F2DCD}, Status=NOTAUTHED, StatusDetail=2000 : The Authorisation was Declined by the bank., AVSCV2=DATA NOT CHECKED, AddressResult=NOTPROVIDED, PostCodeResult=NOTPROVIDED, CV2Result=NOTPROVIDED, GiftAid=0, 3DSecureStatus=NOTCHECKED, CardType=MC, Last4Digits=3208, VPSSignature=234C17BC30B57D50C7CAE74B2FB98AA9}
    

    This is the response from the notification URL:

    11/02/2020
    16:21:33.296 +0000  INFO [tomcat-http--58] [00761DE0-5A8C-40D8-E5B4-3CE3914F2DCD] 11 02 2020 16:21:33,296 (JdkHttpClient.java:94) - Response received: HttpResponse{body='', statusCode=301, statusMessage='Moved Permanently'}
    Host:
    
    HEXVGWA01
    

    Could this be something to do with using Cloudflare?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Feb 11, 2020 @ 16:48
    Matt Brailsford
    100

    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

  • Neil Hodges 338 posts 987 karma points
    Feb 13, 2020 @ 15:07
    Neil Hodges
    0

    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.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Feb 13, 2020 @ 15:12
    Matt Brailsford
    0

    Fantastic.

    Glad to hear you got it all working, and glad I could help.

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft