Skip to content

Commit

Permalink
Merge pull request #428 from magento-mpi/MAGETWO-32996
Browse files Browse the repository at this point in the history
[MPI] Worldpay
  • Loading branch information
dkvashninbay committed Jul 10, 2015
2 parents c673db6 + 9722d12 commit 6bfde04
Show file tree
Hide file tree
Showing 36 changed files with 815 additions and 72 deletions.
22 changes: 22 additions & 0 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -898,4 +898,26 @@ protected function addStatusCommentOnUpdate(
}
return $this;
}

/**
* Sets method code
*
* @param string $methodCode
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @return void
*/
public function setMethodCode($methodCode)
{
}

/**
* Sets path pattern
*
* @param string $pathPattern
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @return void
*/
public function setPathPattern($pathPattern)
{
}
}
118 changes: 118 additions & 0 deletions app/code/Magento/Payment/Block/ConfigurableInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Payment\Block;

use Magento\Framework\Phrase;
use Magento\Framework\View\Element\Template\Context;
use Magento\Payment\Gateway\ConfigInterface;

class ConfigurableInfo extends \Magento\Payment\Block\Info
{
/**
* @var ConfigInterface
*/
private $config;

/**
* @param Context $context
* @param ConfigInterface $config
* @param array $data
*/
public function __construct(
Context $context,
ConfigInterface $config,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;

if (isset($data['pathPattern'])) {
$this->config->setPathPattern($data['pathPattern']);
}

if (isset($data['pathPattern'])) {
$this->config->setMethodCode($data['methodCode']);
}
}

/**
* Prepare PayPal-specific payment information
*
* @param \Magento\Framework\Object|array|null $transport
* @return \Magento\Framework\Object
*/
protected function _prepareSpecificInformation($transport = null)
{
$transport = parent::_prepareSpecificInformation($transport);
$payment = $this->getInfo();
$fieldsToStore = explode(',', (string)$this->config->getValue('paymentInfoKeys'));
if ($this->getIsSecureMode()) {
$fieldsToStore = array_diff(
$fieldsToStore,
explode(',', (string)$this->config->getValue('privateInfoKeys'))
);
}

foreach ($fieldsToStore as $field) {
if ($payment->getAdditionalInformation($field) !== null) {
$this->setDataToTransfer(
$transport,
$field,
$payment->getAdditionalInformation($field)
);

}
}

return $transport;
}

/**
* Sets data to transport
*
* @param \Magento\Framework\Object $transport
* @param string $field
* @param string $value
* @return void
*/
protected function setDataToTransfer(
\Magento\Framework\Object $transport,
$field,
$value
) {
$transport->setData(
(string)$this->getLabel($field),
(string)$this->getValueView(
$field,
$value
)
);
}

/**
* Returns label
*
* @param string $field
* @return string | Phrase
*/
protected function getLabel($field)
{
return $field;
}

/**
* Returns value view
*
* @param string $field
* @param string $value
* @return string | Phrase
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function getValueView($field, $value)
{
return $value;
}
}
1 change: 1 addition & 0 deletions app/code/Magento/Payment/Block/Info/Cc.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ protected function _prepareSpecificInformation($transport = null)
if ($this->getInfo()->getCcLast4()) {
$data[(string)__('Credit Card Number')] = sprintf('xxxx-%s', $this->getInfo()->getCcLast4());
}

if (!$this->getIsSecureMode()) {
if ($ccSsIssue = $this->getInfo()->getCcSsIssue()) {
$data[(string)__('Switch/Solo/Maestro Issue Number')] = $ccSsIssue;
Expand Down
25 changes: 25 additions & 0 deletions app/code/Magento/Payment/Gateway/Command/NullCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Payment\Gateway\Command;

use Magento\Payment\Gateway\Command;
use Magento\Payment\Gateway\CommandInterface;

class NullCommand implements CommandInterface
{
/**
* Null command. Does nothing. Stable.
*
* @param array $commandSubject
*
* @return null|Command\ResultInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute(array $commandSubject)
{
return null;
}
}
24 changes: 23 additions & 1 deletion app/code/Magento/Payment/Gateway/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,36 @@ class Config implements ConfigInterface
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
$methodCode,
$methodCode = '',
$pathPattern = self::DEFAULT_PATH_PATTERN
) {
$this->scopeConfig = $scopeConfig;
$this->methodCode = $methodCode;
$this->pathPattern = $pathPattern;
}

/**
* Sets method code
*
* @param string $methodCode
* @return void
*/
public function setMethodCode($methodCode)
{
$this->methodCode = $methodCode;
}

/**
* Sets path pattern
*
* @param string $pathPattern
* @return void
*/
public function setPathPattern($pathPattern)
{
$this->pathPattern = $pathPattern;
}

/**
* Retrieve information from payment configuration
*
Expand Down
16 changes: 16 additions & 0 deletions app/code/Magento/Payment/Gateway/ConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,20 @@ interface ConfigInterface
* @return mixed
*/
public function getValue($field, $storeId = null);

/**
* Sets method code
*
* @param string $methodCode
* @return void
*/
public function setMethodCode($methodCode);

/**
* Sets path pattern
*
* @param string $pathPattern
* @return void
*/
public function setPathPattern($pathPattern);
}
17 changes: 17 additions & 0 deletions app/code/Magento/Payment/Gateway/Data/AddressAdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/
namespace Magento\Payment\Gateway\Data;

