From 3cafbdc3efe60201dceba7fd838381f567713708 Mon Sep 17 00:00:00 2001 From: "mudududla.sony" Date: Thu, 30 Dec 2021 00:58:43 +0530 Subject: [PATCH 01/24] Added edit subscription for admin --- Block/Adminhtml/Subscription/Edit.php | 43 +++---- Block/Adminhtml/Subscription/Edit/Form.php | 120 ++++++++++++++---- Controller/Adminhtml/Subscription/Edit.php | 35 ++--- Controller/Adminhtml/Subscription/Save.php | 103 +++++++++++++++ Ui/Component/Listing/Column/Actions.php | 10 ++ .../layout/subscribed_subscription_edit.xml | 2 +- 6 files changed, 246 insertions(+), 67 deletions(-) create mode 100644 Controller/Adminhtml/Subscription/Save.php diff --git a/Block/Adminhtml/Subscription/Edit.php b/Block/Adminhtml/Subscription/Edit.php index 3731c55..a195b48 100644 --- a/Block/Adminhtml/Subscription/Edit.php +++ b/Block/Adminhtml/Subscription/Edit.php @@ -1,8 +1,8 @@ _coreRegistry = $registry; parent::__construct($context, $data); } - + /** * Department edit block * @@ -36,30 +36,25 @@ protected function _construct() $this->_objectId = 'entity_id'; $this->_blockGroup = 'Razorpay_Subscription'; $this->_controller = 'adminhtml_subscription'; - + parent::_construct(); - - if ($this->_isAllowedAction('Razorpay_Subscription::subscription_upgrade')) { + + if ($this->_isAllowedAction('Razorpay_Subscription::subscription_save')) { $this->buttonList->update('save', 'label', __('Save Subscription')); - $this->buttonList->add( - 'saveandcontinue', - [ - 'label' => __('Save and Continue Edit'), - 'class' => 'save', - 'data_attribute' => [ - 'mage-init' => [ - 'button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form'], - ], - ] - ], - -100 + + $this->buttonList->remove('back'); + $data = array( + 'label' => 'Back', + 'onclick' => 'setLocation(\'' . $this->getUrl('subscribed/index/index/') . '\')', + 'class' => 'back' ); + $this->buttonList->add('back', $data); } else { $this->buttonList->remove('save'); } - + } - + /** * Get header with Department name * @@ -73,7 +68,7 @@ public function getHeaderText() return __('New Subscription'); } } - + /** * Check permission for passed action * @@ -84,7 +79,7 @@ protected function _isAllowedAction($resourceId) { return $this->_authorization->isAllowed($resourceId); } - + /** * Getter of url for "Save and Continue" button * tab_id will be replaced by desired by JS later @@ -93,6 +88,6 @@ protected function _isAllowedAction($resourceId) */ protected function _getSaveAndContinueUrl() { - return $this->getUrl('subscribed/*/upgrade', ['_current' => true, 'back' => 'edit', 'active_tab' => '']); + return $this->getUrl('subscribed/*/save', ['_current' => true, 'back' => 'edit', 'active_tab' => '']); } } \ No newline at end of file diff --git a/Block/Adminhtml/Subscription/Edit/Form.php b/Block/Adminhtml/Subscription/Edit/Form.php index b3c1d83..e517488 100644 --- a/Block/Adminhtml/Subscription/Edit/Form.php +++ b/Block/Adminhtml/Subscription/Edit/Form.php @@ -1,16 +1,16 @@ _systemStore = $systemStore; parent::__construct($context, $registry, $formFactory, $data); } - + /** * Init form * @@ -37,10 +37,10 @@ public function __construct( protected function _construct() { parent::_construct(); - $this->setId('department_form'); - $this->setTitle(__('Department Information')); + $this->setId('subscription_form'); + $this->setTitle(__('Subscription Information')); } - + /** * Prepare form * @@ -48,41 +48,109 @@ protected function _construct() */ protected function _prepareForm() { - /** @var \Maxime\Jobs\Model\Department $model */ + $subscriptionInfo = $this->getLayout()->createBlock( + 'Razorpay\Subscription\Block\View')->getSubscrib(); + $subscriptionInfo['s_id'] = $this->_request->getParam('subscription_id'); + + $plans = $this->getLayout()->createBlock('Razorpay\Subscription\Block\Edit')->getPlans($subscriptionInfo['product_id']); + $pending = $this->getLayout()->createBlock('Razorpay\Subscription\Block\Edit')->pendingUpdate(); + $readonly = !empty($pending) ? true : false; + + foreach($plans as $option){ + $options[] = ["value" => $option['plan_id'],"label" => $option['plan_name']]; + } + + /** @var \Razorpay\Subscription\Model\Subscriptions $model */ $model = $this->_coreRegistry->registry('subscribed_subscription'); - + /** @var \Magento\Framework\Data\Form $form */ $form = $this->_formFactory->create( ['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']] ); - - $form->setHtmlIdPrefix('department_'); - + + $form->setHtmlIdPrefix('subscription_'); + $fieldset = $form->addFieldset( 'base_fieldset', - ['legend' => __('General Information'), 'class' => 'fieldset-wide'] + ['legend' => __('Subscription Details'), 'class' => 'fieldset-wide'] ); - + if ($model->getId()) { $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']); } - + $fieldset->addField('s_id', 'hidden', ['name' => 's_id']); + + $fieldset->addField( + 'subscription_id', + 'text', + ['name' => 'subscription_id', 'label' => __('Subscription Id'), 'title' => __('Subscription Id'), 'required' => true,'disabled'=>true] + ); + + $fieldset->addField( + 'razorpay_customer_id', + 'text', + ['name' => 'razorpay_customer_id', 'label' => __('Customer Id'), 'title' => __('Customer Id'), 'required' => true,'disabled'=>true] + ); + $fieldset->addField( + 'plan_id', + 'select', + ['name' => 'plan_id', 'label' => __('Select Plan'), 'title' => __('Select Plan'), 'required' => true,'values' => $options,'disabled'=>$readonly] + ); + $fieldset->addField( + 'plan_name', + 'text', + ['name' => 'plan_name', 'label' => __('Plan Name'), 'title' => __('Plan Name'), 'required' => true,'disabled'=>true] + ); + $fieldset->addField( + 'plan_type', + 'text', + ['name' => 'plan_type', 'label' => __('Plan Type'), 'title' => __('Plan Type'), 'required' => true,'disabled'=>true] + ); + $fieldset->addField( + 'value', + 'text', + ['name' => 'value', 'label' => __('Product Name'), 'title' => __('Product Name'), 'required' => true,'disabled'=>true] + ); $fieldset->addField( - 'name', + 'status', 'text', - ['name' => 'name', 'label' => __('Department Name'), 'title' => __('Department Name'), 'required' => true] + ['name' => 'status', 'label' => __('Status'), 'title' => __('Status'), 'required' => true,'disabled'=>true] ); - $fieldset->addField( - 'description', - 'textarea', - ['name' => 'description', 'label' => __('Department Description'), 'title' => __('Department Description'), 'required' => true] + 'total_count', + 'text', + ['name' => 'total_count', 'label' => __('Total Count'), 'title' => __('Total Count'), 'required' => true,'disabled'=>true] + ); + $fieldset->addField( + 'paid_count', + 'text', + ['name' => 'paid_count', 'label' => __('Paid Count'), 'title' => __('Paid Count'), 'required' => true,'disabled'=>true] + ); + $fieldset->addField( + 'subscription_created_at', + 'text', + ['name' => 'subscription_created_at', 'label' => __('Created At'), 'title' => __('Created At'), 'required' => true,'disabled'=>true] + ); + $fieldset->addField( + 'next_charge_at', + 'text', + ['name' => 'next_charge_at', 'label' => __('Next Charge At'), 'title' => __('Next Charge At'), 'required' => true,'disabled'=>true] + ); + $fieldset->addField( + 'start_at', + 'text', + ['name' => 'start_at', 'label' => __('Start At'), 'title' => __('Start At'), 'required' => true,'disabled'=>true] + ); + $fieldset->addField( + 'end_at', + 'text', + ['name' => 'end_at', 'label' => __('End At'), 'title' => __('End At'), 'required' => true,'disabled'=>true] ); - - $form->setValues($model->getData()); + + $form->setValues($subscriptionInfo); $form->setUseContainer(true); $this->setForm($form); - + return parent::_prepareForm(); } -} +} \ No newline at end of file diff --git a/Controller/Adminhtml/Subscription/Edit.php b/Controller/Adminhtml/Subscription/Edit.php index cc0cc90..150ca67 100644 --- a/Controller/Adminhtml/Subscription/Edit.php +++ b/Controller/Adminhtml/Subscription/Edit.php @@ -1,27 +1,29 @@ _model = $model; parent::__construct($context); } - + /** * {@inheritdoc} */ protected function _isAllowed() { - return $this->_authorization->isAllowed('Razorpay_Subscription::subscription_upgrade'); + return $this->_authorization->isAllowed('Razorpay_Subscription::subscription_save'); } - + /** * Init actions * @@ -58,12 +60,12 @@ protected function _initAction() // load layout, set active menu and breadcrumbs /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->_resultPageFactory->create(); - $resultPage->setActiveMenu('Magento_Sales::sales') + $resultPage->setActiveMenu('Razorpay_Subscription::rzp_subscriptions') ->addBreadcrumb(__('Subscription'), __('Subscription')) ->addBreadcrumb(__('Manage Subscriptions'), __('Manage Subscriptions')); return $resultPage; } - + /** * Edit Department * @@ -72,27 +74,28 @@ protected function _initAction() */ public function execute() { + $this->_coreRegistry->register(self::REGISTRY_KEY_POST_ID, $this->_request->getParam('id')); $id = $this->getRequest()->getParam('id'); $model = $this->_model; - + if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This subscription not exists.')); /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); - + return $resultRedirect->setPath('*/*/'); } } - + $data = $this->_getSession()->getFormData(true); if (!empty($data)) { $model->setData($data); } - + $this->_coreRegistry->register('subscribed_subscription', $model); - + /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->_initAction(); $resultPage->addBreadcrumb( @@ -102,7 +105,7 @@ public function execute() $resultPage->getConfig()->getTitle()->prepend(__('Subscriptions')); $resultPage->getConfig()->getTitle() ->prepend($model->getId() ? $model->getName() : __('New Subscription')); - + return $resultPage; } } \ No newline at end of file diff --git a/Controller/Adminhtml/Subscription/Save.php b/Controller/Adminhtml/Subscription/Save.php new file mode 100644 index 0000000..4e4881c --- /dev/null +++ b/Controller/Adminhtml/Subscription/Save.php @@ -0,0 +1,103 @@ +_model = $model; + } + + /** + * {@inheritdoc} + **/ + protected function _isAllowed() + { + return $this->_authorization->isAllowed('Razorpay_Subscription::subscription_save'); + } + + /** + * Save action + * @return \Magento\Framework\Controller\ResultInterface + * */ + public function execute() + { + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + + /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + $resultRedirect = $this->resultRedirectFactory->create(); + + $data = $this->getRequest()->getPostValue(); + if ($data) { + /** @var \Razorpay\Subscription\Model\Subscrib $model */ + $model = $this->_model; + $id = $this->getRequest()->getParam('entity_id'); + $subscriptionId = $this->getRequest()->getParam('s_id'); + + if ($id) { + $model->load($id); + } + + unset($data['entity_id']); + unset($data['form_key']); + unset($data['s_id']); + + $planData = $objectManager->get('Razorpay\Subscription\Model\Plans') + ->getCollection() + ->addFieldToFilter('plan_id', $data['plan_id']) + ->getFirstItem() + ->getData(); + + try { + + $entity_id = $planData['entity_id']; + $data['schedule_change_at'] = 'cycle_end'; + + $connection = $objectManager->get('Magento\Framework\App\ResourceConnection')->getConnection('\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION'); + $key_id = $connection->fetchAll("SELECT * FROM core_config_data WHERE `path` LIKE 'payment/razorpay/key_id'"); + $key_secret = $connection->fetchAll("SELECT * FROM core_config_data WHERE `path` LIKE 'payment/razorpay/key_secret'"); + + $rzpId = $key_id[0]['value']; + $rzpSecret = $key_secret[0]['value']; + $rzp = new Api($rzpId, $rzpSecret); + + $subscriptionResponse = $rzp->subscription->fetch($subscriptionId)->update($data); + $subscription = $objectManager->create('Razorpay\Subscription\Model\Subscriptions'); + $postUpdate = $subscription->load($subscriptionId, 'subscription_id'); + $postUpdate->setPlanEntityId($entity_id); + $postUpdate->save(); + + $this->messageManager->addSuccess(__("Subscription updated")); + + $this->_getSession()->setFormData(false); + + return $resultRedirect->setPath('subscribed/index/index/'); + } catch (\Exception $e) { + $this->messageManager->addErrorMessage(__($e->getMessage())); + return $resultRedirect->setPath('subscribed/index/index/'); + } + + $this->_getSession()->setFormData($data); + return $resultRedirect->setPath('*/*/edit', ['entity_id' => $this->getRequest()->getParam('id')]); + } + return $resultRedirect->setPath('*/*/'); + } + +} \ No newline at end of file diff --git a/Ui/Component/Listing/Column/Actions.php b/Ui/Component/Listing/Column/Actions.php index 3f4d794..3f0063f 100644 --- a/Ui/Component/Listing/Column/Actions.php +++ b/Ui/Component/Listing/Column/Actions.php @@ -15,6 +15,7 @@ class Actions extends Column /** Url Path */ const SUBSCRIPTION_VIEW_URL_PATH = 'subscribed/subscription/view'; + const SUBSCRIPTION_EDIT_URL_PATH = 'subscribed/subscription/edit'; const CANCEL_URL_PATH = 'subscribed/subscription/cancel'; const PAUSE_URL_PATH = 'subscribed/subscription/pause'; const RESUME_URL_PATH = 'subscribed/subscription/resume'; @@ -47,6 +48,15 @@ public function prepareDataSource(array $dataSource) 'label' => __('View'), '__disableTmpl' => true, ]; + + if($item['status'] == 'active'){ + $item[$name]['edit'] = [ + 'href' => $this->urlBuilder->getUrl(self::SUBSCRIPTION_EDIT_URL_PATH, ['subscription_id' => strip_tags($item['subscription_id']),'id' => $item['entity_id']]), + 'label' => __('Edit'), + '__disableTmpl' => true, + ]; + } + $item[$name]['pause'] = [ 'href' => $this->urlBuilder->getUrl(self::PAUSE_URL_PATH, ['subscription_id' => strip_tags($item['subscription_id'])]), 'label' => __('Pause'), diff --git a/view/adminhtml/layout/subscribed_subscription_edit.xml b/view/adminhtml/layout/subscribed_subscription_edit.xml index 3e3105e..1e4e2a0 100644 --- a/view/adminhtml/layout/subscribed_subscription_edit.xml +++ b/view/adminhtml/layout/subscribed_subscription_edit.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file From cb4a23ce6373f324ace805da8ae13d10514be826 Mon Sep 17 00:00:00 2001 From: Hancil Sequeira Date: Mon, 10 Jan 2022 12:29:16 +0530 Subject: [PATCH 02/24] Add webhook events for failed payments --- Helper/SubscriptionWebhook.php | 26 ++++++------------- Model/SubscriptionWebhookEvents.php | 39 ++++++++++++++++++----------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/Helper/SubscriptionWebhook.php b/Helper/SubscriptionWebhook.php index dfd7e2b..3429789 100644 --- a/Helper/SubscriptionWebhook.php +++ b/Helper/SubscriptionWebhook.php @@ -284,7 +284,8 @@ public function processSubscriptionAction($data) $rzpSubscriptionId = $data['payload']['subscription']['entity']['id']; $quoteId = $data['payload']['subscription']['entity']['notes']['magento_quote_id']; $webHookSource = $data['payload']['subscription']['entity']['notes']['source']; - + $status = $data['payload']['subscription']['entity']['status']; + if (empty($quoteId)) { $this->_logger->info("Razorpay Subscription Webhook: Quote ID not set for Razorpay subscription id(:$rzpSubscriptionId)"); return; @@ -292,26 +293,13 @@ public function processSubscriptionAction($data) // Process only if its from magento source if ($webHookSource == "magento-subscription") { - - switch ($data['event']) { - case 'subscription.paused': - $status = 'paused'; - break; - - case 'subscription.resumed': - $status = 'active'; - break; - - case 'subscription.cancelled': - $status = 'cancelled'; - break; - } - $subscription = $this->_objectManagement->create('Razorpay\Subscription\Model\Subscriptions'); $postUpdate = $subscription->load($rzpSubscriptionId, 'subscription_id'); $postUpdate->setStatus($status); - $postUpdate->setCancelBy('Razorpay'); - $postUpdate->save(); + if($status == "cancelled"){ + $postUpdate->setCancelBy('Razorpay'); + } + $postUpdate->save(); $this->_logger->info("Razorpay Subscription Webhook Processed successfully for Razorpay subscriptionId(:$rzpSubscriptionId)"); } @@ -476,4 +464,4 @@ protected function createOrderFromQuote($quote, $amount, $paymentId) return $order; } -} \ No newline at end of file +} diff --git a/Model/SubscriptionWebhookEvents.php b/Model/SubscriptionWebhookEvents.php index a62793d..116d19a 100644 --- a/Model/SubscriptionWebhookEvents.php +++ b/Model/SubscriptionWebhookEvents.php @@ -17,20 +17,31 @@ public function toOptionArray() foreach ($webhookEvent->toOptionArray() as $value){ array_push($events, $value); } - array_push($events,[ - 'value' => "subscription.charged", - 'label' => __('subscription.charged') - ]); - - array_push($events,[ - 'value' => "subscription.paused", - 'label' => __('subscription.paused') - ]); - - array_push($events,[ - 'value' => "subscription.cancelled", - 'label' => __('subscription.cancelled') - ]); + $subscriptionEvents = [ + [ + 'value' => "subscription.charged", + 'label' => __('subscription.charged') + ], + [ + 'value' => "subscription.paused", + 'label' => __('subscription.paused') + ], + [ + 'value' => "subscription.cancelled", + 'label' => __('subscription.cancelled') + ], + [ + 'value' => "subscription.pending", + 'label' => __('subscription.pending') + ], + [ + 'value' => "subscription.halted", + 'label' => __('subscription.halted') + ] + ]; + foreach ($subscriptionEvents as $value){ + array_push($events, $value); + } return $events; } } From 152803f439f509d441893e388e91920fe308ea7f Mon Sep 17 00:00:00 2001 From: Hancil Sequeira Date: Wed, 12 Jan 2022 14:15:05 +0530 Subject: [PATCH 03/24] Add webhook events for resume subscriptions --- Model/SubscriptionWebhookEvents.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Model/SubscriptionWebhookEvents.php b/Model/SubscriptionWebhookEvents.php index 116d19a..a2c50ad 100644 --- a/Model/SubscriptionWebhookEvents.php +++ b/Model/SubscriptionWebhookEvents.php @@ -26,6 +26,10 @@ public function toOptionArray() 'value' => "subscription.paused", 'label' => __('subscription.paused') ], + [ + 'value' => "subscription.resumed", + 'label' => __('subscription.resumed') + ], [ 'value' => "subscription.cancelled", 'label' => __('subscription.cancelled') From 91650f110db7a570d18463efd260e4fb28488878 Mon Sep 17 00:00:00 2001 From: sofiya02 Date: Tue, 18 Jan 2022 16:46:08 +0530 Subject: [PATCH 04/24] Escape function with return --- Helper/SubscriptionWebhook.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Helper/SubscriptionWebhook.php b/Helper/SubscriptionWebhook.php index 3429789..e7540b6 100644 --- a/Helper/SubscriptionWebhook.php +++ b/Helper/SubscriptionWebhook.php @@ -95,7 +95,7 @@ public function processSubscriptionCharged($data) $orderLinkCollection->setWebhookFirstNotifiedAt(time()) ->setWebhookCount($orderLink['webhook_count'] + 1) ->save(); - exit; + return; } $webhookWaitTime = $this->_config->getConfigData(Config::WEBHOOK_WAIT_TIME) ?? 300; @@ -108,7 +108,7 @@ public function processSubscriptionCharged($data) ->save(); header('Status: 409 Conflict, too early for processing', true, 409); - exit; + return; } // checking if payment id is null hen processing same quote for order else creating new order From ff913258dad89dd47057546d4d3a49aca76e92cc Mon Sep 17 00:00:00 2001 From: sofiya02 Date: Tue, 18 Jan 2022 16:51:05 +0530 Subject: [PATCH 05/24] replaced global variable with Magento php enviroment request --- Controller/Subscription/SubscriptionOrder.php | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Controller/Subscription/SubscriptionOrder.php b/Controller/Subscription/SubscriptionOrder.php index f579ecc..10ae569 100644 --- a/Controller/Subscription/SubscriptionOrder.php +++ b/Controller/Subscription/SubscriptionOrder.php @@ -6,6 +6,7 @@ use Razorpay\Magento\Controller\BaseController; use Razorpay\Magento\Model\PaymentMethod; use Razorpay\Subscription\Helper\Subscription; +use Magento\Framework\HTTP\PhpEnvironment\Request; class SubscriptionOrder extends BaseController { @@ -46,7 +47,12 @@ class SubscriptionOrder extends BaseController * @var CheckoutSession */ protected $checkoutSession; + /** + * @var Request + */ + protected $request; + /** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Customer\Model\Session $customerSession @@ -55,6 +61,7 @@ class SubscriptionOrder extends BaseController * @param \Magento\Framework\App\CacheInterface $cache * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository * @param \Psr\Log\LoggerInterface $logger + * @param Request $request */ public function __construct( \Magento\Framework\App\Action\Context $context, @@ -66,7 +73,8 @@ public function __construct( \Magento\Framework\App\CacheInterface $cache, \Magento\Sales\Api\OrderRepositoryInterface $orderRepository, \Razorpay\Subscription\Helper\Subscription $subscription, - \Psr\Log\LoggerInterface $logger + \Psr\Log\LoggerInterface $logger, + Request $request ) { parent::__construct( $context, @@ -74,7 +82,7 @@ public function __construct( $checkoutSession, $config ); - + $this->request = $request; $this->config = $config; $this->cartManagement = $cartManagement; $this->customerSession = $customerSession; @@ -89,16 +97,18 @@ public function __construct( public function execute() { + + $post = $this->getRequest()->getPost(); try{ $receiptId = $this->getQuote()->getId(); - if(empty($_POST['error']) === false) + if(empty($post['error']) === false) { $this->messageManager->addError(__('Payment Failed')); return $this->_redirect('checkout/cart'); } - if (isset($_POST['order_check'])) + if (isset($post['order_check'])) { if (empty($this->cache->load("quote_processing_".$receiptId)) === false) { @@ -174,7 +184,7 @@ public function execute() return $response; } - if(isset($_POST['razorpay_payment_id'])) + if(isset($post['razorpay_payment_id'])) { $this->getQuote()->getPayment()->setMethod(PaymentMethod::METHOD_CODE); @@ -195,7 +205,7 @@ public function execute() } else { - if (empty($_POST['email']) === true) { + if (empty($post['email']) === true) { $this->logger->info("Email field is required"); $responseContent = [ @@ -206,7 +216,7 @@ public function execute() $code = 200; } else { $paymentAction = $this->config->getPaymentAction(); - $this->customerSession->setCustomerEmailAddress($_POST['email']); + $this->customerSession->setCustomerEmailAddress($post['email']); $responseContent = [ 'message' => 'Unable to create your order. Please contact support.', From 82a6e39ad5dda2673c6e02f0cff15adb4d45af7e Mon Sep 17 00:00:00 2001 From: sofiya02 Date: Wed, 19 Jan 2022 12:21:22 +0530 Subject: [PATCH 06/24] changed gobal variable --- Model/SubscriptionPaymentMethod.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Model/SubscriptionPaymentMethod.php b/Model/SubscriptionPaymentMethod.php index f4fd260..773fff6 100644 --- a/Model/SubscriptionPaymentMethod.php +++ b/Model/SubscriptionPaymentMethod.php @@ -8,6 +8,7 @@ use Razorpay\Api\Api; use Razorpay\Magento\Model\Config; + /** * Class SubscriptionPaymentMethod * @package Razorpay\Magento\Model @@ -205,13 +206,13 @@ public function authorize(InfoInterface $payment, $amount) //validate RzpOrderamount with quote/order amount before signature $orderAmount = (int) (number_format($order->getGrandTotal() * 100, 0, ".", "")); - if((empty($request) === true) and (isset($_POST['razorpay_signature']) === true)) + if((empty($request) === true) and (isset($request['razorpay_signature']) === true)) { //set request data based on redirect flow $request['paymentMethod']['additional_data'] = [ - 'rzp_payment_id' => $_POST['razorpay_payment_id'], - 'rzp_order_id' => $_POST['razorpay_order_id'], - 'rzp_signature' => $_POST['razorpay_signature'] + 'rzp_payment_id' => $request['razorpay_payment_id'], + 'rzp_order_id' => $request['razorpay_order_id'], + 'rzp_signature' => $request['razorpay_signature'] ]; } From 5f99a41834d5962ac3d00c5fa195f969d073fd12 Mon Sep 17 00:00:00 2001 From: sofiya02 Date: Tue, 25 Jan 2022 17:38:17 +0530 Subject: [PATCH 07/24] format and chnages as per magento marketplace report --- .DS_Store | Bin 0 -> 8196 bytes .idea/.gitignore | 8 ++ .idea/git_toolbox_prj.xml | 15 ++++ .idea/magento2plugin.xml | 6 ++ .idea/modules.xml | 8 ++ .idea/subscriptions-magento-plugin.iml | 12 +++ .idea/vcs.xml | 6 ++ Api/Data/SubscribInterface.php | 10 +-- Block/Adminhtml/Plan/Edit.php | 6 +- Block/Adminhtml/Plan/Edit/Form.php | 49 ++++++----- Block/Adminhtml/Subscription/Edit.php | 6 +- Block/Display.php | 71 ++++++++------- Block/Edit.php | 24 +++-- Block/View.php | 56 ++++++++---- Controller/.DS_Store | Bin 0 -> 6148 bytes Controller/Adminhtml/Index/Index.php | 3 +- Controller/Adminhtml/Plan/Edit.php | 20 +++-- Controller/Adminhtml/Plan/Index.php | 6 +- Controller/Adminhtml/Plan/MassDisable.php | 10 ++- Controller/Adminhtml/Plan/MassEnable.php | 10 ++- Controller/Adminhtml/Plan/NewAction.php | 6 +- Controller/Adminhtml/Subscription/Cancel.php | 11 ++- Controller/Adminhtml/Subscription/Edit.php | 8 +- Controller/Adminhtml/Subscription/Index.php | 4 +- .../Adminhtml/Subscription/MassCancel.php | 7 +- .../Adminhtml/Subscription/MassPause.php | 7 +- .../Adminhtml/Subscription/MassResume.php | 7 +- .../Adminhtml/Subscription/NewAction.php | 6 +- Controller/Adminhtml/Subscription/Pause.php | 11 ++- Controller/Adminhtml/Subscription/Resume.php | 11 ++- Controller/Adminhtml/Subscription/Upgrade.php | 14 +-- Controller/Adminhtml/Subscription/View.php | 6 +- Controller/Customer/CancelSubscription.php | 15 ++-- Controller/Customer/Index.php | 3 +- .../Customer/MassCancelSubscription.php | 23 +++-- Controller/Customer/MassPauseSubscription.php | 23 +++-- .../Customer/MassResumeSubscription.php | 23 +++-- Controller/Customer/PauseSubscription.php | 15 ++-- Controller/Customer/ResumeSubscription.php | 15 ++-- Controller/Subscrib/Edit.php | 6 +- Controller/Subscrib/FormPost.php | 35 ++++---- Controller/Subscrib/View.php | 6 +- Controller/Subscription/SubscriptionOrder.php | 52 ++++++----- Helper/Subscription.php | 52 ++++++----- Helper/SubscriptionWebhook.php | 35 ++++---- Logger/SubscriptionLogger.php | 3 + Model/.DS_Store | Bin 0 -> 6148 bytes Model/Plans.php | 9 +- .../ResourceModel/Plans/CollectionFactory.php | 4 +- Model/ResourceModel/Subscrib.php | 1 + Model/ResourceModel/Subscrib/Collection.php | 2 + Model/Source/ProductList.php | 2 +- Model/Subscrib.php | 12 +-- Model/SubscriptionConfig.php | 8 +- Model/SubscriptionPaymentMethod.php | 83 +++++++++--------- .../CheckoutCartProductAddAfterObserver.php | 27 +++--- Observer/OrderPlaceSaveAfterObserver.php | 10 +-- Observer/PaymentMethodActiveObserver.php | 10 +-- ...RestrictRecurringProductToCartObserver.php | 11 ++- Plugin/CsrfValidatorSkip.php | 6 +- Setup/UpgradeData.php | 9 +- Setup/UpgradeSchema.php | 54 +++++++----- Ui/Component/Listing/Column/Actions.php | 10 ++- Ui/Component/Listing/Column/PlanActions.php | 10 +-- .../Listing/Column/SubscriptionView.php | 10 ++- Ui/DataProvider/Plan/Collection.php | 7 +- Ui/DataProvider/Plan/ListingDataProvider.php | 1 + Ui/DataProvider/Subscriptions/Collection.php | 1 + .../Subscriptions/ListingDataProvider.php | 1 + .../subscription_order_details_view.phtml | 2 +- .../templates/subscription_view.phtml | 44 +++++----- .../product/product_view_options.phtml | 22 ++--- .../product/subscription_options.phtml | 12 ++- view/frontend/templates/subscrib/edit.phtml | 24 ++--- .../templates/subscrib/subscribed.phtml | 32 ++++--- view/frontend/templates/subscrib/view.phtml | 66 +++++++------- 76 files changed, 689 insertions(+), 531 deletions(-) create mode 100644 .DS_Store create mode 100644 .idea/.gitignore create mode 100644 .idea/git_toolbox_prj.xml create mode 100644 .idea/magento2plugin.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/subscriptions-magento-plugin.iml create mode 100644 .idea/vcs.xml create mode 100644 Controller/.DS_Store create mode 100644 Model/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b2478dc6958c1a3bd28b0627f34b326da7ce52af GIT binary patch literal 8196 zcmeI1OK;Oa5XWcp!U32M{kfRv`Kpc0RY@HhaXabvXx*Bd2HBM3pc z^9^`?1-=JxMSK=c@ZVh%`OzRw6p@{3chWTK`x-_Te@KyTS!$3= zoObD1%<^N*@)WJpb)54SU87C9LARk7>44f%KXxhRH-~d`*mY3%$fhp5o}$Ici+R3| zc@}U*SdkAOj=OY)cg*MepZHjVUMKj5@x|)6PR}owzp+$0lg*tljDk^^D?D!Q^Fh;Z z`Tbs_)qN%L7mdurMWi-kg=Pp;SZtWaAe=&SHdi4%- zgRmet(rI-(so$e@B%{M-*K@hIC!A5z;O5hAlw3-ThM$BSR@VmOPLgu!>+ftsbUzH)ANLotlv^)snWB5~KrOdi*d{}VxVlY)=vC#j7PiApXqjaK zX*KzIk^gT_|NcMAi1gewf&ZQW%WO0^8kpv + + + + + + \ No newline at end of file diff --git a/.idea/magento2plugin.xml b/.idea/magento2plugin.xml new file mode 100644 index 0000000..6485e05 --- /dev/null +++ b/.idea/magento2plugin.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..33e26f8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/subscriptions-magento-plugin.iml b/.idea/subscriptions-magento-plugin.iml new file mode 100644 index 0000000..dce58b7 --- /dev/null +++ b/.idea/subscriptions-magento-plugin.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Api/Data/SubscribInterface.php b/Api/Data/SubscribInterface.php index fa7128d..88fb89e 100644 --- a/Api/Data/SubscribInterface.php +++ b/Api/Data/SubscribInterface.php @@ -51,7 +51,7 @@ public function getId(); /** * Set SubscriptionId * - * @param string $SubscriptionId + * @param string $SubscriptionId * @return $this */ public function setSubscriptionId($SubscriptionId); @@ -59,7 +59,7 @@ public function setSubscriptionId($SubscriptionId); /** * Set Status * - * @param string $status + * @param string $status * @return $this */ public function setStatus($status); @@ -67,7 +67,7 @@ public function setStatus($status); /** * Set Value * - * @param string $value + * @param string $value * @return $this */ public function setValue($value); @@ -75,7 +75,7 @@ public function setValue($value); /** * Set Crated At * - * @param int $nextChargeAt + * @param int $nextChargeAt * @return $this */ public function setNextChargeAt($nextChargeAt); @@ -83,7 +83,7 @@ public function setNextChargeAt($nextChargeAt); /** * Set ID * - * @param int $id + * @param int $id * @return $this */ public function setId($id); diff --git a/Block/Adminhtml/Plan/Edit.php b/Block/Adminhtml/Plan/Edit.php index 4031725..0f4f838 100644 --- a/Block/Adminhtml/Plan/Edit.php +++ b/Block/Adminhtml/Plan/Edit.php @@ -14,8 +14,8 @@ class Edit extends Container /** * @param \Magento\Backend\Block\Widget\Context $context - * @param \Magento\Framework\Registry $registry - * @param array $data + * @param \Magento\Framework\Registry $registry + * @param array $data */ public function __construct( \Magento\Backend\Block\Widget\Context $context, @@ -77,7 +77,7 @@ public function getHeaderText() /** * Check permission for passed action * - * @param string $resourceId + * @param string $resourceId * @return bool */ protected function _isAllowedAction($resourceId) diff --git a/Block/Adminhtml/Plan/Edit/Form.php b/Block/Adminhtml/Plan/Edit/Form.php index 499ac08..d9d02a6 100644 --- a/Block/Adminhtml/Plan/Edit/Form.php +++ b/Block/Adminhtml/Plan/Edit/Form.php @@ -20,13 +20,13 @@ class Form extends Generic protected $_productList; /** - * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Data\FormFactory $formFactory - * @param \Magento\Store\Model\System\Store $systemStore + * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\Framework\Registry $registry + * @param \Magento\Framework\Data\FormFactory $formFactory + * @param \Magento\Store\Model\System\Store $systemStore * @param \Razorpay\Subscription\Model\Source\Plan\Status $status * @param \Razorpay\Subscription\Model\Source\ProductList $productList - * @param array $data + * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, @@ -62,10 +62,14 @@ protected function _construct() */ protected function _prepareForm() { - /** @var \Razorpay\Subscription\Model\Plans $model */ + /** + * @var \Razorpay\Subscription\Model\Plans $model +*/ $model = $this->_coreRegistry->registry('subscribed_plan'); - /** @var \Magento\Framework\Data\Form $form */ + /** + * @var \Magento\Framework\Data\Form $form +*/ $form = $this->_formFactory->create( ['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']] ); @@ -80,7 +84,8 @@ protected function _prepareForm() if ($model->getId()) { $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']); $readonly = true; - }else { $readonly=false;} + }else { $readonly=false; + } $fieldset->addField( 'plan_name', @@ -96,11 +101,11 @@ protected function _prepareForm() // product List - Dropdown $productList = $this->_productList->toOptionArray(); - $fieldset->addField( - 'magento_product_id', - 'select', - ['name' => 'magento_product_id', 'label' => __('Select Product'), 'title' => __('Select Product'), 'required' => true, 'values' => $productList,'disabled'=>$readonly] - ); + $fieldset->addField( + 'magento_product_id', + 'select', + ['name' => 'magento_product_id', 'label' => __('Select Product'), 'title' => __('Select Product'), 'required' => true, 'values' => $productList,'disabled'=>$readonly] + ); $fieldset->addField( 'plan_bill_amount', 'text', @@ -122,28 +127,29 @@ protected function _prepareForm() array( 'value' => '', 'label' => 'Please Select', - ), + ), array( 'value' => 'daily', 'label' => 'Daily', - ), + ), array( 'value' => 'weekly', 'label' => 'Weekly', - ), + ), array( 'value' => 'monthly', 'label' => 'Monthly', - ), + ), array( 'value' => 'yearly', 'label' => 'Yearly', - ) + ) ), 'required'=>true, 'disabled'=>$readonly ) - )->setAfterElementHtml(" + )->setAfterElementHtml( + " "); + " + ); - $fieldset->addField( + $fieldset->addField( 'plan_bill_cycle', 'text', ['name' => 'plan_bill_cycle', 'label' => __('No. of Billing Cycles'), 'title' => __('No. of Billing Cycles'), 'required' => true,'disabled'=>$readonly,'class'=> 'required-entry validate-digits'] diff --git a/Block/Adminhtml/Subscription/Edit.php b/Block/Adminhtml/Subscription/Edit.php index a195b48..14d2450 100644 --- a/Block/Adminhtml/Subscription/Edit.php +++ b/Block/Adminhtml/Subscription/Edit.php @@ -14,8 +14,8 @@ class Edit extends Container /** * @param \Magento\Backend\Block\Widget\Context $context - * @param \Magento\Framework\Registry $registry - * @param array $data + * @param \Magento\Framework\Registry $registry + * @param array $data */ public function __construct( \Magento\Backend\Block\Widget\Context $context, @@ -72,7 +72,7 @@ public function getHeaderText() /** * Check permission for passed action * - * @param string $resourceId + * @param string $resourceId * @return bool */ protected function _isAllowedAction($resourceId) diff --git a/Block/Display.php b/Block/Display.php index 86abbdc..5e01498 100644 --- a/Block/Display.php +++ b/Block/Display.php @@ -23,24 +23,23 @@ class Display extends Template /** * Constructor - * @param Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param SubscribCollectionFactory $subscribCollectionFactory + * + * @param Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param SubscribCollectionFactory $subscribCollectionFactory * @param \Magento\Framework\App\ResourceConnection $Resource - * @param \Magento\Framework\Module\Dir\Reader $moduleReader - * @param array $data + * @param \Magento\Framework\Module\Dir\Reader $moduleReader + * @param array $data */ public function __construct( Context $context, \Magento\Customer\Model\Session $customerSession, SubscribCollectionFactory $subscribCollectionFactory, \Magento\Framework\App\ResourceConnection $Resource, - \Magento\Framework\Module\Dir\Reader $moduleReader, \Psr\Log\LoggerInterface $logger, \Magento\Framework\UrlInterface $urlInterface, array $data = [] - ) { $this->_subscribCollectionFactory = $subscribCollectionFactory; $this->_resource = $Resource; @@ -65,9 +64,9 @@ protected function filterOrder() $this->catalog_product_entity_varchar_table = $this->getTable("catalog_product_entity"); $this->getSelect() - ->join(array('pid' => $this->catalog_product_entity_varchar_table), $this->catalog_product_entity_table . '.entity_id= pid.entity_id', - - ); + ->join( + array('pid' => $this->catalog_product_entity_varchar_table), $this->catalog_product_entity_table . '.entity_id= pid.entity_id', + ); } public function getSubscribs() @@ -84,13 +83,17 @@ public function getSubscribs() $second_table_name = $this->_resource->getTableName('catalog_product_entity_varchar'); $third_table_name = $this->_resource->getTableName('eav_attribute'); - $subscribCollection->getSelect()->joinLeft(array('second' => $second_table_name), - 'main_table.product_id = second.entity_id', - array('second.value')); + $subscribCollection->getSelect()->joinLeft( + array('second' => $second_table_name), + 'main_table.product_id = second.entity_id', + array('second.value') + ); - $subscribCollection->getSelect()->joinLeft(array('third' => $third_table_name), - 'third.attribute_id = second.attribute_id', - array('third.attribute_id as attribute_id')); + $subscribCollection->getSelect()->joinLeft( + array('third' => $third_table_name), + 'third.attribute_id = second.attribute_id', + array('third.attribute_id as attribute_id') + ); $subscribCollection->getSelect()->where("third.attribute_code='name' and second.entity_id=main_table.product_id"); $subscribCollection->getSelect()->where("main_table.magento_user_id=".$customerId); @@ -104,7 +107,8 @@ public function getSubscribs() /** * For a given subscrib, returns its url - * @param Subscrib $subscrib + * + * @param Subscrib $subscrib * @return string */ @@ -124,21 +128,21 @@ protected function _prepareLayout() $subscribCollection = $this->_subscribCollectionFactory->create(); try{ - parent::_prepareLayout(); - if ($this->getSubscribs()) { - $pager = $this->getLayout()->createBlock( - \Magento\Theme\Block\Html\Pager::class, - 'razorpaysubscription.customer.index' - )->setCollection( - $this->getSubscribs() - ); - $this->setChild('pager', $pager); - $this->getSubscribs()->load(); + parent::_prepareLayout(); + if ($this->getSubscribs()) { + $pager = $this->getLayout()->createBlock( + \Magento\Theme\Block\Html\Pager::class, + 'razorpaysubscription.customer.index' + )->setCollection( + $this->getSubscribs() + ); + $this->setChild('pager', $pager); + $this->getSubscribs()->load(); + } + return $this; + }catch(\Exception $e){ + $this->logger->info("Exception subscription paging: {$e->getMessage()}"); } - return $this; - }catch(\Exception $e){ - $this->logger->info("Exception subscription paging: {$e->getMessage()}"); - } } /** @@ -153,7 +157,8 @@ public function getPagerHtml() /** * For a given subscrib, returns its url - * @param Subscrib $subscrib + * + * @param Subscrib $subscrib * @return string */ public function editSubscribUrl( @@ -163,5 +168,5 @@ public function editSubscribUrl( return $this->urlInterface->getUrl() ."razorpaysubscription/subscrib/edit/id/{$subscrib->getSubscriptionId()}"; } - + } diff --git a/Block/Edit.php b/Block/Edit.php index 01bd61f..1f48cc0 100644 --- a/Block/Edit.php +++ b/Block/Edit.php @@ -17,18 +17,21 @@ class Edit extends Template { /** * Core registry + * * @var Registry */ protected $_coreRegistry; /** * Subscrib + * * @var null|Subscrib */ protected $_subscrib = null; /** * SubscribCollectionFactory + * * @var null|SubscribFactory */ protected $_planCollectionFactory = null; @@ -43,10 +46,11 @@ class Edit extends Template protected $_resource; /** * Constructor - * @param Context $context - * @param Registry $coreRegistry + * + * @param Context $context + * @param Registry $coreRegistry * @param SubscribFactory $SubscribCollectionFactory - * @param array $data + * @param array $data */ public function __construct( Context $context, @@ -67,6 +71,7 @@ public function __construct( /** * fetch current plan + * * @return array */ public function getCurrentPlan() @@ -76,11 +81,13 @@ public function getCurrentPlan() $planCollection = $this->_planCollectionFactory->create(); $second_table_name = $this->_resource->getTableName('razorpay_subscriptions'); - $planCollection->getSelect()->joinLeft(array('second' => $second_table_name), - 'main_table.entity_id = second.plan_entity_id'); + $planCollection->getSelect()->joinLeft( + array('second' => $second_table_name), + 'main_table.entity_id = second.plan_entity_id' + ); $planCollection->addFieldToFilter('main_table.entity_id', $planArr['plan_entity_id']); - $planCollection->addFieldToFilter('second.subscription_id',$this->getSubscriptionId()); + $planCollection->addFieldToFilter('second.subscription_id', $this->getSubscriptionId()); $singleData= $planCollection->getFirstItem(); $data = $singleData->getData(); return $data; @@ -88,6 +95,7 @@ public function getCurrentPlan() /** * fetch all plans + * * @return array */ public function getPlans($productId) @@ -101,6 +109,7 @@ public function getPlans($productId) /** * Retrieves the entity id from the registry + * * @return int */ public function getSubscriptionId() @@ -112,6 +121,7 @@ public function getSubscriptionId() /** * Retrieves the subscription Id + * * @return string */ public function getSubscription() @@ -140,7 +150,7 @@ public function pendingUpdate() { $_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $self = $_objectManager->create('Razorpay\Subscription\Model\SubscriptionPaymentMethod'); - $subscriptionInvoices = $this->_subscription->pendingUpdate($this->getSubscriptionId(), $self->rzp) ; + $subscriptionInvoices = $this->_subscription->pendingUpdate($this->getSubscriptionId(), $self->rzp); return $subscriptionInvoices ; } } diff --git a/Block/View.php b/Block/View.php index fb59e07..9682bb0 100644 --- a/Block/View.php +++ b/Block/View.php @@ -19,18 +19,21 @@ class View extends Template { /** * Core registry + * * @var Registry */ protected $_coreRegistry; /** * Subscrib + * * @var null|Subscrib */ protected $_subscrib = null; /** * SubscribCollectionFactory + * * @var null|SubscribFactory */ protected $_subscribFactory = null; @@ -45,13 +48,14 @@ class View extends Template /** * Constructor - * @param Context $context - * @param Registry $coreRegistry - * @param SubscribFactory $subscribFactory + * + * @param Context $context + * @param Registry $coreRegistry + * @param SubscribFactory $subscribFactory * @param SubscribCollectionFactory $subscribCollectionFactory - * @param ResourceConnection $Resource - * @param Subscription $subscription - * @param array $data + * @param ResourceConnection $Resource + * @param Subscription $subscription + * @param array $data */ public function __construct( Context $context, @@ -72,6 +76,7 @@ public function __construct( /** * Lazy loads the requested subscrib + * * @return Subscrib * @throws LocalizedException */ @@ -86,29 +91,41 @@ public function getSubscrib() $six_table_name = $this->_resource->getTableName('sales_invoice'); $seventh_table_name = $this->_resource->getTableName('razorpay_plans'); - $subscribCollection->getSelect()->joinLeft(array('second' => $second_table_name), + $subscribCollection->getSelect()->joinLeft( + array('second' => $second_table_name), 'main_table.product_id = second.entity_id', - array('second.value')); + array('second.value') + ); - $subscribCollection->getSelect()->joinLeft(array('third' => $third_table_name), + $subscribCollection->getSelect()->joinLeft( + array('third' => $third_table_name), 'third.attribute_id = second.attribute_id', - array('third.attribute_id as attribute_id')); + array('third.attribute_id as attribute_id') + ); - $subscribCollection->getSelect()->joinLeft(array('fourth' => $fourth_table_name), + $subscribCollection->getSelect()->joinLeft( + array('fourth' => $fourth_table_name), 'main_table.product_id = fourth.entity_id', - array('fourth.sku')); + array('fourth.sku') + ); - $subscribCollection->getSelect()->joinLeft(array('five' => $fiveth_table_name), + $subscribCollection->getSelect()->joinLeft( + array('five' => $fiveth_table_name), 'main_table.subscription_id = five.rzp_order_id', - array('five.increment_order_id')); + array('five.increment_order_id') + ); - $subscribCollection->getSelect()->joinLeft(array('six' => $six_table_name), + $subscribCollection->getSelect()->joinLeft( + array('six' => $six_table_name), 'six.transaction_id = five.rzp_payment_id', - array('six.subtotal','six.grand_total','six.total_qty','six.store_currency_code','six.base_shipping_amount')); + array('six.subtotal','six.grand_total','six.total_qty','six.store_currency_code','six.base_shipping_amount') + ); - $subscribCollection->getSelect()->joinLeft(array('seven' => $seventh_table_name), + $subscribCollection->getSelect()->joinLeft( + array('seven' => $seventh_table_name), 'main_table.plan_entity_id = seven.entity_id', - array('seven.plan_id','seven.plan_type','seven.plan_name')); + array('seven.plan_id','seven.plan_type','seven.plan_name') + ); $subscribCollection->getSelect()->where("third.attribute_code='name' and second.entity_id=main_table.product_id"); @@ -121,6 +138,7 @@ public function getSubscrib() /** * Retrieves the subscrib id from the registry + * * @return int */ protected function _getSubscribId() @@ -153,7 +171,7 @@ public function getSubscriptionInvoice() $_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $self = $_objectManager->create('Razorpay\Subscription\Model\SubscriptionPaymentMethod'); - $subscriptionInvoices = $this->_subscription->fetchSubscriptionInvoice($singleData->getSubscriptionId(), $self->rzp) ; + $subscriptionInvoices = $this->_subscription->fetchSubscriptionInvoice($singleData->getSubscriptionId(), $self->rzp); return $subscriptionInvoices ; } diff --git a/Controller/.DS_Store b/Controller/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4ab2b121e9fe342895ef1a59ffacb48ef6d91307 GIT binary patch literal 6148 zcmeHKO>fgM7=GQA;S>-(OaciZ`NFNBMrfOMK+3vt=nW|d4uG~~sc57uu9B2$l%m}E z3-BBGBi#8p@c5$>S(wBLA?8TQ^x2$7p zHi1m{k<*kaI;Cu!wX$8szo>v(JCF7$!K$V7%lgTaIFm72)vK`&fAm8eBK0~P(40!F zwFGZM#W-u^e{JQ5$dAD|p#tN?&3tzMLjFx^=Fc!vim~zwyib41ix=h0&gWY^%hIwM z4!^U`M)%t0b8xOddQw_HB-x3?b;gul198i=Lu@9Yf3?$BSY zJbvea|73i8diH+#VfFDd<_BZ=y0qQ4xP~tXF4gK?Smc?^-y&ztU-KL~1)Ks`T>-l* z@EccM2seMHfK#BQfZ87fTw!3bHmJ7_6#5DP?4nv5V)etQIKpCJu{MYn7&BC$p)z~L zV1|x*VeP(UVi^?lH8M1 zz$x%wDZsji;o%5VvS({+a_X!V@ME|#l~)@)ry$TrF>=*Wd>5__^+E-}z+!C>H8A%h Npk;7{Q{b;E@DmK*jWYlM literal 0 HcmV?d00001 diff --git a/Controller/Adminhtml/Index/Index.php b/Controller/Adminhtml/Index/Index.php index 5754df2..86912a0 100755 --- a/Controller/Adminhtml/Index/Index.php +++ b/Controller/Adminhtml/Index/Index.php @@ -9,6 +9,7 @@ /** * Class Index + * * @package Razorpay\Grid\Controller\Adminhtml\Index */ class Index extends Action @@ -21,7 +22,7 @@ class Index extends Action /** * Constructor * - * @param \Magento\Backend\App\Action\Context $context + * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\View\Result\PageFactory $rawFactory */ public function __construct(Context $context, PageFactory $rawFactory) diff --git a/Controller/Adminhtml/Plan/Edit.php b/Controller/Adminhtml/Plan/Edit.php index 35b88ab..d648b8f 100644 --- a/Controller/Adminhtml/Plan/Edit.php +++ b/Controller/Adminhtml/Plan/Edit.php @@ -23,10 +23,10 @@ class Edit extends Action protected $_model; /** - * @param Action\Context $context + * @param Action\Context $context * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory - * @param \Magento\Framework\Registry $registry - * @param \Razorpay\Subscription\Model\Plans $model + * @param \Magento\Framework\Registry $registry + * @param \Razorpay\Subscription\Model\Plans $model */ public function __construct( Action\Context $context, @@ -56,7 +56,9 @@ protected function _isAllowed() protected function _initAction() { // load layout, set active menu and breadcrumbs - /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ + /** + * @var \Magento\Backend\Model\View\Result\Page $resultPage +*/ $resultPage = $this->_resultPageFactory->create(); $resultPage->setActiveMenu('Razorpay_Subscription::rzp_subscriptions') ->addBreadcrumb(__('Plan'), __('Plan')) @@ -67,7 +69,7 @@ protected function _initAction() /** * Edit Plan * - * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect + * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() @@ -80,7 +82,9 @@ public function execute() $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This plan not exists.')); - /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + /** + * \Magento\Backend\Model\View\Result\Redirect $resultRedirect +*/ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); @@ -94,7 +98,9 @@ public function execute() $this->_coreRegistry->register('subscribed_plan', $model); - /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ + /** + * @var \Magento\Backend\Model\View\Result\Page $resultPage +*/ $resultPage = $this->_initAction(); $resultPage->addBreadcrumb( $id ? __('Edit Plan') : __('New Plan'), diff --git a/Controller/Adminhtml/Plan/Index.php b/Controller/Adminhtml/Plan/Index.php index d618544..ccc69fc 100644 --- a/Controller/Adminhtml/Plan/Index.php +++ b/Controller/Adminhtml/Plan/Index.php @@ -15,7 +15,7 @@ class Index extends Action protected $resultPageFactory; /** - * @param Context $context + * @param Context $context * @param PageFactory $resultPageFactory */ public function __construct( @@ -33,7 +33,9 @@ public function __construct( */ public function execute() { - /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ + /** + * @var \Magento\Backend\Model\View\Result\Page $resultPage +*/ $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Razorpay_Subscription::rzp_subscriptions'); $resultPage->addBreadcrumb(__('Plans'), __('Plans')); diff --git a/Controller/Adminhtml/Plan/MassDisable.php b/Controller/Adminhtml/Plan/MassDisable.php index 420028d..dd9a2f4 100644 --- a/Controller/Adminhtml/Plan/MassDisable.php +++ b/Controller/Adminhtml/Plan/MassDisable.php @@ -20,8 +20,8 @@ class MassDisable extends \Magento\Backend\App\Action /** - * @param Context $context - * @param Filter $filter + * @param Context $context + * @param Filter $filter * @param CollectionFactory $collectionFactory */ public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory) @@ -42,13 +42,15 @@ public function execute() $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = $collection->getSize(); foreach ($collection as $item) { - $item->setData('plan_status',0); + $item->setData('plan_status', 0); $item->save(); } $this->messageManager->addSuccess(__('A total of %1 record(s) have been Disabled.', $collectionSize)); - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + /** + * @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect +*/ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); } diff --git a/Controller/Adminhtml/Plan/MassEnable.php b/Controller/Adminhtml/Plan/MassEnable.php index d756f56..85b67ea 100644 --- a/Controller/Adminhtml/Plan/MassEnable.php +++ b/Controller/Adminhtml/Plan/MassEnable.php @@ -20,8 +20,8 @@ class MassEnable extends \Magento\Backend\App\Action /** - * @param Context $context - * @param Filter $filter + * @param Context $context + * @param Filter $filter * @param CollectionFactory $collectionFactory */ public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory) @@ -41,13 +41,15 @@ public function execute() $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = $collection->getSize(); foreach ($collection as $item) { - $item->setData('plan_status',1); + $item->setData('plan_status', 1); $item->save(); } $this->messageManager->addSuccess(__('A total of %1 record(s) have been Enabled.', $collectionSize)); - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + /** + * @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect +*/ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); } diff --git a/Controller/Adminhtml/Plan/NewAction.php b/Controller/Adminhtml/Plan/NewAction.php index 7098764..12e4fbc 100644 --- a/Controller/Adminhtml/Plan/NewAction.php +++ b/Controller/Adminhtml/Plan/NewAction.php @@ -11,7 +11,7 @@ class NewAction extends Action protected $_resultForwardFactory; /** - * @param \Magento\Backend\App\Action\Context $context + * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory */ public function __construct( @@ -37,7 +37,9 @@ protected function _isAllowed() */ public function execute() { - /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */ + /** + * @var \Magento\Backend\Model\View\Result\Forward $resultForward +*/ $resultForward = $this->_resultForwardFactory->create(); return $resultForward->forward('edit'); } diff --git a/Controller/Adminhtml/Subscription/Cancel.php b/Controller/Adminhtml/Subscription/Cancel.php index 8d92778..4b7eedc 100644 --- a/Controller/Adminhtml/Subscription/Cancel.php +++ b/Controller/Adminhtml/Subscription/Cancel.php @@ -64,8 +64,8 @@ class Cancel extends BaseController protected $checkoutSession; /** - * @param Context $context - * @param Filter $filter + * @param Context $context + * @param Filter $filter * @param CollectionFactory $collectionFactory */ public function __construct( @@ -78,8 +78,7 @@ public function __construct( \Magento\Backend\Helper\Data $backendHelper, \Razorpay\Subscription\Helper\Subscription $subscription, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { $this->filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct( @@ -109,14 +108,14 @@ public function execute() try { $id = $this->getRequest()->getParam('subscription_id'); $entity_id = $this->getRequest()->getParam('id'); - if($id){ + if($id) { $updateBy = 'admin'; $this->subscription->cancelSubscription($id, $this->rzp, $updateBy); $this->messageManager->addSuccess(__('Subscription has been cancelled.')); $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - if($entity_id){ + if($entity_id) { return $resultRedirect->setPath('subscribed/subscription/view/subscription_id/'.$id.'/id/'.$entity_id); } return $resultRedirect->setPath('subscribed/index/index'); diff --git a/Controller/Adminhtml/Subscription/Edit.php b/Controller/Adminhtml/Subscription/Edit.php index 150ca67..42bc255 100644 --- a/Controller/Adminhtml/Subscription/Edit.php +++ b/Controller/Adminhtml/Subscription/Edit.php @@ -41,15 +41,15 @@ public function __construct( $this->_model = $model; parent::__construct($context); } - + /** * {@inheritdoc} */ protected function _isAllowed() { - return $this->_authorization->isAllowed('Razorpay_Subscription::subscription_save'); + return $this->_authorization->isAllowed('Razorpay_Subscription::subscription_upgrade'); } - + /** * Init actions * @@ -105,7 +105,7 @@ public function execute() $resultPage->getConfig()->getTitle()->prepend(__('Subscriptions')); $resultPage->getConfig()->getTitle() ->prepend($model->getId() ? $model->getName() : __('New Subscription')); - + return $resultPage; } } \ No newline at end of file diff --git a/Controller/Adminhtml/Subscription/Index.php b/Controller/Adminhtml/Subscription/Index.php index 298723e..d2b5b0e 100644 --- a/Controller/Adminhtml/Subscription/Index.php +++ b/Controller/Adminhtml/Subscription/Index.php @@ -14,7 +14,9 @@ class Index extends Subscription */ public function execute() { - /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ + /** + * @var \Magento\Backend\Model\View\Result\Page $resultPage +*/ $resultPage = $this->_resultPageFactory->create(); $resultPage->setActiveMenu('Razorpay_Subscription::rzp_subscriptions'); $resultPage->addBreadcrumb(__('Jobs'), __('Jobs')); diff --git a/Controller/Adminhtml/Subscription/MassCancel.php b/Controller/Adminhtml/Subscription/MassCancel.php index 30b7a27..7439e41 100644 --- a/Controller/Adminhtml/Subscription/MassCancel.php +++ b/Controller/Adminhtml/Subscription/MassCancel.php @@ -64,8 +64,8 @@ class MassCancel extends BaseController protected $checkoutSession; /** - * @param Context $context - * @param Filter $filter + * @param Context $context + * @param Filter $filter * @param CollectionFactory $collectionFactory */ public function __construct( @@ -78,8 +78,7 @@ public function __construct( \Magento\Backend\Helper\Data $backendHelper, \Razorpay\Subscription\Helper\Subscription $subscription, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { $this->filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct( diff --git a/Controller/Adminhtml/Subscription/MassPause.php b/Controller/Adminhtml/Subscription/MassPause.php index d2888ba..21e7857 100644 --- a/Controller/Adminhtml/Subscription/MassPause.php +++ b/Controller/Adminhtml/Subscription/MassPause.php @@ -64,8 +64,8 @@ class MassPause extends BaseController protected $checkoutSession; /** - * @param Context $context - * @param Filter $filter + * @param Context $context + * @param Filter $filter * @param CollectionFactory $collectionFactory */ public function __construct( @@ -78,8 +78,7 @@ public function __construct( \Magento\Backend\Helper\Data $backendHelper, \Razorpay\Subscription\Helper\Subscription $subscription, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { $this->filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct( diff --git a/Controller/Adminhtml/Subscription/MassResume.php b/Controller/Adminhtml/Subscription/MassResume.php index 376386d..62ec396 100644 --- a/Controller/Adminhtml/Subscription/MassResume.php +++ b/Controller/Adminhtml/Subscription/MassResume.php @@ -64,8 +64,8 @@ class MassResume extends BaseController protected $checkoutSession; /** - * @param Context $context - * @param Filter $filter + * @param Context $context + * @param Filter $filter * @param CollectionFactory $collectionFactory */ public function __construct( @@ -78,8 +78,7 @@ public function __construct( \Magento\Backend\Helper\Data $backendHelper, \Razorpay\Subscription\Helper\Subscription $subscription, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { $this->filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct( diff --git a/Controller/Adminhtml/Subscription/NewAction.php b/Controller/Adminhtml/Subscription/NewAction.php index fd04d4e..746501f 100644 --- a/Controller/Adminhtml/Subscription/NewAction.php +++ b/Controller/Adminhtml/Subscription/NewAction.php @@ -11,7 +11,7 @@ class NewAction extends Action protected $_resultForwardFactory; /** - * @param \Magento\Backend\App\Action\Context $context + * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory */ public function __construct( @@ -37,7 +37,9 @@ protected function _isAllowed() */ public function execute() { - /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */ + /** + * @var \Magento\Backend\Model\View\Result\Forward $resultForward +*/ $resultForward = $this->_resultForwardFactory->create(); return $resultForward->forward('edit'); } diff --git a/Controller/Adminhtml/Subscription/Pause.php b/Controller/Adminhtml/Subscription/Pause.php index 6702580..4fb9189 100644 --- a/Controller/Adminhtml/Subscription/Pause.php +++ b/Controller/Adminhtml/Subscription/Pause.php @@ -64,8 +64,8 @@ class Pause extends BaseController protected $checkoutSession; /** - * @param Context $context - * @param Filter $filter + * @param Context $context + * @param Filter $filter * @param CollectionFactory $collectionFactory */ public function __construct( @@ -78,8 +78,7 @@ public function __construct( \Magento\Backend\Helper\Data $backendHelper, \Razorpay\Subscription\Helper\Subscription $subscription, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { $this->filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct( @@ -109,14 +108,14 @@ public function execute() try { $id = $this->getRequest()->getParam('subscription_id'); $entity_id = $this->getRequest()->getParam('id'); - if($id){ + if($id) { $updateBy = 'admin'; $this->subscription->pauseSubscription($id, $this->rzp, $updateBy); $this->messageManager->addSuccess(__('Subscription has been paused.')); $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - if($entity_id){ + if($entity_id) { return $resultRedirect->setPath('subscribed/subscription/view/subscription_id/'.$id.'/id/'.$entity_id); } return $resultRedirect->setPath('subscribed/index/index'); diff --git a/Controller/Adminhtml/Subscription/Resume.php b/Controller/Adminhtml/Subscription/Resume.php index fcd779d..7804a73 100644 --- a/Controller/Adminhtml/Subscription/Resume.php +++ b/Controller/Adminhtml/Subscription/Resume.php @@ -64,8 +64,8 @@ class Resume extends BaseController protected $checkoutSession; /** - * @param Context $context - * @param Filter $filter + * @param Context $context + * @param Filter $filter * @param CollectionFactory $collectionFactory */ public function __construct( @@ -78,8 +78,7 @@ public function __construct( \Magento\Backend\Helper\Data $backendHelper, \Razorpay\Subscription\Helper\Subscription $subscription, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { $this->filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct( @@ -109,14 +108,14 @@ public function execute() try { $id = $this->getRequest()->getParam('subscription_id'); $entity_id = $this->getRequest()->getParam('id'); - if($id){ + if($id) { $updateBy = 'admin'; $this->subscription->resumeSubscription($id, $this->rzp, $updateBy); $this->messageManager->addSuccess(__('Subscription has been resumed.')); $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - if($entity_id){ + if($entity_id) { return $resultRedirect->setPath('subscribed/subscription/view/subscription_id/'.$id.'/id/'.$entity_id); } return $resultRedirect->setPath('subscribed/index/index'); diff --git a/Controller/Adminhtml/Subscription/Upgrade.php b/Controller/Adminhtml/Subscription/Upgrade.php index 1e38fe7..a5a0b26 100644 --- a/Controller/Adminhtml/Subscription/Upgrade.php +++ b/Controller/Adminhtml/Subscription/Upgrade.php @@ -12,14 +12,13 @@ class Upgrade extends Action protected $_model; /** - * @param Action\Context $context + * @param Action\Context $context * @param \Maxime\Jobs\Model\Department $model **/ public function __construct( Action\Context $context, \Razorpay\Subscription\Model\Subscrib $model - ) - { + ) { parent::__construct($context); $this->_model = $model; } @@ -34,17 +33,22 @@ protected function _isAllowed() /** * Save action + * * @return \Magento\Framework\Controller\ResultInterface * */ public function execute() { $data = $this->getRequest()->getPostValue(); - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + /** + * @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect +*/ $resultRedirect = $this->resultRedirectFactory->create(); if ($data) { - /** @var \Maxime\Jobs\Model\Department $model */ + /** + * @var \Maxime\Jobs\Model\Department $model +*/ $model = $this->_model; $id = $this->getRequest()->getParam('id'); diff --git a/Controller/Adminhtml/Subscription/View.php b/Controller/Adminhtml/Subscription/View.php index a04708d..621a13c 100644 --- a/Controller/Adminhtml/Subscription/View.php +++ b/Controller/Adminhtml/Subscription/View.php @@ -15,6 +15,7 @@ class View extends Action /** * Core registry + * * @var Registry */ protected $coreRegistry; @@ -25,8 +26,8 @@ class View extends Action protected $resultPageFactory; /** - * @param Context $context - * @param Registry $coreRegistry + * @param Context $context + * @param Registry $coreRegistry * @param PageFactory $resultPageFactory * * @codeCoverageIgnore @@ -46,6 +47,7 @@ public function __construct( /** * Saves the blog id to the register and renders the page + * * @return Page * @throws LocalizedException */ diff --git a/Controller/Customer/CancelSubscription.php b/Controller/Customer/CancelSubscription.php index 0847331..b1059d0 100644 --- a/Controller/Customer/CancelSubscription.php +++ b/Controller/Customer/CancelSubscription.php @@ -28,15 +28,14 @@ class CancelSubscription extends BaseController private $subscription; /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Razorpay\Model\Config\Payment $razorpayConfig - * @param \Magento\Framework\App\CacheInterface $cache - * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\App\CacheInterface $cache + * @param \Psr\Log\LoggerInterface $logger */ public function __construct( - \Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, @@ -45,14 +44,12 @@ public function __construct( \Razorpay\Subscription\Helper\Subscription $subscription, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { parent::__construct( $context, $customerSession, $checkoutSession, $config - ); $this->messageManager = $messageManager; $this->config = $config; diff --git a/Controller/Customer/Index.php b/Controller/Customer/Index.php index 5823e0b..c01aac6 100644 --- a/Controller/Customer/Index.php +++ b/Controller/Customer/Index.php @@ -16,7 +16,7 @@ class Index extends Action protected $resultPageFactory; /** - * @param Context $context + * @param Context $context * @param PageFactory $resultPageFactory * * @codeCoverageIgnore @@ -32,6 +32,7 @@ public function __construct(Context $context,PageFactory $resultPageFactory) /** * Prints the blog from informed order id + * * @return Page * @throws LocalizedException */ diff --git a/Controller/Customer/MassCancelSubscription.php b/Controller/Customer/MassCancelSubscription.php index 746c1f3..5b9907b 100644 --- a/Controller/Customer/MassCancelSubscription.php +++ b/Controller/Customer/MassCancelSubscription.php @@ -28,15 +28,14 @@ class MassCancelSubscription extends BaseController private $subscription; /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Razorpay\Model\Config\Payment $razorpayConfig - * @param \Magento\Framework\App\CacheInterface $cache - * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\App\CacheInterface $cache + * @param \Psr\Log\LoggerInterface $logger */ public function __construct( - \Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, @@ -45,14 +44,12 @@ public function __construct( \Razorpay\Subscription\Helper\Subscription $subscription, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { parent::__construct( $context, $customerSession, $checkoutSession, $config - ); $this->messageManager = $messageManager; $this->config = $config; @@ -73,9 +70,9 @@ public function execute() $updateBy = 'customer'; foreach ($orders as $order) { - $subscriptionData = $this->getSubscription($order); - if($subscriptionData['status'] != "created" || $subscriptionData['status'] != "cancelled"){ - $this->subscription->cancelSubscription($subscriptionData['subscription_id'], $this->rzp, $updateBy); + $subscriptionData = $this->getSubscription($order); + if($subscriptionData['status'] != "created" || $subscriptionData['status'] != "cancelled") { + $this->subscription->cancelSubscription($subscriptionData['subscription_id'], $this->rzp, $updateBy); } } @@ -83,7 +80,7 @@ public function execute() return $this->_redirect('razorpaysubscription/customer/index/'); } catch (\Exception $e) { $this->messageManager->addErrorMessage(__($e->getMessage())); - return $this->_redirect('razorpaysubscription/customer/index/'); + return $this->_redirect('razorpaysubscription/customer/index/'); } } diff --git a/Controller/Customer/MassPauseSubscription.php b/Controller/Customer/MassPauseSubscription.php index c7ee3fc..7ea8203 100644 --- a/Controller/Customer/MassPauseSubscription.php +++ b/Controller/Customer/MassPauseSubscription.php @@ -28,15 +28,14 @@ class MassPauseSubscription extends BaseController private $subscription; /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Razorpay\Model\Config\Payment $razorpayConfig - * @param \Magento\Framework\App\CacheInterface $cache - * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\App\CacheInterface $cache + * @param \Psr\Log\LoggerInterface $logger */ public function __construct( - \Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, @@ -45,14 +44,12 @@ public function __construct( \Razorpay\Subscription\Helper\Subscription $subscription, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { parent::__construct( $context, $customerSession, $checkoutSession, $config - ); $this->messageManager = $messageManager; $this->config = $config; @@ -73,9 +70,9 @@ public function execute() $updateBy = 'customer'; foreach ($orders as $order) { - $subscriptionData = $this->getSubscription($order); - if($subscriptionData['status'] == "active"){ - $this->subscription->pauseSubscription($subscriptionData['subscription_id'], $this->rzp, $updateBy); + $subscriptionData = $this->getSubscription($order); + if($subscriptionData['status'] == "active") { + $this->subscription->pauseSubscription($subscriptionData['subscription_id'], $this->rzp, $updateBy); } } @@ -83,7 +80,7 @@ public function execute() return $this->_redirect('razorpaysubscription/customer/index/'); } catch (\Exception $e) { $this->messageManager->addErrorMessage(__($e->getMessage())); - return $this->_redirect('razorpaysubscription/customer/index/'); + return $this->_redirect('razorpaysubscription/customer/index/'); } } diff --git a/Controller/Customer/MassResumeSubscription.php b/Controller/Customer/MassResumeSubscription.php index f4881a2..d047f68 100644 --- a/Controller/Customer/MassResumeSubscription.php +++ b/Controller/Customer/MassResumeSubscription.php @@ -28,15 +28,14 @@ class MassResumeSubscription extends BaseController private $subscription; /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Razorpay\Model\Config\Payment $razorpayConfig - * @param \Magento\Framework\App\CacheInterface $cache - * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\App\CacheInterface $cache + * @param \Psr\Log\LoggerInterface $logger */ public function __construct( - \Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, @@ -45,14 +44,12 @@ public function __construct( \Razorpay\Subscription\Helper\Subscription $subscription, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { parent::__construct( $context, $customerSession, $checkoutSession, $config - ); $this->messageManager = $messageManager; $this->config = $config; @@ -73,9 +70,9 @@ public function execute() $updateBy = 'customer'; foreach ($orders as $order) { - $subscriptionData = $this->getSubscription($order); - if($subscriptionData['status'] == "paused"){ - $this->subscription->resumeSubscription($subscriptionData['subscription_id'], $this->rzp, $updateBy); + $subscriptionData = $this->getSubscription($order); + if($subscriptionData['status'] == "paused") { + $this->subscription->resumeSubscription($subscriptionData['subscription_id'], $this->rzp, $updateBy); } } @@ -83,7 +80,7 @@ public function execute() return $this->_redirect('razorpaysubscription/customer/index/'); } catch (\Exception $e) { $this->messageManager->addErrorMessage(__($e->getMessage())); - return $this->_redirect('razorpaysubscription/customer/index/'); + return $this->_redirect('razorpaysubscription/customer/index/'); } } diff --git a/Controller/Customer/PauseSubscription.php b/Controller/Customer/PauseSubscription.php index b5d920d..7ba1d48 100644 --- a/Controller/Customer/PauseSubscription.php +++ b/Controller/Customer/PauseSubscription.php @@ -28,15 +28,14 @@ class PauseSubscription extends BaseController private $subscription; /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Razorpay\Model\Config\Payment $razorpayConfig - * @param \Magento\Framework\App\CacheInterface $cache - * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\App\CacheInterface $cache + * @param \Psr\Log\LoggerInterface $logger */ public function __construct( - \Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, @@ -45,14 +44,12 @@ public function __construct( \Razorpay\Subscription\Helper\Subscription $subscription, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { parent::__construct( $context, $customerSession, $checkoutSession, $config - ); $this->messageManager = $messageManager; $this->config = $config; diff --git a/Controller/Customer/ResumeSubscription.php b/Controller/Customer/ResumeSubscription.php index 296bb73..b0b8573 100644 --- a/Controller/Customer/ResumeSubscription.php +++ b/Controller/Customer/ResumeSubscription.php @@ -28,15 +28,14 @@ class ResumeSubscription extends BaseController private $subscription; /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Razorpay\Model\Config\Payment $razorpayConfig - * @param \Magento\Framework\App\CacheInterface $cache - * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\App\CacheInterface $cache + * @param \Psr\Log\LoggerInterface $logger */ public function __construct( - \Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, @@ -45,14 +44,12 @@ public function __construct( \Razorpay\Subscription\Helper\Subscription $subscription, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { parent::__construct( $context, $customerSession, $checkoutSession, $config - ); $this->messageManager = $messageManager; $this->config = $config; diff --git a/Controller/Subscrib/Edit.php b/Controller/Subscrib/Edit.php index 355c576..6b78c6c 100644 --- a/Controller/Subscrib/Edit.php +++ b/Controller/Subscrib/Edit.php @@ -15,6 +15,7 @@ class Edit extends Action /** * Core registry + * * @var Registry */ protected $_coreRegistry; @@ -25,8 +26,8 @@ class Edit extends Action protected $_resultPageFactory; /** - * @param Context $context - * @param Registry $coreRegistry + * @param Context $context + * @param Registry $coreRegistry * @param PageFactory $resultPageFactory * * @codeCoverageIgnore @@ -47,6 +48,7 @@ public function __construct( /** * Saves the blog id to the register and renders the page + * * @return Page * @throws LocalizedException */ diff --git a/Controller/Subscrib/FormPost.php b/Controller/Subscrib/FormPost.php index 9241b52..6386024 100644 --- a/Controller/Subscrib/FormPost.php +++ b/Controller/Subscrib/FormPost.php @@ -31,26 +31,27 @@ class FormPost extends BaseController /** * SubscribCollectionFactory + * * @var null|SubscribFactory */ protected $_subscribCollectionFactory = null; /** * PlanCollectionFactory + * * @var null|PlanFactory */ protected $_planCollectionFactory = null; /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Razorpay\Model\Config\Payment $razorpayConfig - * @param \Magento\Framework\App\CacheInterface $cache - * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\App\CacheInterface $cache + * @param \Psr\Log\LoggerInterface $logger */ public function __construct( - \Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, @@ -61,14 +62,12 @@ public function __construct( PlanCollectionFactory $planCollectionFactory, SubscribCollectionFactory $subscribCollectionFactory, \Magento\Framework\Message\ManagerInterface $messageManager - ) - { + ) { parent::__construct( $context, $customerSession, $checkoutSession, $config - ); $this->messageManager = $messageManager; $this->config = $config; @@ -95,17 +94,17 @@ public function execute() return $this->_redirect('customer/account/login'); } - if($this->planValidate($subscriptionId, $plan['magento_product_id'])){ - $postValues['entity_id'] = $plan['entity_id']; - $postValues['schedule_change_at'] = 'cycle_end'; - $this->subscription->editSubscription($subscriptionId, $postValues, $this->rzp); - $this->messageManager->addSuccess(__("Subscription updated successfully!")); + if($this->planValidate($subscriptionId, $plan['magento_product_id'])) { + $postValues['entity_id'] = $plan['entity_id']; + $postValues['schedule_change_at'] = 'cycle_end'; + $this->subscription->editSubscription($subscriptionId, $postValues, $this->rzp); + $this->messageManager->addSuccess(__("Subscription updated successfully!")); } return $this->_redirect('razorpaysubscription/customer/index/'); } catch (\Exception $e) { $this->messageManager->addErrorMessage(__($e->getMessage())); - return $this->_redirect('razorpaysubscription/customer/index/'); + return $this->_redirect('razorpaysubscription/customer/index/'); } } @@ -119,11 +118,11 @@ protected function planValidate($subscriptionId, $productId) $singleData= $subscribCollection->getFirstItem(); $data = $singleData->getData(); - if(count($data)==0){ - return $response; + if(count($data)==0) { + return $response; } - if($data['product_id']==$productId){ + if($data['product_id']==$productId) { $response = true; } diff --git a/Controller/Subscrib/View.php b/Controller/Subscrib/View.php index 40f5ed3..85ee4bf 100644 --- a/Controller/Subscrib/View.php +++ b/Controller/Subscrib/View.php @@ -15,6 +15,7 @@ class View extends Action /** * Core registry + * * @var Registry */ protected $_coreRegistry; @@ -25,8 +26,8 @@ class View extends Action protected $_resultPageFactory; /** - * @param Context $context - * @param Registry $coreRegistry + * @param Context $context + * @param Registry $coreRegistry * @param PageFactory $resultPageFactory * * @codeCoverageIgnore @@ -46,6 +47,7 @@ public function __construct( /** * Saves the blog id to the register and renders the page + * * @return Page * @throws LocalizedException */ diff --git a/Controller/Subscription/SubscriptionOrder.php b/Controller/Subscription/SubscriptionOrder.php index 10ae569..4f5c558 100644 --- a/Controller/Subscription/SubscriptionOrder.php +++ b/Controller/Subscription/SubscriptionOrder.php @@ -48,20 +48,20 @@ class SubscriptionOrder extends BaseController */ protected $checkoutSession; /** - * @var Request - */ + * @var Request + */ protected $request; /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Razorpay\Model\Config\Payment $razorpayConfig - * @param \Magento\Framework\App\CacheInterface $cache + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Razorpay\Model\Config\Payment $razorpayConfig + * @param \Magento\Framework\App\CacheInterface $cache * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Psr\Log\LoggerInterface $logger - * @param Request $request + * @param \Psr\Log\LoggerInterface $logger + * @param Request $request */ public function __construct( \Magento\Framework\App\Action\Context $context, @@ -102,24 +102,21 @@ public function execute() try{ $receiptId = $this->getQuote()->getId(); - if(empty($post['error']) === false) - { + if(empty($post['error']) === false) { $this->messageManager->addError(__('Payment Failed')); return $this->_redirect('checkout/cart'); } - if (isset($post['order_check'])) - { - if (empty($this->cache->load("quote_processing_".$receiptId)) === false) - { + if (isset($post['order_check'])) { + if (empty($this->cache->load("quote_processing_".$receiptId)) === false) { $responseContent = [ 'success' => true, 'order_id' => false, 'parameters' => [] ]; - # fetch the related sales order and verify the payment ID with rzp payment id - # To avoid duplicate order entry for same quote + // fetch the related sales order and verify the payment ID with rzp payment id + // To avoid duplicate order entry for same quote $collection = $this->_objectManager->get('Magento\Sales\Model\Order') ->getCollection() ->addFieldToSelect('entity_id') @@ -128,10 +125,11 @@ public function execute() $salesOrder = $collection->getData(); - if (empty($salesOrder['entity_id']) === false) - { - $this->logger->info("Razorpay inside order already processed with webhook quoteID:" . $receiptId - ." and OrderID:".$salesOrder['entity_id']); + if (empty($salesOrder['entity_id']) === false) { + $this->logger->info( + "Razorpay inside order already processed with webhook quoteID:" . $receiptId + ." and OrderID:".$salesOrder['entity_id'] + ); $this->checkoutSession ->setLastQuoteId($this->getQuote()->getId()) @@ -151,8 +149,7 @@ public function execute() } else { - if(empty($receiptId) === false) - { + if(empty($receiptId) === false) { //set the chache to stop webhook processing $this->cache->save("started", "quote_Front_processing_$receiptId", ["razorpay"], 30); @@ -165,8 +162,10 @@ public function execute() } else { - $this->logger->info("Razorpay order already processed with quoteID:" . $this->checkoutSession - ->getLastQuoteId()); + $this->logger->info( + "Razorpay order already processed with quoteID:" . $this->checkoutSession + ->getLastQuoteId() + ); $responseContent = [ 'success' => true, @@ -184,8 +183,7 @@ public function execute() return $response; } - if(isset($post['razorpay_payment_id'])) - { + if(isset($post['razorpay_payment_id'])) { $this->getQuote()->getPayment()->setMethod(PaymentMethod::METHOD_CODE); try diff --git a/Helper/Subscription.php b/Helper/Subscription.php index 598de06..976b5e5 100644 --- a/Helper/Subscription.php +++ b/Helper/Subscription.php @@ -45,8 +45,9 @@ public function __construct(Product $product, LoggerInterface $logger, Cart $ca /** * This function is used to create subscription for the user - * @param $quote - * @param $rzp + * + * @param $quote + * @param $rzp * @return mixed * @throws \Exception */ @@ -96,7 +97,7 @@ public function createSubscription($quote, $rzp) ->setSubscriptionId($subscriptionResponse->id) ->setRazorpayCustomerId($subscriptionResponse->customer_id) ->setmagentoUserId($quote->getCustomerId()) - ->setProductId( $planData['magento_product_id']) + ->setProductId($planData['magento_product_id']) ->setQuoteId($quote->getId()) ->setStatus($subscriptionResponse->status) ->setTotalCount($subscriptionResponse->total_count) @@ -151,7 +152,8 @@ public function fetchPlanId($quote) /** * This function gets the product details from quotes - * @param $quote + * + * @param $quote * @return array */ public function getPlanIdFromQuote($quote) @@ -165,8 +167,9 @@ public function getPlanIdFromQuote($quote) /** * This functions creates customers in razorpay - * @param $quote - * @param $rzp + * + * @param $quote + * @param $rzp * @return mixed * @throws \Exception */ @@ -203,7 +206,8 @@ public function getCustomerId($quote, $rzp) /** * This function get the merchant preferences from razorpay dashboard - * @param $apiKey + * + * @param $apiKey * @return array */ public function getMerchantPreferences($apiKey) @@ -233,8 +237,8 @@ public function getMerchantPreferences($apiKey) } /** - * @param $cartItems - * @param $validateTo + * @param $cartItems + * @param $validateTo * @return bool */ public function validateIsASubscriptionProduct($cartItems, $validateTo) @@ -263,8 +267,9 @@ public function validateIsASubscriptionProduct($cartItems, $validateTo) /** * Cancel subscription - * @param $id - * @param $rzp + * + * @param $id + * @param $rzp * @throws \Exception */ public function cancelSubscription($id, $rzp, $updateBy) @@ -284,7 +289,8 @@ public function cancelSubscription($id, $rzp, $updateBy) /** * Pause Subscription - * @param $id + * + * @param $id * @return array */ public function pauseSubscription($id, $rzp, $updateBy) @@ -304,7 +310,8 @@ public function pauseSubscription($id, $rzp, $updateBy) /** * Resume Subscription - * @param $id + * + * @param $id * @return array */ public function resumeSubscription($id, $rzp, $updateBy) @@ -324,10 +331,12 @@ public function resumeSubscription($id, $rzp, $updateBy) /** * Fetch all Subscription invoices - * @param $subscriptionId + * + * @param $subscriptionId * @return array */ - public function fetchSubscriptionInvoice($subscriptionId, $rzp){ + public function fetchSubscriptionInvoice($subscriptionId, $rzp) + { $subscriptionResponse = $rzp->invoice->all(["subscription_id"=>$subscriptionId]); @@ -335,7 +344,7 @@ public function fetchSubscriptionInvoice($subscriptionId, $rzp){ $subscription = $this->objectManagement->create('Razorpay\Subscription\Model\Subscriptions'); $postUpdate = $subscription->load($subscriptionId, 'subscription_id'); - if($subscriptionResponse->count > $postUpdate->getPaidCount()){ + if($subscriptionResponse->count > $postUpdate->getPaidCount()) { $postUpdate->setRemainingCount($postUpdate->getTotalCount() - $subscriptionResponse->count); $postUpdate->setPaidCount($subscriptionResponse->count); $postUpdate->setNextChargeAt($subscriptionResponse->items[0]['billing_end']); @@ -346,7 +355,8 @@ public function fetchSubscriptionInvoice($subscriptionId, $rzp){ /** * Edit Subscription - * @param $subscriptionId + * + * @param $subscriptionId * @return array */ public function editSubscription($subscriptionId, $attributes, $rzp) @@ -361,13 +371,14 @@ public function editSubscription($subscriptionId, $attributes, $rzp) $postUpdate->save(); }catch(\Error $e){ - throw new \Exception( $e->getMessage() ); + throw new \Exception($e->getMessage()); } } /** * Fetch pending updates - * @param $subscriptionId + * + * @param $subscriptionId * @return array */ public function pendingUpdate($subscriptionId, $rzp) @@ -375,13 +386,14 @@ public function pendingUpdate($subscriptionId, $rzp) try{ $subscriptionResponse = $rzp->subscription->fetch($subscriptionId)->pendingUpdate(); return $subscriptionResponse; - }catch(Error $e){ + }catch(Error $e){ return []; } } /** * Checking if subscription is active or not in payment setting + * * @return bool */ public function isSubscriptionActive() diff --git a/Helper/SubscriptionWebhook.php b/Helper/SubscriptionWebhook.php index e7540b6..201b6fc 100644 --- a/Helper/SubscriptionWebhook.php +++ b/Helper/SubscriptionWebhook.php @@ -58,7 +58,8 @@ public function __construct($logger) /** * Processing subscription charge event - * @param $data + * + * @param $data * @return int|void * @throws \Magento\Framework\Exception\LocalizedException */ @@ -95,7 +96,7 @@ public function processSubscriptionCharged($data) $orderLinkCollection->setWebhookFirstNotifiedAt(time()) ->setWebhookCount($orderLink['webhook_count'] + 1) ->save(); - return; + return; } $webhookWaitTime = $this->_config->getConfigData(Config::WEBHOOK_WAIT_TIME) ?? 300; @@ -338,14 +339,16 @@ protected function getQuoteObject($post, $quoteId) $customer = $customer->loadByEmail($email); //if quote billing address doesn't contains address, set it as customer default billing address - if ((empty($quote->getBillingAddress()->getFirstname()) === true) and - (empty($customer->getEntityId()) === false)) { + if ((empty($quote->getBillingAddress()->getFirstname()) === true) + and (empty($customer->getEntityId()) === false) + ) { $quote->getBillingAddress()->setCustomerAddressId($customer->getDefaultBillingAddress()['id']); } //If need to insert new customer as guest - if ((empty($customer->getEntityId()) === true) or - (empty($quote->getBillingAddress()->getCustomerId()) === true)) { + if ((empty($customer->getEntityId()) === true) + or (empty($quote->getBillingAddress()->getCustomerId()) === true) + ) { $quote->setCustomerFirstname($firstName); $quote->setCustomerLastname($lastName); $quote->setCustomerEmail($email); @@ -370,8 +373,9 @@ protected function getQuoteObject($post, $quoteId) * Fetch the related sales order and verify * the payment ID with rzp payment id * To avoid duplicate order entry for same quote - * @param $quoteId - * @param $paymentId + * + * @param $quoteId + * @param $paymentId * @return bool */ protected function verifyPaymentIdTowardsOrder($quoteId, $paymentId): bool @@ -397,9 +401,9 @@ protected function verifyPaymentIdTowardsOrder($quoteId, $paymentId): bool } /** - * @param $data - * @param $subscriptionData - * @param $quote + * @param $data + * @param $subscriptionData + * @param $quote * @return array */ protected function createNewOrderData($data, $subscriptionData, $quote): array @@ -438,9 +442,10 @@ protected function createNewOrderData($data, $subscriptionData, $quote): array /** * creating new order from quote - * @param $quote - * @param $amount - * @param $paymentId + * + * @param $quote + * @param $amount + * @param $paymentId * @return mixed */ protected function createOrderFromQuote($quote, $amount, $paymentId) @@ -464,4 +469,4 @@ protected function createOrderFromQuote($quote, $amount, $paymentId) return $order; } -} +} \ No newline at end of file diff --git a/Logger/SubscriptionLogger.php b/Logger/SubscriptionLogger.php index feec8d4..d5c5447 100755 --- a/Logger/SubscriptionLogger.php +++ b/Logger/SubscriptionLogger.php @@ -11,17 +11,20 @@ class SubscriptionLogger extends \Magento\Framework\Logger\Handler\Base { /** * Logging level + * * @var int */ protected $loggerType = \Monolog\Logger::INFO; /** * File name + * * @var string */ public $fileName = ''; /** * File name + * * @var string */ public $cutomfileName = 'NO_PATH'; diff --git a/Model/.DS_Store b/Model/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0_init(\Razorpay\Subscription\Model\ResourceModel\Plans::class); } - public function getEnableStatus() { + public function getEnableStatus() + { return 1; } - public function getDisableStatus() { + public function getDisableStatus() + { return 0; } - public function getAvailableStatuses() { + public function getAvailableStatuses() + { return [$this->getDisableStatus() => __('Disabled'), $this->getEnableStatus() => __('Enabled')]; } } diff --git a/Model/ResourceModel/Plans/CollectionFactory.php b/Model/ResourceModel/Plans/CollectionFactory.php index 02e1e56..4c07876 100644 --- a/Model/ResourceModel/Plans/CollectionFactory.php +++ b/Model/ResourceModel/Plans/CollectionFactory.php @@ -21,7 +21,7 @@ class CollectionFactory * Factory constructor * * @param \Magento\Framework\ObjectManagerInterface $objectManager - * @param string $instanceName + * @param string $instanceName */ public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = '\\Razorpay\\Subscription\\Model\\ResourceModel\\Plans\\Collection') { @@ -32,7 +32,7 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan /** * Create class instance with specified parameters * - * @param array $data + * @param array $data * @return \Razorpay\Subscription\Model\ResourceModel\Plans\Collection */ public function create(array $data = array()) diff --git a/Model/ResourceModel/Subscrib.php b/Model/ResourceModel/Subscrib.php index a6e1eb6..ab9c204 100644 --- a/Model/ResourceModel/Subscrib.php +++ b/Model/ResourceModel/Subscrib.php @@ -6,6 +6,7 @@ /** * Class Subscrib + * * @package Razorpay\Subscription\Model\ResourceModel */ class Subscrib extends AbstractDb diff --git a/Model/ResourceModel/Subscrib/Collection.php b/Model/ResourceModel/Subscrib/Collection.php index 448e8f6..d821854 100755 --- a/Model/ResourceModel/Subscrib/Collection.php +++ b/Model/ResourceModel/Subscrib/Collection.php @@ -6,6 +6,7 @@ /** * Class Collection + * * @package Razorpay\Subscription\Model\ResourceModel\Subscrib */ class Collection extends AbstractCollection @@ -25,6 +26,7 @@ class Collection extends AbstractCollection /** * Define resource model + * * @return void */ protected function _construct() diff --git a/Model/Source/ProductList.php b/Model/Source/ProductList.php index e735637..b3d94d9 100644 --- a/Model/Source/ProductList.php +++ b/Model/Source/ProductList.php @@ -22,7 +22,7 @@ public function toOptionArray() $options[] = ['label' => '-- Please Select --', 'value' => '']; $collection = $this->collectionFactory->create() ->addAttributeToSelect('*') - ->addAttributeToFilter('type_id', array('in' => array('simple','configurable'))); + ->addAttributeToFilter('type_id', array('in' => array('simple','configurable'))); foreach ($collection as $category) { $options[] = [ diff --git a/Model/Subscrib.php b/Model/Subscrib.php index 11e98de..bcbbd4b 100755 --- a/Model/Subscrib.php +++ b/Model/Subscrib.php @@ -8,6 +8,7 @@ /** * Class Subscrib + * * @package Razorpay\Subscription\Model */ class Subscrib extends AbstractModel implements SubscribInterface, IdentityInterface @@ -71,6 +72,7 @@ public function getId() /** * Return identities + * * @return string[] */ public function getIdentities() @@ -81,7 +83,7 @@ public function getIdentities() /** * Set SubscriptionId * - * @param string $SubscriptionId + * @param string $SubscriptionId * @return $this */ public function setSubscriptionId($SubscriptionId) @@ -92,7 +94,7 @@ public function setSubscriptionId($SubscriptionId) /** * Set Status * - * @param string $Status + * @param string $Status * @return $this */ public function setStatus($status) @@ -103,7 +105,7 @@ public function setStatus($status) /** * Set Value * - * @param string $value + * @param string $value * @return $this */ public function setValue($value) @@ -114,7 +116,7 @@ public function setValue($value) /** * Set Next Charge At * - * @param string $nextChargeAt + * @param string $nextChargeAt * @return $this */ public function setNextChargeAt($nextChargeAt) @@ -125,7 +127,7 @@ public function setNextChargeAt($nextChargeAt) /** * Set ID * - * @param int $id + * @param int $id * @return $this */ public function setId($id) diff --git a/Model/SubscriptionConfig.php b/Model/SubscriptionConfig.php index bfa3329..ac5d252 100644 --- a/Model/SubscriptionConfig.php +++ b/Model/SubscriptionConfig.php @@ -42,7 +42,7 @@ public function __construct( /** * Retrieve information from payment configuration * - * @param string $field + * @param string $field * @param null|string $storeId * * @return mixed @@ -59,7 +59,7 @@ public function getConfigData($field, $storeId = null) } /** - * @param int $storeId + * @param int $storeId * @return $this */ public function setStoreId($storeId) @@ -71,8 +71,8 @@ public function setStoreId($storeId) /** * Set information from payment configuration * - * @param string $field - * @param string $value + * @param string $field + * @param string $value * @param null|string $storeId * * @return mixed diff --git a/Model/SubscriptionPaymentMethod.php b/Model/SubscriptionPaymentMethod.php index 773fff6..c400fe9 100644 --- a/Model/SubscriptionPaymentMethod.php +++ b/Model/SubscriptionPaymentMethod.php @@ -11,7 +11,8 @@ /** * Class SubscriptionPaymentMethod - * @package Razorpay\Magento\Model + * + * @package Razorpay\Magento\Model * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) @@ -95,22 +96,22 @@ class SubscriptionPaymentMethod extends \Magento\Payment\Model\Method\AbstractMe protected $orderRepository; /** - * @param \Magento\Framework\Model\Context $context - * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory - * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory - * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Payment\Model\Method\Logger $logger - * @param \Razorpay\Magento\Model\Config $config - * @param \Magento\Framework\App\RequestInterface $request - * @param TransactionCollectionFactory $salesTransactionCollectionFactory - * @param \Magento\Framework\App\ProductMetadataInterface $productMetaData - * @param \Magento\Directory\Model\RegionFactory $regionFactory - * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection - * @param array $data + * @param \Magento\Framework\Model\Context $context + * @param \Magento\Framework\Registry $registry + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory + * @param \Magento\Payment\Helper\Data $paymentData + * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param \Magento\Payment\Model\Method\Logger $logger + * @param \Razorpay\Magento\Model\Config $config + * @param \Magento\Framework\App\RequestInterface $request + * @param TransactionCollectionFactory $salesTransactionCollectionFactory + * @param \Magento\Framework\App\ProductMetadataInterface $productMetaData + * @param \Magento\Directory\Model\RegionFactory $regionFactory + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource + * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository + * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection + * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -186,8 +187,8 @@ public function validate() /** * Authorizes specified amount * - * @param InfoInterface $payment - * @param string $amount + * @param InfoInterface $payment + * @param string $amount * @return $this * @throws LocalizedException */ @@ -195,7 +196,9 @@ public function authorize(InfoInterface $payment, $amount) { try { - /** @var \Magento\Sales\Model\Order\Payment $payment */ + /** + * @var \Magento\Sales\Model\Order\Payment $payment +*/ $order = $payment->getOrder(); $orderId = $order->getIncrementId(); @@ -206,8 +209,7 @@ public function authorize(InfoInterface $payment, $amount) //validate RzpOrderamount with quote/order amount before signature $orderAmount = (int) (number_format($order->getGrandTotal() * 100, 0, ".", "")); - if((empty($request) === true) and (isset($request['razorpay_signature']) === true)) - { + if((empty($request) === true) and (isset($request['razorpay_signature']) === true)) { //set request data based on redirect flow $request['paymentMethod']['additional_data'] = [ 'rzp_payment_id' => $request['razorpay_payment_id'], @@ -216,8 +218,7 @@ public function authorize(InfoInterface $payment, $amount) ]; } - if(empty($request['payload']['payment']['entity']['id']) === false) - { + if(empty($request['payload']['payment']['entity']['id']) === false) { $payment_id = $request['payload']['payment']['entity']['id']; $rzp_order_id = $request['payload']['subscription']['entity']['id']; @@ -231,18 +232,19 @@ public function authorize(InfoInterface $payment, $amount) $payment_id = $request['paymentMethod']['additional_data']['rzp_payment_id']; $rzp_order_id = $this->order->getOrderId(); - if ($orderAmount !== $this->order->getRazorpayOrderAmount()) - { + if ($orderAmount !== $this->order->getRazorpayOrderAmount()) { $rzpOrderAmount = $order->getOrderCurrency()->formatTxt(number_format($this->order->getRazorpayOrderAmount() / 100, 2, ".", "")); throw new LocalizedException(__("Cart order amount = %1 doesn't match with amount paid = %2", $order->getOrderCurrency()->formatTxt($order->getGrandTotal()), $rzpOrderAmount)); } - $this->validateSignature([ + $this->validateSignature( + [ 'razorpay_payment_id' => $payment_id, 'razorpay_subscription_id' => $rzp_order_id, 'razorpay_signature' => $request['paymentMethod']['additional_data']['rzp_signature'] - ]); + ] + ); } @@ -268,8 +270,8 @@ public function authorize(InfoInterface $payment, $amount) /** * Capture specified amount with authorization * - * @param InfoInterface $payment - * @param string $amount + * @param InfoInterface $payment + * @param string $amount * @return $this */ @@ -317,13 +319,11 @@ protected function updatePaymentNote($paymentId, $order, $rzpSubscriptionId, $is $orderLink = $orderLinkCollection->getData(); - if (empty($orderLink['entity_id']) === false) - { + if (empty($orderLink['entity_id']) === false) { $orderLinkCollection->setRzpPaymentId($paymentId) ->setIncrementOrderId($order->getIncrementId()); - if ($isWebhookCall) - { + if ($isWebhookCall) { $orderLinkCollection->setByWebhook(true)->save(); } else @@ -336,8 +336,7 @@ protected function updatePaymentNote($paymentId, $order, $rzpSubscriptionId, $is $subscriptionCollection = $_objectManager->get('Razorpay\Subscription\Model\Subscriptions') ->getCollection() ->addFilter('subscription_id', $rzpSubscriptionId) - ->getFirstItem() - ; + ->getFirstItem(); $subscriptionData = $subscriptionCollection->getData(); if (!empty($subscriptionData)) { @@ -353,17 +352,16 @@ protected function updatePaymentNote($paymentId, $order, $rzpSubscriptionId, $is $productId = $item->getProduct()->getId(); } - if ($isWebhookCall) - { + if ($isWebhookCall) { $subscriptionOrderMapping->setByWebhook(true); } else { $subscriptionOrderMapping->setByFrontend(true); $productObject = $_objectManager->get('Magento\Catalog\Model\Product')->load($productId); - if($productObject){ + if($productObject) { /* @var Magento\Catalog\Model\Product $productObject */ - if($productObject->getRazorpaySubscriptionTrial()){ + if($productObject->getRazorpaySubscriptionTrial()) { $subscriptionOrderMapping->setIsTrialOrder(true); } } @@ -400,7 +398,8 @@ protected function validateSignature($request) /** * [validateWebhookSignature Used in case of webhook request for payment auth] - * @param array $post + * + * @param array $post * @return [type] */ public function validateWebhookSignature(array $post) @@ -432,7 +431,7 @@ protected function getChannel() /** * Retrieve information from payment configuration * - * @param string $field + * @param string $field * @param int|string|null|\Magento\Store\Model\Store $storeId * * @return mixed diff --git a/Observer/CheckoutCartProductAddAfterObserver.php b/Observer/CheckoutCartProductAddAfterObserver.php index 0616a8e..ade5471 100644 --- a/Observer/CheckoutCartProductAddAfterObserver.php +++ b/Observer/CheckoutCartProductAddAfterObserver.php @@ -25,17 +25,16 @@ class CheckoutCartProductAddAfterObserver implements ObserverInterface private $objectManagement; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\App\RequestInterface $request + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\Serialize\SerializerInterface $serializer - * @param \Psr\Log\LoggerInterface $logger + * @param \Psr\Log\LoggerInterface $logger */ public function __construct( \Magento\Framework\App\RequestInterface $request, \Magento\Framework\Serialize\SerializerInterface $serializer, \Psr\Log\LoggerInterface $logger - ) - { + ) { $this->request = $request; $this->serializer = $serializer; $this->logger = $logger; @@ -44,7 +43,7 @@ public function __construct( } /** - * @param EventObserver $observer + * @param EventObserver $observer * @return void */ public function execute(EventObserver $observer) @@ -52,7 +51,7 @@ public function execute(EventObserver $observer) /* @var \Magento\Quote\Model\Quote\Item $item */ $item = $observer->getQuoteItem(); $additionalOptions = array(); - if ($additionalOption = $item->getOptionByCode('additional_options')){ + if ($additionalOption = $item->getOptionByCode('additional_options')) { $additionalOptions = $this->serializer->unserialize($additionalOption->getValue()); } @@ -61,8 +60,7 @@ public function execute(EventObserver $observer) $this->logger->info($planId); - if($paymentOption == "subscription" ) - { + if($paymentOption == "subscription" ) { $planData = $this->objectManagement->get('Razorpay\Subscription\Model\Plans') ->getCollection() ->addFieldToSelect("plan_bill_amount", "price") @@ -72,7 +70,7 @@ public function execute(EventObserver $observer) ->getFirstItem() ->getData(); - if(!empty($planData)){ + if(!empty($planData)) { $item->setCustomPrice($planData["price"]); $item->setOriginalCustomPrice($planData["price"]); $item->getProduct()->setIsSuperMode(true); @@ -85,13 +83,14 @@ public function execute(EventObserver $observer) ]; - if(count($additionalOptions) > 0) - { - $item->addOption(array( + if(count($additionalOptions) > 0) { + $item->addOption( + array( 'product_id' => $item->getProductId(), 'code' => 'additional_options', 'value' => $this->serializer->serialize($additionalOptions) - )); + ) + ); } } diff --git a/Observer/OrderPlaceSaveAfterObserver.php b/Observer/OrderPlaceSaveAfterObserver.php index 53c8943..c4693a8 100644 --- a/Observer/OrderPlaceSaveAfterObserver.php +++ b/Observer/OrderPlaceSaveAfterObserver.php @@ -50,15 +50,16 @@ public function execute(Observer $observer) $order = $observer->getOrder(); - /** @var Payment $payment */ + /** + * @var Payment $payment +*/ $payment = $order->getPayment(); $paymentMethod = $payment->getMethodInstance(); $code = $paymentMethod->getCode(); - if($code === SubscriptionPaymentMethod::METHOD_CODE) - { + if($code === SubscriptionPaymentMethod::METHOD_CODE) { $this->updateOrderLinkStatus($payment); } @@ -102,8 +103,7 @@ private function updateOrderLinkStatus(Payment $payment) $orderLink = $orderLinkCollection->getData(); - if (empty($orderLink['entity_id']) === false) - { + if (empty($orderLink['entity_id']) === false) { $orderLinkCollection->setOrderId($order->getEntityId()) ->setOrderPlaced(true) ->save(); diff --git a/Observer/PaymentMethodActiveObserver.php b/Observer/PaymentMethodActiveObserver.php index a0888c9..182c2a0 100644 --- a/Observer/PaymentMethodActiveObserver.php +++ b/Observer/PaymentMethodActiveObserver.php @@ -43,8 +43,7 @@ public function __construct( ProductRepositoryInterface $productRepository, Cart $cart, ManagerInterface $messageManager - ) - { + ) { $this->logger = $logger; $this->productRepository = $productRepository; $this->subscriptionHelper = $subscriptionHelper; @@ -53,7 +52,7 @@ public function __construct( } /** - * @param Observer $observer + * @param Observer $observer * @return void */ public function execute(Observer $observer) @@ -62,7 +61,7 @@ public function execute(Observer $observer) $code = $observer->getEvent()->getMethodInstance()->getCode(); $quote = $this->cart->getQuote(); - if ( $this->cart->getQuote()->getItemsCount() > 1) { + if ($this->cart->getQuote()->getItemsCount() > 1) { $this->disablePaymentMethod($result, SubscriptionPaymentMethod::METHOD_CODE, $code); } else { /* @var \Magento\Quote\Model\Quote $quote */ @@ -88,6 +87,7 @@ public function execute(Observer $observer) /** * Disabling the payment method + * * @param $result * @param $paymentMethod * @param $methodCode @@ -95,7 +95,7 @@ public function execute(Observer $observer) public function disablePaymentMethod($result, $paymentMethod, $methodCode) { $this->logger->info("-------------disabling $paymentMethod ---------------------"); - if( $methodCode == $paymentMethod) { + if($methodCode == $paymentMethod) { $result->setData('is_available', false); } } diff --git a/Observer/RestrictRecurringProductToCartObserver.php b/Observer/RestrictRecurringProductToCartObserver.php index 48146f8..e910944 100644 --- a/Observer/RestrictRecurringProductToCartObserver.php +++ b/Observer/RestrictRecurringProductToCartObserver.php @@ -46,8 +46,7 @@ public function __construct( Product $product, LoggerInterface $logger, Subscription $subscriptionHelper - ) - { + ) { $this->messageManager = $messageManager; $this->cart = $cart; $this->logger = $logger; @@ -82,15 +81,15 @@ public function execute(Observer $observer) } /** - * @param $allCartItems - * @param $cartItemsCount - * @param $validateTo + * @param $allCartItems + * @param $cartItemsCount + * @param $validateTo * @return string */ private function verifyProductInCart($allCartItems, $cartItemsCount, $validateTo): string { $message = ""; - if($this->subscriptionHelper->validateIsASubscriptionProduct($allCartItems, $validateTo)){ + if($this->subscriptionHelper->validateIsASubscriptionProduct($allCartItems, $validateTo)) { $message = "You cannot have regular products and subscriptions product in your shopping cart"; } else if($cartItemsCount >= 1 && $this->paymentType != "oneTime") { $message = "You can only have 1 recurring subscription product in your shopping cart at a time."; diff --git a/Plugin/CsrfValidatorSkip.php b/Plugin/CsrfValidatorSkip.php index 16e6388..e713db1 100644 --- a/Plugin/CsrfValidatorSkip.php +++ b/Plugin/CsrfValidatorSkip.php @@ -5,9 +5,9 @@ class CsrfValidatorSkip { /** * @param \Magento\Framework\App\Request\CsrfValidator $subject - * @param \Closure $proceed - * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Framework\App\ActionInterface $action + * @param \Closure $proceed + * @param \Magento\Framework\App\RequestInterface $request + * @param \Magento\Framework\App\ActionInterface $action */ public function aroundValidate( $subject, diff --git a/Setup/UpgradeData.php b/Setup/UpgradeData.php index 45ba08f..d6c5f00 100644 --- a/Setup/UpgradeData.php +++ b/Setup/UpgradeData.php @@ -37,8 +37,8 @@ public function __construct( \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, \Magento\Eav\Model\Entity\Attribute\SetFactory $attributeSetFactory, \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory $groupCollectionFactory, - EavSetupFactory $eavSetupFactory) - { + EavSetupFactory $eavSetupFactory + ) { $this->eavSetupFactory = $eavSetupFactory; $this->eavTypeFactory = $eavTypeFactory; $this->attributeSetFactory = $attributeSetFactory; @@ -54,7 +54,8 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface } - public function installEntities($setup){ + public function installEntities($setup) + { $groupName = 'Subscriptions by Razorpay'; @@ -95,7 +96,7 @@ public function installEntities($setup){ $eavSetup->addAttribute(Product::ENTITY, $attributeCode, $attribute); } - $this->sortGroup($groupName,11); + $this->sortGroup($groupName, 11); } private function sortGroup($attributeGroupName, $order) diff --git a/Setup/UpgradeSchema.php b/Setup/UpgradeSchema.php index 9965065..bffa8b0 100755 --- a/Setup/UpgradeSchema.php +++ b/Setup/UpgradeSchema.php @@ -10,20 +10,28 @@ use Razorpay\Subscription\Model\ResourceModel\Plans; use Razorpay\Subscription\Model\ResourceModel\Subscriptions; use Razorpay\Subscription\Model\ResourceModel\SubscriptionsOrderMapping; - -class UpgradeSchema implements UpgradeSchemaInterface +/** + * @UpgradeSchema to update the current db with subscription + **/ +class UpgradeSchema implements UpgradeSchemaInterface { - public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context){ + /** + * @upgrade database and create table + **/ + public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context) + { $setup->startSetup(); $this->createPlanTable($setup); $this->createSubscriptionTable($setup); $this->createSubscriptionOrderMappingTable($setup); - $setup->endSetup(); } - - private function createPlanTable($setup){ +/** + * @createPlanTable create plan table + **/ + private function createPlanTable($setup) + { $table = $setup->getConnection()->newTable($setup->getTable(Plans::TABLE_NAME)); $table @@ -76,7 +84,7 @@ private function createPlanTable($setup){ 'comment' => 'Razorpay Plan Description' ] ) - ->addColumn( + ->addColumn( 'plan_type', Table::TYPE_TEXT, 30, @@ -164,17 +172,17 @@ private function createPlanTable($setup){ ) ->addIndex( 'plan_product', - ['plan_id', 'plan_type','magento_product_id','plan_name'], + ['plan_id', 'plan_type', 'magento_product_id', 'plan_name'], [ 'type' => AdapterInterface::INDEX_TYPE_INDEX, ] - ) - ; + ); $setup->getConnection()->createTable($table); - } - +/** + * @createSubscriptionTable - subsription record + **/ private function createSubscriptionTable($setup) { $table = $setup->getConnection()->newTable($setup->getTable(Subscriptions::TABLE_NAME)); @@ -366,32 +374,32 @@ private function createSubscriptionTable($setup) ) ->addIndex( 'subscription_status', - ['subscription_id','status'], + ['subscription_id', 'status'], [ 'type' => AdapterInterface::INDEX_TYPE_INDEX, ] ) ->addIndex( 'product_id', - ['subscription_id','product_id'], + ['subscription_id', 'product_id'], [ 'type' => AdapterInterface::INDEX_TYPE_INDEX, ] ) ->addIndex( 'subscription_user', - ['subscription_id','razorpay_customer_id','magento_user_id'], + ['subscription_id', 'razorpay_customer_id', 'magento_user_id'], [ 'type' => AdapterInterface::INDEX_TYPE_INDEX, ] - ) - ; + ); $setup->getConnection()->createTable($table); - } - - public function createSubscriptionOrderMappingTable($setup) + /** + * @createSubscriptionOrderMappingTable mapping order and subscription + */ + public function createSubscriptionOrderMappingTable($setup) { $table = $setup->getConnection()->newTable($setup->getTable(SubscriptionsOrderMapping::TABLE_NAME)); @@ -481,14 +489,12 @@ public function createSubscriptionOrderMappingTable($setup) ) ->addIndex( 'order_details', - ['is_trial_order','increment_order_id','rzp_payment_id'], + ['is_trial_order', 'increment_order_id', 'rzp_payment_id'], [ 'type' => AdapterInterface::INDEX_TYPE_INDEX, 'nullable' => false, ] - ) - ; + ); $setup->getConnection()->createTable($table); - } } diff --git a/Ui/Component/Listing/Column/Actions.php b/Ui/Component/Listing/Column/Actions.php index 3f0063f..5577217 100644 --- a/Ui/Component/Listing/Column/Actions.php +++ b/Ui/Component/Listing/Column/Actions.php @@ -13,7 +13,9 @@ class Actions extends Column */ private $urlBuilder; - /** Url Path */ + /** + * Url Path +*/ const SUBSCRIPTION_VIEW_URL_PATH = 'subscribed/subscription/view'; const SUBSCRIPTION_EDIT_URL_PATH = 'subscribed/subscription/edit'; const CANCEL_URL_PATH = 'subscribed/subscription/cancel'; @@ -25,8 +27,8 @@ public function __construct( UiComponentFactory $uiComponentFactory, array $components = array(), UrlInterface $urlBuilder, - array $data = array()) - { + array $data = array() + ) { parent::__construct($context, $uiComponentFactory, $components, $data); $this->urlBuilder = $urlBuilder; } @@ -34,7 +36,7 @@ public function __construct( /** * Prepare Data Source * - * @param array $dataSource + * @param array $dataSource * @return void */ public function prepareDataSource(array $dataSource) diff --git a/Ui/Component/Listing/Column/PlanActions.php b/Ui/Component/Listing/Column/PlanActions.php index a26a173..a746bd3 100644 --- a/Ui/Component/Listing/Column/PlanActions.php +++ b/Ui/Component/Listing/Column/PlanActions.php @@ -21,11 +21,11 @@ class PlanActions extends Column protected $urlBuilder; /** - * @param ContextInterface $context + * @param ContextInterface $context * @param UiComponentFactory $uiComponentFactory - * @param UrlInterface $urlBuilder - * @param array $components - * @param array $data + * @param UrlInterface $urlBuilder + * @param array $components + * @param array $data */ public function __construct( ContextInterface $context, @@ -41,7 +41,7 @@ public function __construct( /** * Prepare Data Source * - * @param array $dataSource + * @param array $dataSource * @return array */ public function prepareDataSource(array $dataSource) diff --git a/Ui/Component/Listing/Column/SubscriptionView.php b/Ui/Component/Listing/Column/SubscriptionView.php index 139ae32..ca110f6 100644 --- a/Ui/Component/Listing/Column/SubscriptionView.php +++ b/Ui/Component/Listing/Column/SubscriptionView.php @@ -13,7 +13,9 @@ class SubscriptionView extends Column */ private $urlBuilder; - /** Url Path */ + /** + * Url Path +*/ const SUBSCRIPTION_VIEW_URL_PATH = 'subscribed/subscription/view'; public function __construct( @@ -21,8 +23,8 @@ public function __construct( UiComponentFactory $uiComponentFactory, array $components = array(), UrlInterface $urlBuilder, - array $data = array()) - { + array $data = array() + ) { parent::__construct($context, $uiComponentFactory, $components, $data); $this->urlBuilder = $urlBuilder; } @@ -30,7 +32,7 @@ public function __construct( /** * Prepare Data Source * - * @param array $dataSource + * @param array $dataSource * @return void */ public function prepareDataSource(array $dataSource) diff --git a/Ui/DataProvider/Plan/Collection.php b/Ui/DataProvider/Plan/Collection.php index f20f47a..7408f89 100755 --- a/Ui/DataProvider/Plan/Collection.php +++ b/Ui/DataProvider/Plan/Collection.php @@ -6,6 +6,7 @@ /** * Class Collection + * * @package MageDigest\Grid\Ui\DataProvider\Category\Listing */ class Collection extends SearchResult @@ -18,17 +19,17 @@ class Collection extends SearchResult protected function _initSelect() { - $this->getSelect()->joinLeft( + $this->getSelect()->joinLeft( ['secondTable' => $this->getTable('catalog_product_entity_varchar')], 'main_table.magento_product_id = secondTable.entity_id', ['value'] ); - $this->getSelect()->joinLeft( + $this->getSelect()->joinLeft( ['thirdTable' => $this->getTable('eav_attribute')], 'thirdTable.attribute_id = secondTable.attribute_id', ['attribute_id'] ); - $this->getSelect()->where("thirdTable.attribute_code='name' and secondTable.entity_id=main_table.magento_product_id"); + $this->getSelect()->where("thirdTable.attribute_code='name' and secondTable.entity_id=main_table.magento_product_id"); parent::_initSelect(); $this->addFilterToMap('entity_id', 'main_table.entity_id'); } diff --git a/Ui/DataProvider/Plan/ListingDataProvider.php b/Ui/DataProvider/Plan/ListingDataProvider.php index f99140b..36dfad5 100644 --- a/Ui/DataProvider/Plan/ListingDataProvider.php +++ b/Ui/DataProvider/Plan/ListingDataProvider.php @@ -4,6 +4,7 @@ /** * Class ListingDataProvider + * * @package Razorpay\Subscription\Ui\DataProvider\Reviews */ class ListingDataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider diff --git a/Ui/DataProvider/Subscriptions/Collection.php b/Ui/DataProvider/Subscriptions/Collection.php index d88d7aa..915d024 100755 --- a/Ui/DataProvider/Subscriptions/Collection.php +++ b/Ui/DataProvider/Subscriptions/Collection.php @@ -6,6 +6,7 @@ /** * Class Collection + * * @package MageDigest\Grid\Ui\DataProvider\Category\Listing */ class Collection extends SearchResult diff --git a/Ui/DataProvider/Subscriptions/ListingDataProvider.php b/Ui/DataProvider/Subscriptions/ListingDataProvider.php index 72711f9..fc11432 100644 --- a/Ui/DataProvider/Subscriptions/ListingDataProvider.php +++ b/Ui/DataProvider/Subscriptions/ListingDataProvider.php @@ -4,6 +4,7 @@ /** * Class ListingDataProvider + * * @package Razorpay\Subscription\Ui\DataProvider\Reviews */ class ListingDataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider diff --git a/view/adminhtml/templates/subscription_order_details_view.phtml b/view/adminhtml/templates/subscription_order_details_view.phtml index afd4097..b462ed8 100644 --- a/view/adminhtml/templates/subscription_order_details_view.phtml +++ b/view/adminhtml/templates/subscription_order_details_view.phtml @@ -6,7 +6,7 @@ $subscriptionDetails = $block->fetchSubscriptionOrderDetails(); ?> - + diff --git a/view/adminhtml/templates/subscription_view.phtml b/view/adminhtml/templates/subscription_view.phtml index 6860e14..f7701d3 100644 --- a/view/adminhtml/templates/subscription_view.phtml +++ b/view/adminhtml/templates/subscription_view.phtml @@ -1,4 +1,6 @@ - + getSubscrib(); @@ -12,19 +14,19 @@ $invoices = $block->getSubscriptionInvoice(); Back + if ($subscriptionInfo['status'] != 'paused') : ?> - + - +