I have CL Billing integrated with eway and card on file to be able to handle payment processing automatically.

Successful payments are working great, however, I am running into issues with failed payments.

Is there any existing functionality to handle failed payments on a recurring order. Or do I need to add my own custom processing to roll back the license renewal processes that are occurring in commerce_license_billing_cycle_renew_queue_process()?

Thanks!

Comments

bojanz’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

twistedindustries’s picture

I'd like to reopen this issue. I've got Commerce Dunning and although it does try and attempt to recharge cards, it doesn't, revoke the license, or stop the billing cycle from happening. From my testing even if a hard decline happens the system will continue to recreate recurring orders and the users license will still be good. An admin would have to manually go in and make changes. If there were just some simple conditions to commerce_license_billing_generate_recurring_order or maybe a hook to allow developers to only allow orders with a certain order status to be used to generate a recurring order. A way to then revoke the license would then fall onto the Commerce License devs.

twistedindustries’s picture

Status: Closed (fixed) » Active
janvonmulert’s picture

Hi I have just run into a similar problem, and Im glad Im not alone!

When I used the dunning test module to test dunning, at the end of the dunning cycle, the order was set to past due. The corresponding 'recurring: open', order was still there. The license still has status 'active'.

My license is a remote one, so a remote service needs to be notified (via the license's synchronise function) when the licenses status is set to 'expired' or 'revoked'. When you manually revoke a licence or when it expires, that licenses sync status is set to 'COMMERCE_LICENSE_NEEDS_SYNC' (in addition to its status being set to 'expired' or 'revoked'), so the synchronise function gets called. What I'm trying to figure out is how to make this happen when the order gets set to past due. Maybe I should be doing this with rules or maybe there is a hook I can use?

Im not sure if this should be in the issue queue for commerce license billing, commerce license or commerce dunning. Any suggestions appreciated! Ill report back if I figure something out.

janvonmulert’s picture

I have a solution, there is an event provided by commerce dunning called "After dunning cycle ended", that can trigger a rule to revoke the license on the order. I noticed that commerce license has a rule to activate all licenses on an order, but not a rule to revoke them, so I made a rules action based on that one that can be placed in a custom module.

<?php
/**
 * Implements hook_rules_action_info().
 */
function mymodule_rules_action_info() {
  $actions['mymodule_revoke_licenses_action'] = array(
    'label' => t('Revoke an orders licenses'),
    'parameter' => array(
      'commerce_order' => array(
        'type' => 'commerce_order',
        'label' => t('Order'),
      ),
    ),
    'group' => t('Commerce License'),
    'callbacks' => array(
      'execute' => 'mymodule_revoke_licenses_action',
    ),
  );
  return $actions;
}

function mymodule_revoke_licenses_action($order){
  $licenses = commerce_license_get_order_licenses($order);
  foreach ($licenses as $license) {
    $license->revoke();
  }
}

then use a rule to fire this action after the dunning cycle ends.

{ "rules_revoke_licenses_at_end_of_dunning_cycle" : {
    "LABEL" : "Revoke licenses at end of dunning cycle",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "mymodule", "commerce_dunning" ],
    "ON" : { "commerce_dunning_cycle_end" : [] },
    "DO" : [
      { "mymodule_revoke_licenses_action" : { "commerce_order" : [ "order" ] } }
    ]
  }
}

Obviously replace 'mymodule' with the name of your custom module.

According to here https://www.drupal.org/node/2218153, once a license is set to revoked the billing cycle should stop renewing.

I think this action should be part of commerce license so i will be submitting it there.

wizonesolutions’s picture

@Pharitz: Did you propose that action as a patch to Commerce License in the end? I could review it for you.

vaccinemedia’s picture

@wizonesolutions did this ever get patched into Commerce Licence?

drupov’s picture

Well, this is a bit interesting:

  • the action definition should be a part of commerce_license
  • the exported rule should rather be part of commerce_dunning