-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fabien SUAREZ
committed
Jan 25, 2017
0 parents
commit 48b4a3e
Showing
83 changed files
with
3,986 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Monext\Payline\Api; | ||
|
||
use Magento\Quote\Api\Data\AddressInterface; | ||
use Magento\Quote\Api\Data\PaymentInterface; | ||
|
||
/** | ||
* @api | ||
*/ | ||
interface GuestPaymentManagementInterface | ||
{ | ||
/** | ||
* @param string $cartId | ||
* @param string $email | ||
* @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod | ||
* @param \Magento\Quote\Api\Data\AddressInterface|null $billingAddress | ||
* @throws \Magento\Framework\Exception\CouldNotSaveException | ||
* @return array | ||
*/ | ||
public function saveCheckoutPaymentInformationFacade( | ||
$cartId, | ||
$email, | ||
PaymentInterface $paymentMethod, | ||
AddressInterface $billingAddress = null | ||
); | ||
} |
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,24 @@ | ||
<?php | ||
|
||
namespace Monext\Payline\Api; | ||
|
||
use Magento\Quote\Api\Data\AddressInterface; | ||
use Magento\Quote\Api\Data\PaymentInterface; | ||
|
||
/** | ||
* @api | ||
*/ | ||
interface PaymentManagementInterface | ||
{ | ||
/** | ||
* @param int $cartId | ||
* @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod | ||
* @param \Magento\Quote\Api\Data\AddressInterface|null $billingAddress | ||
* @return array | ||
*/ | ||
public function saveCheckoutPaymentInformationFacade( | ||
$cartId, | ||
PaymentInterface $paymentMethod, | ||
AddressInterface $billingAddress = null | ||
); | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace Monext\Payline\Block\Adminhtml\System\Config\Form\Field; | ||
|
||
use Magento\Config\Block\System\Config\Form\Field; | ||
|
||
class Contract extends Field | ||
{ | ||
protected function _prepareLayout() | ||
{ | ||
parent::_prepareLayout(); | ||
if (!$this->getTemplate()) { | ||
$this->setTemplate('Monext_Payline::system/config/contract.phtml'); | ||
} | ||
return $this; | ||
} | ||
|
||
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
{ | ||
return parent::_getElementHtml($element) . $this->_toHtml(); | ||
} | ||
} | ||
|
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,29 @@ | ||
<?php | ||
|
||
namespace Monext\Payline\Block\Adminhtml\System\Config\Form; | ||
|
||
use Magento\Config\Block\System\Config\Form\Fieldset as BaseFieldset; | ||
|
||
class Fieldset extends BaseFieldset | ||
{ | ||
/** | ||
* Return header comment part of html for fieldset | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @return string | ||
*/ | ||
protected function _getHeaderCommentHtml($element) | ||
{ | ||
$groupConfig = $element->getGroup(); | ||
|
||
if (empty($groupConfig['help_url']) || !$element->getComment()) { | ||
return parent::_getHeaderCommentHtml($element); | ||
} | ||
|
||
$html = '<div class="comment">' . | ||
__($element->getComment(), $groupConfig['help_url']) | ||
. '</div>'; | ||
|
||
return $html; | ||
} | ||
} |
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,56 @@ | ||
<?php | ||
|
||
namespace Monext\Payline\Block\WebPayment; | ||
|
||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Monext\Payline\Helper\Constants as HelperConstants; | ||
use Monext\Payline\Model\CartManagement as PaylineCartManagement; | ||
use Payline\PaylineSDK; | ||
|
||
class WidgetIframeForm extends Template | ||
{ | ||
/** | ||
* @var PaylineCartManagement | ||
*/ | ||
protected $paylineCartManagement; | ||
|
||
public function __construct( | ||
Context $context, | ||
PaylineCartManagement $paylineCartManagement, | ||
array $data = [] | ||
) | ||
{ | ||
parent::__construct($context, $data); | ||
$this->paylineCartManagement = $paylineCartManagement; | ||
} | ||
|
||
public function getWidgetJsUrl() | ||
{ | ||
if($this->_scopeConfig->getValue(HelperConstants::CONFIG_PATH_PAYLINE_GENERAL_ENVIRONMENT) == PaylineSDK::ENV_PROD) { | ||
return 'https://payment.payline.com/scripts/widget-min.js'; | ||
} else { | ||
return 'https://homologation-payment.payline.com/scripts/widget-min.js'; | ||
} | ||
} | ||
|
||
public function getWidgetCssUrl() | ||
{ | ||
if($this->_scopeConfig->getValue(HelperConstants::CONFIG_PATH_PAYLINE_GENERAL_ENVIRONMENT) == PaylineSDK::ENV_PROD) { | ||
return 'https://payment.payline.com/styles/widget-min.css'; | ||
} else { | ||
return 'https://homologation-payment.payline.com/styles/widget-min.css'; | ||
} | ||
} | ||
|
||
public function getToken() | ||
{ | ||
return $this->getRequest()->getParam('token'); | ||
} | ||
|
||
public function getWidgetDisplay() | ||
{ | ||
$quote = $this->paylineCartManagement->getCartByToken($this->getToken()); | ||
return $quote->getPayment()->getMethodInstance()->getConfigData('widget_display'); | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Monext\Payline\Controller; | ||
|
||
use Magento\Framework\App\Action\Action as BaseAction; | ||
|
||
abstract class Action extends BaseAction | ||
{ | ||
protected function getToken() | ||
{ | ||
$token = $this->getRequest()->getParam('paylinetoken'); | ||
|
||
if(empty($token)) { | ||
$token = $this->getRequest()->getParam('token'); | ||
} | ||
|
||
return $token; | ||
} | ||
} | ||
|
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,39 @@ | ||
<?php | ||
|
||
namespace Monext\Payline\Controller\Adminhtml\Contract; | ||
|
||
use Magento\Backend\App\AbstractAction; | ||
use Magento\Backend\App\Action\Context; | ||
use Magento\Backend\Model\View\Result\RedirectFactory as ResultRedirectFactory; | ||
use Monext\Payline\Model\ContractManagement; | ||
|
||
class Refresh extends AbstractAction | ||
{ | ||
/** | ||
* @var ContractManagement | ||
*/ | ||
protected $contractManagement; | ||
|
||
/** | ||
* @var ResultRedirectFactory | ||
*/ | ||
protected $resultRedirectFactory; | ||
|
||
public function __construct( | ||
Context $context, | ||
ContractManagement $contractManagement | ||
) | ||
{ | ||
parent::__construct($context); | ||
$this->contractManagement = $contractManagement; | ||
} | ||
|
||
public function execute() | ||
{ | ||
$this->contractManagement->refreshContracts(); | ||
|
||
$resultRedirect = $this->resultRedirectFactory->create(); | ||
$resultRedirect->setRefererUrl(); | ||
return $resultRedirect; | ||
} | ||
} |
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,34 @@ | ||
<?php | ||
|
||
namespace Monext\Payline\Controller\WebPayment; | ||
|
||
use Magento\Framework\App\Action\Context; | ||
use Monext\Payline\Controller\Action; | ||
use Monext\Payline\Model\PaymentManagement as PaylinePaymentManagement; | ||
|
||
class CancelFromPaymentGateway extends Action | ||
{ | ||
/** | ||
* @var PaylinePaymentManagement | ||
*/ | ||
protected $paylinePaymentManagement; | ||
|
||
public function __construct( | ||
Context $context, | ||
PaylinePaymentManagement $paylinePaymentManagement | ||
) | ||
{ | ||
parent::__construct($context); | ||
$this->paylinePaymentManagement = $paylinePaymentManagement; | ||
} | ||
|
||
public function execute() | ||
{ | ||
// TODO handle exception | ||
$this->paylinePaymentManagement->handlePaymentGatewayCancelByToken($this->getToken()); | ||
|
||
$resultRedirect = $this->resultRedirectFactory->create(); | ||
$resultRedirect->setPath('checkout'); | ||
return $resultRedirect; | ||
} | ||
} |
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,55 @@ | ||
<?php | ||
|
||
namespace Monext\Payline\Controller\WebPayment; | ||
|
||
use Magento\Framework\App\Action\Context; | ||
use Magento\Framework\Controller\Result\RawFactory as ResultRawFactory; | ||
use Magento\Framework\View\Element\TemplateFactory; | ||
use Monext\Payline\Controller\Action; | ||
use Monext\Payline\Model\GuestCartManagement as PaylineGuestCartManagement; | ||
|
||
class GuestReturnFromWidget extends Action | ||
{ | ||
/** | ||
* @var PaylineGuestCartManagement | ||
*/ | ||
protected $paylineGuestCartManagement; | ||
|
||
/** | ||
* @var ResultRawFactory | ||
*/ | ||
protected $resultRawFactory; | ||
|
||
/** | ||
* @var TemplateFactory | ||
*/ | ||
protected $templateFactory; | ||
|
||
public function __construct( | ||
Context $context, | ||
PaylineGuestCartManagement $paylineGuestCartManagement, | ||
ResultRawFactory $resultRawFactory, | ||
TemplateFactory $templateFactory | ||
) | ||
{ | ||
parent::__construct($context); | ||
$this->resultRawFactory = $resultRawFactory; | ||
$this->paylineGuestCartManagement = $paylineGuestCartManagement; | ||
$this->templateFactory = $templateFactory; | ||
} | ||
|
||
public function execute() | ||
{ | ||
// TODO CatchException | ||
$this->paylineGuestCartManagement->placeOrderByToken($this->getToken()); | ||
|
||
$resultRaw = $this->resultRawFactory->create(); | ||
|
||
$block = $this->templateFactory->create(); | ||
$block->setTemplate('Monext_Payline::web_payment/widget_iframe_success.phtml'); | ||
$resultRaw->setContents($block->toHtml()); | ||
|
||
return $resultRaw; | ||
} | ||
} | ||
|
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,43 @@ | ||
<?php | ||
|
||
namespace Monext\Payline\Controller\WebPayment; | ||
|
||
use Magento\Framework\App\Action\Context; | ||
use Magento\Framework\Controller\Result\RawFactory as ResultRawFactory; | ||
use Monext\Payline\Controller\Action; | ||
use Monext\Payline\Block\WebPayment\WidgetIframeFormFactory; | ||
|
||
class LoadWidgetIframeForm extends Action | ||
{ | ||
/** | ||
* @var ResultRawFactory | ||
*/ | ||
protected $resultRawFactory; | ||
|
||
/** | ||
* @var WidgetIframeFormFactory | ||
*/ | ||
protected $widgetIframeFormFactory; | ||
|
||
public function __construct( | ||
Context $context, | ||
ResultRawFactory $resultRawFactory, | ||
WidgetIframeFormFactory $widgetIframeFormFactory | ||
) | ||
{ | ||
parent::__construct($context); | ||
$this->resultRawFactory = $resultRawFactory; | ||
$this->widgetIframeFormFactory = $widgetIframeFormFactory; | ||
} | ||
|
||
public function execute() | ||
{ | ||
$resultRaw = $this->resultRawFactory->create(); | ||
|
||
$block = $this->widgetIframeFormFactory->create(); | ||
$block->setTemplate('Monext_Payline::web_payment/widget_iframe_form.phtml'); | ||
$resultRaw->setContents($block->toHtml()); | ||
|
||
return $resultRaw; | ||
} | ||
} |
Oops, something went wrong.