After installing commerce_cardonfile, the option is displayed to the user in checkout to save their card even if "Enable Card on File functionality with this payment method using Authorize.Net CIM" hasn't been checked in the commerce_authnet settings page.

Comments

andyg5000’s picture

Project: Commerce Authorize.Net » Commerce Card on File

Module should check to see if any payment gateways have card on file enabled before presenting option to save card for customer.

berdir’s picture

The problem is that this information isn't standardized. So we either define how that setting should be called by default, or this module could actually alter all settings forms, check if it supports card on file and display the settings.

joshmiller’s picture

Status: Active » Needs review
StatusFileSize
new7.18 KB

First stab at this feature.

Things we may want to add...

- An update function that "enables" the module (assuming this would only be disabled if first installed or explicitly turned off).
- Figure out how want to notify people that they must turn it on.

Josh

berdir’s picture

+++ b/commerce_cardonfile.moduleundefined
@@ -225,59 +225,63 @@ function commerce_cardonfile_form_alter(&$form, &$form_state, $form_id) {
+          // Check if the module should be enabled
+          $enabled = variable_get('commerce_cardonfile_enable', FALSE);
+          if ($enabled) {

I think this shouldn't be a global variable_get() option but a payment specific one. Should be possible to extend the standard form I guess and place that setting there if the module supports cardonfile. Then check it there·

I'd also say that it should be enabled by default, because then it works if you enable the module, otherwise you need to edit all payment instances and check the setting.

Last, there should be a "." at the end of the comment :)

+++ b/commerce_cardonfile.moduleundefined
@@ -438,8 +442,8 @@ function commerce_cardonfile_data_save(&$card_data) {
  */
-function commerce_cardonfile_data_delete($card_id) {
+function commerce_cardonfile_data_delete($type,$card_id) {
   db_delete('commerce_card_data')
-    ->condition($type, $id)
+    ->condition($type, $card_id)
     ->execute();

Looks like an unrelated fix, I think there's already an issue for this.

berdir’s picture

Status: Needs review » Needs work
dwkitchen’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Assigned: Unassigned » dwkitchen

Moving forward to 2.x branch. I have identified that it is still there.

hitfactory’s picture

Here's a patch which simply checks $payment_method['settings'] instead of $payment_method.

dwkitchen’s picture

Status: Needs work » Fixed

Had it on my radar to fix, simple in the end. Thanks for the patch

balintbrews’s picture

Priority: Normal » Critical
Status: Fixed » Needs review
StatusFileSize
new1.28 KB

It seems this patch breaks the detection of Card on File-capable payment gateways. Checking the settings key inside the payment method array means that the defined callbacks are not detected. Moving them under the settings key in hook_commerce_payment_method_info() doesn't help either: commerce_payment_method_instance_load() injects the settings specific to the context of the payment method instance under the same key, but it initiates an empty array, so all the specified callbacks for Card on File would be gone.

My suggestion is not to modify _commerce_cardonfile_capable_payment_method_check() for this purpose, since it's only meant to check if a payment method is CoF-capable. Let's change the payment form altering instead, where we can check the settings of the payment gateway instance.

joshmiller’s picture

Patch applied, checkbox showed back up for my card on file form :D

dwkitchen’s picture

Status: Needs review » Needs work

I have committed the patch to fix the regression but want to look at those tick boxes again.