-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- new functionality in the order view panel: Generate payment link - new status for payment: "Dotpay payment possible duplicate (The payment has been confirmed twice - check for possible duplicated payment)" - minor fixes
- Loading branch information
Showing
28 changed files
with
999 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?php | ||
/** | ||
* NOTICE OF LICENSE. | ||
* | ||
* This source file is subject to the Academic Free License (AFL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/afl-3.0.php | ||
* | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* @author Dotpay Team <[email protected]> | ||
* @copyright Dotpay | ||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) | ||
*/ | ||
|
||
namespace Dotpay\Payment\Api\Data; | ||
|
||
/** | ||
* Interface of card brand model. | ||
*/ | ||
interface OrderRetryPaymentInterface | ||
{ | ||
/** | ||
* Column name of brand id in database. | ||
*/ | ||
const LINK_ID = 'entity_id'; | ||
|
||
/** | ||
* Column name of brand name in database. | ||
*/ | ||
const ORDER_ID = 'order_id'; | ||
|
||
/** | ||
* Column name of brand logo in database. | ||
*/ | ||
const URL = 'url'; | ||
|
||
/** | ||
* Column name of brand logo in database. | ||
*/ | ||
const TOKEN = 'token'; | ||
|
||
/** | ||
* Return id of card brand. | ||
* | ||
* @return int | ||
*/ | ||
public function getId(); | ||
|
||
/** | ||
* Set id of card brand. | ||
* | ||
* @param int $id id of card brand | ||
* | ||
* @return $this | ||
*/ | ||
public function setId($id); | ||
|
||
/** | ||
* Return name of card brand. | ||
* | ||
* @return string | ||
*/ | ||
public function getOrderId(); | ||
|
||
/** | ||
* Set name of card brand. | ||
* | ||
* @param string $orderId Name of card brand | ||
* | ||
* @return $this | ||
*/ | ||
public function setOrderId($orderId); | ||
|
||
/** | ||
* Return url of card brand's logo. | ||
* | ||
* @return string | ||
*/ | ||
public function getUrl(); | ||
|
||
/** | ||
* Set url of card brand's logo. | ||
* | ||
* @param string $url Url of card brand | ||
* | ||
* @return $this | ||
*/ | ||
public function setUrl($url); | ||
|
||
/** | ||
* Return url of card brand's logo. | ||
* | ||
* @return string | ||
*/ | ||
public function getToken(); | ||
|
||
/** | ||
* Set url of card brand's logo. | ||
* | ||
* @param string $token Url of card brand | ||
* | ||
* @return $this | ||
*/ | ||
public function setToken($token); | ||
|
||
/** | ||
* Return url of card brand's logo. | ||
* | ||
* @return string | ||
*/ | ||
public function getCreatedAt(); | ||
|
||
/** | ||
* Set url of card brand's logo. | ||
* | ||
* @param string $createdAt Url of card brand | ||
* | ||
* @return $this | ||
*/ | ||
public function setCreatedAt($createdAt); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
namespace Dotpay\Payment\Block\Adminhtml\Order\View; | ||
|
||
use Dotpay\Payment\Api\Data\OrderInterface; | ||
use Dotpay\Payment\Model\OrderRetryPayment; | ||
use Dotpay\Payment\Model\OrderRetryPaymentFactory; | ||
|
||
class RetryPayment extends \Magento\Sales\Block\Adminhtml\Order\AbstractOrder | ||
{ | ||
|
||
/** | ||
* @var \Dotpay\Payment\Model\OrderRetryPaymentFactory | ||
*/ | ||
protected $_orderRetryPaymentFactory; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param OrderRetryPaymentFactory $newsFactory | ||
* @param \Magento\Framework\Registry $registry | ||
* @param \Magento\Sales\Helper\Admin $adminHelper | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
OrderRetryPaymentFactory $orderRetryPaymentFactory, | ||
\Magento\Framework\Registry $registry, | ||
\Magento\Sales\Helper\Admin $adminHelper, | ||
array $data = [] | ||
) { | ||
$this->_orderRetryPaymentFactory = $orderRetryPaymentFactory; | ||
parent::__construct($context, $registry, $adminHelper, $data); | ||
} | ||
|
||
public function getRetryPayments() | ||
{ | ||
$collection = $this->_orderRetryPaymentFactory->create()->getCollection()->addFieldToFilter('order_id', $this->getOrder()->getEntityId()); | ||
return $collection; | ||
} | ||
|
||
public function getSaveUrl() | ||
{ | ||
return $this->getUrl("dotpay/order_retryPayment/save", ["order_id" => $this->getOrder()->getEntityId()]); | ||
} | ||
|
||
public function getDeleteUrl($id) | ||
{ | ||
return $this->getUrl("dotpay/order_retryPayment/delete", ["id" => $id]); | ||
} | ||
|
||
public function canRetry() | ||
{ | ||
$status = $this->getOrder()->getStatus(); | ||
if( | ||
$status === OrderInterface::STATUS_PENDING | ||
&& count($this->getRetryPayments()) < 1 | ||
) | ||
return true; | ||
|
||
return false; | ||
} | ||
|
||
public function canDelete() | ||
{ | ||
$status = $this->getOrder()->getStatus(); | ||
if( | ||
$status === OrderInterface::STATUS_PENDING | ||
) | ||
return true; | ||
|
||
return false; | ||
} | ||
|
||
public function canShowBlock() | ||
{ | ||
$status = $this->getOrder()->getStatus(); | ||
if(in_array($status, [OrderInterface::STATUS_PENDING, OrderInterface::STATUS_CANCELED, OrderInterface::STATUS_COMPLETE, OrderInterface::STATUS_DUPLICATE])) | ||
return true; | ||
|
||
$statuses = $this->getOrder()->getAllStatusHistory(); | ||
foreach($statuses as $status) | ||
{ | ||
if(in_array($status->getStatus(), [OrderInterface::STATUS_PENDING, OrderInterface::STATUS_CANCELED, OrderInterface::STATUS_COMPLETE, OrderInterface::STATUS_DUPLICATE])) | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?php | ||
|
||
namespace Dotpay\Payment\Controller\Adminhtml\Order; | ||
|
||
use Dotpay\Resource\Seller as SellerResource; | ||
use Dotpay\Model\Configuration; | ||
use Dotpay\Loader\Loader; | ||
use Dotpay\Loader\Parser; | ||
use Dotpay\Bootstrap; | ||
use Dotpay\Tool\Curl; | ||
use Magento\Framework\Exception\InputException; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Sales\Api\OrderRepositoryInterface; | ||
|
||
abstract class RetryPayment extends \Magento\Backend\App\Action { | ||
/** | ||
* @var \Magento\Framework\App\Action\Context Application context | ||
*/ | ||
protected $context; | ||
|
||
/** | ||
* @var \Magento\Customer\Model\Session Customer session | ||
*/ | ||
protected $customerSession; | ||
|
||
/** | ||
* @var \Magento\Checkout\Model\Session Checkout session | ||
*/ | ||
protected $checkoutSession; | ||
|
||
/** | ||
* @var \Magento\Sales\Model\OrderFactory Magento order factory | ||
*/ | ||
protected $orderFactory; | ||
|
||
/** | ||
* @var \Magento\Framework\Locale\Resolver Locale resolver | ||
*/ | ||
protected $localeResolver; | ||
|
||
/** | ||
* @var \Magento\Framework\Registry Magento registry | ||
*/ | ||
protected $coreRegistry; | ||
|
||
/** | ||
* @var \Magento\Framework\View\Result\PageFactory Factory of result page | ||
*/ | ||
protected $resultPageFactory; | ||
|
||
/** | ||
* @var \Magento\Framework\ObjectManagerInterface Object manager | ||
*/ | ||
protected $objectManager; | ||
|
||
/** | ||
* @var OrderRepositoryInterface | ||
*/ | ||
protected $orderRepository; | ||
|
||
/** | ||
* @var \Dotpay\Payment\Helper\Url Helper for generating urls used in the Dotpay payment plugin | ||
*/ | ||
protected $urlHelper; | ||
|
||
/** | ||
* @var \Dotpay\Model\Configuration SDK configuration object | ||
*/ | ||
protected $config; | ||
|
||
/** | ||
* Initialize the controller. | ||
* | ||
* @param \Magento\Backend\App\Action\Context $context | ||
* @param \Magento\Customer\Model\Session $customerSession | ||
* @param \Magento\Checkout\Model\Session $checkoutSession | ||
* @param \Magento\Framework\Registry $coreRegistry | ||
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory | ||
* @param \Dotpay\Payment\Helper\Url $urlHelper | ||
* @param \Dotpay\Payment\Helper\Data\Configuration $configHelper | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\App\Action\Context $context, | ||
\Magento\Customer\Model\Session $customerSession, | ||
\Magento\Checkout\Model\Session $checkoutSession, | ||
\Magento\Framework\Registry $coreRegistry, | ||
\Magento\Framework\View\Result\PageFactory $resultPageFactory, | ||
OrderRepositoryInterface $orderRepository, | ||
\Dotpay\Payment\Helper\Url $urlHelper, | ||
\Dotpay\Payment\Helper\Data\Configuration $configHelper | ||
) { | ||
$this->context = $context; | ||
$this->customerSession = $customerSession; | ||
$this->checkoutSession = $checkoutSession; | ||
$this->coreRegistry = $coreRegistry; | ||
$this->resultPageFactory = $resultPageFactory; | ||
$this->objectManager = $context->getObjectManager(); | ||
$this->orderRepository = $orderRepository; | ||
$this->urlHelper = $urlHelper; | ||
$this->configHelper = $configHelper; | ||
|
||
parent::__construct($context); | ||
|
||
Loader::load( | ||
new Parser(Bootstrap::getMainDir().'/di.xml') | ||
); | ||
|
||
$this->config = Configuration::createFromData($configHelper); | ||
} | ||
|
||
/** | ||
* Initialize order model instance | ||
* | ||
* @return \Magento\Sales\Api\Data\OrderInterface|false | ||
*/ | ||
protected function _initOrder($id) | ||
{ | ||
try { | ||
$order = $this->orderRepository->get($id); | ||
} catch (NoSuchEntityException $e) { | ||
$this->messageManager->addError(__('This order no longer exists.')); | ||
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); | ||
return false; | ||
} catch (InputException $e) { | ||
$this->messageManager->addError(__('This order no longer exists.')); | ||
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); | ||
return false; | ||
} | ||
return $order; | ||
} | ||
} |
Oops, something went wrong.