|
3 | 3 | * Plugin Name: PostFinance Checkout |
4 | 4 | * Plugin URI: https://wordpress.org/plugins/woo-postfinancecheckout |
5 | 5 | * Description: Process WooCommerce payments with PostFinance Checkout. |
6 | | - * Version: 2.1.14 |
| 6 | + * Version: 2.1.15 |
7 | 7 | * License: Apache2 |
8 | 8 | * License URI: http://www.apache.org/licenses/LICENSE-2.0 |
9 | 9 | * Author: wallee AG |
10 | 10 | * Author URI: https://www.wallee.com |
11 | 11 | * Requires at least: 4.7 |
12 | 12 | * Tested up to: 6.2 |
13 | 13 | * WC requires at least: 3.0.0 |
14 | | - * WC tested up to: 7.6.1 |
| 14 | + * WC tested up to: 7.7.0 |
15 | 15 | * |
16 | 16 | * Text Domain: postfinancecheckout |
17 | 17 | * Domain Path: /languages/ |
@@ -39,14 +39,14 @@ final class WooCommerce_PostFinanceCheckout { |
39 | 39 | const CK_INTEGRATION = 'wc_postfinancecheckout_integration'; |
40 | 40 | const CK_ORDER_REFERENCE = 'wc_postfinancecheckout_order_reference'; |
41 | 41 | const CK_ENFORCE_CONSISTENCY = 'wc_postfinancecheckout_enforce_consistency'; |
42 | | - const WC_MAXIMUM_VERSION = '7.6.1'; |
| 42 | + const WC_MAXIMUM_VERSION = '7.7.0'; |
43 | 43 |
|
44 | 44 | /** |
45 | 45 | * WooCommerce PostFinanceCheckout version. |
46 | 46 | * |
47 | 47 | * @var string |
48 | 48 | */ |
49 | | - private $version = '2.1.14'; |
| 49 | + private $version = '2.1.15'; |
50 | 50 |
|
51 | 51 | /** |
52 | 52 | * The single instance of the class. |
@@ -158,6 +158,14 @@ protected function init_hooks() { |
158 | 158 | ) |
159 | 159 | ); |
160 | 160 |
|
| 161 | + add_action( |
| 162 | + 'woocommerce_thankyou', |
| 163 | + array( |
| 164 | + $this, |
| 165 | + 'secure_redirect_order_confirmed', |
| 166 | + ) |
| 167 | + ); |
| 168 | + |
161 | 169 | add_action( |
162 | 170 | 'plugins_loaded', |
163 | 171 | array( |
@@ -205,6 +213,27 @@ protected function init_hooks() { |
205 | 213 | ); |
206 | 214 | } |
207 | 215 |
|
| 216 | + |
| 217 | + /** |
| 218 | + * Secirity check in the thank you page. |
| 219 | + * |
| 220 | + * Note: If for some reason order status is still pending, it will redirect you to the payment form. |
| 221 | + * |
| 222 | + */ |
| 223 | + |
| 224 | + public function secure_redirect_order_confirmed($order_id) { |
| 225 | + $order = wc_get_order( $order_id ); |
| 226 | + $wc_service_transaction = WC_PostFinanceCheckout_Service_Transaction::instance(); |
| 227 | + $sdk_service_transaction = new \PostFinanceCheckout\Sdk\Service\TransactionService(WC_PostFinanceCheckout_Helper::instance()->get_api_client()); |
| 228 | + $wc_transaction_info = WC_PostFinanceCheckout_Entity_Transaction_Info::load_by_order_id($order_id); |
| 229 | + $state = $sdk_service_transaction->read(get_option(self::CK_SPACE_ID), $wc_transaction_info->get_transaction_id())->getState(); |
| 230 | + |
| 231 | + if ($state == \PostFinanceCheckout\Sdk\Model\TransactionState::CONFIRMED) { |
| 232 | + wp_redirect($wc_service_transaction->get_payment_page_url(get_option(self::CK_SPACE_ID), $wc_transaction_info->get_transaction_id())); |
| 233 | + exit; |
| 234 | + } |
| 235 | + } |
| 236 | + |
208 | 237 | /** |
209 | 238 | * Load Localization files. |
210 | 239 | * |
|
0 commit comments