| 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 |
public function initialize() { |
| 19 |
$gw = \WC_Gateway_VippsCard::instance(); |
| 20 |
$this->settings = get_option( 'woocommerce_vipps_card_settings', [] ); |
| 21 |
$this->payment_method_name = $gw->get_title(); |
| 22 |
$this->description = $gw->get_option('description'); |
| 23 |
} |
| 24 |
|
| 25 |
// Register this payment method IOK 2020-08-10 |
| 26 |
public static function register() { |
| 27 |
add_action( 'woocommerce_blocks_payment_method_type_registration', |
| 28 |
function ($registry) { |
| 29 |
$registry->register(new static()); |
| 30 |
}); |
| 31 |
} |
| 32 |
|
| 33 |
public function is_active() { |
| 34 |
return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN ); |
| 35 |
} |
| 36 |
public function get_payment_method_script_handles() { |
| 37 |
|
| 38 |
$version = filemtime(dirname(__FILE__) . "/js/wc-payment-method-vipps-card.js"); |
| 39 |
$path = plugins_url('js/wc-payment-method-vipps-card.js', __FILE__); |
| 40 |
$handle = 'wc-payment-method-vipps-card'; |
| 41 |
$dependencies = array('wp-hooks', 'vipps-gw'); |
| 42 |
|
| 43 |
wp_register_script($handle, $path, $dependencies,$version,true); |
| 44 |
|
| 45 |
|
| 46 |
// Will not use wp_set_script_translations yet, it seems to be not fully compatible with Loco Translate etc. Instead use |
| 47 |
// old-fashioned localize-script IOK 2020-08-11 |
| 48 |
// wp_set_script_translations( 'wc-payment-method-vipps', 'woo-vipps' ); |
| 49 |
// VippsLocale is localized for vipps-gw instead of this, as it seems it does no longer work to do localize-script at this point. |
| 50 |
// IOK 2022-12-13 |
| 51 |
|
| 52 |
return [ 'wc-payment-method-vipps-card' ]; |
| 53 |
} |
| 54 |
|
| 55 |
public function get_payment_method_data() { |
| 56 |
$logo = $src = plugins_url('../../img/cclogos.svg',__FILE__); |
| 57 |
|
| 58 |
return [ |
| 59 |
'title' => $this->payment_method_name, |
| 60 |
'description' => $this->description, |
| 61 |
'iconsrc' => apply_filters('woo_vipps_card_block_logo_url', $logo) |
| 62 |
]; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
|