summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWesley Jones2015-10-20 06:26:33 (GMT)
committerWesley Jones2015-10-20 06:26:33 (GMT)
commitc47a8fdc15053b983e487aa56fbedfb081786c9d (patch)
tree433aa258803490716ee4a86cf0679aa43f8a31bc
parentc73a88a5c38606ab460f3890b71df819dbb38885 (diff)
Updating paypal code during cron run to properly cancel the license
-rw-r--r--commerce_license_billing_paypal.module24
1 files changed, 17 insertions, 7 deletions
diff --git a/commerce_license_billing_paypal.module b/commerce_license_billing_paypal.module
index fb9df9e..248dbb0 100644
--- a/commerce_license_billing_paypal.module
+++ b/commerce_license_billing_paypal.module
@@ -80,18 +80,28 @@ function commerce_license_billing_paypal_cron() {
// Need to catch these possible values: Pending, Cancelled, Suspended, Expired.
if ($response['STATUS'] == 'Cancelled' || $response['STATUS'] == 'Pending' ||
$response['STATUS'] == 'Suspended' || $response['STATUS'] == 'Expired') {
- $license->revoke();
+
+ // Suspend the license.
+ $license->wrapper->status->set(COMMERCE_LICENSE_SUSPENDED);
+ $license->save();
+
+ // set cycle status to zero and save the cycle
+ $billing_cycle = commerce_license_billing_get_license_billing_cycle($license);
+ $billing_cycle->status = 0;
+ $billing_cycle->save();
}
else {
// Do nothing since customer's paypal account is still in good standing.
}
}// if response = success
- watchdog(
- 'commerce_license_billing_paypal',
- 'The API call to Paypal to determine the status of the paypal account associated with license id %license_id was not successful.',
- array('%license_id' => $license->license_id),
- WATCHDOG_ERROR
- );
+ else {
+ watchdog(
+ 'commerce_license_billing_paypal',
+ 'The API call to Paypal to determine the status of the paypal account associated with license id %license_id was not successful.',
+ array('%license_id' => $license->license_id),
+ WATCHDOG_ERROR
+ );
+ }
} // if payment_method
} // foreach EFQ results
} // if EFQ results