Skip to content

Commit

Permalink
Merge pull request #35 from genecommerce/release/3.2.0
Browse files Browse the repository at this point in the history
Release/3.2.0
  • Loading branch information
Paul Canning authored Jul 31, 2019
2 parents a00d35d + c24b14f commit 7b235c7
Show file tree
Hide file tree
Showing 21 changed files with 116 additions and 112 deletions.
2 changes: 1 addition & 1 deletion Block/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private function getVaultPayment(): MethodInterface
*/
private function getPaymentDataHelper(): Data
{
if ($this->paymentDataHelper === null) {
if (null === $this->paymentDataHelper) {
$this->paymentDataHelper = ObjectManager::getInstance()->get(Data::class);
}

Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.2.0]
### Added
- 3DS 2 now supported
- Basic validation to Dynamic Descriptor configuration options to alleviate errors in checkout

### Fixed
- PayPal breaking Grouped Product pages
- Return type stopping Swagger from compiling (https://github.com/Thundar)
- Handling of exceptions in GatewayCommand class that would show "blank" errors on checkout
- Broken CSS selector
- Giftcards not working with PayPal
- Reverted a change introduced in 3.1.2 where card details were only stored in the database if
the Vault config option was enabled. This is because partial invoicing, refunds etc need the stored card data. However,
a bug in core Magento 2.3.1 means that if the Vault is turned off, cards are always shown in customer accounts

### Removed
- Layout options for PayPal buttons, due to the buttons now being rendered separately

## [3.1.3]
### Fixed
- Issue with Configurable Product prices
- Return type issue for Google Pay configuration

## [3.1.2]
### Added
- Callback to delete stored card in Braintree when Customer deletes card in account
Expand Down Expand Up @@ -38,6 +61,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Vaulted cards now work correctly

[3.2.0]: https://github.com/genecommerce/module-braintree-magento2/compare/3.1.3...3.2.0
[3.1.3]: https://github.com/genecommerce/module-braintree-magento2/compare/3.1.2...3.1.3
[3.1.2]: https://github.com/genecommerce/module-braintree-magento2/compare/3.1.1...3.1.2
[3.1.1]: https://github.com/genecommerce/module-braintree-magento2/compare/3.1.0...3.1.1
[3.1.0]: https://github.com/genecommerce/module-braintree-magento2/compare/3.0.7...3.1.0
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Command/GatewayCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function execute(array $commandSubject)
);

$response = $this->client->placeRequest($transferO);
if ($this->validator !== null) {
if (null !== $this->validator) {
$result = $this->validator->validate(
array_merge($commandSubject, ['response' => $response])
);
Expand Down
19 changes: 2 additions & 17 deletions Gateway/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

/**
* Class Config
* @package Magento\Braintree\Gateway\Config
*/
class Config extends \Magento\Payment\Gateway\Config\Config
{
Expand All @@ -26,7 +27,6 @@ class Config extends \Magento\Payment\Gateway\Config\Config
const KEY_COUNTRY_CREDIT_CARD = 'countrycreditcard';
const KEY_CC_TYPES = 'cctypes';
const KEY_CC_TYPES_BRAINTREE_MAPPER = 'cctypes_braintree_mapper';
const KEY_SDK_URL = 'sdk_url';
const KEY_USE_CVV = 'useccv';
const KEY_USE_CVV_VAULT = 'useccv_vault';
const KEY_VERIFY_3DSECURE = 'verify_3dsecure';
Expand Down Expand Up @@ -72,8 +72,8 @@ public function __construct(
$pathPattern = self::DEFAULT_PATH_PATTERN,
Json $serializer = null
) {
$this->storeConfigResolver = $storeConfigResolver;
parent::__construct($scopeConfig, $methodCode, $pathPattern);
$this->storeConfigResolver = $storeConfigResolver;
$this->serializer = $serializer ?: ObjectManager::getInstance()
->get(Json::class);
}
Expand Down Expand Up @@ -275,21 +275,6 @@ public function getMerchantId()
);
}

/**
* Get Sdk Url
*
* @return string
* @throws InputException
* @throws NoSuchEntityException
*/
public function getSdkUrl(): string
{
return $this->getValue(
self::KEY_SDK_URL,
$this->storeConfigResolver->getStoreId()
);
}

/**
* Check for fraud protection
*
Expand Down
14 changes: 7 additions & 7 deletions Gateway/Config/PayPalCredit/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/**
* Class Config
* @package Magento\Braintree\Gateway\Config\PayPalCredit
*/
class Config implements ConfigInterface
{
Expand All @@ -18,7 +19,6 @@ class Config implements ConfigInterface
const KEY_CLIENT_ID = 'client_id';
const KEY_SECRET = 'secret';
const KEY_SANDBOX = 'sandbox';

const DEFAULT_PATH_PATTERN = 'payment/%s/%s';

/**
Expand Down Expand Up @@ -83,7 +83,7 @@ public function setPathPattern($pathPattern)
*/
public function getValue($field, $storeId = null)
{
if ($this->methodCode === null || $this->pathPattern === null) {
if (null === $this->methodCode || null === $this->pathPattern) {
return null;
}

Expand Down Expand Up @@ -164,7 +164,7 @@ public function getActivationCode()
*/
public function getSandbox(): bool
{
return $this->getConfigValue('payment/braintree/environment') === 'sandbox';
return 'sandbox' === $this->getConfigValue('payment/braintree/environment');
}

/**
Expand Down Expand Up @@ -192,7 +192,7 @@ public function getSecret()
*/
public function isUk(): bool
{
return $this->getMerchantCountry() === 'GB';
return 'GB' === $this->getMerchantCountry();
}

/**
Expand All @@ -201,7 +201,7 @@ public function isUk(): bool
*/
public function isUS(): bool
{
return $this->getMerchantCountry() === 'US';
return 'US' === $this->getMerchantCountry();
}

/**
Expand All @@ -227,7 +227,7 @@ public function getBmlDisplay($section)

/**
* Get Position option from stored config
*
*
* @param string $section
* @return mixed
*/
Expand All @@ -238,7 +238,7 @@ public function getBmlPosition($section)

/**
* Get Size option from stored config
*
*
* @param string $section
* @return mixed
*/
Expand Down
31 changes: 4 additions & 27 deletions Gateway/Request/VaultDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
*/
namespace Magento\Braintree\Gateway\Request;

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

/**
* Vault Data Builder
Expand All @@ -25,36 +23,15 @@ class VaultDataBuilder implements BuilderInterface
*/
const STORE_IN_VAULT_ON_SUCCESS = 'storeInVaultOnSuccess';

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

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

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

if (!empty($data[VaultConfigProvider::IS_ACTIVE_CODE])) {
$result[self::OPTIONS] = [
return [
self::OPTIONS => [
self::STORE_IN_VAULT_ON_SUCCESS => true
];
}

return $result;
]
];
}
}
8 changes: 2 additions & 6 deletions Model/Adapter/BraintreeAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ public function privateKey($value = null)

/**
* @param array $params
* @return Successful|Error|string|null
* @return string
*/
public function generate(array $params = [])
{
try {
return ClientToken::generate($params);
} catch (Exception $e) {
return null;
return '';
}
}

Expand Down Expand Up @@ -215,10 +215,6 @@ public function cloneTransaction($transactionId, array $attributes)
return Transaction::cloneTransaction($transactionId, $attributes);
}

/**
* @param $token
* @return mixed
*/
/**
* @param $token
* @return mixed
Expand Down
6 changes: 0 additions & 6 deletions Model/Ui/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ class ConfigProvider implements ConfigProviderInterface
{
const CODE = 'braintree';

/**
* @deprecated
*/
const PAYPAL_CODE = 'braintree_paypal';

const CC_VAULT_CODE = 'braintree_cc_vault';

/**
Expand Down Expand Up @@ -100,7 +95,6 @@ public function getConfig(): array
'isActive' => $this->config->isActive(),
'clientToken' => $this->getClientToken(),
'ccTypesMapper' => $this->config->getCcTypesMapper(),
'sdkUrl' => $this->config->getSdkUrl(),
'countrySpecificCardTypes' => $this->config->getCountrySpecificCardTypeConfig(),
'availableCardTypes' => $this->config->getAvailableCardTypes(),
'useCvv' => $this->config->isCvvEnabled(),
Expand Down
12 changes: 6 additions & 6 deletions Plugin/DeleteStoredPaymentPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public function __construct(
*/
public function beforeDelete(PaymentTokenRepositoryInterface $subject, PaymentTokenInterface $paymentToken)
{
$token = $paymentToken->getGatewayToken();

if ($this->braintreeAdapter->deletePaymentMethod($token)) {
$this->logger->debug('vault payment deleted ' . $token);
return null;
try {
$token = $paymentToken->getGatewayToken();
$this->braintreeAdapter->deletePaymentMethod($token);
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
}

return false;
return null;
}
}
10 changes: 5 additions & 5 deletions Test/Unit/Model/Ui/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Magento\Braintree\Gateway\Config\Config;
use Magento\Braintree\Model\Adapter\BraintreeAdapter;
use Magento\Braintree\Model\Ui\ConfigProvider;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Magento\Braintree\Gateway\Config\PayPal\Config as PayPalConfig;
use Magento\Payment\Model\CcConfig;
Expand All @@ -18,7 +19,7 @@
*
* Test for class \Magento\Braintree\Model\Ui\ConfigProvider
*/
class ConfigProviderTest extends \PHPUnit\Framework\TestCase
class ConfigProviderTest extends TestCase
{
const SDK_URL = 'https://js.braintreegateway.com/v2/braintree.js';
const CLIENT_TOKEN = 'token';
Expand Down Expand Up @@ -148,7 +149,7 @@ public function getConfigDataProvider()
'getEnvironment' => 'test-environment',
'getKountMerchantId' => 'test-kount-merchant-id',
'getMerchantId' => 'test-merchant-id',
'hasFraudProtection' => true,
'hasFraudProtection' => true
],
'expected' => [
'payment' => [
Expand All @@ -171,12 +172,11 @@ public function getConfigDataProvider()
'style' => [
'shape' => null,
'size' => null,
'layout' => null,
'color' => null,
'color' => null
],
'disabledFunding' => [
'card' => null,
'elv' => null,
'elv' => null
],
'icons' => []
],
Expand Down
6 changes: 2 additions & 4 deletions Test/Unit/Model/Ui/PayPal/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ public function getConfigDataProvider()
'style' => [
'shape' => null,
'size' => null,
'layout' => null,
'color' => null,
'color' => null
]
],

Expand All @@ -133,8 +132,7 @@ public function getConfigDataProvider()
'style' => [
'shape' => null,
'size' => null,
'layout' => null,
'color' => null,
'color' => null
]
]
]
Expand Down
Loading

0 comments on commit 7b235c7

Please sign in to comment.