/**
* Interface AddressAdapterInterface
*/
interface AddressAdapterInterface
{
/**
Expand Down Expand Up @@ -90,4 +93,18 @@ public function getCustomerId();
* @return string
*/
public function getEmail();

/**
* Returns name prefix
*
* @return string
*/
public function getPrefix();

/**
* Returns name suffix
*
* @return string
*/
public function getSuffix();
}
23 changes: 23 additions & 0 deletions app/code/Magento/Payment/Gateway/Data/Order/AddressAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Magento\Payment\Gateway\Data\AddressAdapterInterface;
use Magento\Sales\Api\Data\OrderAddressInterface;

/**
* Class AddressAdapter
*/
class AddressAdapter implements AddressAdapterInterface
{
/**
Expand Down Expand Up @@ -144,4 +147,24 @@ public function getEmail()
{
return $this->address->getEmail();
}

/**
* Returns name prefix
*
* @return string
*/
public function getPrefix()
{
return $this->address->getPrefix();
}

/**
* Returns name suffix
*
* @return string
*/
public function getSuffix()
{
return $this->address->getSuffix();
}
}
3 changes: 3 additions & 0 deletions app/code/Magento/Payment/Gateway/Data/Order/OrderAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Magento\Payment\Gateway\Data\OrderAdapterInterface;
use Magento\Sales\Api\Data\OrderInterface;

/**
* Class OrderAdapter
*/
class OrderAdapter implements OrderAdapterInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/
namespace Magento\Payment\Gateway\Data;

/**
* Interface OrderAdapterInterface
*/
interface OrderAdapterInterface
{
/**
Expand Down
23 changes: 23 additions & 0 deletions app/code/Magento/Payment/Gateway/Data/Quote/AddressAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Magento\Payment\Gateway\Data\AddressAdapterInterface;
use Magento\Quote\Api\Data\AddressInterface;

/**
* Class AddressAdapter
*/
class AddressAdapter implements AddressAdapterInterface
{
/**
Expand Down Expand Up @@ -144,4 +147,24 @@ public function getEmail()
{
return $this->address->getEmail();
}

/**
* Returns name prefix
*
* @return string
*/
public function getPrefix()
{
return $this->address->getPrefix();
}

/**
* Returns name suffix
*
* @return string
*/
public function getSuffix()
{
return $this->address->getSuffix();
}
}
4 changes: 4 additions & 0 deletions app/code/Magento/Payment/Gateway/Data/Quote/QuoteAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
*/
namespace Magento\Payment\Gateway\Data\Quote;

use Magento\Framework\Exception\LocalizedException;
use Magento\Payment\Gateway\Data\OrderAdapterInterface;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Payment\Gateway\Data\AddressAdapterInterface;

/**
* Class QuoteAdapter
*/
class QuoteAdapter implements OrderAdapterInterface
{
/**
Expand Down
Loading

0 comments on commit 6bfde04

Please sign in to comment.