PATH:
home
/
letacommog
/
laindinois
/
wp-content
/
plugins
/
wiloke-listing-tools
/
app
/
Framework
/
Payment
<?php namespace WilokeListingTools\Framework\Payment; use WilokeListingTools\Framework\Helpers\GetSettings; use WilokeListingTools\Framework\Helpers\GetWilokeSubmission; use WilokeListingTools\Framework\Helpers\Validation; class Receipt { public $aInfo = []; public $thankyouUrl; public $cancelUrl; public $productID; public $userID; public $planID; protected $planSettingKey = null; protected $packageType = null; public $aPlan = []; public $aRequested = []; public $couponCode = ''; public $aCouponInfo = []; public $subTotal = 0; public $total = 0; public $discount = 0; public $tax = 0; protected $isNonrecurringPayment = true; protected $aPlanSettings = []; public function __construct($aInfo) { $this->aInfo = $aInfo; $this->aRequested = isset($aInfo['aRequested']) ? $aInfo['aRequested'] : []; } protected function getPlanSettingKey($planID) { if ($this->planSettingKey !== null) { return $this->planSettingKey; } $postType = get_post_field('post_type', $planID); $this->packageType = $postType; $this->planSettingKey = 'add_'.$postType; } public function roundPrice($price) { return round(trim($price), 2); } public function getTax() { return $this->tax; } public function getPrice() { return $this->roundPrice($this->aPlanSettings['regular_price']); } public function getPackageType() { return $this->packageType; } public function getPlanID() { $this->planID = isset($this->aInfo['planID']) ? abs(trim($this->aInfo['planID'])) : ''; return $this; } protected function setPlanName($planID) { return get_the_title($planID); } protected function setTax() { return GetWilokeSubmission::calculateTax($this->getPrice()); } protected function setToken($token) { $this->aInfo['token'] = $token; return $this; } protected function setThankyouUrl($thankyouUrl) { $this->thankyouUrl = $thankyouUrl; return $this; } protected function setCancelUrl($cancelUrl) { $this->cancelUrl = $cancelUrl; return $this; } public function getTaxRate() { return GetWilokeSubmission::getTaxRate(); } public function getPlanName() { return $this->aPlan['planName']; } public function setPlanID($planID) { $this->planID = $planID; return $this; } protected function setRegularPeriod() { $this->regularPeriod = isset($this->aPlanSettings['regular_period']) ? abs(trim($this->aPlanSettings['regular_period'])) : ''; return $this; } protected function setTotal($total) { $this->total = $total; return $this; } protected function setSubTotal($subTotal) { $this->subTotal = $subTotal; return $this; } protected function setCouponCode() { $this->couponCode = isset($this->aInfo['couponCode']) ? trim($this->aInfo['couponCode']) : ''; return $this; } protected function setNonRecurringPayment($isNonRecurringPayment) { $this->isNonrecurringPayment = $isNonRecurringPayment; } /** * @throws \Exception */ public function setupPriceDirectly() { $this->userID = $this->aInfo['userID']; $this->thankyouUrl = GetWilokeSubmission::getField('thankyou', true); $this->cancelUrl = GetWilokeSubmission::getField('cancel', true); $this->isNonrecurringPayment = $this->aInfo['isNonRecurringPayment']; if (!isset($this->aInfo['productID'])) { if ((!isset($this->aInfo['total']) || !isset($this->aInfo['planName']) || !isset($this->aInfo['packageType']))) { $msg = esc_html__('The total price, packageType, and plan name are required', 'wiloke-listing-tools'); if (wp_doing_ajax()) { wp_send_json_error( [ 'msg' => $msg ] ); } else { throw new \Exception($msg); } } $this->total = $this->roundPrice($this->aInfo['total']); $this->subTotal = $this->total; } else { if (get_post_type($this->aInfo['productID']) !== 'product' || get_post_status($this->aInfo['productID']) !== 'publish') { $msg = esc_html__('The product does not exist', 'wiloke-listing-tools'); if (wp_doing_ajax()) { wp_send_json_error( [ 'msg' => $msg ] ); } else { throw new \Exception($msg); } } $this->productID = $this->aInfo['productID']; $this->setTax(); } if (isset($this->aInfo['oStripeData'])) { if (is_string($this->aInfo['oStripeData'])) { if ($aStripeData = Validation::isValidJson($this->aInfo['oStripeData'])) { $this->aInfo['oStripeData'] = Validation::getJsonDecoded(); } } $this->aRequested['email'] = $this->aInfo['oStripeData']['email']; $this->aRequested['token'] = $this->aInfo['oStripeData']['token']; } $this->aPlan['planName'] = $this->aInfo['planName']; $this->packageType = $this->aInfo['packageType']; $this->aCouponInfo['discountPrice'] = 0; } /** * @return $this */ public function setupPlan() { $this->planID = $this->aInfo['planID']; $this->getPlanSettingKey($this->planID); $this->aPlanSettings = GetSettings::getPostMeta($this->planID, $this->planSettingKey); $this->productID = isset($this->aInfo['productID']) ? $this->aInfo['productID'] : ''; $this->aPlan['ID'] = $this->planID; $this->aPlan['post_type'] = get_post_type($this->planID); $this->userID = $this->aInfo['userID']; $this->thankyouUrl = GetWilokeSubmission::getField('thankyou', true); $this->cancelUrl = GetWilokeSubmission::getField('cancel', true); $this->aPlan['slug'] = get_post_field('post_name', $this->planID); $this->isNonrecurringPayment = $this->aInfo['isNonRecurringPayment']; if (empty($this->productID)) { $this->aPlan['regularPeriod'] = isset($this->aPlanSettings['regular_period']) ? abs(trim($this->aPlanSettings['regular_period'])) : ''; $this->aPlan['trialPeriod'] = isset($this->aPlanSettings['trial_period']) ? abs(trim($this->aPlanSettings['trial_period'])) : ''; $this->aPlan['planName'] = $this->setPlanName($this->planID); $total = $this->getPrice(); $this->aPlan['total'] = $total; $this->subTotal = $this->aPlan['total']; $this->couponCode = isset($this->aInfo['couponCode']) ? $this->aInfo['couponCode'] : ''; $this->total = $this->subTotal; $this->setTax(); if ($this->isNonrecurringPayment) { if (!empty($this->couponCode)) { $instCoupon = new Coupon(); $instCoupon->getCouponID($this->couponCode); $instCoupon->getCouponSlug(); $instCoupon->getCouponInfo(); if (!$instCoupon->isCouponExpired() && $instCoupon->isPostTypeSupported($this->aPlan['post_type'])) { $this->aCouponInfo = $instCoupon->aSettings; $this->aCouponInfo['amount'] = $this->roundPrice($this->aCouponInfo['amount']); if ($this->aCouponInfo['type'] == 'percentage') { $this->aCouponInfo['discountPrice'] = $this->roundPrice($this->total * $this->aCouponInfo['amount'] / 100); } else { $this->aCouponInfo['discountPrice'] = $this->aCouponInfo['amount']; } } } } else { if (!empty($this->aPlanSettings['trialPeriod'])) { if (GetWilokeSubmission::canUserTrial($this->aPlan['ID'], $this->userID)) { $this->aPlanSettings['trialPeriod'] = ''; } } } } return $this; } }
[+]
..
[-] CancelSubscriptionInterface.php
[edit]
[-] SuspendSubscriptionPlan.php
[edit]
[-] Billable.php
[edit]
[-] SuspendInterface.php
[edit]
[-] StripePayment.php
[edit]
[+]
FreePlan
[-] PayPalPayment.php
[edit]
[-] WebhookHandler.php
[edit]
[-] CancelSubscriptionStaticFactory.php
[edit]
[-] CreatedPaymentHook.php
[edit]
[-] RefundFactory.php
[edit]
[+]
Stripe
[+]
PaymentHook
[-] Checkout.php
[edit]
[+]
DirectBankTransfer
[-] RefundInterface.php
[edit]
[-] Coupon.php
[edit]
[-] ProceededPaymentHook.php
[edit]
[-] AbstractSuspend.php
[edit]
[-] AddListingRetrieve.php
[edit]
[-] PaymentMethodInterface.php
[edit]
[+]
Invoice
[+]
PayPal
[+]
Receipt
[-] ChangePlanInterface.php
[edit]
[-] WebhookInterface.php
[edit]
[+]
WooCommerce
[-] PaymentGatewayStaticFactory.php
[edit]
[-] Receipt.php
[edit]