PluginProbe
Pay with Vipps and MobilePay for WooCommerce / trunk
Pay with Vipps and MobilePay for WooCommerce vtrunk
6.2.0 6.1.10 6.1.9 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1.0 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 6.0.0 5.4.3 5.4.2 5.4.1 5.4.0 5.3.4 trunk 1.10.0 All 182 releases
woo-vipps / payment / payment.php

payment.php in Pay with Vipps and MobilePay for WooCommerce trunk, at payment/payment.php

87 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 This file is part of the plugin Pay with Vipps and MobilePay for WooCommerce
4 Copyright (c) 2019 WP-Hosting AS
5
6 MIT License
7
8 Copyright (c) 2019 WP-Hosting AS
9
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in all
18 copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 SOFTWARE.
27
28 */
29
30 if ( ! defined( 'ABSPATH' ) ) {
31 exit; // Exit if accessed directly
32 }
33
34 // Report version externally
35 define('WOO_VIPPS_VERSION', '6.2.0');
36
37 define( 'WC_VIPPS_PAYMENT_MAIN_FILE', __FILE__ );
38
39 // Legacy way of starting test mode - please use developer- and test-modes from now on. IOK 2019-08-30
40 if ( ! defined('VIPPS_TEST_MODE' )) {
41 define('VIPPS_TEST_MODE', false);
42 }
43
44 /* Instantiate the singleton, stash it in a global and add hooks. IOK 2018-02-07 */
45 require_once(dirname(__FILE__) . '/Vipps.class.php');
46 global $Vipps;
47 $Vipps = Vipps::instance();
48 Vipps::register_hooks();
49
50 /* The QR Code functionality is in its own class for modularity reasons. It is a singleton too. */
51 require_once(dirname(__FILE__) . '/VippsQRCodeController.class.php');
52 VippsQRCodeController::register_hooks();
53
54 /* If Checkout is activated, load its support. It can still be turned on and off. */
55 if (get_option('woo_vipps_checkout_activated', false)) {
56 require_once(dirname(__FILE__) . '/VippsCheckout.class.php');
57 VippsCheckout::register_hooks();
58 }
59
60 // Register built Gutenberg blocks. LP 15.11.2024
61 require_once __DIR__ . '/Blocks/woo-vipps-blocks.php';
62
63 // Helper code for specific plugins, themes etc
64 require_once(dirname(__FILE__) . '/woo-vipps-compatibility.php');
65
66
67 add_action ('before_woocommerce_init', function () {
68 $url = sanitize_text_field($_SERVER['REQUEST_URI']);
69 # This removes cookies for the wc-api callback events for the vipps plugin, to be 100% sure no sessions are restored when they ought not be IOK 2020-07-01
70 # Re-added and modified IOK 2022-06-20
71 if (preg_match('!(wc_gateway_vipps|vipps_shipping_details|vipps-consent-removal)!', $url) && preg_match('!\bwc-api\b!', $url)) {
72 // Disallow woo from setting any cookies for these URLs. This happens very early, so we need to do this a bit awkwardly.
73 add_filter('woocommerce_set_cookie_enabled', function ($val,$name ,$value, $expire, $secure) {
74 return false;
75 }, 999, 5);
76 // Any cookies that was previously set: Remove them.
77 foreach($_COOKIE as $key=>$value) unset($_COOKIE[$key]);
78 }
79 },1);
80
81 // Load the extra Checkout Shipping classes only when necessary
82 add_action( 'woocommerce_shipping_init', function () {
83 if (!class_exists('VippsCheckout_Shipping_Method') && get_option('woo_vipps_checkout_activated', false)) {
84 require_once(dirname(__FILE__) . '/VippsCheckoutShippingMethods.php');
85 }
86 });
87