Changeset 3322376
- Timestamp:
- 07/04/2025 02:12:17 PM (9 months ago)
- Location:
- sepay-gateway
- Files:
-
- 5 deleted
- 4 edited
- 11 copied
-
tags/1.1.15 (copied) (copied from sepay-gateway/trunk)
-
tags/1.1.15/assets/css/sepay.css (copied) (copied from sepay-gateway/trunk/assets/css/sepay.css)
-
tags/1.1.15/assets/js/block/checkout.js (copied) (copied from sepay-gateway/trunk/assets/js/block/checkout.js)
-
tags/1.1.15/assets/js/sepay.js (copied) (copied from sepay-gateway/trunk/assets/js/sepay.js)
-
tags/1.1.15/css (deleted)
-
tags/1.1.15/imgs (deleted)
-
tags/1.1.15/includes/block (deleted)
-
tags/1.1.15/includes/class-sepay-woocommerce-block-checkout.php (deleted)
-
tags/1.1.15/includes/class-wc-gateway-sepay.php (copied) (copied from sepay-gateway/trunk/includes/class-wc-gateway-sepay.php) (8 diffs)
-
tags/1.1.15/includes/class-wc-sepay-api.php (copied) (copied from sepay-gateway/trunk/includes/class-wc-sepay-api.php) (11 diffs)
-
tags/1.1.15/includes/class-wc-sepay-blocks-support.php (copied) (copied from sepay-gateway/trunk/includes/class-wc-sepay-blocks-support.php)
-
tags/1.1.15/includes/views (copied) (copied from sepay-gateway/trunk/includes/views)
-
tags/1.1.15/includes/views/oauth2-connect.php (copied) (copied from sepay-gateway/trunk/includes/views/oauth2-connect.php)
-
tags/1.1.15/js (deleted)
-
tags/1.1.15/readme.txt (copied) (copied from sepay-gateway/trunk/readme.txt) (1 diff)
-
tags/1.1.15/sepay-gateway.php (copied) (copied from sepay-gateway/trunk/sepay-gateway.php) (1 diff)
-
trunk/includes/class-wc-gateway-sepay.php (modified) (8 diffs)
-
trunk/includes/class-wc-sepay-api.php (modified) (11 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/sepay-gateway.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sepay-gateway/tags/1.1.15/includes/class-wc-gateway-sepay.php
r3306117 r3322376 90 90 } 91 91 } 92 92 93 93 if (isset($_GET['disconnect']) && isset($_GET['_wpnonce'])) { 94 94 if (wp_verify_nonce($_GET['_wpnonce'], 'sepay_disconnect') && current_user_can('manage_woocommerce')) { … … 115 115 if ($this->cached_bank_account_data === null && $this->get_option('bank_account') && $this->api->is_connected()) { 116 116 $this->cached_bank_account_data = $this->api->get_bank_account($this->get_option('bank_account')); 117 117 118 118 if ($this->cached_bank_account_data) { 119 119 $settings = get_option('woocommerce_sepay_settings', []); … … 189 189 } 190 190 191 $prefix_data = array_values(array_filter($pay_code_prefixes, function ($prefix) use ($pay_code_prefix) {191 $prefix_data = array_values(array_filter($pay_code_prefixes, function ($prefix) use ($pay_code_prefix) { 192 192 return $prefix['prefix'] === $pay_code_prefix; 193 193 })); … … 262 262 { 263 263 if (! $this->api->is_connected()) { 264 $this->init_old_form_fields(); 264 try { 265 $this->api->refresh_token(); 266 } catch (Exception $e) { 267 WC_Admin_Settings::add_error('Không thể làm mới token. Vui lòng thử lại sau.'); 268 $this->init_old_form_fields(); 269 return; 270 } 271 272 $this->init_form_fields(); 265 273 return; 266 274 } … … 521 529 $statuses = wc_get_order_statuses(); 522 530 $result = []; 523 531 524 532 foreach ($statuses as $key => $label) { 525 533 $result[str_replace('wc-', '', $key)] = $label; … … 561 569 'sepay_reconnect' 562 570 ); 563 571 564 572 $disconnect_url = wp_nonce_url( 565 573 admin_url('admin.php?page=wc-settings&tab=checkout§ion=sepay&disconnect=1'), … … 604 612 $order = wc_get_order($order_id); 605 613 $remark = $this->get_remark($order_id); 606 614 607 615 if ($this->api->is_connected() && $this->cached_bank_account_data) { 608 616 $bank_account_id = $this->get_option('bank_account'); … … 616 624 $account_number = $this->get_option('bank_account_number'); 617 625 $account_holder_name = $this->get_option('bank_account_holder'); 618 626 619 627 $bank_select = $this->get_option('bank_select'); 620 628 $bank_info = $this->get_bank_data()[$bank_select]; 621 629 622 630 if ($bank_info) { 623 631 $bank_bin = $bank_info['bin']; 624 632 $bank_logo_url = sprintf('https://my.sepay.vn/assets/images/banklogo/%s.png', strtolower($bank_info['short_name'])); 625 633 626 634 if ($this->bank_name_display_type == "brand_name") { 627 635 $displayed_bank_name = $bank_info['short_name']; -
sepay-gateway/tags/1.1.15/includes/class-wc-sepay-api.php
r3322085 r3322376 38 38 public function get_bank_accounts($cache = true) 39 39 { 40 if (!$this->is_connected()) { 41 return null; 42 } 43 40 44 if ($cache) { 41 45 $bank_accounts = get_transient('wc_sepay_bank_accounts'); … … 64 68 public function get_company_info($cache = true) 65 69 { 70 if (!$this->is_connected()) { 71 return null; 72 } 73 66 74 if ($cache) { 67 75 $company = get_transient('wc_sepay_company'); … … 122 130 public function update_company_configurations($data) 123 131 { 132 if (!$this->is_connected()) { 133 return null; 134 } 135 124 136 try { 125 137 $response = $this->make_request('company/configurations', 'PATCH', $data); … … 143 155 public function make_request($endpoint, $method = 'GET', $data = null) 144 156 { 157 if (!$this->is_connected()) { 158 return null; 159 } 160 145 161 try { 146 162 $access_token = $this->get_access_token(); … … 266 282 public function is_connected() 267 283 { 268 return !empty(get_option('wc_sepay_access_token')) && !empty(get_option('wc_sepay_refresh_token')); 284 return !empty(get_option('wc_sepay_access_token')) 285 && !empty(get_option('wc_sepay_refresh_token')) 286 && get_option('wc_sepay_token_expires') > time() + 300; 269 287 } 270 288 … … 293 311 public function get_webhooks($data = null) 294 312 { 313 if (!$this->is_connected()) { 314 return []; 315 } 316 295 317 try { 296 318 $response = $this->make_request('webhooks', 'GET', $data); … … 304 326 public function get_webhook($id) 305 327 { 328 if (!$this->is_connected()) { 329 return null; 330 } 331 332 $cache = get_transient('wc_sepay_webhook_' . $id); 333 334 if ($cache) { 335 return $cache; 336 } 337 306 338 try { 307 339 $response = $this->make_request('webhooks/' . $id); 340 341 if ($response['data']) { 342 set_transient('wc_sepay_webhook_' . $id, $response['data'], 3600); 343 } 344 308 345 return $response['data'] ?? null; 309 346 } catch (Exception $e) { … … 314 351 public function create_webhook($bank_account_id, $webhook_id = null) 315 352 { 353 if (!$this->is_connected()) { 354 return null; 355 } 356 316 357 $api_key = wp_generate_password(32, false); 317 358 … … 363 404 public function get_bank_sub_accounts($bank_account_id, $cache = true) 364 405 { 406 if (!$this->is_connected()) { 407 return []; 408 } 409 365 410 if ($cache) { 366 411 $sub_accounts = get_transient('wc_sepay_bank_sub_accounts_' . $bank_account_id); … … 389 434 public function update_webhook($webhook_id, $data) 390 435 { 436 if (!$this->is_connected()) { 437 return null; 438 } 439 391 440 try { 392 441 $response = $this->make_request('webhooks/' . $webhook_id, 'PATCH', $data); … … 400 449 public function get_user_info() 401 450 { 451 if (!$this->is_connected()) { 452 return null; 453 } 454 402 455 $user_info = get_transient('wc_sepay_user_info'); 403 456 -
sepay-gateway/tags/1.1.15/readme.txt
r3322085 r3322376 4 4 - Tags: woocommerce, payment gateway, vietqr, ngan hang, thanh toan 5 5 - Requires WooCommerce at least: 2.1 6 - Stable Tag: 1.1.1 47 - Version: 1.1.1 46 - Stable Tag: 1.1.15 7 - Version: 1.1.15 8 8 - Tested up to: 6.6 9 9 - Requires at least: 5.6 -
sepay-gateway/tags/1.1.15/sepay-gateway.php
r3322085 r3322376 6 6 * Author: SePay Team 7 7 * Author URI: https://sepay.vn/ 8 * Version: 1.1.1 48 * Version: 1.1.15 9 9 * Requires Plugins: woocommerce 10 10 * Text Domain: sepay-gateway -
sepay-gateway/trunk/includes/class-wc-gateway-sepay.php
r3306117 r3322376 90 90 } 91 91 } 92 92 93 93 if (isset($_GET['disconnect']) && isset($_GET['_wpnonce'])) { 94 94 if (wp_verify_nonce($_GET['_wpnonce'], 'sepay_disconnect') && current_user_can('manage_woocommerce')) { … … 115 115 if ($this->cached_bank_account_data === null && $this->get_option('bank_account') && $this->api->is_connected()) { 116 116 $this->cached_bank_account_data = $this->api->get_bank_account($this->get_option('bank_account')); 117 117 118 118 if ($this->cached_bank_account_data) { 119 119 $settings = get_option('woocommerce_sepay_settings', []); … … 189 189 } 190 190 191 $prefix_data = array_values(array_filter($pay_code_prefixes, function ($prefix) use ($pay_code_prefix) {191 $prefix_data = array_values(array_filter($pay_code_prefixes, function ($prefix) use ($pay_code_prefix) { 192 192 return $prefix['prefix'] === $pay_code_prefix; 193 193 })); … … 262 262 { 263 263 if (! $this->api->is_connected()) { 264 $this->init_old_form_fields(); 264 try { 265 $this->api->refresh_token(); 266 } catch (Exception $e) { 267 WC_Admin_Settings::add_error('Không thể làm mới token. Vui lòng thử lại sau.'); 268 $this->init_old_form_fields(); 269 return; 270 } 271 272 $this->init_form_fields(); 265 273 return; 266 274 } … … 521 529 $statuses = wc_get_order_statuses(); 522 530 $result = []; 523 531 524 532 foreach ($statuses as $key => $label) { 525 533 $result[str_replace('wc-', '', $key)] = $label; … … 561 569 'sepay_reconnect' 562 570 ); 563 571 564 572 $disconnect_url = wp_nonce_url( 565 573 admin_url('admin.php?page=wc-settings&tab=checkout§ion=sepay&disconnect=1'), … … 604 612 $order = wc_get_order($order_id); 605 613 $remark = $this->get_remark($order_id); 606 614 607 615 if ($this->api->is_connected() && $this->cached_bank_account_data) { 608 616 $bank_account_id = $this->get_option('bank_account'); … … 616 624 $account_number = $this->get_option('bank_account_number'); 617 625 $account_holder_name = $this->get_option('bank_account_holder'); 618 626 619 627 $bank_select = $this->get_option('bank_select'); 620 628 $bank_info = $this->get_bank_data()[$bank_select]; 621 629 622 630 if ($bank_info) { 623 631 $bank_bin = $bank_info['bin']; 624 632 $bank_logo_url = sprintf('https://my.sepay.vn/assets/images/banklogo/%s.png', strtolower($bank_info['short_name'])); 625 633 626 634 if ($this->bank_name_display_type == "brand_name") { 627 635 $displayed_bank_name = $bank_info['short_name']; -
sepay-gateway/trunk/includes/class-wc-sepay-api.php
r3322085 r3322376 38 38 public function get_bank_accounts($cache = true) 39 39 { 40 if (!$this->is_connected()) { 41 return null; 42 } 43 40 44 if ($cache) { 41 45 $bank_accounts = get_transient('wc_sepay_bank_accounts'); … … 64 68 public function get_company_info($cache = true) 65 69 { 70 if (!$this->is_connected()) { 71 return null; 72 } 73 66 74 if ($cache) { 67 75 $company = get_transient('wc_sepay_company'); … … 122 130 public function update_company_configurations($data) 123 131 { 132 if (!$this->is_connected()) { 133 return null; 134 } 135 124 136 try { 125 137 $response = $this->make_request('company/configurations', 'PATCH', $data); … … 143 155 public function make_request($endpoint, $method = 'GET', $data = null) 144 156 { 157 if (!$this->is_connected()) { 158 return null; 159 } 160 145 161 try { 146 162 $access_token = $this->get_access_token(); … … 266 282 public function is_connected() 267 283 { 268 return !empty(get_option('wc_sepay_access_token')) && !empty(get_option('wc_sepay_refresh_token')); 284 return !empty(get_option('wc_sepay_access_token')) 285 && !empty(get_option('wc_sepay_refresh_token')) 286 && get_option('wc_sepay_token_expires') > time() + 300; 269 287 } 270 288 … … 293 311 public function get_webhooks($data = null) 294 312 { 313 if (!$this->is_connected()) { 314 return []; 315 } 316 295 317 try { 296 318 $response = $this->make_request('webhooks', 'GET', $data); … … 304 326 public function get_webhook($id) 305 327 { 328 if (!$this->is_connected()) { 329 return null; 330 } 331 332 $cache = get_transient('wc_sepay_webhook_' . $id); 333 334 if ($cache) { 335 return $cache; 336 } 337 306 338 try { 307 339 $response = $this->make_request('webhooks/' . $id); 340 341 if ($response['data']) { 342 set_transient('wc_sepay_webhook_' . $id, $response['data'], 3600); 343 } 344 308 345 return $response['data'] ?? null; 309 346 } catch (Exception $e) { … … 314 351 public function create_webhook($bank_account_id, $webhook_id = null) 315 352 { 353 if (!$this->is_connected()) { 354 return null; 355 } 356 316 357 $api_key = wp_generate_password(32, false); 317 358 … … 363 404 public function get_bank_sub_accounts($bank_account_id, $cache = true) 364 405 { 406 if (!$this->is_connected()) { 407 return []; 408 } 409 365 410 if ($cache) { 366 411 $sub_accounts = get_transient('wc_sepay_bank_sub_accounts_' . $bank_account_id); … … 389 434 public function update_webhook($webhook_id, $data) 390 435 { 436 if (!$this->is_connected()) { 437 return null; 438 } 439 391 440 try { 392 441 $response = $this->make_request('webhooks/' . $webhook_id, 'PATCH', $data); … … 400 449 public function get_user_info() 401 450 { 451 if (!$this->is_connected()) { 452 return null; 453 } 454 402 455 $user_info = get_transient('wc_sepay_user_info'); 403 456 -
sepay-gateway/trunk/readme.txt
r3322085 r3322376 4 4 - Tags: woocommerce, payment gateway, vietqr, ngan hang, thanh toan 5 5 - Requires WooCommerce at least: 2.1 6 - Stable Tag: 1.1.1 47 - Version: 1.1.1 46 - Stable Tag: 1.1.15 7 - Version: 1.1.15 8 8 - Tested up to: 6.6 9 9 - Requires at least: 5.6 -
sepay-gateway/trunk/sepay-gateway.php
r3322085 r3322376 6 6 * Author: SePay Team 7 7 * Author URI: https://sepay.vn/ 8 * Version: 1.1.1 48 * Version: 1.1.15 9 9 * Requires Plugins: woocommerce 10 10 * Text Domain: sepay-gateway
Note: See TracChangeset
for help on using the changeset viewer.