Skip to content

Commit

Permalink
Bump v3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
olegisk committed Jan 22, 2024
1 parent 3f1a818 commit d7139af
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 3.1.1
* Fixed: Don't perform online refund when manual refund is clicked

Version 3.1.0
* Removed Full refund button
* Improved refund behavior of Refund button
Expand Down
23 changes: 20 additions & 3 deletions includes/class-swedbank-pay-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function __construct() {
// Refund actions
add_action( 'woocommerce_create_refund', array( $this, 'save_refund_parameters' ), 10, 2 );
add_action( 'woocommerce_order_refunded', array( $this, 'remove_refund_parameters' ), 10, 2 );
add_action( 'woocommerce_order_fully_refunded', array( $this, 'prevent_online_refund' ), 10, 2 );

add_filter(
'woocommerce_admin_order_should_render_refunds',
Expand All @@ -67,6 +68,18 @@ public function __construct() {
);
}

public function prevent_online_refund( $order_id, $refund_id ) {
$order = wc_get_order( $order_id );
$payment_method = $order->get_payment_method();
if ( in_array( $payment_method, Swedbank_Pay_Plugin::PAYMENT_METHODS, true ) ) {
// Prevent online refund when order status changed to "refunded"
set_transient(
'sb_refund_prevent_online_refund_' . $order_id,
$refund_id,
5 * MINUTE_IN_SECONDS
);
}
}

/**
* Allow processing/completed statuses for capture
Expand Down Expand Up @@ -169,9 +182,6 @@ public static function order_meta_box_payment_actions( $order ) {
* @param WC_Order $order
*/
public static function add_action_buttons( $order ) {
//$ddd = $order->get_meta( '_payex_refunded_items' );
//var_dump($ddd); exit();

if ( function_exists( 'wcs_is_subscription' ) && wcs_is_subscription( $order ) ) {
// Buttons are available for orders only
return;
Expand Down Expand Up @@ -397,6 +407,13 @@ public static function order_status_changed_transaction( $order_id, $old_status,

break;
case 'refunded':
$refund_id = get_transient( 'sb_refund_prevent_online_refund_' . $order_id );
if ( ! empty( $refund_id ) ) {
delete_transient( 'sb_refund_prevent_online_refund_' . $order_id );

return;
}

$gateway->api->log( WC_Log_Levels::INFO, 'Try to refund...' );
$lines = swedbank_pay_get_available_line_items_for_refund( $order );
$result = $gateway->payment_actions_handler->refund_payment(
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This plugin provides the Swedbank Pay Payment Menu for WooCommerce.
* Requires at least: 5.3
* Tested up to: 6.3.1
* Requires PHP: 7.0
* Stable tag: 3.1.0
* Stable tag: 3.1.1
* [License: Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)

## Description
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, swedbank,
Requires at least: 5.3
Tested up to: 6.3.1
Requires PHP: 7.0
Stable tag: 3.1.0
Stable tag: 3.1.1
License: Apache License 2.0
License URI: http://www.apache.org/licenses/LICENSE-2.0

Expand Down
2 changes: 1 addition & 1 deletion swedbank-pay-payment-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Author URI: https://profiles.wordpress.org/swedbankpay/
* License: Apache License 2.0
* License URI: http://www.apache.org/licenses/LICENSE-2.0
* Version: 3.1.0
* Version: 3.1.1
* Text Domain: swedbank-pay-woocommerce-checkout
* Domain Path: /languages
* WC requires at least: 5.5.1
Expand Down

0 comments on commit d7139af

Please sign in to comment.