From eddc1d683125f74a80f9ce3977014e728b241af8 Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Wed, 10 Jul 2019 14:23:19 +0100 Subject: [PATCH 01/17] Update Braintree JS SDK version. Update 3DS to version 2, with new params and callback. --- composer.json | 1 - view/base/requirejs-config.js | 19 +++++----- .../frontend/web/js/view/payment/3d-secure.js | 35 +++++++++++-------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index 64f770fb..7fa049c4 100755 --- a/composer.json +++ b/composer.json @@ -1,7 +1,6 @@ { "name": "gene/module-braintree", "description": "Fork from the Magento Braintree 2.2.0 module by Gene Commerce for PayPal.", - "version": "3.1.3", "require": { "magento/module-config": "101.0.*|101.1.*", "magento/module-directory": "100.2.*|100.3.*", diff --git a/view/base/requirejs-config.js b/view/base/requirejs-config.js index 9d8fb899..b4a3afea 100755 --- a/view/base/requirejs-config.js +++ b/view/base/requirejs-config.js @@ -1,18 +1,21 @@ - +/** + * Config to pull in all the relevant Braintree JS SDKs + * @type {{paths: {braintreePayPalCheckout: string, braintreeHostedFields: string, braintreeDataCollector: string, braintreeThreeDSecure: string, braintreeGooglePay: string, braintreeApplePay: string, googlePayLibrary: string}, map: {"*": {braintree: string}}}} + */ var config = { map: { '*': { - braintree: 'https://js.braintreegateway.com/web/3.32.0/js/client.min.js', + braintree: 'https://js.braintreegateway.com/web/3.47.0/js/client.min.js', } }, paths: { - "braintreePayPalCheckout": "https://js.braintreegateway.com/web/3.32.0/js/paypal-checkout.min", - "braintreeHostedFields": "https://js.braintreegateway.com/web/3.32.0/js/hosted-fields.min", - "braintreeDataCollector": "https://js.braintreegateway.com/web/3.32.0/js/data-collector.min", - "braintreeThreeDSecure": "https://js.braintreegateway.com/web/3.32.0/js/three-d-secure.min", - "braintreeApplePay": 'https://js.braintreegateway.com/web/3.32.0/js/apple-pay.min', - "braintreeGooglePay": 'https://js.braintreegateway.com/web/3.32.0/js/google-payment.min', + "braintreePayPalCheckout": "https://js.braintreegateway.com/web/3.47.0/js/paypal-checkout.min", + "braintreeHostedFields": "https://js.braintreegateway.com/web/3.47.0/js/hosted-fields.min", + "braintreeDataCollector": "https://js.braintreegateway.com/web/3.47.0/js/data-collector.min", + "braintreeThreeDSecure": "https://js.braintreegateway.com/web/3.47.0/js/three-d-secure.min", + "braintreeApplePay": 'https://js.braintreegateway.com/web/3.47.0/js/apple-pay.min', + "braintreeGooglePay": 'https://js.braintreegateway.com/web/3.47.0/js/google-payment.min', "googlePayLibrary": "https://pay.google.com/gp/p/js/pay" } }; diff --git a/view/frontend/web/js/view/payment/3d-secure.js b/view/frontend/web/js/view/payment/3d-secure.js index 45740be7..f8b0e768 100755 --- a/view/frontend/web/js/view/payment/3d-secure.js +++ b/view/frontend/web/js/view/payment/3d-secure.js @@ -63,6 +63,7 @@ define([ var setup3d = function(clientInstance) { threeDSecure.create({ + version: 2, client: clientInstance }, function (threeDSecureErr, threeDSecureInstance) { if (threeDSecureErr) { @@ -87,26 +88,32 @@ define([ threeDSecureInstance.verifyCard({ amount: totalAmount, nonce: context.paymentMethodNonce, - addFrame: function (err, iframe) { - fullScreenLoader.stopLoader(); - - if (err) { - console.log("Unable to verify card over 3D Secure", err); - return state.reject($t('Please try again with another form of payment.')); - } - - tdbody.appendChild(iframe); - document.body.appendChild(threeDSContainer); + billingAddress: { + givenName: billingAddress.firstname, + surname: billingAddress.lastname, + phoneNumber: billingAddress.telephone, + streetAddress: billingAddress.street[0], + extendedAddress: billingAddress.street[1], + locality: billingAddress.city, + region: billingAddress.region, + postalCode: billingAddress.postcode, + countryCodeAlpha2: billingAddress.countryId }, - removeFrame: function () { - fullScreenLoader.startLoader(); - document.body.removeChild(threeDSContainer); + onLookupComplete: function (data, next) { + console.log(data); + if (data.paymentMethod.threeDSecureInfo.enrolled === 'Y' + || data.threeDSecureInfo.liabilityShifted + || (!data.threeDSecureInfo.liabilityShifted && !data.threeDSecureInfo.liabilityShiftPossible)) { + next(); + } else { + state.reject($t('Please try again with another form of payment.')); + } } }, function (err, response) { fullScreenLoader.stopLoader(); if (err) { - console.log("3dsecure validation failed", err); + console.error("3dsecure validation failed", err); return state.reject($t('Please try again with another form of payment.')); } From fd663ad3a09c7a35c8438cdc738332f024199416 Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Thu, 11 Jul 2019 11:24:05 +0100 Subject: [PATCH 02/17] Re-add addFrame and removeFrame callbacks. --- view/frontend/web/js/view/payment/3d-secure.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/view/frontend/web/js/view/payment/3d-secure.js b/view/frontend/web/js/view/payment/3d-secure.js index f8b0e768..6a591fb5 100755 --- a/view/frontend/web/js/view/payment/3d-secure.js +++ b/view/frontend/web/js/view/payment/3d-secure.js @@ -108,6 +108,21 @@ define([ } else { state.reject($t('Please try again with another form of payment.')); } + }, + addFrame: function (err, iframe) { + fullScreenLoader.stopLoader(); + + if (err) { + console.log("Unable to verify card over 3D Secure", err); + return state.reject($t('Please try again with another form of payment.')); + } + + tdbody.appendChild(iframe); + document.body.appendChild(threeDSContainer); + }, + removeFrame: function () { + fullScreenLoader.startLoader(); + document.body.removeChild(threeDSContainer); } }, function (err, response) { fullScreenLoader.stopLoader(); From 4dbba293d8905c4c1b517489d1221529c1867ea0 Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Thu, 11 Jul 2019 11:25:51 +0100 Subject: [PATCH 03/17] Remove logic from new onLookupComplete callback until more info is provided. --- view/frontend/web/js/view/payment/3d-secure.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/view/frontend/web/js/view/payment/3d-secure.js b/view/frontend/web/js/view/payment/3d-secure.js index 6a591fb5..3e194b1b 100755 --- a/view/frontend/web/js/view/payment/3d-secure.js +++ b/view/frontend/web/js/view/payment/3d-secure.js @@ -100,14 +100,7 @@ define([ countryCodeAlpha2: billingAddress.countryId }, onLookupComplete: function (data, next) { - console.log(data); - if (data.paymentMethod.threeDSecureInfo.enrolled === 'Y' - || data.threeDSecureInfo.liabilityShifted - || (!data.threeDSecureInfo.liabilityShifted && !data.threeDSecureInfo.liabilityShiftPossible)) { - next(); - } else { - state.reject($t('Please try again with another form of payment.')); - } + next(); }, addFrame: function (err, iframe) { fullScreenLoader.stopLoader(); From ceb50c6fce84c67d75e3dfea60e1a64dd6537587 Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Thu, 11 Jul 2019 15:27:32 +0100 Subject: [PATCH 04/17] Add basic validation to Dynamic Descriptors config to help alleviate errors in checkout. --- Gateway/Config/Config.php | 2 +- etc/adminhtml/system.xml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Gateway/Config/Config.php b/Gateway/Config/Config.php index 7e836a05..1c44e189 100755 --- a/Gateway/Config/Config.php +++ b/Gateway/Config/Config.php @@ -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); } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 7f10fca2..5bdf2afe 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -620,6 +620,7 @@ payment/braintree/descriptor_name + validate-length maximum-length-22 The value in the business name field of a customer's statement. Company name/DBA section must be either 3, 7 or 12 characters and the product descriptor can be up to 18, 14, or 9 characters respectively (with an * in between for a total descriptor name of 22 characters). @@ -628,6 +629,7 @@ payment/braintree/descriptor_phone + validate-length minimum-length-10 maximum-length-14 The value in the phone number field of a customer's statement. Phone must be 10-14 characters and can only contain numbers, dashes, parentheses and periods. @@ -635,6 +637,7 @@ payment/braintree/descriptor_url + validate-length maximum-length-13 The value in the URL/web address field of a customer's statement. The URL must be 13 characters or shorter. From 1bb8f2a98660ef1210f0a80e05204cbfe2fec063 Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Mon, 15 Jul 2019 10:30:41 +0100 Subject: [PATCH 05/17] Update changelog, remove layout from tests, add some additional module dependencies. --- Block/Form.php | 2 +- CHANGELOG.md | 22 +++++++++++++++++++ Gateway/Config/Config.php | 16 -------------- Model/Ui/ConfigProvider.php | 6 ----- Test/Unit/Model/Ui/ConfigProviderTest.php | 10 ++++----- .../Model/Ui/PayPal/ConfigProviderTest.php | 6 ++--- etc/config.xml | 1 - etc/module.xml | 2 ++ etc/payment.xml | 3 +++ 9 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Block/Form.php b/Block/Form.php index da6f01a6..8977f854 100755 --- a/Block/Form.php +++ b/Block/Form.php @@ -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); } diff --git a/CHANGELOG.md b/CHANGELOG.md index b83e7779..77a25e3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,26 @@ 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 + +### 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 @@ -38,6 +58,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 diff --git a/Gateway/Config/Config.php b/Gateway/Config/Config.php index 1c44e189..f39c33d8 100755 --- a/Gateway/Config/Config.php +++ b/Gateway/Config/Config.php @@ -26,7 +26,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'; @@ -275,21 +274,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 * diff --git a/Model/Ui/ConfigProvider.php b/Model/Ui/ConfigProvider.php index 5d928d87..a6d29a1d 100644 --- a/Model/Ui/ConfigProvider.php +++ b/Model/Ui/ConfigProvider.php @@ -25,11 +25,6 @@ class ConfigProvider implements ConfigProviderInterface { const CODE = 'braintree'; - /** - * @deprecated - */ - const PAYPAL_CODE = 'braintree_paypal'; - const CC_VAULT_CODE = 'braintree_cc_vault'; /** @@ -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(), diff --git a/Test/Unit/Model/Ui/ConfigProviderTest.php b/Test/Unit/Model/Ui/ConfigProviderTest.php index a60b91e4..5d67d7eb 100644 --- a/Test/Unit/Model/Ui/ConfigProviderTest.php +++ b/Test/Unit/Model/Ui/ConfigProviderTest.php @@ -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; @@ -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'; @@ -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' => [ @@ -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' => [] ], diff --git a/Test/Unit/Model/Ui/PayPal/ConfigProviderTest.php b/Test/Unit/Model/Ui/PayPal/ConfigProviderTest.php index 9845ea7e..29ccdd2a 100644 --- a/Test/Unit/Model/Ui/PayPal/ConfigProviderTest.php +++ b/Test/Unit/Model/Ui/PayPal/ConfigProviderTest.php @@ -113,8 +113,7 @@ public function getConfigDataProvider() 'style' => [ 'shape' => null, 'size' => null, - 'layout' => null, - 'color' => null, + 'color' => null ] ], @@ -133,8 +132,7 @@ public function getConfigDataProvider() 'style' => [ 'shape' => null, 'size' => null, - 'layout' => null, - 'color' => null, + 'color' => null ] ] ] diff --git a/etc/config.xml b/etc/config.xml index 493ac579..7c14de26 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -41,7 +41,6 @@ processing sandbox 0 - cvv,number diff --git a/etc/module.xml b/etc/module.xml index 4f0761c6..df14a07f 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -9,6 +9,8 @@ + + diff --git a/etc/payment.xml b/etc/payment.xml index 9f1a1981..99df7906 100644 --- a/etc/payment.xml +++ b/etc/payment.xml @@ -4,5 +4,8 @@ 0 + + 0 + \ No newline at end of file From 35fb452b8c1cacbda4bcd37656bcc9938fae06cb Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Wed, 17 Jul 2019 11:47:50 +0100 Subject: [PATCH 06/17] Small cody tidy. --- Gateway/Command/GatewayCommand.php | 2 +- Model/Adapter/BraintreeAdapter.php | 4 ---- view/frontend/web/js/view/payment/method-renderer/cc-form.js | 2 +- view/frontend/web/js/view/payment/method-renderer/paypal.js | 3 ++- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Gateway/Command/GatewayCommand.php b/Gateway/Command/GatewayCommand.php index 2ae86ff2..0c834ec6 100644 --- a/Gateway/Command/GatewayCommand.php +++ b/Gateway/Command/GatewayCommand.php @@ -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]) ); diff --git a/Model/Adapter/BraintreeAdapter.php b/Model/Adapter/BraintreeAdapter.php index df8aed58..f253736a 100755 --- a/Model/Adapter/BraintreeAdapter.php +++ b/Model/Adapter/BraintreeAdapter.php @@ -215,10 +215,6 @@ public function cloneTransaction($transactionId, array $attributes) return Transaction::cloneTransaction($transactionId, $attributes); } - /** - * @param $token - * @return mixed - */ /** * @param $token * @return mixed diff --git a/view/frontend/web/js/view/payment/method-renderer/cc-form.js b/view/frontend/web/js/view/payment/method-renderer/cc-form.js index 9545c6ec..fef81875 100755 --- a/view/frontend/web/js/view/payment/method-renderer/cc-form.js +++ b/view/frontend/web/js/view/payment/method-renderer/cc-form.js @@ -186,7 +186,7 @@ define( // stop loader when frame will be loaded if ($('#braintree-hosted-field-number').length) { clearInterval(intervalId); - fullScreenLoader.stopLoader(); + fullScreenLoader.stopLoader(true); } }, 500); diff --git a/view/frontend/web/js/view/payment/method-renderer/paypal.js b/view/frontend/web/js/view/payment/method-renderer/paypal.js index 041ac83c..90512089 100644 --- a/view/frontend/web/js/view/payment/method-renderer/paypal.js +++ b/view/frontend/web/js/view/payment/method-renderer/paypal.js @@ -237,6 +237,7 @@ define([ Braintree.setPayPalInstance(null); } else { Braintree.setup(); + this.enableButton(); } }, @@ -392,7 +393,7 @@ define([ */ enableButton: function () { $('[data-button="place"]').removeAttr('disabled'); - fullScreenLoader.stopLoader(); + fullScreenLoader.stopLoader(true); }, /** From aa3981c3c9ff34c283a4ab9a7b5e3671f0b5ed31 Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Wed, 17 Jul 2019 11:52:04 +0100 Subject: [PATCH 07/17] Added some module dependencies. --- composer.json | 5 +++-- etc/module.xml | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 7fa049c4..7ee57a92 100755 --- a/composer.json +++ b/composer.json @@ -2,17 +2,18 @@ "name": "gene/module-braintree", "description": "Fork from the Magento Braintree 2.2.0 module by Gene Commerce for PayPal.", "require": { + "magento/module-customer": "101.0.*|102.0.*", "magento/module-config": "101.0.*|101.1.*", + "magento/module-sales": "101.0.*|102.0.*", "magento/module-directory": "100.2.*|100.3.*", "magento/module-payment": "100.2.*|100.3.*", "magento/module-checkout": "100.2.*|100.3.*", - "magento/module-sales": "101.0.*|102.0.*", "magento/module-backend": "100.2.*|101.0.*", "magento/module-vault": "101.0.*|101.1.*", - "magento/module-customer": "101.0.*|102.0.*", "magento/module-catalog": "102.0.*|103.0.*", "magento/module-quote": "101.0.*|101.1.*", "magento/module-paypal": "100.2.*|100.3.*", + "magento/module-theme": "100.2.*|100.3.*", "magento/module-ui": "101.0.*|101.1.*", "guzzlehttp/psr7": "^1.5", "ext-json": "*" diff --git a/etc/module.xml b/etc/module.xml index df14a07f..cfac3c20 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -6,11 +6,12 @@ */ --> - + + @@ -18,6 +19,7 @@ + From 590dc44ea15d149e52913b72b30e3b3cdb201491 Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Wed, 24 Jul 2019 15:04:37 +0100 Subject: [PATCH 08/17] Google MErchant ID validation. --- etc/adminhtml/system.xml | 1 + view/adminhtml/templates/payment/script.phtml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 5bdf2afe..c40a33fb 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -219,6 +219,7 @@ payment/braintree_googlepay/merchant_id + required-entry diff --git a/view/adminhtml/templates/payment/script.phtml b/view/adminhtml/templates/payment/script.phtml index a542bd7d..c198b2b3 100755 --- a/view/adminhtml/templates/payment/script.phtml +++ b/view/adminhtml/templates/payment/script.phtml @@ -18,7 +18,7 @@ $code = $block->escapeHtml($block->getCode()); 'jquery', 'domReady!' ], function(Braintree, $) { - let config = getPaymentConfig() ?>, + let config = escapeJs($block->getPaymentConfig()) ?>, payment, form = $('#payment_form_escapeJs($code) ?>'); From 4487c21bdc3d4728e7f292725af67e3abcd19e5a Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Mon, 29 Jul 2019 13:56:18 +0100 Subject: [PATCH 09/17] Changed return type for client token method. --- Model/Adapter/BraintreeAdapter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/Adapter/BraintreeAdapter.php b/Model/Adapter/BraintreeAdapter.php index f253736a..e02064a3 100755 --- a/Model/Adapter/BraintreeAdapter.php +++ b/Model/Adapter/BraintreeAdapter.php @@ -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 ''; } } From 49eb78402387e3be9bcb3374de8fa77a43a3f94b Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Mon, 29 Jul 2019 16:14:57 +0100 Subject: [PATCH 10/17] Updated composer.json. --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 7ee57a92..e7bb08b7 100755 --- a/composer.json +++ b/composer.json @@ -1,6 +1,9 @@ { "name": "gene/module-braintree", "description": "Fork from the Magento Braintree 2.2.0 module by Gene Commerce for PayPal.", + "version": "3.2.0", + "type": "magento2-module", + "license": "proprietary", "require": { "magento/module-customer": "101.0.*|102.0.*", "magento/module-config": "101.0.*|101.1.*", @@ -13,18 +16,15 @@ "magento/module-catalog": "102.0.*|103.0.*", "magento/module-quote": "101.0.*|101.1.*", "magento/module-paypal": "100.2.*|100.3.*", - "magento/module-theme": "100.2.*|100.3.*", + "magento/module-theme": "100.2.*|101.1.*", "magento/module-ui": "101.0.*|101.1.*", "guzzlehttp/psr7": "^1.5", - "ext-json": "*" + "ext-json": "*", + "php": "^7.0" }, "replace": { "magento/module-braintree": "100.*.*" }, - "type": "magento2-module", - "license": [ - "proprietary" - ], "autoload": { "files": [ "registration.php" From 536de9881d42e9155288be2ca0075e86a5e04d1f Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Mon, 29 Jul 2019 17:23:19 +0100 Subject: [PATCH 11/17] Composer update and small code tidy. --- Gateway/Config/Config.php | 1 + Gateway/Config/PayPalCredit/Config.php | 14 ++++++------- composer.json | 28 +++++++++++++------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Gateway/Config/Config.php b/Gateway/Config/Config.php index f39c33d8..ebd200b8 100755 --- a/Gateway/Config/Config.php +++ b/Gateway/Config/Config.php @@ -14,6 +14,7 @@ /** * Class Config + * @package Magento\Braintree\Gateway\Config */ class Config extends \Magento\Payment\Gateway\Config\Config { diff --git a/Gateway/Config/PayPalCredit/Config.php b/Gateway/Config/PayPalCredit/Config.php index a0a9d955..94049a7c 100644 --- a/Gateway/Config/PayPalCredit/Config.php +++ b/Gateway/Config/PayPalCredit/Config.php @@ -9,6 +9,7 @@ /** * Class Config + * @package Magento\Braintree\Gateway\Config\PayPalCredit */ class Config implements ConfigInterface { @@ -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'; /** @@ -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; } @@ -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'); } /** @@ -192,7 +192,7 @@ public function getSecret() */ public function isUk(): bool { - return $this->getMerchantCountry() === 'GB'; + return 'GB' === $this->getMerchantCountry(); } /** @@ -201,7 +201,7 @@ public function isUk(): bool */ public function isUS(): bool { - return $this->getMerchantCountry() === 'US'; + return 'US' === $this->getMerchantCountry(); } /** @@ -227,7 +227,7 @@ public function getBmlDisplay($section) /** * Get Position option from stored config - * + * * @param string $section * @return mixed */ @@ -238,7 +238,7 @@ public function getBmlPosition($section) /** * Get Size option from stored config - * + * * @param string $section * @return mixed */ diff --git a/composer.json b/composer.json index e7bb08b7..9e8db2aa 100755 --- a/composer.json +++ b/composer.json @@ -1,23 +1,23 @@ { - "name": "gene/module-braintree", + "name": "paypal/module-braintree", "description": "Fork from the Magento Braintree 2.2.0 module by Gene Commerce for PayPal.", "version": "3.2.0", "type": "magento2-module", "license": "proprietary", "require": { - "magento/module-customer": "101.0.*|102.0.*", - "magento/module-config": "101.0.*|101.1.*", - "magento/module-sales": "101.0.*|102.0.*", - "magento/module-directory": "100.2.*|100.3.*", - "magento/module-payment": "100.2.*|100.3.*", - "magento/module-checkout": "100.2.*|100.3.*", - "magento/module-backend": "100.2.*|101.0.*", - "magento/module-vault": "101.0.*|101.1.*", - "magento/module-catalog": "102.0.*|103.0.*", - "magento/module-quote": "101.0.*|101.1.*", - "magento/module-paypal": "100.2.*|100.3.*", - "magento/module-theme": "100.2.*|101.1.*", - "magento/module-ui": "101.0.*|101.1.*", + "magento/module-customer": "101.0.*||102.0.*", + "magento/module-config": "101.0.*||101.1.*", + "magento/module-sales": "101.0.*||102.0.*", + "magento/module-directory": "100.2.*||100.3.*", + "magento/module-payment": "100.2.*||100.3.*", + "magento/module-checkout": "100.2.*||100.3.*", + "magento/module-backend": "100.2.*||101.0.*", + "magento/module-vault": "101.0.*||101.1.*", + "magento/module-catalog": "102.0.*||103.0.*", + "magento/module-quote": "101.0.*||101.1.*", + "magento/module-paypal": "100.2.*||100.3.*", + "magento/module-theme": "100.2.*||101.0.*", + "magento/module-ui": "101.0.*||101.1.*", "guzzlehttp/psr7": "^1.5", "ext-json": "*", "php": "^7.0" From 2401f6eb1a251738763c2757f580781c6f1ee633 Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Mon, 29 Jul 2019 17:32:17 +0100 Subject: [PATCH 12/17] Fix vendor name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9e8db2aa..b226a79f 100755 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "paypal/module-braintree", + "name": "gene/module-braintree", "description": "Fork from the Magento Braintree 2.2.0 module by Gene Commerce for PayPal.", "version": "3.2.0", "type": "magento2-module", From 6bb792e362913ffd355dca77b0c1761ffe55841f Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Tue, 30 Jul 2019 16:04:50 +0100 Subject: [PATCH 13/17] Revert changes to VaultDataBuilder so that partial invoices will work correctly. --- Gateway/Request/VaultDataBuilder.php | 29 ++++------------------------ 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/Gateway/Request/VaultDataBuilder.php b/Gateway/Request/VaultDataBuilder.php index 58554745..7a65fffe 100755 --- a/Gateway/Request/VaultDataBuilder.php +++ b/Gateway/Request/VaultDataBuilder.php @@ -25,36 +25,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; + ] + ]; } } From be51941cc35269a438e366cd4f9f2ecafe0c6d42 Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Tue, 30 Jul 2019 16:09:15 +0100 Subject: [PATCH 14/17] Removed unused includes. --- Gateway/Request/VaultDataBuilder.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Gateway/Request/VaultDataBuilder.php b/Gateway/Request/VaultDataBuilder.php index 7a65fffe..e77f2de4 100755 --- a/Gateway/Request/VaultDataBuilder.php +++ b/Gateway/Request/VaultDataBuilder.php @@ -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 From 96f08d00296c4cb59b2183f0caf28720af19e57f Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Wed, 31 Jul 2019 10:53:25 +0100 Subject: [PATCH 15/17] Updated changelog and improved logic for DeleteStoredPayment plugin. --- CHANGELOG.md | 3 +++ Plugin/DeleteStoredPaymentPlugin.php | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77a25e3b..844a6602 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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 diff --git a/Plugin/DeleteStoredPaymentPlugin.php b/Plugin/DeleteStoredPaymentPlugin.php index 83b9ba0f..3903eba1 100644 --- a/Plugin/DeleteStoredPaymentPlugin.php +++ b/Plugin/DeleteStoredPaymentPlugin.php @@ -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; } } From 5c015b0ab0769825c5212d2bd3b9edd29c75a82e Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Wed, 31 Jul 2019 11:18:16 +0100 Subject: [PATCH 16/17] Updated minify exclusing rule to wrap Google Pay JS SDK in a custom element. --- etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/config.xml b/etc/config.xml index 7c14de26..7808201c 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -10,7 +10,7 @@ - https://pay.google.com/gp/p/js/pay + https://pay.google.com/gp/p/js/pay From c24b14ff526d1ebc4af232a059bda18fcfad0614 Mon Sep 17 00:00:00 2001 From: Paul Canning Date: Wed, 31 Jul 2019 11:45:37 +0100 Subject: [PATCH 17/17] Revert minify exclude config change. --- etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/config.xml b/etc/config.xml index 7808201c..7c14de26 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -10,7 +10,7 @@ - https://pay.google.com/gp/p/js/pay + https://pay.google.com/gp/p/js/pay