close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

SagePay error affecting US customers

Thread began 5/09/2014 7:01 pm by Steve E | Last modified 5/14/2014 4:18 pm by Steve E | 758 views | 7 replies

Steve E

SOLVED

This is the diagnosis and solution to the error message(s)

Sage Pay error: Status: MALFORMED 3147 : The BillingState field is required
or
Sage Pay error: Status: MALFORMED 3147 : The DeliveryState field is required

As per the Sage Pay protocol 2.23 specification the’ BillingState’ and ‘DeliveryState’ values must be the 2 letters state codes only not a value in the address. Check the Protocol 2.23 documentation for more details.
I created a dB table and added it to my ecommerce database to store the state codes;

I had to create parallel pages to introduce a separate U.S. Checkout pathway which meant creating U.S. versions of the following forms

User registration
Update user profile
Checkout
Confirm

and edit

to Protox-VSPF.php

The reason for this is the US 2 digit codes are required for US purchases from US card holders or from non US customers having the product shipped to a US address. These codes mean nothing nor are there are any compatible codes for the rest of the planet so you still need to either capture these separately or omit the county/state field completely which is no good when printing address labels later.


You need to add the following to Protox-VSPF.php
(In my case around line 28)

, $tBillingState,$tShippingState
ALSO add this
(In my case around line 100)
if ($tBillingState) {
$retStr .= "BillingState=" . $tBillingState . "&";
}
if ($tShippingState) {
$retStr .= "DeliveryState=" . $tShippingState . "&";
}


You need to add this code to the bottom of your confirm.php

Look for the function WA_Protx_VSPFormHash (around line 580 in my script)

Within the value pairs crypt input array at the end after the last values before the closing /> input tags and above the modify button.
"".((isset($_POST["state_province"]))?$_POST["state_province"]:"") ."", "".((isset($_POST["shipping_state_province"]))?$_POST["shipping_state_province"]:"") ."");


Simply upload the scripts and replace the existing ones; Please back up your existing files first so you can roll back if it goes wrong.

This will work in the case of a US registered user shipping to a US address however will still generate a error if a non US citizen is shipping to the US this can be fixed by amending the following input value on the checkout.php page.
STATE_PROVINCE
<input type="text" name="state_province" id="state_province" value="<?php if($row_UserRS1['UserCountry'] == "United States" || $row_UserRS1['UserCountry']=="United States Minor Outlying Islands" || $row_UserRS1['UserCountry']=="Virgin Islands, US") {echo $row_UserRS1['UserState'];} else {echo '';} ?>" placeholder="LEAVE BLANK"/>
That solves both instances however you will not be logging the County/state address field for non US customers unless you do as I and create a parallel system and you will need to ensure they are still using the original forms.

I hope this helps if you remember Back up everything you can always go back and are risking nothing.

Thanks very much to Jason and all at Webassist for the prompt response and fantastic support.

All the best

Steve

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...