Before or on the 1st of February, all European entities accepting Direct Debits must officially switch to the new SEPA Direct Debit payments standard. This will require the user to enter BIC & IBAN rather than bank account & sort code.

The new payment standard will affect all countries in the Single European Payment Area, but other countries like the UK will be unaffected by the changes. Therefore, this needs to be implemented as a new payment method rather than updating the existing one, so that both can be used alongside each other with Rules to determine which should be used (eg, based on language or currency).

Comments

fastangel’s picture

Status: Active » Needs review
StatusFileSize
new4.28 KB

I created a patch for this integration. I added a variable for enable sepa or not. When you enable is showed a textfield for request IBAN/BIC code.

fastangel’s picture

Created a new version with validation of IBAN and SWIFT code.

fastangel’s picture

Created a new patch for old versions.

fastangel’s picture

some improve in the patch.

fastangel’s picture

Added some fix.

fastangel’s picture

Added some fix.

fastangel’s picture

Added to patch integration with views.

sja1’s picture

Hello Fastangel, one question and one comment...

Question: Of the patches you have uploaded, does more than one need to be applied? Do they apply to the stable 1.0 release or the 1.x dev release?

Comment: The maintenance status of this module is "Seeking new maintainer.", and the development status is "No further development." I point this out in case you might be interested in contacting the owner to take over maintenance.

fastangel’s picture

New update.

roam2345’s picture

Fix broken patch by fastangel.

roam2345’s picture

Dang, did not work.

Rebuilt patch by hand against latest 7.x-1.x branch.

fastangel’s picture

I changed a little description text.

anybody’s picture

This patch seems very important to me and should be integrated into the current .dev release as soon as possible. Thank you so much for your great work!

fastangel’s picture

Removed eregi and change to preg_replace.

fastangel’s picture

Sorry some fixed. I talked with the owner to add this patch to dev version.

fastangel’s picture

New patch with some title changes. This weekend I will pass to dev version.

anybody’s picture

I thought a bit about this and I'm not sure if perhaps a separate module or at least a module rename would make sense.

Some reasons:
1. The name of the payment still contains "UK", which is not right for the SEPA case
2. A separate module would make development easier and better split up different cases. I think it would also speed up development.
3. Users can decide when to switch by using the Direct Debit SEPA module and the UK module would be kept clean

What's your oppinion?

anybody’s picture

Status: Needs review » Needs work

I've tested your patch - many things seem to work fine but the validation function doesn't seem correct.

If I enter correct BIC and IBAN the form tells me "Your sort code must contain 6 numbers." as error, which is wrong.

Furthermore please keep in mind that it should be possible to (optionally) split the IBAN in groups for easier input. Example: DEXX XXXX XXXX XXXX XXXX XX

This should not trigger an error for usability reasons I think.

mrfelton’s picture

> The name of the payment still contains "UK", which is not right for the SEPA case

What do you mean? The name of the module is commerce_directdebit, which is exactly what it is. We use the exiting module both in the UK and Ireland already. It just supports the new European direct debits too that will be coming into effect in 2014. I'd recommend just updating the description on the project page, cutting a new major release, and detailing the new enhanced support in the release notes.

> 2. A separate module would make development easier and better split up different cases. I think it would also speed up development.

There is already a community of people here using and developing for this module, many of which will also need to switch to the new scheme in 2014. By keeping it all here, it becomes a simple config change for them, rather than the implementation of yet another new module.

> 3. Users can decide when to switch by using the Direct Debit SEPA module and the UK module would be kept clean

They can already do that with this setup. We are already using it. You can even use both alongside each other - it's a simple setting in the rules config to determine which style of direct debit you want to use.

anybody’s picture

Thanks a lot for your response. As described above, this was just a suggestion. The "UK" is also somewhere in the rules I think... I'll look it up but I'm sure that I've seen it somewhere on the Shop-Website itself.

