Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept both formats of Canadian routing numbers #4568

Merged
merged 2 commits into from
Oct 19, 2022

Conversation

molbrown
Copy link
Contributor

@molbrown molbrown commented Sep 9, 2022

Canadian routing numbers are typically handled either in print/MICR format or electronic format (see https://en.wikipedia.org/wiki/Routing_number_(Canada)#Format).

Adds ability to send valid MICR formatted Canadian routing numbers, which may still be expected by some gateways.

Unit tests:
5308 tests, 76382 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed

Rubocop:
746 files inspected, no offenses detected

ECS-2144

@molbrown molbrown requested review from therufs and a team September 9, 2022 17:52
Copy link
Contributor

@aenand aenand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

test/unit/check_test.rb Show resolved Hide resolved
test/unit/check_test.rb Outdated Show resolved Hide resolved
@therufs
Copy link
Contributor

therufs commented Sep 9, 2022

Kind of a philosophical question, but my original thought when doing this implementation was that if the gateway expects a specific format of routing number, that's something the gateway adapter should handle, rather than requiring someone who's integrating against AM to potentially have to create different payment methods for the same account.

Thoughts?

@molbrown
Copy link
Contributor Author

molbrown commented Sep 9, 2022

@therufs It's a good question. I stuck it back in here because I saw this format used to be here. In response to your question, I see these two formats as potentially equally standard, and can't be certain how widely used either is. For example, the format validated for US routing numbers via the checksum is also an MICR format. In that case, it's the only standard format, but I think the Canadian MICR does fit in here as well.

I don't consider the retainment and reuse of payment methods to be concerns of Active Merchant. 🤔 What to you think?

@therufs
Copy link
Contributor

therufs commented Sep 15, 2022

@molbrown I see it less as being relevant to payment method retention, more about presenting an interface that's gateway agnostic -- it seems like (?) some gateways want one format and some want the other, and I don't think an AM user should have to keep track of which gateway wants which behavior. (I know there's a whole options hash that belies this, but if it's avoidable, we should probably avoid it.)

I wonder if we could implement a pair of methods on check.rb that would allow the number to be returned in either format? (I wish I had thought of this when I was doing the original implementation 😅)

@molbrown molbrown force-pushed the canadian_routing_number branch 3 times, most recently from ffcd56f to e5ede11 Compare September 27, 2022 20:27
@molbrown
Copy link
Contributor Author

@therufs I like that idea, here's a stab at such an approach, with some mild refactoring (maybe could use more).

Copy link
Contributor

@therufs therufs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aw heck yeah love this 🤩

I don't see anything that obviously wants refactoring, but if there's particular stuff you have in mind, happy to take another look!

Canadian routing numbers are typically handled either in print/MICR format or
electronic format (see https://en.wikipedia.org/wiki/Routing_number_(Canada)#Format).

Adds ability to send valid MICR formatted Canadian routing numbers,
which may still be expected by some gateways. Adds public methods to Check that can
be used in a gateway adapter expecting one format of Canadian routing number.

Unit tests:
5308 tests, 76382 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Rubocop:
746 files inspected, no offenses detected

ECS-2144
@molbrown molbrown force-pushed the canadian_routing_number branch from e5ede11 to 862219b Compare October 19, 2022 19:31
@molbrown molbrown merged commit bb19e0a into activemerchant:master Oct 19, 2022
@molbrown molbrown deleted the canadian_routing_number branch October 19, 2022 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants