Heyo :). I'm working on recurring payment functionality and it occurs to me that it would be really useful to allow users to define a default card to use. At the moment, my patch for the Authorize.net module (http://drupal.org/node/1418348#comment-5534734) just takes the first card on file for a user that it finds and uses that. This may sound like a piece of functionality relevant only to recurring payments but I think it's also handy for users who do a lot of checkouts and would like to define a default card so they don't pick the wrong one by accident.

CommentFileSizeAuthor
#6 commerce_cardonfile-default_card.patch7.94 KBDevElCuy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BenK’s picture

This is definitely needed... any progress on this?

R.J. Steinert’s picture

Nope, but I'm definitely going to need to tackle this soon..

SolomonGifford’s picture

Wouldn't a better way to solve this be to create a commerce_card_on_file_reference field module that would allow a card_on_file to be attached to an order....

Then when modules do recurring orders, they grab the card on file associated with the order?

It seems to me that I may want my $10 recurring order on one card and my $20 recurring order on my other card.

DevElCuy’s picture

Recurring billing happens on cron run and is supposed to be automatic. So if I change my card or want to manage more than one, it would be a mess to change the card I wan to be billed to on every recurring order.

DevElCuy’s picture

In the other hand, if nothing has changed, order should be billed to the card in the order, so a default card makes sense only when order's card fails. That should be an option: "Bill to user's default payment method if order's card fails".

DevElCuy’s picture

Status: Active » Needs review
FileSize
7.94 KB

Attached patch adds field "is_default" to db table "commerce_card_data" via hook_schema and hook_update_N. There is another hook_update_N that sets the first card data as default card for each user.

The patch implements a new contextual link "set as default" in the user's profile "stored payment methods" tab.

recrit’s picture

@develCuy: thanks for your work. In parallel, we've been working on a fork that incorporates a default card setting and various other improvements, @see http://drupal.org/sandbox/recrit/1810130. We're working on merging this fork to a 2.x branch. The default card handling is fairly close to your implementation with the addition of ensuring only 1 default per payment method instance and default can be set during checkout.

DevElCuy’s picture

@recrit, can't wait to see it merged :)

dwkitchen’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Fixed

This has now been included in the 2.x branch

Status: Fixed » Closed (fixed)

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