Skip to content

Commit

Permalink
Merge branch 'dev-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mason authored and mason committed Jul 12, 2022
2 parents e0467d4 + eb94e2f commit c124193
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ View our full installation guide: <https://docs.paymentwall.com/modules/woocomme

== Changelog ==

= v1.11.0 [07/12/2022] =
* Support subscription cancellation

= v1.10.2 [07/04/2022] =
* Only display selected local payment method on widget

Expand Down
21 changes: 14 additions & 7 deletions src/includes/class-paymentwall-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Paymentwall_Gateway extends Paymentwall_Abstract {
public function __construct() {
$this->supports = array(
'products',
'subscriptions'
'subscriptions',
'subscription_cancellation'
);

parent::__construct();
Expand Down Expand Up @@ -252,20 +253,20 @@ 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()) {

if ($order->get_status() == PW_ORDER_STATUS_PROCESSING) {
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));
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/paymentwall-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c124193

Please sign in to comment.