4

I can't figure this one out. I just have a standard checkout form that is hooked up to SagePay Server.

In the Store settings there is no mapping of billing firstname and surname but in the gateway class I can see the values being requested. When i submit the form, I get the message saying "3107 : The BillingSurname field is required."

If I amend the gateway class to hardcode values in the field it goes through fine. What makes it even stranger is that on a live site using the same codebase and database, it all goes through to SagePay without any errors at all.

Any suggestions?

Thanks

  • Found the problem. Looks like Store has a single name field set up by default (billing_name) and then in the _normalize_card_params() method of the Merchant class, it splits (on space) the name field into first_name and last_name parameters. So when you submit a name without a space, you get a blank surname and therefore an error. That seems clumsy to me - is there a way to set first_name and last_name in the config so that each can have its own input fields? – Russ Back Jan 21 '13 at 17:49
2

As mentioned in your comment - Store only supports a single billing "name" field. To separate these into first name and last name fields, there is an add-on on Devot:ee by Michael Rog which will let you use a custom field for this: Store: Firstname/Lastname. There is also a feature request for it, and it will most likely be addressed officially in a future version.

As some gateways require separate first name and last name fields, the name field is currently split after the first space when sent to the payment gateway. This is sufficient for 99% of cases, and mostly only leads to errors during testing when you don't put a real name in :)

Update: Store v2 has separate first_name and last_name fields.

| improve this answer | |
  • Hi Adrian, We have had a couple of issues along these lines since our site went live about 2 weeks ago. Our site sells to customers around the world perhaps the current set up isn't appropriate to name structures globally. I appreciate that most online stores have a single 'name on card' field, but is there a more sophisticated way to extract the required data for the payment gateways? Cheers! – Tomtids Sep 16 '13 at 10:36
  • While you haven't mentioned exactly why this is causing problems for you, you can either use the above mentioned extension, or upgrade to Store 2 which has separate first name / last name fields :) – Adrian Macneil Sep 16 '13 at 10:54
1

If anyone else has this issue and wants a quick fix, I solved it by utilising JQuery validation and ensuring the field had 2 names separated by a space.

JavaScript:

$.validator.addMethod("fullname", function(value, element) {
   return /\w+\s+\w+/.test(value);
}, "Please specify firstname and lastname and separate with a space");

$(document).ready(function() {
    $("form#billing").validate({
        ignore: ""
    });
});

And in the template:

{exp:store:checkout next="/checkout/delivery" form_id="billing"
    require="name|order_email|address1|address3|postcode|country|phone"
    error_handling="inline" error_delimiters='<label class="error">|</label>'
    secure_action="yes" secure_return="yes"}

<input type="text" name="billing_name" value="{billing_name}"
    placeholder="John Doe" required class="fullname">
    {error:billing_name}

Note the required triggers the JQuery validator and the class="fullname" fires the custom method and validation for only that field.

I couldn't use the Store: Firstname/Lastname add-on as it requires custom1 and custom2 fields which I was already using, so would involve a lot of effort to update or a hack to the add-on.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.