Skip to content

Commit

Permalink
Merge pull request #562 from magento-mpi/MPI-PR-S82
Browse files Browse the repository at this point in the history
Fixed issue:
 - MAGETWO-59124 [Backport] - [GITHUB] Credit Card capture not associated with the Authorization since upgrade to 2.1.1 #6716 - for 2.1
 - MAGETWO-59578 Merge PayPal Ask MAGETWO-40517 and MAGETWO-52475 to 2.1.x
 - MAGETWO-59581 Merge PayPal Ask MAGETWO-53942 to 2.1.x
 - MAGETWO-59894 [Backport] Email Associated with PayPal Merchant Account Adaptation for On-Boarding
  • Loading branch information
Oleksii Korshenko authored Nov 2, 2016
2 parents a79389c + 0b56a73 commit d83dd4c
Show file tree
Hide file tree
Showing 401 changed files with 13,272 additions and 2,216 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Authorizenet/Model/Source/Cctype.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class Cctype extends PaymentCctype
*/
public function getAllowedTypes()
{
return ['VI', 'MC', 'AE', 'DI', 'OT', 'JCB', 'DN'];
return ['VI', 'MC', 'AE', 'DI', 'JCB', 'DN'];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Braintree\Block\Customer\PayPal;

use Magento\Braintree\Gateway\Config\PayPal\Config;
use Magento\Braintree\Model\Ui\PayPal\ConfigProvider;
use Magento\Framework\View\Element\Template;
use Magento\Vault\Api\Data\PaymentTokenInterface;
use Magento\Vault\Block\AbstractTokenRenderer;

/**
* Class VaultTokenRenderer
*/
class VaultTokenRenderer extends AbstractTokenRenderer
{
/**
* @var Config
*/
private $config;

public function __construct(
Template\Context $context,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;
}

/**
* @inheritdoc
*/
public function getIconUrl()
{
return $this->config->getPayPalIcon()['url'];
}

/**
* @inheritdoc
*/
public function getIconHeight()
{
return $this->config->getPayPalIcon()['height'];
}

/**
* @inheritdoc
*/
public function getIconWidth()
{
return $this->config->getPayPalIcon()['width'];
}

/**
* Can render specified token
*
* @param PaymentTokenInterface $token
* @return boolean
*/
public function canRender(PaymentTokenInterface $token)
{
return $token->getPaymentMethodCode() === ConfigProvider::PAYPAL_CODE;
}

/**
* Get email of PayPal payer
* @return string
*/
public function getPayerEmail()
{
return $this->getTokenDetails()['payerEmail'];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,25 @@ private function isExpiredAuthorization(OrderPaymentInterface $payment)
*/
private function isExistsCaptureTransaction(OrderPaymentInterface $payment)
{
$filters[] = $this->filterBuilder->setField('payment_id')
->setValue($payment->getId())
->create();
$this->searchCriteriaBuilder->addFilters(
[
$this->filterBuilder
->setField('payment_id')
->setValue($payment->getId())
->create(),
]
);

$filters[] = $this->filterBuilder->setField('txn_type')
->setValue(TransactionInterface::TYPE_CAPTURE)
->create();
$this->searchCriteriaBuilder->addFilters(
[
$this->filterBuilder
->setField('txn_type')
->setValue(TransactionInterface::TYPE_CAPTURE)
->create(),
]
);

$searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)
->create();
$searchCriteria = $this->searchCriteriaBuilder->create();

$count = $this->transactionRepository->getList($searchCriteria)->getTotalCount();
return (boolean) $count;
Expand Down
24 changes: 24 additions & 0 deletions app/code/Magento/Braintree/Gateway/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ class Config extends \Magento\Payment\Gateway\Config\Config
const KEY_KOUNT_MERCHANT_ID = 'kount_id';
const FRAUD_PROTECTION = 'fraudprotection';

/**
* Get list of available dynamic descriptors keys
* @var array
*/
private static $dynamicDescriptorKeys = [
'name', 'phone', 'url'
];

/**
* Return the country specific card type config
*
Expand Down Expand Up @@ -170,6 +178,22 @@ public function isActive()
return (bool) $this->getValue(self::KEY_ACTIVE);
}

/**
* Get list of configured dynamic descriptors
* @return array
*/
public function getDynamicDescriptors()
{
$values = [];
foreach (self::$dynamicDescriptorKeys as $key) {
$value = $this->getValue('descriptor_' . $key);
if (!empty($value)) {
$values[$key] = $value;
}
}
return $values;
}

/**
* Get Merchant account ID
*
Expand Down
51 changes: 51 additions & 0 deletions app/code/Magento/Braintree/Gateway/Config/PayPal/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/
namespace Magento\Braintree\Gateway\Config\PayPal;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Payment\Model\CcConfig;

/**
* Class Config
*/
Expand All @@ -22,6 +25,26 @@ class Config extends \Magento\Payment\Gateway\Config\Config

const KEY_REQUIRE_BILLING_ADDRESS = 'require_billing_address';

/**
* @var CcConfig
*/
private $ccConfig;

/**
* @var array
*/
private $icon = [];

public function __construct(
ScopeConfigInterface $scopeConfig,
CcConfig $ccConfig,
$methodCode = null,
$pathPattern = self::DEFAULT_PATH_PATTERN
) {
parent::__construct($scopeConfig, $methodCode, $pathPattern);
$this->ccConfig = $ccConfig;
}

/**
* Get Payment configuration status
*
Expand Down Expand Up @@ -79,4 +102,32 @@ public function getTitle()
{
return $this->getValue(self::KEY_TITLE);
}

/**
* Is need to skip order review
* @return bool
*/
public function isSkipOrderReview()
{
return (bool) $this->getValue('skip_order_review');
}

/**
* Get PayPal icon
* @return array
*/
public function getPayPalIcon()
{
if (empty($this->icon)) {
$asset = $this->ccConfig->createAsset('Magento_Braintree::images/paypal.png');
list($width, $height) = getimagesize($asset->getSourceFile());
$this->icon = [
'url' => $asset->getUrl(),
'width' => $width,
'height' => $height
];
}

return $this->icon;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function readAmount(array $subject)
*/
public function readCustomerId(array $subject)
{
if (empty($subject['customer_id'])) {
if (!isset($subject['customer_id'])) {
throw new \InvalidArgumentException('The "customerId" field does not exists');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Braintree\Gateway\Request;

use Magento\Payment\Gateway\Request\BuilderInterface;
use Magento\Braintree\Gateway\Config\Config;

/**
* Class DescriptorDataBuilder
*/
class DescriptorDataBuilder implements BuilderInterface
{
/**
* @var string
*/
private static $descriptorKey = 'descriptor';

/**
* @var Config
*/
private $config;

/**
* DescriptorDataBuilder constructor.
* @param Config $config
*/
public function __construct(Config $config)
{
$this->config = $config;
}

/**
* @inheritdoc
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function build(array $buildSubject)
{
$values = $this->config->getDynamicDescriptors();
return !empty($values) ? [self::$descriptorKey => $values] : [];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Braintree\Gateway\Request\PayPal;

use Magento\Braintree\Gateway\Helper\SubjectReader;
use Magento\Braintree\Observer\DataAssignObserver;
use Magento\Payment\Gateway\Request\BuilderInterface;

/**
* Class DeviceDataBuilder
*/
class DeviceDataBuilder implements BuilderInterface
{
/**
* @var string
*/
private static $deviceDataKey = 'deviceData';

/**
* @var SubjectReader
*/
private $subjectReader;

/**
* DeviceDataBuilder constructor.
* @param SubjectReader $subjectReader
*/
public function __construct(SubjectReader $subjectReader)
{
$this->subjectReader = $subjectReader;
}

/**
* @inheritdoc
*/
public function build(array $buildSubject)
{
$result = [];
$paymentDO = $this->subjectReader->readPayment($buildSubject);

$payment = $paymentDO->getPayment();
$data = $payment->getAdditionalInformation();
if (!empty($data[DataAssignObserver::DEVICE_DATA])) {
$result[self::$deviceDataKey] = $data[DataAssignObserver::DEVICE_DATA];
}

return $result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Braintree\Gateway\Request\PayPal;

use Magento\Braintree\Gateway\Helper\SubjectReader;
use Magento\Payment\Gateway\Request\BuilderInterface;
use Magento\Vault\Model\Ui\VaultConfigProvider;

/**
* Vault Data Builder
*/
class VaultDataBuilder implements BuilderInterface
{
/**
* Additional options in request to gateway
*/
private static $optionsKey = 'options';

/**
* The option that determines whether the payment method associated with
* the successful transaction should be stored in the Vault.
*/
private static $storeInVaultOnSuccess = 'storeInVaultOnSuccess';

/**
* @var SubjectReader
*/
private $subjectReader;

/**
* VaultDataBuilder constructor.
* @param SubjectReader $subjectReader
*/
public function __construct(SubjectReader $subjectReader)
{
$this->subjectReader = $subjectReader;
}

/**
* @inheritdoc
*/
public function build(array $buildSubject)
{
$result = [];
$paymentDO = $this->subjectReader->readPayment($buildSubject);

$payment = $paymentDO->getPayment();
$data = $payment->getAdditionalInformation();
if (!empty($data[VaultConfigProvider::IS_ACTIVE_CODE])) {
$result[self::$optionsKey] = [
self::$storeInVaultOnSuccess => true
];
}

return $result;
}
}
Loading

0 comments on commit d83dd4c

Please sign in to comment.