-
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.
Merge pull request #3 from TendoPayPlugins/develop
v2 integration
- Loading branch information
Showing
33 changed files
with
1,453 additions
and
683 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,51 @@ | ||
<?php | ||
|
||
namespace TendoPay\TendopayPayment\Block\Adminhtml\Form\Field; | ||
|
||
use Magento\Config\Block\System\Config\Form\Field as BaseField; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Magento\Framework\UrlInterface; | ||
|
||
class RedirectUrl extends BaseField | ||
{ | ||
/** | ||
* Render element value | ||
* | ||
* @param AbstractElement $element | ||
* @return string | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
protected function _renderValue(AbstractElement $element) | ||
{ | ||
$stores = $this->_storeManager->getStores(); | ||
$valueReturn = ''; | ||
$urlArray = []; | ||
|
||
foreach ($stores as $store) { | ||
$baseUrl = $store->getBaseUrl(UrlInterface::URL_TYPE_WEB, true); | ||
if ($baseUrl) { | ||
$value = $baseUrl . 'tendopay/standard/success/'; | ||
$urlArray[] = "<div>" . $this->escapeHtml($value) . "</div>"; | ||
} | ||
} | ||
|
||
$urlArray = array_unique($urlArray); | ||
foreach ($urlArray as $uniqueUrl) { | ||
$valueReturn .= "<div>" . $uniqueUrl . "</div>"; | ||
} | ||
|
||
return '<td class="value">' . $valueReturn . '</td>'; | ||
} | ||
|
||
/** | ||
* Render element value | ||
* | ||
* @param AbstractElement $element | ||
* @return string | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
protected function _renderInheritCheckbox(AbstractElement $element) | ||
{ | ||
return '<td class="use-default"></td>'; | ||
} | ||
} |
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,103 @@ | ||
<?php | ||
/** | ||
* TendoPay | ||
* | ||
* Do not edit or add to this file if you wish to upgrade to newer versions in the future. | ||
* If you wish to customize this module for your needs. | ||
* | ||
* @category TendoPay | ||
* @package TendoPay_TendopayPayment | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html | ||
*/ | ||
|
||
namespace TendoPay\TendopayPayment\Block\Adminhtml\Payment; | ||
|
||
use Magento\Framework\View\Element\Template; | ||
|
||
/** | ||
* Class Info | ||
* @package TendoPay\TendopayPayment\Block\Payment | ||
*/ | ||
class Info extends \Magento\Payment\Block\Info | ||
{ | ||
/** | ||
* @var \TendoPay\TendopayPayment\Helper\Data | ||
*/ | ||
private $tendopayHelper; | ||
|
||
/** | ||
* Info constructor. | ||
* @param Template\Context $context | ||
* @param \TendoPay\TendopayPayment\Helper\Data $tendopayHelper | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Template\Context $context, | ||
\TendoPay\TendopayPayment\Helper\Data $tendopayHelper, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
$this->tendopayHelper = $tendopayHelper; | ||
} | ||
|
||
/** | ||
* @param null $transport | ||
* @return \Magento\Framework\DataObject|null | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
*/ | ||
protected function _prepareSpecificInformation($transport = null) | ||
{ | ||
if (null !== $this->_paymentSpecificInformation) { | ||
return $this->_paymentSpecificInformation; | ||
} | ||
|
||
$transport = parent::_prepareSpecificInformation($transport); | ||
|
||
$helper = $this->tendopayHelper; | ||
|
||
if (!$this->getIsSecureMode()) { | ||
$info = $this->getInfo(); | ||
$order = $info->getOrder(); | ||
$txnId = $info->getLastTransId(); | ||
if (!$txnId) { // if order doesn't have transaction (for instance: Pending Payment orders) | ||
$tendopayOrderId = $order->getData('tendopay_order_id'); | ||
$tendopayToken = $order->getData('tendopay_token'); | ||
$tendopayDisposition = $order->getData('tendopay_disposition'); | ||
$tendopayVerificationToken = $order->getData('tendopay_verification_token'); | ||
$tendopayFetchedAt = $order->getData('tendopay_fetched_at'); | ||
$transport->addData( | ||
['Tendopay Order ID' => $tendopayOrderId ? $tendopayOrderId : __('(none)')] | ||
); | ||
$transport->addData( | ||
['Tendopay Order Token' => $tendopayToken ? $tendopayToken : __('(none)')] | ||
); | ||
$transport->addData( | ||
['Tendopay Order Status' => $tendopayDisposition ? $tendopayDisposition : __('(none)')] | ||
); | ||
$transport->addData( | ||
['Tendopay Verification Token' => $tendopayVerificationToken ? $tendopayVerificationToken : __('(none)')] | ||
); | ||
$transport->addData( | ||
['Tendopay Token Fetched At' => ($tendopayFetchedAt && $tendopayFetchedAt != '0000-00-00 00:00:00') ? | ||
$helper->getFormateDate($tendopayFetchedAt, 'M d, Y') : | ||
__('(none)')] | ||
); | ||
} else { // if order already has transaction | ||
$transport->addData(['Transaction ID' => $txnId]); | ||
|
||
$additionalInfo = $info->getAdditionalInformation(); | ||
|
||
if (is_array($additionalInfo)) { | ||
if (isset($additionalInfo['tp_transaction_status'])) { | ||
$transport->addData(['Transaction Status' => $additionalInfo['tp_transaction_status']]); | ||
} | ||
if (isset($additionalInfo['tp_created_at'])) { | ||
$transport->addData(['Transaction Created At' => $additionalInfo['tp_created_at']]); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return $transport; | ||
} | ||
} |
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,15 @@ | ||
<?php | ||
|
||
|
||
namespace TendoPay\TendopayPayment\Client; | ||
|
||
|
||
use TendoPay\SDK\V2\TendoPayClient; | ||
|
||
class Client extends TendoPayClient | ||
{ | ||
public function __construct($config = []) | ||
{ | ||
parent::__construct($config); | ||
} | ||
} |
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,59 @@ | ||
<?php | ||
|
||
|
||
namespace TendoPay\TendopayPayment\Client; | ||
|
||
|
||
use Magento\Framework\ObjectManagerInterface; | ||
use Magento\Payment\Gateway\ConfigInterface; | ||
use Magento\Store\Model\ScopeInterface; | ||
use TendoPay\TendopayPayment\Helper\Data; | ||
|
||
class ClientFactory implements ClientFactoryInterface | ||
{ | ||
/** | ||
* @var ObjectManagerInterface | ||
*/ | ||
private $objectManager; | ||
/** | ||
* @var ConfigInterface | ||
*/ | ||
private $config; | ||
/** | ||
* @var Data | ||
*/ | ||
private $helper; | ||
/** | ||
* @var string | ||
*/ | ||
private $instanceName; | ||
|
||
/** | ||
* ClientFactory constructor. | ||
* @param ObjectManagerInterface $objectManager | ||
* @param ConfigInterface $config | ||
* @param string $instanceName | ||
*/ | ||
public function __construct( | ||
ObjectManagerInterface $objectManager, | ||
ConfigInterface $config, | ||
$instanceName = '\\TendoPay\\TendopayPayment\\Client\\Client' | ||
) { | ||
$this->objectManager = $objectManager; | ||
$this->config = $config; | ||
$this->instanceName = $instanceName; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function create() | ||
{ | ||
$config = [ | ||
Data::CLIENT_ID_KEY => $this->config->getValue('api_client_id'), | ||
Data::CLIENT_SECRET_KEY => $this->config->getValue('api_client_secret'), | ||
Data::TENDOPAY_SANDBOX_ENABLED => $this->config->getValue('api_mode') | ||
]; | ||
return $this->objectManager->create($this->instanceName, ['config' => $config]); | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
|
||
namespace TendoPay\TendopayPayment\Client; | ||
|
||
|
||
use Magento\Store\Model\ScopeInterface; | ||
|
||
interface ClientFactoryInterface | ||
{ | ||
/** | ||
* @return Client | ||
*/ | ||
public function create(); | ||
|
||
} |
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,13 @@ | ||
<?php | ||
|
||
|
||
namespace TendoPay\TendopayPayment\Client\Model; | ||
|
||
|
||
class Payment extends \TendoPay\SDK\Models\Payment | ||
{ | ||
public function __construct(array $data = []) | ||
{ | ||
parent::__construct($data); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
|
||
namespace TendoPay\TendopayPayment\Controller\Standard; | ||
|
||
|
||
use Magento\Framework\App\ResponseInterface; | ||
|
||
class PlaceOrder extends \TendoPay\TendopayPayment\Controller\TendopayAbstract | ||
{ | ||
|
||
public function execute() | ||
{ | ||
|
||
|
||
// $this->_initService(); | ||
// $this->_service->placeOrder(); | ||
// | ||
// $quoteId = $this->getQuote()->getId(); | ||
// $this->getCheckoutSession()->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId); | ||
// | ||
// $order = $this->_service->getOrder(); | ||
// | ||
// if ($order) { | ||
// $this->getCheckoutSession()->setLastOrderId($order->getId()) | ||
// ->setLastRealOrderId($order->getIncrementId()); | ||
// } | ||
// | ||
// $this->_redirect('checkout/onepage/success'); | ||
} | ||
} |
Oops, something went wrong.