By the way: We need the module for a German website, so independency from the British special cases is important to us, if we don't start a separate project (which would be sad I think) :)

Thanks a lot again.

fastangel’s picture

Pushed to dev branch and working in the changes commented #18

anybody’s picture

I've just tested the new version. Now I have two separate payment methods available in rules:

  • UK Lastschrift Zahlungsmethode
  • UK Direct Debit payment method (SEPA)

The first one can be editied in rules (as before). The second one has no options if I try to edit it. It also displays no value in the payment options (but can be selected as payment method by clients).

Furthermore the first one still has the same validation problems, but that might be correct?

anybody’s picture

This doesn't work for me at all. If I enter correct values for BIC / IBAN in the "old" payment method (UK) then I always receive the error:

Your sort code must contain 6 numbers.

What am I doing wrong and could you perhaps provide some examples for correct values? Could you have a try in your environment?

anybody’s picture

Ok I just debugged a bit and the reason is the following:

If I enable the "Enable SEPA integration" checkbox, the field "sort_code" does not exist anymore. But it is being checked in function "commerce_directdebit_submit_form_validate" which so always fails.

There is some duplicate code in link 235 which should be removed, I think.

fastangel’s picture

I think that you are confused. If you want to enter BIC/IBAN you need to enable the checkbox in the rules in other case the code that you need is how the old module. More clear now?

anybody’s picture

Sorry there is some misunderstanding.

The problem is, that there is some duplicate code in the module which ALWAYS checks the sort_code, even if SEPA is enabled. I've removed it and now everything is logical and works fine :)
Sorry for the confusion. You shoud correct this in the .dev release:

Original from the code (mind the duplication of "Validate sort code"):

// Validate sort code
  if (strlen(preg_replace('/[^0-9]+/', '', $sort_code)) < 6) {
    form_set_error(implode('][', array_merge($form_parents, array('sort_code'))), t('Your sort code must contain 6 numbers.'));

    // Even though the form error is enough to stop the submission of the form,
    // it's not enough to stop it from a Commerce standpoint because of the
    // combined validation / submission going on per-pane in the checkout form.
    return FALSE;
  }

  $settings = $payment_method['settings'];

  //IF is SEPA validate iban and swift
  if ($settings['merchant_enable_sepa']) {
    //Validate IBAN
    if (!commerce_directdebit_verify_iban($pane_values['iban'])) {
      form_set_error(implode('][', array_merge($form_parents, array('iban'))), t('Your IBAN code is invalid.'));
      return FALSE;
    }

    //Validate SWIFT code
    if(!preg_match("/^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/", $pane_values['swift'])) {
      form_set_error(implode('][', array_merge($form_parents, array('swift'))), t('Your BIC code is invalid.'));
      return FALSE;
    }
  }
  else {
    // Validate sort code
    if (strlen(preg_replace('/[^0-9]+/', '', $pane_values['sort_code'])) < 6) {
      form_set_error(implode('][', array_merge($form_parents, array('sort_code'))), t('Your sort code must contain 6 numbers.'));
      // Even though the form error is enough to stop the submission of the form,
      // it's not enough to stop it from a Commerce standpoint because of the
      // combined validation / submission going on per-pane in the checkout form.
      return FALSE;
    }
    // Validate account number
    if (strlen(preg_replace('/[^0-9]+/', '', $pane_values['account_number'])) < 8) {
      form_set_error(implode('][', array_merge($form_parents, array('account_number'))), t('Your account number must contain 8 numbers.'));

      // Even though the form error is enough to stop the submission of the form,
      // it's not enough to stop it from a Commerce standpoint because of the
      // combined validation / submission going on per-pane in the checkout form.
      return FALSE;
    }
  }

Thanks a lot for your quick reply.

fastangel’s picture

uhmm yes looks like that my patch was bad. I will try fix this afternoon. Thanks.

fastangel’s picture

Issue summary: View changes
Status: Needs work » Fixed

fixed and commited.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.