| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.8/wp-content/plugins/fluentform/app/Modules/Payments/Classes/ |
Upload File : |
<?php
namespace FluentForm\App\Modules\Payments\Classes;
use FluentForm\App\Modules\Payments\PaymentHelper;
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
class PaymentManagement
{
public function cancelSubscription($subscription)
{
$validStatuses = [
'active',
'trialling',
'failing'
];
if (!in_array($subscription->status, $validStatuses)) {
return new \WP_Error('wrong_status', 'Sorry, You can not cancel this subscription');
}
$oldStatus = $subscription->status;
$newStatus = 'cancelled';
$submission = fluentFormApi('submissions')->find($subscription->submission_id);
// Now let's try to cancel this subscription
$handler = apply_filters_deprecated(
'fluentform_payment_manager_class_' . $submission->payment_method,
[
false
],
FLUENTFORM_FRAMEWORK_UPGRADE,
'fluentform/payment_manager_class_' . $submission->payment_method,
'Use fluentform/payment_manager_class_' . $submission->payment_method . ' instead of fluentform_payment_manager_class_' . $submission->payment_method
);
$handler = apply_filters('fluentform/payment_manager_class_' . $submission->payment_method, $handler);
$message = 'Subscription has been marked as cancelled';
if($handler) { // we have handler so the subscription cancellation will be managed by them
$response = $handler->cancelSubscription($subscription, 'admin', $submission);
if(is_wp_error($response)) {
return $response;
}
} else {
PaymentHelper::recordSubscriptionCancelled($subscription, false, [
'parent_source_id' => $submission->form_id,
'source_type' => 'submission_item',
'source_id' => $submission->id,
'component' => 'General',
'status' => 'info',
'title' => __('Subscription has been cancelled by admin', 'fluentform'),
'description' => __('Subscription has been cancelled locally. Subscription may not cancelled at ', 'fluentform') . $submission->payment_method
]);
}
do_action_deprecated(
'fluentform_payment_subscription_status_to_cancelled',
[
$subscription,
$submission,
$oldStatus
],
FLUENTFORM_FRAMEWORK_UPGRADE,
'fluentform/payment_subscription_status_to_cancelled',
'Use fluentform/payment_subscription_status_to_cancelled instead of fluentform_payment_subscription_status_to_cancelled.'
);
do_action('fluentform/payment_subscription_status_to_cancelled', $subscription, $submission, $oldStatus);
do_action_deprecated(
'fluentform_payment_subscription_status_' . $submission->payment_method . '_to_' . $newStatus,
[
$subscription,
$submission,
$oldStatus
],
FLUENTFORM_FRAMEWORK_UPGRADE,
'fluentform/payment_subscription_status_' . $submission->payment_method . '_to_' . $newStatus,
'Use fluentform/payment_subscription_status_' . $submission->payment_method . '_to_' . $newStatus . ' instead of fluentform_payment_subscription_status_' . $submission->payment_method . '_to_' . $newStatus
);
do_action('fluentform/payment_subscription_status_' . $submission->payment_method . '_to_' . $newStatus, $subscription, $submission, $oldStatus);
return $message;
}
}