diff --git a/commerce_license_billing_paypal.module b/commerce_license_billing_paypal.module index 8c3bee6..81b19f5 100644 --- a/commerce_license_billing_paypal.module +++ b/commerce_license_billing_paypal.module @@ -46,13 +46,12 @@ function commerce_license_billing_paypal_cron() { if (!empty($results['commerce_license'])) { foreach (array_keys($results['commerce_license']) as $license_id) { - $license = entity_load_single('commerce_license', $license_id); // Find the line item for this license. $query = new EntityFieldQuery(); $query ->entityCondition('entity_type', 'commerce_line_item') - ->fieldCondition('commerce_license', 'target_id', $license->license_id, '='); + ->fieldCondition('commerce_license', 'target_id', $license_id, '='); $results = $query->execute(); $line_item_id = key($results['commerce_line_item']); @@ -81,6 +80,8 @@ function commerce_license_billing_paypal_cron() { if ($response['STATUS'] == 'Cancelled' || $response['STATUS'] == 'Pending' || $response['STATUS'] == 'Suspended' || $response['STATUS'] == 'Expired') { + $license = entity_load_single('commerce_license', $license_id); + // Suspend the license. $license->wrapper->status->set(COMMERCE_LICENSE_REVOKED); $license->save();