PluginProbe
Pay with Vipps and MobilePay for WooCommerce / 5.4.3
Pay with Vipps and MobilePay for WooCommerce v5.4.3
6.2.1 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 All 183 releases
woo-vipps / payment / Blocks / Payment / Vipps.class.php

Vipps.class.php in Pay with Vipps and MobilePay for WooCommerce 5.4.3, at payment/Blocks/Payment/Vipps.class.php

74 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Vipps payment gateway implementation for Gutenberg Blocks
4 *
5 * @package WooCommerce/Blocks
6 * @since 3.0.0
7 */
8
9 namespace Automattic\WooCommerce\Blocks\Payments\Integrations;
10
11 final class Vipps extends AbstractPaymentMethodType {
12 private $localized=0;
13 protected $name = 'vipps';
14 protected $payment_method_name = "Vipps";
15
16 public function initialize() {
17 $this->settings = get_option( 'woocommerce_vipps_settings', [] );
18 $this->payment_method_name = \WC_Gateway_Vipps::instance()->get_payment_method_name();
19 }
20
21 // Register this payment method IOK 2020-08-10
22 public static function register() {
23 add_action( 'woocommerce_blocks_payment_method_type_registration',
24 function ($registry) {
25 $registry->register(new static());
26 });
27 }
28
29 public function is_active() {
30 return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN );
31 }
32 public function get_payment_method_script_handles() {
33
34 $version = filemtime(dirname(__FILE__) . "/js/wc-payment-method-vipps.js");
35 $path = plugins_url('js/wc-payment-method-vipps.js', __FILE__);
36 $handle = 'wc-payment-method-vipps';
37 $dependencies = array('wp-hooks', 'vipps-gw');
38
39 wp_register_script($handle, $path, $dependencies,$version,true);
40
41
42 // Will not use wp_set_script_translations yet, it seems to be not fully compatible with Loco Translate etc. Instead use
43 // old-fashioned localize-script IOK 2020-08-11
44 // wp_set_script_translations( 'wc-payment-method-vipps', 'woo-vipps' );
45 // VippsLocale is localized for vipps-gw instead of this, as it seems it does no longer work to do localize-script at this point.
46 // IOK 2022-12-13
47
48 return [ 'wc-payment-method-vipps' ];
49 }
50
51 public function get_express_checkout_button () {
52 $button = \Vipps::instance()->express_checkout_button_shortcode();
53 return $button;
54 }
55 public function show_express_checkout_button () {
56 $gw = \Vipps::instance()->gateway();
57 if (!$gw->cart_supports_express_checkout()) return false;
58 return $gw->show_express_checkout();
59 }
60
61 public function get_payment_method_data() {
62
63 $logo = ($this->payment_method_name == "Vipps") ? plugins_url('../../img/vipps-mark.svg', __FILE__) : plugins_url('../../img/mobilepay-mark.png', __FILE__);
64
65 return [
66 'title' => $this->payment_method_name,
67 'description' => $this->get_setting( 'description' ),
68 'iconsrc' => apply_filters('woo_vipps_block_logo_url', $logo),
69 'show_express_checkout' => $this->show_express_checkout_button(),
70 'expressbutton' => $this->get_express_checkout_button()
71 ];
72 }
73 }
74