-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MAGETWO-59578' into MPI-PR-S82
- Loading branch information
Showing
401 changed files
with
13,272 additions
and
2,216 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
76 changes: 76 additions & 0 deletions
76
app/code/Magento/Braintree/Block/Customer/PayPal/VaultTokenRenderer.php
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,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']; | ||
} | ||
} |
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
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
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
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
44 changes: 44 additions & 0 deletions
44
app/code/Magento/Braintree/Gateway/Request/DescriptorDataBuilder.php
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,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] : []; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
app/code/Magento/Braintree/Gateway/Request/PayPal/DeviceDataBuilder.php
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,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; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
app/code/Magento/Braintree/Gateway/Request/PayPal/VaultDataBuilder.php
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,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; | ||
} | ||
} |
Oops, something went wrong.