Skip to content

Commit

Permalink
Merge pull request #1 from Worldpay/release-v2.4.2-rc0821
Browse files Browse the repository at this point in the history
AWP Magento 2 Plugin
  • Loading branch information
chandan-PS authored Aug 2, 2021
2 parents 7044426 + f2d5816 commit 52c283e
Show file tree
Hide file tree
Showing 335 changed files with 33,938 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Api/DdcRequestInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

namespace Sapient\AccessWorldpay\Api;

/**
*
* @author aatrai
*/
interface DdcRequestInterface
{
/**
* Create DDcRequest
*
* @api
* @param string $cartId
* @param mixed $paymentData
* @return null|string
*/
public function createDdcRequest($cartId, $paymentData);
}
16 changes: 16 additions & 0 deletions Api/DirectSessionHrefInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Sapient\AccessWorldpay\Api;

interface DirectSessionHrefInterface
{
/**
* Create SessionHref for Direct Integration
*
* @api
* @param string $id
* @param mixed $paymentData
* @return null|string
*/
public function createSessionHref($id, $paymentData);
}
17 changes: 17 additions & 0 deletions Api/HistoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* @copyright 2020 Sapient
*/
namespace Sapient\AccessWorldpay\Api;

interface HistoryInterface
{
/**
* Retrive order Notification
*
* @api
* @param Integer $order OrderId.
* @return json
*/
public function getHistory($order);
}
17 changes: 17 additions & 0 deletions Api/PaymentTypeInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* @copyright 2020 Sapient
*/
namespace Sapient\AccessWorldpay\Api;

interface PaymentTypeInterface
{
/**
* Retrive Payment Types
*
* @api
* @param string $countryId.
* @return json
*/
public function getPaymentType($countryId);
}
185 changes: 185 additions & 0 deletions Block/Addnewcard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
<?php
/**
* @copyright 2020 Sapient
*/
namespace Sapient\AccessWorldpay\Block;

class Addnewcard extends \Magento\Framework\View\Element\Template
{
/**
* @var \Magento\Customer\Model\Session
*/
protected $_customerSession;
/**
* @var array
*/
protected static $_months;
/**
* @var array
*/
protected static $_expiryYears;

/**
* Constructor
*
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Customer\Model\Session $customerSession
* @param \Sapient\AccessWorldpay\Helper\Data $worldpayHelper
* @param \Magento\Customer\Helper\Session\CurrentCustomerAddress $currentCustomerAddress
* @param \Magento\Customer\Model\Address\Config $addressConfig
* @param \Magento\Customer\Model\Address\Mapper $addressMapper
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param \Magento\Integration\Model\Oauth\TokenFactory $tokenModelFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Customer\Model\Session $customerSession,
\Sapient\AccessWorldpay\Helper\Data $worldpayHelper,
\Magento\Customer\Helper\Session\CurrentCustomerAddress $currentCustomerAddress,
\Magento\Customer\Model\Address\Config $addressConfig,
\Magento\Customer\Model\Address\Mapper $addressMapper,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Message\ManagerInterface $messageManager,
\Magento\Integration\Model\Oauth\TokenFactory $tokenModelFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
array $data = []
) {
$this->_customerSession = $customerSession;
$this->worldpayHelper = $worldpayHelper;
$this->currentCustomerAddress = $currentCustomerAddress;
$this->_addressConfig = $addressConfig;
$this->addressMapper = $addressMapper;
$this->scopeConfig = $scopeConfig;
$this->_messageManager = $messageManager;
$this->_tokenModelFactory = $tokenModelFactory;
$this->_storeManager = $storeManager;
parent::__construct($context, $data);
}

public function requireCvcEnabled()
{
return $this->worldpayHelper->isCcRequireCVC();
}

/**
* Get Store code
*
* @return string
*/
public function getStoreCode()
{
return $this->_storeManager->getStore()->getCode();
}

public function getSessionId()
{
return $this->_customerSession->getSessionId();
}

public function getCustomerToken()
{
$customerId = $this->_customerSession->getCustomer()->getId();
$customerToken = $this->_tokenModelFactory->create();
return $customerToken->createCustomerToken($customerId)->getToken();
}

public function getPrimaryBillingAddressHtml()
{
/** @var \Magento\Customer\Block\Address\Renderer\RendererInterface $renderer */
$address = $this->currentCustomerAddress->getDefaultBillingAddress();

if ($address) {
$renderer = $this->_addressConfig->getFormatByCode('html')->getRenderer();
return $renderer->renderArray($this->addressMapper->toFlatArray($address));
} else {
return $this->escapeHtml(__('You have not set a default billing address.'));
}
}

public function getCCtypes()
{
$cctypes = $this->worldpayHelper->getCcTypes();
return $cctypes;
}

/**
* Helps to build year html dropdown
*
* @return array
*/
public function getMonths()
{
if (!self::$_months) {
self::$_months = ['' => __('Month')];
for ($i = 1; $i < 13; $i++) {
$month = str_pad($i, 2, '0', STR_PAD_LEFT);
self::$_months[$month] = date("$i - F", mktime(0, 0, 0, $i, 1));
}
}
return self::$_months;
}

/**
* Helps to build year html dropdown
*
* @return array
*/
public function getExpiryYears()
{
if (!self::$_expiryYears) {
self::$_expiryYears = ['' => __('Year')];
$year = date('Y');
$endYear = ($year + 20);
while ($year < $endYear) {
self::$_expiryYears[$year] = $year;
$year++;
}
}
return self::$_expiryYears;
}

/**
* IsDisclaimer Enabled
*/
public function getDisclaimerMessageEnable()
{
return $this->worldpayHelper->isDisclaimerMessageEnable();
}

/**
* Get Disclaimer Message
*/
public function getDisclaimerText()
{
return $this->worldpayHelper->getDisclaimerMessage();
}

/**
* IsDisclaimer Mandatory
*/
public function getDisclaimerMessageMandatory()
{
return $this->worldpayHelper->isDisclaimerMessageMandatory();
}

/**
* IsCvcRequired
*/
public function getIsCvcRequired()
{
return $this->worldpayHelper->isCcRequireCVC();
}

public function getAccountAlert($alertCode)
{
return $this->worldpayHelper->getMyAccountSpecificexception($alertCode);
}

public function getAccountLabelbyCode($labelCode)
{
return $this->worldpayHelper->getAccountLabelbyCode($labelCode);
}
}
34 changes: 34 additions & 0 deletions Block/Adminhtml/Form/Field/AdminLabels.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Sapient\AccessWorldpay\Block\Adminhtml\Form\Field;


