diff --git a/README.txt b/README.txt index 7f5af24..9fab814 100755 --- a/README.txt +++ b/README.txt @@ -165,6 +165,8 @@ Alternatively you could look into using WooCommerce "Early renewals": [https://d = 2.1.2 = * Fixed: Cleaning up old cancelled orders that were initiated via Checkout now works as intended. * Fixed: Old agreements that customers now cancelled in the Vipps or MobilePay apps are now cancelled properly in WooCommerce. +* Fixed: VAT is now properly shown when a subscription is switched to Vipps MobilePay. +* Fixed: If an agreement is cancelled we don't want to listen for webhooks when the actor is the merchant, i.e. ourselves. This prevents us from cancelling our subscription when changing payment gateway from Vipps MobilePay to Vipps MobilePay. = 2.1.1 = * Fixed: Added two new hosts to `allowed_redirect_hosts`: `pay.mobilepay.dk` and `pay.mobilepay.fi`. This fixes a bug where customers were not able to switch to MobilePay. diff --git a/includes/wc-gateway-vipps-recurring.php b/includes/wc-gateway-vipps-recurring.php index 57a3636..4514f38 100755 --- a/includes/wc-gateway-vipps-recurring.php +++ b/includes/wc-gateway-vipps-recurring.php @@ -1384,7 +1384,7 @@ public function create_vipps_agreement_from_order( $order, $subscription = null, $redirect_url = WC_Vipps_Recurring_Helper::get_payment_redirect_url( $order, $is_gateway_change ); // total no longer returns the order amount when gateway is being changed - $agreement_total = $is_gateway_change ? $subscription->get_subtotal() : $subscription->get_total( 'code' ); + $agreement_total = $subscription->get_total( 'code' ); // when we're performing a variation switch we need some special logic in Vipps $is_subscription_switch = wcs_order_contains_switch( $order ); @@ -1668,11 +1668,11 @@ public function process_payment( $order_id, bool $retry = true, bool $previous_e WC_Vipps_Recurring_Helper::update_meta_data( $order, WC_Vipps_Recurring_Helper::META_AGREEMENT_ID, $response['agreementId'] ); WC_Vipps_Recurring_Helper::update_meta_data( $order, WC_Vipps_Recurring_Helper::META_CHARGE_PENDING, true ); - } - /* translators: Vipps/MobilePay Agreement ID */ - $message = sprintf( __( 'Agreement created: %s. Customer sent to Vipps/MobilePay for confirmation.', 'vipps-recurring-payments-gateway-for-woocommerce' ), $response['agreementId'] ); - $order->add_order_note( $message ); + /* translators: Vipps/MobilePay Agreement ID */ + $message = sprintf( __( 'Agreement created: %s. Customer sent to Vipps/MobilePay for confirmation.', 'vipps-recurring-payments-gateway-for-woocommerce' ), $response['agreementId'] ); + $order->add_order_note( $message ); + } $debug_msg .= sprintf( 'Created agreement with agreement ID: %s', $response['agreementId'] ) . "\n"; @@ -2499,6 +2499,12 @@ public function handle_webhook_callback( array $webhook_data ): void { // Customers can now cancel their agreements directly from the app. if ( $event_type === 'recurring.agreement-stopped.v1' ) { + // If the initiator of this webhook is ourselves, we must discard it. + // Otherwise, we risk cancelling payment gateway changes etc. + if ( $webhook_data['actor'] === 'MERCHANT' ) { + return; + } + $subscription_id = $this->maybe_get_subscription_id_from_agreement_webhook( $webhook_data ); if ( empty( $subscription_id ) ) { return;