SagePay MALFORMED error - billing state required

  • Posts: 35
  • Thank you received: 1
12 years 2 weeks ago #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:

"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 or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
12 years 2 weeks ago #75308

Hi,

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

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

Thanks to give us a feedback.

Please Log in or Create an account to join the conversation.

  • Posts: 35
  • Thank you received: 1
12 years 2 weeks ago #75331

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

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
12 years 2 weeks ago #75333

Yes you're right, can you try this:

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

Please Log in or Create an account to join the conversation.

  • Posts: 35
  • Thank you received: 1
12 years 2 weeks ago #75377

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

Please Log in or Create an account to join the conversation.

Time to create page: 0.078 seconds
Powered by Kunena Forum