Skip to content

Commit

Permalink
WOOC-1571 part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
PPmmesquita committed Jan 14, 2025
1 parent aa8138d commit 8b71070
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 50 deletions.
18 changes: 18 additions & 0 deletions src/Gateway/PayplugCreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ public function __construct() {
'products',
'refunds',
'tokenization',

'subscriptions',
'subscription_cancellation',
'subscription_suspension',
'subscription_reactivation',
'subscription_amount_changes',
'subscription_date_changes',
'subscription_payment_method_change',
'subscription_payment_method_change_customer',
'subscription_payment_method_change_admin',
'multiple_subscriptions',
);

// Ensure the description is not empty to correctly display users's save cards
Expand Down Expand Up @@ -55,6 +66,13 @@ public function __construct() {

add_action('wp_enqueue_scripts', [$this, 'scripts']);

// Check if subscriptions are enabled and add support for them.
if(PayplugWoocommerceHelper::is_subscriptions_enabled()){
add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id,
[ $this, 'process_subscription_payment' ], 10, 2 );

}


}

Expand Down
51 changes: 1 addition & 50 deletions src/Gateway/PayplugGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,30 +151,6 @@ public function __construct()
$GLOBALS['hide_save_button'] = true;
}

$this->id = 'payplug';
$this->icon = '';
$this->has_fields = false;
$this->method_title = _x('PayPlug', 'Gateway method title', 'payplug');
$this->method_description = __('Enable PayPlug for your customers.', 'payplug');
$this->supports = array(
'products',
'refunds',
'tokenization',

'subscriptions',
'subscription_cancellation',
'subscription_suspension',
'subscription_reactivation',
'subscription_amount_changes',
'subscription_date_changes',
'subscription_payment_method_change',
'subscription_payment_method_change_customer',
'subscription_payment_method_change_admin',
'multiple_subscriptions',

);
$this->new_method_label = __('Pay with another credit card', 'payplug');

$this->init_settings();
$this->requirements = new PayplugGatewayRequirements($this);
if ($this->user_logged_in()) {
Expand Down Expand Up @@ -206,35 +182,10 @@ public function __construct()
add_filter('woocommerce_get_customer_payment_tokens', [$this, 'filter_tokens'], 10, 3);

self::$log_enabled = $this->debug;

// Ensure the description is not empty to correctly display users's save cards
if (empty($this->description) && 0 !== count($this->get_tokens()) && $this->oneclick_available()) {
$this->description = ' ';
}


if ('test' === $this->mode) {
$this->description .= " \n";
$this->description .= __('You are in TEST MODE. In test mode you can use the card 4242424242424242 with any valid expiration date and CVC.', 'payplug');
$this->description = trim($this->description);
}

//add fields of IP to the description
if($this->payment_method === 'integrated'){
$this->has_fields = true;
}

// Check if subscriptions are enabled and add support for them.
if(PayplugWoocommerceHelper::is_subscriptions_enabled()){
add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id,
[ $this, 'process_subscription_payment' ], 10, 2 );

}

add_filter('woocommerce_get_order_item_totals', [$this, 'customize_gateway_title'], 10, 2);
add_action('wp_enqueue_scripts', [$this, 'scripts']);
add_action('the_post', [$this, 'validate_payment']);
add_action('woocommerce_available_payment_gateways', [$this, 'check_gateway']);

}

public function process_subscription_payment( $amount_to_charge, $renewal_order ){
Expand Down

0 comments on commit 8b71070

Please sign in to comment.