diff --git a/readme.txt b/readme.txt index ebf9863..64f61a2 100644 --- a/readme.txt +++ b/readme.txt @@ -37,6 +37,9 @@ View our full installation guide: supports = array( 'products', - 'subscriptions' + 'subscriptions', + 'subscription_cancellation' ); parent::__construct(); @@ -252,7 +253,13 @@ function ipn_response() { $payment->init_configs(true); $pingback_params = $_GET; $pingback = new Paymentwall_Pingback($pingback_params, $this->getRealClientIP()); + if ($pingback->validate(true)) { + if (paymentwall_subscription_enable()) { + $subscriptions = wcs_get_subscriptions_for_order($original_order_id, array('order_type' => 'parent')); + $subscription = array_shift($subscriptions); + $subscription_key = get_post_meta($original_order_id, '_subscription_id'); + } if ($pingback->isDeliverable()) { @@ -260,12 +267,6 @@ function ipn_response() { die(PW_DEFAULT_SUCCESS_PINGBACK_VALUE); } - if (paymentwall_subscription_enable()) { - $subscriptions = wcs_get_subscriptions_for_order($original_order_id, array('order_type' => 'parent')); - $subscription = array_shift($subscriptions); - $subscription_key = get_post_meta($original_order_id, '_subscription_id'); - } - if ($this->is_valid_renewal_pingback($pingback_params, $original_order_id)) { $subscription->update_status('on-hold'); $subscription->add_order_note(__('Subscription renewal payment due: Status changed from Active to On hold.', PW_TEXT_DOMAIN)); @@ -295,6 +296,12 @@ function ipn_response() { $order->update_status('wc-refunded'); } elseif ($pingback->isUnderReview()) { $order->update_status('on-hold'); + } elseif ( + $pingback->getType() == Paymentwall_Pingback::PINGBACK_TYPE_SUBSCRIPTION_CANCELLATION + && !empty($subscription) + ) { + $subscription->update_status('cancelled'); + $order->update_status('cancelled'); } die(PW_DEFAULT_SUCCESS_PINGBACK_VALUE); diff --git a/src/paymentwall-for-woocommerce.php b/src/paymentwall-for-woocommerce.php index 29292b9..5479f8c 100644 --- a/src/paymentwall-for-woocommerce.php +++ b/src/paymentwall-for-woocommerce.php @@ -5,7 +5,7 @@ * Plugin Name: Paymentwall for WooCommerce * Plugin URI: https://docs.paymentwall.com/modules/woocommerce * Description: Official Paymentwall module for WordPress WooCommerce. - * Version: 1.10.2 + * Version: 1.11.0 * Author: The Paymentwall Team * Author URI: http://www.paymentwall.com/ * Text Domain: paymentwall-for-woocommerce