From c2a369089fba1f55253efe903fcb5e285c18b891 Mon Sep 17 00:00:00 2001 From: Marcus Dahl Date: Wed, 22 Dec 2021 14:40:24 +0100 Subject: [PATCH] fix: fixed an issue where `initialCharge.description` was empty. It cannot be empty under any circumstances --- README.txt | 5 +++++ includes/wc-gateway-vipps-recurring.php | 2 +- includes/wc-vipps-recurring-api.php | 4 +++- woo-vipps-recurring.php | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.txt b/README.txt index 506a5b0..b9a82c4 100755 --- a/README.txt +++ b/README.txt @@ -156,6 +156,11 @@ Alternatively you could look into using WooCommerce "Early renewals": [https://d == Changelog == += 1.12.2 = +* Fixed: Fixed an issue where `initialCharge.description` was empty. It cannot be empty under any circumstances. + +==== End Log ==== + = 1.12.1 = * Fixed: A bug in Klarna Checkout where it would attempt to use Vipps Recurring Payments instead of Vipps Checkout when you're only purchasing one time payment products. * Fixed: Descriptions of products you are not paying for right away is no longer included in initialCharge's description. diff --git a/includes/wc-gateway-vipps-recurring.php b/includes/wc-gateway-vipps-recurring.php index 898f91b..e175635 100755 --- a/includes/wc-gateway-vipps-recurring.php +++ b/includes/wc-gateway-vipps-recurring.php @@ -1479,7 +1479,7 @@ public function process_payment( $order_id, bool $retry = true, bool $previous_e if ( ! $is_zero_amount ) { $initial_charge_description = WC_Vipps_Recurring_Helper::get_product_description( $parent_product ) . ' + ' . $extra_initial_charge_description; - if ( $has_campaign ) { + if ( $has_campaign && ! empty( $extra_initial_charge_description ) ) { $initial_charge_description = $extra_initial_charge_description; } diff --git a/includes/wc-vipps-recurring-api.php b/includes/wc-vipps-recurring-api.php index 08f4e95..e8c2ae8 100755 --- a/includes/wc-vipps-recurring-api.php +++ b/includes/wc-vipps-recurring-api.php @@ -107,7 +107,9 @@ private function process_agreement_body( $body ): array { } if ( isset( $body['initialCharge']['description'] ) ) { - $charge_description = $body['initialCharge']['description']; + $charge_description = ! empty( $body['initialCharge']['description'] ) + ? $body['initialCharge']['description'] + : 'Mangler produktbeskrivelse'; if ( strlen( $charge_description ) > 45 ) { $body['initialCharge']['description'] = mb_substr( $charge_description, 0, 42 ) . '...'; diff --git a/woo-vipps-recurring.php b/woo-vipps-recurring.php index ea828d8..554f020 100755 --- a/woo-vipps-recurring.php +++ b/woo-vipps-recurring.php @@ -5,7 +5,7 @@ * Description: Offer recurring payments with Vipps for WooCommerce Subscriptions * Author: Everyday AS * Author URI: https://everyday.no - * Version: 1.12.1 + * Version: 1.12.2 * Requires at least: 4.4 * Tested up to: 5.8 * WC tested up to: 6.0 @@ -17,7 +17,7 @@ // phpcs:disable WordPress.Files.FileName -define( 'WC_VIPPS_RECURRING_VERSION', '1.12.1' ); +define( 'WC_VIPPS_RECURRING_VERSION', '1.12.2' ); add_action( 'plugins_loaded', 'woocommerce_gateway_vipps_recurring_init' );