[Skip to main content](#vessel-content)

#   SagePay MALFORMED error - billing state required

##

- **[curtisbollington](/forum/user/7813-curtisbollington "View curtisbollington's Profile")**
- [![curtisbollington's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/7813-curtisbollington "View curtisbollington's Profile") Topic Author
- [ Offline](/forum/user/7813-curtisbollington)

Less More

- Posts: 35
- Thank you received: 1
-
-

14 years 5 days ago [\#75247](#75247) by [curtisbollington](/forum/user/7813-curtisbollington "View curtisbollington's Profile")  *[SagePay MALFORMED error - billing state required](/forum/2-general-talk-about-hikashop/75247-sagepay-malformed-error-billing-state-required#75247 "We have a customer in the US trying to make a payment on our site   www.v-kit.com , but gets the following error:  &quot;This transaction attempt had failed. Please use the Proceed button to go back to the web store from which you were purchasing. The details of the failure are given below: MALFORMED 3147: The BillingState field is required.&quot;  We've done a bit of research, and it might be something to do with the US State codes, instead of selecting 'Arkansas' they should select 'AR'.  Is this correct? If not, can you help? And if so, how do I configure this?  I wouldn't have thought it mattered, as the state codes are listed with the state names, so surely there must be some cross-referencing?  One other thing I've noticed is that in my version of HikaShop (Professional) the State codes for the USA show two-letter codes under the column 'Code 3 letters'. Is that correct, and does it make any difference to anything?  Thanks, Curtis")* was created by *[curtisbollington](/forum/user/7813-curtisbollington "View curtisbollington's Profile")*

We have a customer in the US trying to make a payment on our site [ www.v-kit.com](http://www.v-kit.com), but gets the following error:

"This transaction attempt had failed. Please use the Proceed button to go back to the web store from which you were purchasing. The details of the failure are given below:
MALFORMED
3147: The BillingState field is required."

We've done a bit of research, and it might be something to do with the US State codes, instead of selecting 'Arkansas' they should select 'AR'.

Is this correct? If not, can you help? And if so, how do I configure this?

I wouldn't have thought it mattered, as the state codes are listed with the state names, so surely there must be some cross-referencing?

One other thing I've noticed is that in my version of HikaShop (Professional) the State codes for the USA show two-letter codes under the column 'Code 3 letters'. Is that correct, and does it make any difference to anything?

Thanks, Curtis

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc1MjQ3LXNhZ2VwYXktbWFsZm9ybWVkLWVycm9yLWJpbGxpbmctc3RhdGUtcmVxdWlyZWQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

14 years 4 days ago [\#75308](#75308) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Re: SagePay MALFORMED error - billing state required](/forum/2-general-talk-about-hikashop/75247-sagepay-malformed-error-billing-state-required#75308 "We have a customer in the US trying to make a payment on our site   www.v-kit.com , but gets the following error:  &quot;This transaction attempt had failed. Please use the Proceed button to go back to the web store from which you were purchasing. The details of the failure are given below: MALFORMED 3147: The BillingState field is required.&quot;  We've done a bit of research, and it might be something to do with the US State codes, instead of selecting 'Arkansas' they should select 'AR'.  Is this correct? If not, can you help? And if so, how do I configure this?  I wouldn't have thought it mattered, as the state codes are listed with the state names, so surely there must be some cross-referencing?  One other thing I've noticed is that in my version of HikaShop (Professional) the State codes for the USA show two-letter codes under the column 'Code 3 letters'. Is that correct, and does it make any difference to anything?  Thanks, Curtis")*

Hi,

Can you try to edit the file "plugins/hikashoppayment/sagepay/sagepay.php" in the function "onAfterOrderConfirm()" replace the lines: Code:

if(@$order-&gt;cart-&gt;billing_address-&gt;address_country-&gt;zone_code_3=='US'){ $postData['BillingState'] = @$order-&gt;cart-&gt;billing_address-&gt;address_state-&gt;zone_code_3; } if(@$order-&gt;cart-&gt;shipping_address-&gt;address_country-&gt;zone_code_3=='US'){ $postData['DeliveryState'] = @$order-&gt;cart-&gt;shipping_address-&gt;address_state-&gt;zone_code_3; }

By: Code:

if(@$order-&gt;cart-&gt;billing_address-&gt;address_country-&gt;zone_code_2=='US'){ $postData['BillingState'] = @$order-&gt;cart-&gt;billing_address-&gt;address_state-&gt;zone_code_2; } if(@$order-&gt;cart-&gt;shipping_address-&gt;address_country-&gt;zone_code_2=='US'){ $postData['DeliveryState'] = @$order-&gt;cart-&gt;shipping_address-&gt;address_state-&gt;zone_code_2; }

Thanks to give us a feedback.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc1MjQ3LXNhZ2VwYXktbWFsZm9ybWVkLWVycm9yLWJpbGxpbmctc3RhdGUtcmVxdWlyZWQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[curtisbollington](/forum/user/7813-curtisbollington "View curtisbollington's Profile")**
- [![curtisbollington's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/7813-curtisbollington "View curtisbollington's Profile") Topic Author
- [ Offline](/forum/user/7813-curtisbollington)

Less More

- Posts: 35
- Thank you received: 1
-
-

14 years 4 days ago [\#75331](#75331) by [curtisbollington](/forum/user/7813-curtisbollington "View curtisbollington's Profile")  Replied by *[curtisbollington](/forum/user/7813-curtisbollington "View curtisbollington's Profile")* on topic *[Re: SagePay MALFORMED error - billing state required](/forum/2-general-talk-about-hikashop/75247-sagepay-malformed-error-billing-state-required#75331 "We have a customer in the US trying to make a payment on our site   www.v-kit.com , but gets the following error:  &quot;This transaction attempt had failed. Please use the Proceed button to go back to the web store from which you were purchasing. The details of the failure are given below: MALFORMED 3147: The BillingState field is required.&quot;  We've done a bit of research, and it might be something to do with the US State codes, instead of selecting 'Arkansas' they should select 'AR'.  Is this correct? If not, can you help? And if so, how do I configure this?  I wouldn't have thought it mattered, as the state codes are listed with the state names, so surely there must be some cross-referencing?  One other thing I've noticed is that in my version of HikaShop (Professional) the State codes for the USA show two-letter codes under the column 'Code 3 letters'. Is that correct, and does it make any difference to anything?  Thanks, Curtis")*

OK, I've done that by simply changing the '3' to '2', where it's displayed. There was no intelligence behind this, I simply did as instructed, as I know nothing about coding. I'll let you know the outcome.
I've attached a screen grab of the USA state zones, which shows the 2-letter codes in the 3-letter column, is that as it should be (this is the default as supplied with HikaShop). If it's not correct, does this mean that the changes I've made to the code won't work? Just curious.
Thanks
Curtis
[ ![USA-zones-screengrab.jpg](/forum/attachment/6791) ](/forum/attachment/6791 "...screengrab.jpg")

- [ ![USA-zones-screengrab.jpg](/forum/attachment/6791) ](/forum/attachment/6791 "...screengrab.jpg") [ ](/forum/attachment/6791?download=1 "...screengrab.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc1MjQ3LXNhZ2VwYXktbWFsZm9ybWVkLWVycm9yLWJpbGxpbmctc3RhdGUtcmVxdWlyZWQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

14 years 4 days ago [\#75333](#75333) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Re: SagePay MALFORMED error - billing state required](/forum/2-general-talk-about-hikashop/75247-sagepay-malformed-error-billing-state-required#75333 "We have a customer in the US trying to make a payment on our site   www.v-kit.com , but gets the following error:  &quot;This transaction attempt had failed. Please use the Proceed button to go back to the web store from which you were purchasing. The details of the failure are given below: MALFORMED 3147: The BillingState field is required.&quot;  We've done a bit of research, and it might be something to do with the US State codes, instead of selecting 'Arkansas' they should select 'AR'.  Is this correct? If not, can you help? And if so, how do I configure this?  I wouldn't have thought it mattered, as the state codes are listed with the state names, so surely there must be some cross-referencing?  One other thing I've noticed is that in my version of HikaShop (Professional) the State codes for the USA show two-letter codes under the column 'Code 3 letters'. Is that correct, and does it make any difference to anything?  Thanks, Curtis")*

Yes you're right, can you try this: Code:

if(@$order-&gt;cart-&gt;billing_address-&gt;address_country-&gt;zone_code_3=='USA'){ $postData['BillingState'] = @$order-&gt;cart-&gt;billing_address-&gt;address_state-&gt;zone_code_3; } if(@$order-&gt;cart-&gt;shipping_address-&gt;address_country-&gt;zone_code_3=='USA'){ $postData['DeliveryState'] = @$order-&gt;cart-&gt;shipping_address-&gt;address_state-&gt;zone_code_3; }

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc1MjQ3LXNhZ2VwYXktbWFsZm9ybWVkLWVycm9yLWJpbGxpbmctc3RhdGUtcmVxdWlyZWQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[curtisbollington](/forum/user/7813-curtisbollington "View curtisbollington's Profile")**
- [![curtisbollington's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/7813-curtisbollington "View curtisbollington's Profile") Topic Author
- [ Offline](/forum/user/7813-curtisbollington)

Less More

- Posts: 35
- Thank you received: 1
-
-

14 years 4 days ago [\#75377](#75377) by [curtisbollington](/forum/user/7813-curtisbollington "View curtisbollington's Profile")  Replied by *[curtisbollington](/forum/user/7813-curtisbollington "View curtisbollington's Profile")* on topic *[Re: SagePay MALFORMED error - billing state required](/forum/2-general-talk-about-hikashop/75247-sagepay-malformed-error-billing-state-required#75377 "We have a customer in the US trying to make a payment on our site   www.v-kit.com , but gets the following error:  &quot;This transaction attempt had failed. Please use the Proceed button to go back to the web store from which you were purchasing. The details of the failure are given below: MALFORMED 3147: The BillingState field is required.&quot;  We've done a bit of research, and it might be something to do with the US State codes, instead of selecting 'Arkansas' they should select 'AR'.  Is this correct? If not, can you help? And if so, how do I configure this?  I wouldn't have thought it mattered, as the state codes are listed with the state names, so surely there must be some cross-referencing?  One other thing I've noticed is that in my version of HikaShop (Professional) the State codes for the USA show two-letter codes under the column 'Code 3 letters'. Is that correct, and does it make any difference to anything?  Thanks, Curtis")*

We've tested that, and it seems to work fine. Thanks a lot for all your help.
Curtis

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc1MjQ3LXNhZ2VwYXktbWFsZm9ybWVkLWVycm9yLWJpbGxpbmctc3RhdGUtcmVxdWlyZWQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.057 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
