Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.6.1] - 2026-02-16
### Fixed
- Fixed a potential fatal error that could happen in the theme customizer if the gateway was not registered with WooCommerce when getting the block checkout data for the payment method.
- Fixed a compatibility issue with Custom Order Status Manager for WooCommerce in version 4.6.0, caused by changing to registering the gateway with WooCommerce on the init action on priority 10 which happens after the plugin loads available gateways in WooCommerce.

## [2.6.0] - 2026-01-28
### Added
- Added support for manual activation of invoices for payments made with Walley and Klarna invoice methods.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "paytrail-for-woocommerce",
"version": "2.6.0",
"version": "2.6.1",
"description": "Paytrail is a payment gateway that offers 20+ payment methods for Finnish customers.",
"private": true,
"dependencies": {
Expand Down
25 changes: 14 additions & 11 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* Plugin Name: Paytrail for WooCommerce
* Plugin URI: https://github.com/paytrail/paytrail-for-woocommerce
* Description: Paytrail is a payment gateway that offers 20+ payment methods for Finnish customers.
* Version: 2.6.0
* Version: 2.6.1
* Requires at least: 4.9
* Requires Plugins: woocommerce
* Tested up to: 6.9
* Requires PHP: 7.3
* WC requires at least: 3.5
* WC tested up to: 10.4.3
* WC tested up to: 10.5.1
* Author: Paytrail
* Author URI: https://www.paytrail.com/
* Text Domain: paytrail-for-woocommerce
Expand Down Expand Up @@ -176,23 +176,26 @@ function () {
add_action( 'woocommerce_init', array( $this, 'op_lasku_init' ) );

add_action( 'init', array( $this, 'initialize_gateway' ) );
add_filter( 'woocommerce_payment_gateways', array( $this, 'register_gateway' ) );
}

/**
* Initialize the gateway
* Initialize the gateway class to make sure it is loaded and initialized early.
*/
public function initialize_gateway() {
$this->gateway();
}

add_filter(
'woocommerce_payment_gateways',
function ( $gateways ) {
$gateways[] = $this->gateway();
add_action( 'template_redirect', array( $this->gateway, 'on_redirect_to_thankyou_page' ) );
/**
* Register the gateway class with WooCommerce so that it appears in the list of available payment methods in the WooCommerce settings.
*
* @param array $gateways Array of registered gateways.
* @return array
*/
public function register_gateway( $gateways ) {
$gateways[] = $this->gateway();

return $gateways;
}
);
return $gateways;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://www.paytrail.com/
Tags: woocommerce
Requires at least: 4.9
Tested up to: 6.9
Stable tag: 2.6.0
Stable tag: 2.6.1
Requires PHP: 7.3
License: MIT
License URI: https://opensource.org/licenses/MIT
Expand Down Expand Up @@ -55,6 +55,10 @@ Test credentials:
With test credentials, you can test most of the payment methods included in Paytrail’s payment service. You can find the payment method specific credentials needed for testing in Paytrail’s [documentation](https://docs.paytrail.com/#/payment-method-providers).

== Changelog ==
= 2.6.1 =
- Fixed a potential fatal error that could happen in the theme customizer if the gateway was not registered with WooCommerce when getting the block checkout data for the payment method.
- Fixed a compatibility issue with Custom Order Status Manager for WooCommerce in version 4.6.0, caused by changing to registering the gateway with WooCommerce on the init action on priority 10 which happens after the plugin loads available gateways in WooCommerce.

= 2.6.0 =
- Added support for manual activation of invoices for payments made with Walley and Klarna invoice methods.
- Fixed compatibility issue with Visma Pay.
Expand Down
13 changes: 13 additions & 0 deletions src/PaytrailBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,19 @@ public function is_active() {
*/
public function get_payment_method_data( $context = null ) {
$gateway = $this->get_gateway();

// If we don't have a gateway instance yet, return an array with empty or default values to prevent errors in blocks.
if ( null === $gateway ) {
return array(
'title' => '',
'description' => '',
'supports' => array(),
'groups' => array(),
'terms' => '',
'no_providers' => true,
);
}

if ( ! $this->is_provider_selection_enabled() ) {
return array(
'title' => $gateway->title,
Expand Down