From 123bcc57942dbe877ff431d8f7b3ac1c2e520bbf Mon Sep 17 00:00:00 2001 From: Karson Nichols <38633639+nicholsk18@users.noreply.github.com> Date: Wed, 10 Jul 2024 11:51:18 +0000 Subject: [PATCH] dont renew if not active and ignore cancel credit if past cancel window --- thesslstore_module.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/thesslstore_module.php b/thesslstore_module.php index 2fc3226..8ee5fba 100644 --- a/thesslstore_module.php +++ b/thesslstore_module.php @@ -1865,6 +1865,19 @@ public function renewService($package, $service, $parent_package=null, $parent_s $order_status_response = $this->getSSLOrderStatus($old_thesslstore_order_id); + if($order_status_response->OrderStatus->MajorStatus != 'Active') { + $this->log("RenewService Cron | $old_thesslstore_order_id", serialize($order_status_response), "output", false); + $this->Input->setErrors(array('api' => array('internal' => 'Previous certificate was not activated'))); + return; + } + else if (empty($order_status_response->CertificateEndDateInUTC)) { + // if not active it might not be EV + // Check end date + $this->log("RenewService Cron | $old_thesslstore_order_id", serialize($order_status_response), "output", false); + $this->Input->setErrors(array('api' => array('internal' => 'Previous certificate was not activated'))); + return; + } + //Placed Invite order first $api = $this->getApi(); @@ -2121,7 +2134,17 @@ public function cancelService($package, $service, $parent_package=null, $parent_ $this->log($this->api_partner_code . "|ssl-refund-request", serialize($refundReq), "input", true); $refundRes = $api->order_refundrequest($refundReq); - if(!$refundRes->AuthResponse->Message[0]) + + $max_to_refund_date = date('Y-m-d',strtotime('+30 days',strtotime($refundRes->PurchaseDate))); + $current_day = date('Y-m-d'); + + // if we past the return window ignore errors + // so blesta correctly marks this services cancelled + if ($current_day > $max_to_refund_date) { + return; + } + + if(!isset($refundRes->AuthResponse->Message[0])) { $errorMessage=$refundRes->AuthResponse->Message; }