From 5e06c5cbb95724faf7676bf2dc0dc8a787a60a27 Mon Sep 17 00:00:00 2001 From: Adam Grohs Date: Thu, 24 Sep 2020 07:43:30 -0500 Subject: [PATCH 01/15] Update README.md --- README.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 13fa609..9b7a1d7 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,6 @@ This extension makes Zendesk work seamlessly with Magento to enable stores to de - Create support tickets from Contact Us requests - Easily add the [Embeddables](https://www.zendesk.com/embeddables) Web Widget to your site -The latest stable version of the extension can be installed via the [Magento Connect](http://www.magentocommerce.com/magento-connect/catalog/product/view/id/15129/) marketplace. - ## API ### General Notes @@ -149,12 +147,8 @@ During development you may wish to clear out the configuration for the Magento e ## Contribution -Improvements to the extension are always welcome. To contribute, please submit detailed Pull Requests. - -## Bugs - -Please submit bug reports to Zendesk. +Improvements to the extension are always welcome. To contribute, please submit detailed Pull Requests. To share any Issues or potential Bugs, please submit an Issue. ## Copyright and License -Copyright 2012-present, Zendesk Inc. Licensed under the Apache License Version 2.0. +Copyright 2012-present, Zendesk Inc. + Copyright 2020-present, agnoStack, Inc. Licensed under the Apache License Version 2.0. From db111e7c5b5dd7560fc58bc5e59a928607494c9e Mon Sep 17 00:00:00 2001 From: Adam Grohs Date: Thu, 24 Sep 2020 07:44:45 -0500 Subject: [PATCH 02/15] Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index e76a0c3..df5c444 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2015 Zendesk +Copyright Zendesk Inc. + agnoStack, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From a89fa87106e5e97a0d2c2d2f498e2b68c2965287 Mon Sep 17 00:00:00 2001 From: Adam Grohs Date: Thu, 24 Sep 2020 07:47:06 -0500 Subject: [PATCH 03/15] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b7a1d7..7508e4c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ The new 3.0 version fixes several core issues (incorrect/missing order address, # Zendesk Extension for Magento -This extension makes Zendesk work seamlessly with Magento to enable stores to deliver great customer support. **Features include:** +This Extension makes Zendesk work seamlessly with Magento 1 to enable stores to deliver great customer support. It was originally develop by [Zendesk](https://www.zendesk.com) and is now supported and maintained by [agnoStack](https://agnostack.com). +**Features include:** - Enable Single Sign-on with Zendesk - Create support tickets without leaving Magento From e5ad20cdc932b646b29725bcee3e9b9bf9418e95 Mon Sep 17 00:00:00 2001 From: Adam Grohs Date: Thu, 24 Sep 2020 07:47:25 -0500 Subject: [PATCH 04/15] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7508e4c..b42322d 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ The new 3.0 version fixes several core issues (incorrect/missing order address, # Zendesk Extension for Magento This Extension makes Zendesk work seamlessly with Magento 1 to enable stores to deliver great customer support. It was originally develop by [Zendesk](https://www.zendesk.com) and is now supported and maintained by [agnoStack](https://agnostack.com). + **Features include:** - Enable Single Sign-on with Zendesk From cb147bcb5336524db91b3eebc748de21b7c0d643 Mon Sep 17 00:00:00 2001 From: Adam Grohs Date: Wed, 30 Sep 2020 07:37:09 -0500 Subject: [PATCH 05/15] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b42322d..f66f769 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ The new 3.0 version fixes several core issues (incorrect/missing order address, * Enable direct Order Search by ID * Access Order Messages and Notes +Dowload the latest version of the extension at: https://github.com/agnostack/magento_extension/releases/tag/v3.0.0. Additional detailed instructions on configuring agnoStack for the new version can be found at: https://agnostack.com/faqs/setup-onboarding/configuring-magento-1. + # Zendesk Extension for Magento From 1e5e4d4e4164af35fa02e5db3db2fdf3e3fda817 Mon Sep 17 00:00:00 2001 From: Adam Grohs Date: Wed, 30 Sep 2020 07:37:21 -0500 Subject: [PATCH 06/15] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f66f769..216d0dc 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ The new 3.0 version fixes several core issues (incorrect/missing order address, * Enable direct Order Search by ID * Access Order Messages and Notes -Dowload the latest version of the extension at: https://github.com/agnostack/magento_extension/releases/tag/v3.0.0. Additional detailed instructions on configuring agnoStack for the new version can be found at: https://agnostack.com/faqs/setup-onboarding/configuring-magento-1. +Dowload the latest version of the extension at: https://github.com/agnostack/magento_extension/releases/tag/v3.0.0. +Additional detailed instructions on configuring agnoStack for the new version can be found at: https://agnostack.com/faqs/setup-onboarding/configuring-magento-1. # Zendesk Extension for Magento From 90c9771c2cb71f1ab5d76113cf2ae9aa7193887b Mon Sep 17 00:00:00 2001 From: Adam Grohs Date: Wed, 30 Sep 2020 07:37:33 -0500 Subject: [PATCH 07/15] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 216d0dc..825703f 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ The new 3.0 version fixes several core issues (incorrect/missing order address, * Access Order Messages and Notes Dowload the latest version of the extension at: https://github.com/agnostack/magento_extension/releases/tag/v3.0.0. + Additional detailed instructions on configuring agnoStack for the new version can be found at: https://agnostack.com/faqs/setup-onboarding/configuring-magento-1. From b31ce2e6b527f0cfeae54f9c535aa458ca854520 Mon Sep 17 00:00:00 2001 From: rsbowers Date: Tue, 13 Oct 2020 20:18:12 -0500 Subject: [PATCH 08/15] chore: add address only if they exist --- .../community/Zendesk/Zendesk/Helper/Data.php | 73 +++++++++++-------- .../Zendesk/controllers/ApiController.php | 2 +- .../community/Zendesk/Zendesk/etc/config.xml | 2 +- .../default/template/zendesk/left-menu.phtml | 2 +- 4 files changed, 47 insertions(+), 32 deletions(-) diff --git a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php index c304489..c067b5d 100644 --- a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php +++ b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php @@ -479,24 +479,26 @@ protected function formatCustomer($order) protected function formatAddress($address) { - $addressData = array( - 'type' => 'address', - 'first_name' => $address->getFirstname(), - 'last_name' => $address->getLastname(), - 'city' => $address->getCity(), - 'county' => $address->getRegion(), - 'postcode' => $address->getPostcode(), - 'country' => $address->getCountryId(), - 'phone' => $address->getTelephone() - ); - - $entityId = $address->getEntityId(); - $addressId = $address->getCustomerAddressId(); - $addressData['id'] = $addressId ?: $entityId; - - $street = $address->getStreet(); - $addressData['line_1'] = $street[0] ?: ''; - $addressData['line_2'] = $street[1] ?: ''; + if ($address) { + $addressData = array( + 'type' => 'address', + 'first_name' => $address->getFirstname(), + 'last_name' => $address->getLastname(), + 'city' => $address->getCity(), + 'county' => $address->getRegion(), + 'postcode' => $address->getPostcode(), + 'country' => $address->getCountryId(), + 'phone' => $address->getTelephone() + ); + + $entityId = $address->getEntityId(); + $addressId = $address->getCustomerAddressId(); + $addressData['id'] = $addressId ?: $entityId; + + $street = $address->getStreet(); + $addressData['line_1'] = $street[0] ?: ''; + $addressData['line_2'] = $street[1] ?: ''; + } return $addressData; } @@ -517,7 +519,7 @@ public function getShipments($order) if (count($tracks) > 0) { foreach($tracks as $track) { if ($shipmentId == $track->getParentId()) { - $shipments[] = array( + $shipment = array( 'id' => $track->getEntityId(), 'carrier' => $track->getTitle(), 'carrier_code' => $track->getCarrierCode(), @@ -526,24 +528,32 @@ public function getShipments($order) 'created_at' => $track->getCreatedAt(), 'updated_at' => $track->getUpdatedAt(), 'tracking_number' => $track->getTrackNumber(), - 'shipping_address' => $this->formatAddress($shippingAddress), 'order_status' => $orderStatus, ); - } + if ($shippingAddress) { + $shipment['shipping_address'] = $this->formatAddress($shippingAddress); + } + $shipments[] = $shipment; + } } } else { - $shipments[] = array( + $shipment = array( 'service_code' => $serviceCode, 'carrier_code' => $order->getShippingMethod(), - 'shipping_address' => $this->formatAddress($shippingAddress), 'order_status' => $orderStatus, ); + if ($shippingAddress) { + $shipment['shipping_address'] = $this->formatAddress($shippingAddress); + } + $shipments[] = $shipment; } } else { $shippingAddress = $order->getShippingAddress(); - $shipments[] = array( - 'shipping_address' => $this->formatAddress($shippingAddress), - ); + if ($shippingAddress) { + $shipments[] = array( + 'shipping_address' => $this->formatAddress($shippingAddress), + ); + } } return $shipments; @@ -558,13 +568,13 @@ public function getOrderDetailBasic($order) $shippingAddress = $order->getShippingAddress(); $shippingWithTax = $order->getShippingInclTax(); $shippingMethod = $order->getShippingMethod(); + $billingAddress = $order->getBillingAddress(); $orderInfo = array( 'id' => $order->getIncrementId(), 'url' => $urlModel->getUrl('adminhtml/sales_order/view', array('order_id' => $order->getId())), 'transaction_id' => $order->getIncrementId(), 'status' => $order->getStatus(), - 'billing_address' => $this->formatAddress($order->getBillingAddress()), 'meta' => array( 'store_info' => array( 'type' => 'store_info', @@ -590,6 +600,9 @@ public function getOrderDetailBasic($order) ), 'shipments' => array(), ); + if ($billingAddress) { + $orderInfo['billing_address'] = $this->formatAddress($billingAddress); + } foreach($order->getItemsCollection(array(), true) as $item) { $itemWithTax = $item->getRowTotal(); @@ -772,7 +785,9 @@ public function getCustomer($customer) ); foreach($customer->getAddressesCollection() as $address) { - $info['addresses'][] = $this->formatAddress($address); + if ($address) { + $info['addresses'][] = $this->formatAddress($address); + } } return $info; @@ -825,7 +840,7 @@ public function getFilteredOrdersByProduct($customerFilters, $productFilters) ); } - if($email) { + if ($email) { $filteredOrdersData = array_filter(array_values($ordersData), function ($orderData) use ($email) { return ($orderData['email'] == $email); }); diff --git a/src/app/code/community/Zendesk/Zendesk/controllers/ApiController.php b/src/app/code/community/Zendesk/Zendesk/controllers/ApiController.php index d0a255c..65f861c 100644 --- a/src/app/code/community/Zendesk/Zendesk/controllers/ApiController.php +++ b/src/app/code/community/Zendesk/Zendesk/controllers/ApiController.php @@ -23,7 +23,7 @@ public function preDispatch() { // TODO!!!!!!!: read version from config.xml // $configSettings = Mage::getSingleton('Zendesk_Zendesk/config'); // Mage::log(json_encode($configSettings), null, 'zendesk.log'); - $this->getResponse()->setHeader('X-Extension-Version', '3.0.0'); + $this->getResponse()->setHeader('X-Extension-Version', '3.0.1'); return $this; } diff --git a/src/app/code/community/Zendesk/Zendesk/etc/config.xml b/src/app/code/community/Zendesk/Zendesk/etc/config.xml index 9f1e211..0795fa7 100644 --- a/src/app/code/community/Zendesk/Zendesk/etc/config.xml +++ b/src/app/code/community/Zendesk/Zendesk/etc/config.xml @@ -19,7 +19,7 @@ - 3.0.0 + 3.0.1 diff --git a/src/app/design/adminhtml/default/default/template/zendesk/left-menu.phtml b/src/app/design/adminhtml/default/default/template/zendesk/left-menu.phtml index 0cc5f14..ee36804 100644 --- a/src/app/design/adminhtml/default/default/template/zendesk/left-menu.phtml +++ b/src/app/design/adminhtml/default/default/template/zendesk/left-menu.phtml @@ -55,6 +55,6 @@

-

Extension Version: 3.0.0

+

Extension Version: 3.0.1

From d476ce4a52283cd2443c1150a92dfa5b656fe23e Mon Sep 17 00:00:00 2001 From: rsbowers Date: Tue, 13 Oct 2020 20:21:15 -0500 Subject: [PATCH 09/15] chore: update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 825703f..d52e726 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The new 3.0 version fixes several core issues (incorrect/missing order address, * Enable direct Order Search by ID * Access Order Messages and Notes -Dowload the latest version of the extension at: https://github.com/agnostack/magento_extension/releases/tag/v3.0.0. +Dowload the latest version of the extension at: https://github.com/agnostack/magento_extension/releases/tag/v3.0.1. Additional detailed instructions on configuring agnoStack for the new version can be found at: https://agnostack.com/faqs/setup-onboarding/configuring-magento-1. From f6a63d7dfeb17a508d9193542fd715cdd28e1d71 Mon Sep 17 00:00:00 2001 From: rsbowers Date: Wed, 14 Oct 2020 12:24:45 -0500 Subject: [PATCH 10/15] chore: remove signup button front-end post call --- .../Block/Adminhtml/Config/Buttons/Signup.php | 39 +------------------ .../community/Zendesk/Zendesk/Helper/Data.php | 17 -------- .../community/Zendesk/Zendesk/etc/config.xml | 3 -- .../community/Zendesk/Zendesk/etc/system.xml | 5 ++- .../zendesk/config/button-signup.phtml | 12 +----- 5 files changed, 5 insertions(+), 71 deletions(-) diff --git a/src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Config/Buttons/Signup.php b/src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Config/Buttons/Signup.php index 95cb36d..6fc3662 100644 --- a/src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Config/Buttons/Signup.php +++ b/src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Config/Buttons/Signup.php @@ -37,48 +37,11 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) $originalData = $element->getOriginalData(); $this->addData(array( 'button_label' => Mage::helper('zendesk')->__($originalData['button_label']), + 'button_url' => Mage::helper('zendesk')->__($originalData['button_url']), 'html_id' => $element->getHtmlId(), 'url' => Mage::getSingleton('adminhtml/url')->getUrl('*/setup/start') )); return $this->_toHtml(); } - - public function getPostUrl() - { - return Mage::helper('zendesk')->getProvisionUrl(); - } - - public function getPostInfo() - { - $websiteCode = Mage::app()->getRequest()->getParam('website'); - if ($websiteCode) { - $website = Mage::getModel('core/website')->load($websiteCode); - } else { - $website = Mage::getModel('core/website')->getCollection() - ->addFieldToFilter('is_default', 1) - ->getFirstItem(); - } - - $storeCode = Mage::app()->getRequest()->getParam('store'); - if ($storeCode) { - $store = Mage::getModel('core/store')->load($storeCode); - } else { - $store = $website->getDefaultStore(); - } - - $info = array( - 'magento_domain' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB), - 'magento_current_user_id' => Mage::getSingleton('admin/session')->getUser()->getUserId(), - 'magento_user_count' => Mage::getModel('admin/user')->getCollection()->getSize(), - 'magento_auth_token' => Mage::helper('zendesk')->getProvisionToken(true), - 'magento_callback' => Mage::helper('adminhtml')->getUrl('adminhtml/zendesk/redirect', array('type' => 'settings', 'id' => 'zendesk')), - 'magento_locale' => Mage::getStoreConfig('general/locale/code'), - 'magento_timezone' => Mage::getStoreConfig('general/locale/timezone'), - 'magento_api_url' => Mage::getUrl('zendesk/api', array('_store' => $store->getCode())), - 'magento_store_name' => $website->getName(), - ); - - return $info; - } } diff --git a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php index c067b5d..971a4fd 100644 --- a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php +++ b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php @@ -154,23 +154,6 @@ public function setApiToken($token = null) return $token; } - /** - * Returns the provisioning endpoint for new setups. - * - * This uses the config/zendesk/provision_url XML path to retrieve the setting, with a default value set in - * the extension config.xml file. This can be overridden in your website's local.xml file. - * @return null|string URL or null on failure - */ - public function getProvisionUrl() - { - $config = Mage::getConfig(); - $data = $config->getNode('zendesk/provision_url'); - if(!$data) { - return null; - } - return (string)$data; - } - public function getProvisionToken($generate = false) { $token = Mage::getStoreConfig('zendesk/hidden/provision_token', 0); diff --git a/src/app/code/community/Zendesk/Zendesk/etc/config.xml b/src/app/code/community/Zendesk/Zendesk/etc/config.xml index 0795fa7..46437e9 100644 --- a/src/app/code/community/Zendesk/Zendesk/etc/config.xml +++ b/src/app/code/community/Zendesk/Zendesk/etc/config.xml @@ -22,9 +22,6 @@ 3.0.1 - - https://signup.zendesk.com/provisioning/magento/welcome - diff --git a/src/app/code/community/Zendesk/Zendesk/etc/system.xml b/src/app/code/community/Zendesk/Zendesk/etc/system.xml index cee95d9..927b6eb 100644 --- a/src/app/code/community/Zendesk/Zendesk/etc/system.xml +++ b/src/app/code/community/Zendesk/Zendesk/etc/system.xml @@ -471,11 +471,12 @@ 1 1 1 - + Need to set up the agnoStack Zendesk plugin?
Learn More at https://agnostack.com/faqs/setup-onboarding/configure-manage-your-account.

Haven't set up Zendesk Support yet? Click below to get started.

]]>
- Setup Guide + Get Started + https://agnostack.com/book-a-meeting zendesk/adminhtml_config_buttons_signup 1 1 diff --git a/src/app/design/adminhtml/default/default/template/zendesk/config/button-signup.phtml b/src/app/design/adminhtml/default/default/template/zendesk/config/button-signup.phtml index a738194..df2dbf2 100644 --- a/src/app/design/adminhtml/default/default/template/zendesk/config/button-signup.phtml +++ b/src/app/design/adminhtml/default/default/template/zendesk/config/button-signup.phtml @@ -15,16 +15,6 @@ * limitations under the License. */ ?> - - From a3a3a53b47ffb55897b8b3a359a62cb9cfb25fdb Mon Sep 17 00:00:00 2001 From: rsbowers Date: Wed, 14 Oct 2020 15:38:14 -0500 Subject: [PATCH 11/15] chore: return all order shipments in getShipments --- .../community/Zendesk/Zendesk/Helper/Data.php | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php index 971a4fd..11e1fbb 100644 --- a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php +++ b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php @@ -490,52 +490,52 @@ public function getShipments($order) { $shipments = array(); $orderStatus = $order->getStatus(); + $serviceCode = $order->getShippingDescription(); + $tracks = $order->getTracksCollection(); + $shippingMethod = $order->getShippingMethod(); + $orderShippingAddress = $order->getShippingAddress(); foreach($order->getShipmentsCollection() as $shipment) { $shipmentId = $shipment->getEntityId(); $shippingAddress = $shipment->getShippingAddress(); - $serviceCode = $order->getShippingDescription(); - } - - if ($shipmentId) { - $tracks = $order->getTracksCollection(); - if (count($tracks) > 0) { - foreach($tracks as $track) { - if ($shipmentId == $track->getParentId()) { - $shipment = array( - 'id' => $track->getEntityId(), - 'carrier' => $track->getTitle(), - 'carrier_code' => $track->getCarrierCode(), - 'service_code' => $serviceCode, - 'shipping_description' => $track->getDescription() ?: '', - 'created_at' => $track->getCreatedAt(), - 'updated_at' => $track->getUpdatedAt(), - 'tracking_number' => $track->getTrackNumber(), - 'order_status' => $orderStatus, - ); - if ($shippingAddress) { - $shipment['shipping_address'] = $this->formatAddress($shippingAddress); - } - $shipments[] = $shipment; - } + if ($shipmentId) { + if (count($tracks) > 0) { + foreach($tracks as $track) { + if ($shipmentId == $track->getParentId()) { + $shipment = array( + 'id' => $track->getEntityId(), + 'carrier' => $track->getTitle(), + 'carrier_code' => $track->getCarrierCode(), + 'service_code' => $serviceCode, + 'shipping_description' => $track->getDescription() ?: '', + 'created_at' => $track->getCreatedAt(), + 'updated_at' => $track->getUpdatedAt(), + 'tracking_number' => $track->getTrackNumber(), + 'order_status' => $orderStatus, + ); + if ($shippingAddress) { + $shipment['shipping_address'] = $this->formatAddress($shippingAddress); + } + $shipments[] = $shipment; + } + } + } else { + $shipment = array( + 'service_code' => $serviceCode, + 'carrier_code' => $shippingMethod, + 'order_status' => $orderStatus, + ); + if ($shippingAddress) { + $shipment['shipping_address'] = $this->formatAddress($shippingAddress); + } + $shipments[] = $shipment; } } else { - $shipment = array( - 'service_code' => $serviceCode, - 'carrier_code' => $order->getShippingMethod(), - 'order_status' => $orderStatus, - ); - if ($shippingAddress) { - $shipment['shipping_address'] = $this->formatAddress($shippingAddress); + if ($orderShippingAddress) { + $shipments[] = array( + 'shipping_address' => $this->formatAddress($orderShippingAddress), + ); } - $shipments[] = $shipment; - } - } else { - $shippingAddress = $order->getShippingAddress(); - if ($shippingAddress) { - $shipments[] = array( - 'shipping_address' => $this->formatAddress($shippingAddress), - ); } } From a7359f17a56538231316587b62b0b0368cb3d101 Mon Sep 17 00:00:00 2001 From: rsbowers Date: Fri, 16 Oct 2020 12:00:08 -0500 Subject: [PATCH 12/15] chore: remove get/set provision token from API authorize --- .../community/Zendesk/Zendesk/Helper/Data.php | 23 -------- .../Zendesk/controllers/ApiController.php | 56 +++++++++---------- 2 files changed, 25 insertions(+), 54 deletions(-) diff --git a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php index 11e1fbb..8b8f1c6 100644 --- a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php +++ b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php @@ -154,29 +154,6 @@ public function setApiToken($token = null) return $token; } - public function getProvisionToken($generate = false) - { - $token = Mage::getStoreConfig('zendesk/hidden/provision_token', 0); - - if( (!$token || strlen(trim($token)) == 0) && $generate) { - $token = $this->setProvisionToken(); - } - - return $token; - } - - public function setProvisionToken($token = null) - { - if(!$token) { - $token = hash('sha256', Mage::helper('oauth')->generateToken()); - } - - Mage::getModel('core/config')->saveConfig('zendesk/hidden/provision_token', $token, 'default'); - Mage::getConfig()->removeCache(); - - return $token; - } - public function getOrderDetail($order) { // if the admin site has a custom URL, use it diff --git a/src/app/code/community/Zendesk/Zendesk/controllers/ApiController.php b/src/app/code/community/Zendesk/Zendesk/controllers/ApiController.php index 65f861c..54dc0e1 100644 --- a/src/app/code/community/Zendesk/Zendesk/controllers/ApiController.php +++ b/src/app/code/community/Zendesk/Zendesk/controllers/ApiController.php @@ -67,45 +67,39 @@ public function _authorise() } $apiToken = Mage::helper('zendesk')->getApiToken(false); - $provisionToken = Mage::helper('zendesk')->getProvisionToken(false); - - // Provisioning tokens are always accepted, hence why they are deleted after the initial process - if(!$provisionToken || $token != $provisionToken) { - // Use of the provisioning token "overrides" the configuration for the API, so we check this after - // confirming the provisioning token has not been sent - if(!Mage::getStoreConfig('zendesk/api/enabled')) { - $this->getResponse() - ->setBody(json_encode(array('success' => false, 'message' => 'API access disabled'))) - ->setHttpResponseCode(403) - ->setHeader('Content-type', 'application/json', true); + + if(!Mage::getStoreConfig('zendesk/api/enabled')) { + $this->getResponse() + ->setBody(json_encode(array('success' => false, 'message' => 'API access disabled'))) + ->setHttpResponseCode(403) + ->setHeader('Content-type', 'application/json', true); - Mage::log('API access disabled.', null, 'zendesk.log'); + Mage::log('API access disabled.', null, 'zendesk.log'); - return false; - } + return false; + } - // If the API is enabled then check the token - if(!$token) { - $this->getResponse() - ->setBody(json_encode(array('success' => false, 'message' => 'No authorisation token provided'))) - ->setHttpResponseCode(401) - ->setHeader('Content-type', 'application/json', true); + // If the API is enabled then check the token + if(!$token) { + $this->getResponse() + ->setBody(json_encode(array('success' => false, 'message' => 'No authorisation token provided'))) + ->setHttpResponseCode(401) + ->setHeader('Content-type', 'application/json', true); - Mage::log('No authorisation token provided.', null, 'zendesk.log'); + Mage::log('No authorisation token provided.', null, 'zendesk.log'); - return false; - } + return false; + } - if($token != $apiToken) { - $this->getResponse() - ->setBody(json_encode(array('success' => false, 'message' => 'Not authorised'))) - ->setHttpResponseCode(401) - ->setHeader('Content-type', 'application/json', true); + if($token != $apiToken) { + $this->getResponse() + ->setBody(json_encode(array('success' => false, 'message' => 'Not authorised'))) + ->setHttpResponseCode(401) + ->setHeader('Content-type', 'application/json', true); - Mage::log('Not authorised.', null, 'zendesk.log'); + Mage::log('Not authorised.', null, 'zendesk.log'); - return false; - } + return false; } return true; From 72eb75d24d9239112b8e3fabd8695adfd70c6a0a Mon Sep 17 00:00:00 2001 From: rsbowers Date: Mon, 19 Oct 2020 10:55:41 -0500 Subject: [PATCH 13/15] chore: correct pricing including tax --- .../code/community/Zendesk/Zendesk/Helper/Data.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php index 8b8f1c6..6a60f20 100644 --- a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php +++ b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php @@ -541,9 +541,9 @@ public function getOrderDetailBasic($order) 'name' => $order->getStoreName() ), 'display_price' => array( - 'with_tax' => $this->formatPrice($order->getGrandTotal(), $currency), - 'without_tax' => $this->formatPrice($order->getGrandTotal() - $order->getTaxAmount(), $currency), // TODO: get without tax - 'tax' => $this->formatPrice($order->getTaxAmount(), $currency) // TODO: get tax + 'with_tax' => $this->formatPrice($order->getGrandTotal() + $order->getTaxAmount(), $currency), + 'without_tax' => $this->formatPrice($order->getGrandTotal(), $currency), + 'tax' => $this->formatPrice($order->getTaxAmount(), $currency) ), 'timestamps' => array( 'created_at' => $order->getCreatedAt(), @@ -565,7 +565,7 @@ public function getOrderDetailBasic($order) } foreach($order->getItemsCollection(array(), true) as $item) { - $itemWithTax = $item->getRowTotal(); + $itemWithoutTax = $item->getRowTotal(); $itemTax = $item->getTaxAmount(); $productId = $item->getProductId(); @@ -583,8 +583,8 @@ public function getOrderDetailBasic($order) 'refunded' => intval($item->getQtyRefunded()), 'meta' => array( 'display_price' => array( - 'with_tax' => $this->formatPrice($itemWithTax, $currency), - 'without_tax' => $this->formatPrice($itemWithTax - $itemTax, $currency), + 'with_tax' => $this->formatPrice($itemWithoutTax + $itemTax, $currency), + 'without_tax' => $this->formatPrice($itemWithoutTax, $currency), 'tax' => $this->formatPrice($iitemTax, $currency) ), 'timestamps' => array( From c5d2acca3a9587657b3a88f3acbd41bd0fef7df3 Mon Sep 17 00:00:00 2001 From: rsbowers Date: Mon, 19 Oct 2020 11:39:28 -0500 Subject: [PATCH 14/15] chore: display order shipping address if no shipments --- .../code/community/Zendesk/Zendesk/Helper/Data.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php index 6a60f20..c207c6a 100644 --- a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php +++ b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php @@ -507,15 +507,15 @@ public function getShipments($order) } $shipments[] = $shipment; } - } else { - if ($orderShippingAddress) { - $shipments[] = array( - 'shipping_address' => $this->formatAddress($orderShippingAddress), - ); - } } } + if (empty($shipments) && $orderShippingAddress) { + $shipments[] = array( + 'shipping_address' => $this->formatAddress($orderShippingAddress), + ); + } + return $shipments; } From 14b3fdb4b7f3b948612673d881ec2d640caae0ec Mon Sep 17 00:00:00 2001 From: rsbowers Date: Mon, 19 Oct 2020 17:49:36 -0500 Subject: [PATCH 15/15] chore: fix the tax calculation in order transformation --- src/app/code/community/Zendesk/Zendesk/Helper/Data.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php index c207c6a..5202c12 100644 --- a/src/app/code/community/Zendesk/Zendesk/Helper/Data.php +++ b/src/app/code/community/Zendesk/Zendesk/Helper/Data.php @@ -541,8 +541,8 @@ public function getOrderDetailBasic($order) 'name' => $order->getStoreName() ), 'display_price' => array( - 'with_tax' => $this->formatPrice($order->getGrandTotal() + $order->getTaxAmount(), $currency), - 'without_tax' => $this->formatPrice($order->getGrandTotal(), $currency), + 'with_tax' => $this->formatPrice($order->getGrandTotal(), $currency), + 'without_tax' => $this->formatPrice($order->getGrandTotal() - $order->getTaxAmount(), $currency), 'tax' => $this->formatPrice($order->getTaxAmount(), $currency) ), 'timestamps' => array(