Changeset 2711177
- Timestamp:
- 04/18/2022 06:06:27 PM (4 years ago)
- Location:
- drip-payments/trunk
- Files:
-
- 2 edited
-
drip-payments.php (modified) (5 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
drip-payments/trunk/drip-payments.php
r2708634 r2711177 4 4 * Description: Forneça a Drip como opção de pagamento para pedidos do WooCommerce. 5 5 * Author: Drip 6 * Version: 0.1.3 06 * Version: 0.1.31 7 7 */ 8 8 9 9 function drip_payments_show_plugin_version() { 10 return '0.1.3 0';10 return '0.1.31'; 11 11 } 12 12 … … 158 158 } 159 159 160 private function create_date_from_cache($date) { 161 return DateTime::createFromFormat('Y-m-d H:i:s', $date, new DateTimeZone('America/Sao_Paulo')); 162 } 163 164 private function get_actual_datetime() { 165 return new DateTime('now', new DateTimeZone('America/Sao_Paulo')); 166 } 167 168 private function create_cache_expiration_date() { 169 return date_format($this->get_actual_datetime()->add(DateInterval::createFromDateString('1 day')), 'Y-m-d 00:05:00'); 170 } 171 160 172 public function check_is_enabled() 161 173 { … … 166 178 167 179 $server_status = (array) json_decode(get_option('drip_payments_server_status')); 168 $now = new DateTime('now', new DateTimeZone('America/Sao_Paulo')); 169 $expiration_time = new Datetime($server_status['expiration']->date); 170 180 $now = $this->get_actual_datetime(); 181 $expiration_time = $this->create_date_from_cache($server_status['expiration']); 171 182 if(count($server_status) > 1 && $expiration_time > $now) { 172 183 if($server_status['offline']) { … … 190 201 191 202 if (strlen($this->api_key) > 10) { 192 $date = $now->add(DateInterval::createFromDateString('1 day'));193 203 $server_status = json_encode([ 194 204 'offline' => false, 195 205 'online' => true, 196 'expiration' => date_format($date, 'Y-m-d 00:10:00')206 'expiration' => $this->create_cache_expiration_date() 197 207 ]); 198 208 update_option('drip_payments_server_status', $server_status); … … 204 214 public function get_cashback() { 205 215 $actual_cashback = (array) json_decode(get_option('drip_payments_actual_cashback')); 206 $now = new DateTime('now', new DateTimeZone('America/Sao_Paulo')); 207 $expiration_time = new Datetime($actual_cashback['expiration']->date); 208 if(count($actual_cashback) > 1 && $expiration_time > $now) { 216 $expiration_time = $this->create_date_from_cache($actual_cashback['expiration']); 217 if(count($actual_cashback) > 1 && $expiration_time > $this->get_actual_datetime()) { 209 218 return $actual_cashback['value']; 210 219 } 211 $date = $now->add(DateInterval::createFromDateString('1 day'));212 220 $actual_cashback = json_encode([ 213 221 'value' => $this->checkoutRequest->getCashback(), 214 'expiration' => date_format($date, 'Y-m-d 00:10:00')222 'expiration' => $this->create_cache_expiration_date() 215 223 ]); 216 224 update_option('drip_payments_actual_cashback', $actual_cashback); -
drip-payments/trunk/readme.txt
r2708618 r2711177 5 5 Tested up to: 5.9.2 6 6 Requires PHP: 7.0 7 Stable tag: 0.1.3 07 Stable tag: 0.1.31 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.