PluginProbe
Pay with Vipps and MobilePay for WooCommerce / 6.3.0
Pay with Vipps and MobilePay for WooCommerce v6.3.0
6.2.6 6.3.0 6.2.5 6.2.4 6.2.3 6.2.2 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 All 189 releases
woo-vipps / payment / Blocks / Payment / VippsCard.class.php

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

73 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
10 namespace Automattic\WooCommerce\Blocks\Payments\Integrations;
11
12 final class VippsCard extends AbstractPaymentMethodType {
13 private $localized=0;
14 protected $name = 'vipps_card';
15 protected $payment_method_name = "";
16 protected $description = "";
17
18 /** Read card gateway settings and labels for the Blocks registration. */
19 public function initialize() {
20 $gw = \WC_Gateway_VippsCard::instance();
21 $this->settings = get_option( 'woocommerce_vipps_card_settings', [] );
22 $this->payment_method_name = $gw->get_title();
23 $this->description = $gw->get_option('description');
24 }
25
26 // Register this payment method IOK 2020-08-10
27 /** Register the card integration separately from the Vipps widget method. */
28 public static function register() {
29 add_action( 'woocommerce_blocks_payment_method_type_registration',
30 function ($registry) {
31 $registry->register(new static());
32 });
33 }
34
35 /** Only offer the method when the card gateway is enabled. */
36 public function is_active() {
37 return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN );
38 }
39 /** Load the card presentation component after shared gateway code, with cache invalidation. */
40 public function get_payment_method_script_handles() {
41
42 $version = filemtime(dirname(__FILE__) . "/js/wc-payment-method-vipps-card.js");
43 $path = plugins_url('js/wc-payment-method-vipps-card.js', __FILE__);
44 $handle = 'wc-payment-method-vipps-card';
45 $dependencies = array('wp-hooks', 'vipps-gw');
46
47 wp_register_script($handle, $path, $dependencies,$version,true);
48
49
50 // Will not use wp_set_script_translations yet, it seems to be not fully compatible with Loco Translate etc. Instead use
51 // old-fashioned localize-script IOK 2020-08-11
52 // wp_set_script_translations( 'wc-payment-method-vipps', 'woo-vipps' );
53 // VippsLocale is localized for vipps-gw instead of this, as it seems it does no longer work to do localize-script at this point.
54 // IOK 2022-12-13
55
56 return [ 'wc-payment-method-vipps-card' ];
57 }
58
59 /**
60 * Supply vipps_card_data to the JS component. Payment processing stays with
61 * WooCommerce's legacy gateway adapter; this class does not take over redirects.
62 */
63 public function get_payment_method_data() {
64 $logo = $src = plugins_url('../../img/cclogos.svg',__FILE__);
65
66 return [
67 'title' => $this->payment_method_name,
68 'description' => $this->description,
69 'iconsrc' => apply_filters('woo_vipps_card_block_logo_url', $logo)
70 ];
71 }
72 }
73