class AdminLabels extends \Sapient\AccessWorldpay\Block\Form\Field\FieldArray\CustomLabelsArray
{

/**
* Prepare to render.
*
* @return void
*/
protected function _prepareToRender()
{
$this->addColumn(
'wpay_label_code',
['label' => __('Label Code'),
'style' => 'width:100px',
'class' => 'required-entry']
);
$this->addColumn(
'wpay_label_desc',
['label' => __('Default Label'),
'style' => 'width:200px',
'class' => 'required-entry']
);
$this->addColumn('wpay_custom_label', ['label' => __('Custom label'),
'style' => 'width:200px']);

$this->_addAfter = false;
$this->_addButtonLabel = __('Add');
}
}
33 changes: 33 additions & 0 deletions Block/Adminhtml/Form/Field/CheckoutLabels.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Sapient\AccessWorldpay\Block\Adminhtml\Form\Field;

class CheckoutLabels extends \Sapient\AccessWorldpay\Block\Form\Field\FieldArray\CustomLabelsArray
{

/**
* Prepare to render.
*
* @return void
*/
protected function _prepareToRender()
{
$this->addColumn(
'wpay_label_code',
['label' => __('Label Code'),
'style' => 'width:100px',
'class' => 'required-entry']
);
$this->addColumn(
'wpay_label_desc',
['label' => __('Default Label'),
'style' => 'width:200px',
'class' => 'required-entry']
);
$this->addColumn('wpay_custom_label', ['label' => __('Custom label'),
'style' => 'width:200px']);

$this->_addAfter = false;
$this->_addButtonLabel = __('Add');
}
}
28 changes: 28 additions & 0 deletions Block/Adminhtml/Form/Field/CreditCardException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* @copyright 2021 FIS
*/
namespace Sapient\AccessWorldpay\Block\Adminhtml\Form\Field;

class CreditCardException extends \Sapient\AccessWorldpay\Block\Form\Field\FieldArray\AbstractFieldArray
{
/**
* Prepare to render.
*
* @return void
*/
protected function _prepareToRender()
{
$this->addColumn(
'exception_code',
['label' => __('Message Code'),'style' => 'width:100px','class' => 'required-entry']
);
$this->addColumn(
'exception_messages',
['label' => __('Actual Message'),'style' => 'width:300px','class' => 'required-entry']
);
$this->addColumn('exception_module_messages', ['label' => __('Custom Message'),'style' => 'width:200px']);
$this->_addAfter = false;
$this->_addButtonLabel = __('Add');
}
}
28 changes: 28 additions & 0 deletions Block/Adminhtml/Form/Field/GeneralException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* @copyright 2021 FIS
*/
namespace Sapient\AccessWorldpay\Block\Adminhtml\Form\Field;

class GeneralException extends \Sapient\AccessWorldpay\Block\Form\Field\FieldArray\AbstractFieldArray
{
/**
* Prepare to render.
*
* @return void
*/
protected function _prepareToRender()
{
$this->addColumn(
'exception_code',
['label' => __('Message Code'),'style' => 'width:100px','class' => 'required-entry']
);
$this->addColumn(
'exception_messages',
['label' => __('Actual Message'),'style' => 'width:300px','class' => 'required-entry']
);
$this->addColumn('exception_module_messages', ['label' => __('Custom Message'),'style' => 'width:200px']);
$this->_addAfter = false;
$this->_addButtonLabel = __('Add');
}
}
Loading

0 comments on commit 52c283e

Please sign in to comment.