-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Corrige data de próximo pagamento e desabilita renovação automática d…
…e pedido do WC Subscriptions (#102) * Desabilita o handling de renewal orders pelo WC_Subscriptions para assinaturas do Vindi * - Criada função na API para buscar assinatura - Corrigida função de atualizar próximo pagamento para buscar a subscription do Vindi e usar a data correta * Refatora métodos isCanceledSubscription e getSubscription * Altera validação da consulta de status de assinatura (pré-cancelamento) * Ajusta parâmetro 'data do próximo pagamento' * Ajusta validação de certificado para métodos de pagamento
- Loading branch information
1 parent
e39b943
commit e14680f
Showing
6 changed files
with
94 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
if (!defined('ABSPATH')) { | ||
die('not allowed'); | ||
} | ||
|
||
new Vindi_WCS_Disable_Renewal; | ||
|
||
class Vindi_WCS_Disable_Renewal | ||
{ | ||
public function __construct() { | ||
//hook as early as possible to try disabling WC_Subcriptions_Manager handling | ||
add_action( 'wp_loaded', array( __CLASS__, 'hook_before_prepare_renewal' ), 1 ); | ||
} | ||
|
||
static function hook_before_prepare_renewal() { | ||
//check if subscription manager exists | ||
if (class_exists( 'WC_Subscriptions_Manager', false )) { | ||
//prepare_renewal runs on 1 priority, so we hook in first | ||
add_action('woocommerce_scheduled_subscription_payment', array( | ||
__CLASS__, | ||
'maybe_deactivate_prepare_renewal' | ||
), 0, 1); | ||
} | ||
} | ||
|
||
static function maybe_deactivate_prepare_renewal($subscription_id) { | ||
|
||
$subscription = wcs_get_subscription($subscription_id); | ||
|
||
//easy check to see if this subscriptions is a Vindi Subscription | ||
if (!empty($subscription->get_meta('vindi_wc_subscription_id'))) { | ||
//if it is we disable Woocommerce Subscriptions Renewal order and let Vindi handle it via webhooks | ||
remove_action('woocommerce_scheduled_subscription_payment', | ||
'WC_Subscriptions_Manager::prepare_renewal', 1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters