From what I can tell after looking through the code and the database tables, I don't see a way to know which card on file was used for payment on any given order.

CoF could provide an entity reference field. This should fix this since card on file has been moved to be entities.

Of course this would make it the payment gateway module's e.g.(commerce_authnet) responsibility to update the field attached to the order. I believe this should be fine considering the card on file creation has been moved from CoF to the payment gateway modules like commerce_authnet.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Steven Brown’s picture

Status: Active » Needs review
FileSize
2.37 KB

Here's the patch to add the field that was proposed in this issue.

Steven Brown’s picture

Fixed syntax created from the first patch.

Steven Brown’s picture

Added the deletion of the field.

bojanz’s picture

Status: Needs review » Closed (won't fix)

I'm not a fan of this idea.

A card is ephemeral, it can be deactivated, or expire, or be deleted at any moment.
Adding an entityreference field means having to introduce a can_delete() hook and prevent deletion of cards that are referenced.
It also creates additional work for the CoF payment methods, which will result in a spotty implementation.
All this for very dubious gains (stats? You can create a custom table and fill it with the data you need on each charge, if that's your goal).

I can be persuaded otherwise with a really good (and popular) use case. Closing until then.

jpstrikesback’s picture

Status: Closed (won't fix) » Needs review

A use case:

We need to know what card was charged on the first order (multi card & Recurring Entity environment) to select the one charged later (with various handling for card issues, dunning, whatnot), and we also allow a user to switch the card in use for any given recurring entity.

We are using this field (on the Order) to pass information available when the payment happens to a field instance on the Recurring Entity to determine which card was used on the first order (the one which Rules subsequently creates the Recurring Entity from) and then to also allow the user to switch cards later.

If this doesn't land it can easily live in another module which depends on CoF and make a payment module depend on it, but it would be nice for payment methods to have an "available" field/method for this (and any other related) use case without needing another dependency. It could potentially live in the Commerce Cardonfile Recurring module or another sub module to be available for payment methods that would like to implement for whatever reason?

Cheers,
JP

bojanz’s picture

Status: Needs review » Closed (won't fix)

I've discussed that exact use case with FatGuyLaughing on IRC (with the help of rszrama and DamZ).

The described use case is an edge case with logic that is not common to most recurring services.
Recurring services such as AWS, MailChimp, CommerceGuys Marketplace (:P) always require you to have one
active billing profile and one active card. If you want to charge multiple cards, you need to open multiple accounts.

This is something that is easy to explain and document, familiar to people paying for various SaaS services, and
doesn't require the extra code needed for #5. Therefore I don't want to pursue this issue in cardonfile.
On the other hand, I will add additional code to cardonfile that will make it easy to enforce the 1 card per user rule.

Steven Brown’s picture

Bojanz, Ok I think we need to talk again because what you are saying here is different then what I was understanding originally.

Just because they require you to have one billing profile active doesn't mean you can't charge another card with out it being the default card in CoF. Unless you are saying that the AWS, MailChimp, etc will only allow you to charge the default card and not another. Honestly finding that hard to believe.

Let me know if I'm misunderstanding this. Sorry to drag this out.