There is a setting in cardonfile that allows users to store multiple cards or just one. Commerce beanstream ignores this setting.

I've written a patch that makes beanstream recognize this setting. Even if you have been using commerce_beanstream for a while, if you set cardonfile to allow only one card nothing will break. The next time a customer makes a payment commerce_beanstream will keep only the newest card in the local cardonfile table and in the remote beanstream database.

This functionality will work when a user enters a new card at checkout and when they are modifying their cards on the 'stored cards' tab in the user profile.

Comments

chirpy created an issue. See original summary.

momass@gmail.com’s picture

StatusFileSize
new11.57 KB
momass@gmail.com’s picture

Issue summary: View changes
momass@gmail.com’s picture

StatusFileSize
new9.38 KB

The last patch I uploaded is broken, please do not use. Here's the correct patch.

momass@gmail.com’s picture

StatusFileSize
new10.55 KB

When a user adds a new card on the 'stored cards' tab and if the cardonfile setting is set to only allow users to store one card, the current card on file will be overwritten.

I've included in this patch a warning message on the 'stored cards' tab that this will occur. The message will only appear if the cardonfile setting is set to allow users to store one card only and if the user currently has one or more cards in the system.

momass@gmail.com’s picture

Status: Active » Needs review
momass@gmail.com’s picture

StatusFileSize
new11.68 KB

Found a bug in my previous patch.

If a user has multiple credit cards and if commerce_cardonfile has the setting to allow only one stored card, when a new card is added it is not set as the default card.

This latest patch corrects that.

spiderman’s picture

@chirpy Thanks for this patch- I'm aware that in the deployment I was working on this module for originally, we didn't want to allow more than one card on file as it was confusing end users. Obviously I want to support this feature, but would like to validate with one of the other maintainers from that deployment that your patch doesn't break their use case. It may need to be reworked slightly to provide an option or something. Reassigning this to myself to come back to and test properly when I can get a proper test harness setup.

spiderman’s picture

Status: Needs review » Needs work
momass@gmail.com’s picture

@spiderman, I've tested the code with the setting to allow multiple credit cards turned off. We've been running it like this for the past year without issue. I have not tested it with multiple cards turned on but from what I understand commerce_beanstream wasn't respecting this cardonfile setting one way or the other and beanstream was saving multiple cards to payment profiles regardless.

I know allowing only one card works for us, allowing multiple needs testing.

Once you approve and commit the recurring patch, I will re-create this patch with the latest updates.