| @@ -14,8 +14,9 @@ | ||
| 14 | 14 | protected $name = 'vipps_card'; |
| 15 | 15 | protected $payment_method_name = ""; |
| 16 | 16 | protected $description = ""; |
| 17 | 17 | |
| 18 | + /** Read card gateway settings and labels for the Blocks registration. */ | |
| 18 | 19 | public function initialize() { |
| 19 | 20 | $gw = \WC_Gateway_VippsCard::instance(); |
| 20 | 21 | $this->settings = get_option( 'woocommerce_vipps_card_settings', [] ); |
| 21 | 22 | $this->payment_method_name = $gw->get_title(); |
| @@ -22,8 +23,9 @@ | ||
| 22 | 23 | $this->description = $gw->get_option('description'); |
| 23 | 24 | } |
| 24 | 25 | |
| 25 | 26 | // Register this payment method IOK 2020-08-10 |
| 27 | + /** Register the card integration separately from the Vipps widget method. */ | |
| 26 | 28 | public static function register() { |
| 27 | 29 | add_action( 'woocommerce_blocks_payment_method_type_registration', |
| 28 | 30 | function ($registry) { |
| 29 | 31 | $registry->register(new static()); |
| @@ -29,11 +31,13 @@ | ||
| 29 | 31 | $registry->register(new static()); |
| 30 | 32 | }); |
| 31 | 33 | } |
| 32 | 34 | |
| 35 | + /** Only offer the method when the card gateway is enabled. */ | |
| 33 | 36 | public function is_active() { |
| 34 | 37 | return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN ); |
| 35 | 38 | } |
| 39 | + /** Load the card presentation component after shared gateway code, with cache invalidation. */ | |
| 36 | 40 | public function get_payment_method_script_handles() { |
| 37 | 41 | |
| 38 | 42 | $version = filemtime(dirname(__FILE__) . "/js/wc-payment-method-vipps-card.js"); |
| 39 | 43 | $path = plugins_url('js/wc-payment-method-vipps-card.js', __FILE__); |
| @@ -51,8 +55,12 @@ | ||
| 51 | 55 | |
| 52 | 56 | return [ 'wc-payment-method-vipps-card' ]; |
| 53 | 57 | } |
| 54 | 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 | + */ | |
| 55 | 63 | public function get_payment_method_data() { |
| 56 | 64 | $logo = $src = plugins_url('../../img/cclogos.svg',__FILE__); |
| 57 | 65 | |
| 58 | 66 | return [ |
| @@ -61,5 +69,4 @@ | ||
| 61 | 69 | 'iconsrc' => apply_filters('woo_vipps_card_block_logo_url', $logo) |
| 62 | 70 | ]; |
| 63 | 71 | } |
| 64 | 72 | } |
| 65 | - | |