Billing Modification Form Limits State/Province to 2 Characters

Hi! We are using Authorize.net Pro Forms, and it appears that the Billing Modification Form limits the State/Province field to 2 characters. This prevented a customer in Australia from entering his full 3-character province code, and so his card was declined due to an AVS mismatch.

However, the forms for level access (e.g. “Forms for Level #1 Access”) do NOT seem to have this limitation. I can enter several characters into the State/Province field on those forms.

We use both kinds of form on our site, and when I checked the shortcodes, I did not see any attribute that would account for this difference. Both have default_country_code=US.

So I think this might be a quick fix. The Billing Modification Form probably just needs a tweak to allow more than 2 characters.

Thanks for taking a look!

Note: Fixing this will probably also fix: AVS Error 27 - Province - New Zealand

it appears that the Billing Modification Form limits the State/Province field to 2 characters. This prevented a customer in Australia from entering his full 3-character province code, and so his card was declined due to an AVS mismatch.

Where do you see the error? In the pro-form, in the s2 logs, or in your Auth.net?

Does he get a message about the longer state code being wrong in the pro-form, or he can submit it but then the payment just doesn’t go through?

From what you described, it sounds like the pro-form doesn’t allow it, but at the same time it sounds like the form did get submitted and then Authorize.Net declined it.

I took a look at the code for it, found this line in s2member-pro/src/includes/classes/gateways/authnet/authnet-utilities.inc.php

    								$xml .= '<state>'.esc_html(substr($post_vars["x_state"], 0, 2)).'</state>';

You can try changing the 2 for a 3…

Also in the file s2member-pro/src/includes/templates/forms/authnet-update-form.php

				<input type="text" aria-required="true" maxlength="2" autocomplete="off" name="s2member_pro_authnet_update[state]" id="s2member-pro-authnet-update-state" class="s2member-pro-authnet-state s2member-pro-authnet-update-state form-control" value="%%state_value%%" tabindex="120" />

Change the maxlength to 3.

Let me know if that helps :slight_smile:

Hi @clavaque! Thanks for the quick reply! It’s great to see you back on here. :partying_face:

Where do you see the error? In the pro-form, in the s2 logs, or in your Auth.net?

First he tried to type in his 3-character province code in the State/Province field on the Billing Modification form, and the form simply didn’t let him type more than 2 characters.

So then he tried entering only the first 2 characters, and submitting that. The form submitted this (with only the first 2 characters) to Authorize.net, but then later Authorize.net gave the error about the AVS mismatch (wrong address).

Does he get a message about the longer state code being wrong in the pro-form, or he can submit it but then the payment just doesn’t go through?

There is no message in the pro-form, just an inability to type past two characters. The only error comes later, from Authorize.net, as described above.

Thanks for the code suggestions! I will try them and see if they work.

If so, should I submit a patch to github?

1 Like

:kissing_heart:

Thanks for the code suggestions! I will try them and see if they work.
If so, should I submit a patch to github?

Cool! No, you can just reply here. I look forward to your update.

:slight_smile:

1 Like

Hi @clavaque! I finally got around to trying this, and your changes do seem to allow me to enter a 3-letter code in State / Province.

I have not tested whether this change successfully posts to Authorize.net, because I don’t have access to an actual credit card with a 3-letter state code.

But if you’re confident that whatever is entered into a form field will post to Authorize.net, please do update the code for the next s2member release.

Thank you!

Thanks for the update! I may include it in the coming release, then.

:slight_smile:

1 Like

Thanks @clavaque! That would be excellent. It seems like a quick fix, and it would really help with international customers.

1 Like