From 8a31823cca33c9d95e237edfb24860006f4f9ac7 Mon Sep 17 00:00:00 2001 From: hilrob Date: Wed, 16 May 2018 15:32:45 +0200 Subject: [PATCH 01/16] Virtual Discount Fix --- Model/Api.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Model/Api.php b/Model/Api.php index c2083b6..2d198d1 100755 --- a/Model/Api.php +++ b/Model/Api.php @@ -775,6 +775,17 @@ protected function buildAmount($quote) ); } + if ($quote->isVirtual()) { + if($quote->getBillingAddress()->getDiscountAmount()) { + $details->setShippingDiscount( + -( + $quote->getBillingAddress()->getDiscountAmount() + + $quote->getBillingAddress()->getBaseDiscountTaxCompensationAmount() + ) + ); + } + } + $total = $quote->getBaseGrandTotal(); if ((float)$quote->getShippingAddress()->getBaseShippingAmount() == 0 && (float)$quote->getShippingAddress()->getBaseShippingInclTax() >= 0) { $total = (float)$total - (float)$quote->getShippingAddress()->getBaseShippingInclTax(); From c56e1c338672e52d831336968b20673ceb989d80 Mon Sep 17 00:00:00 2001 From: hilrob Date: Wed, 16 May 2018 15:33:46 +0200 Subject: [PATCH 02/16] Code format --- Model/Api.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Model/Api.php b/Model/Api.php index 2d198d1..26b9e36 100755 --- a/Model/Api.php +++ b/Model/Api.php @@ -766,15 +766,6 @@ protected function buildAmount($quote) $quote->getBaseSubtotal() ); - if ($quote->getShippingAddress()->getDiscountAmount()) { - $details->setShippingDiscount( - -( - $quote->getShippingAddress()->getDiscountAmount() - + $quote->getShippingAddress()->getBaseDiscountTaxCompensationAmount() - ) - ); - } - if ($quote->isVirtual()) { if($quote->getBillingAddress()->getDiscountAmount()) { $details->setShippingDiscount( @@ -784,6 +775,15 @@ protected function buildAmount($quote) ) ); } + } else { + if ($quote->getShippingAddress()->getDiscountAmount()) { + $details->setShippingDiscount( + -( + $quote->getShippingAddress()->getDiscountAmount() + + $quote->getShippingAddress()->getBaseDiscountTaxCompensationAmount() + ) + ); + } } $total = $quote->getBaseGrandTotal(); From a42ef2489e13ab4607fa00c0321c055330dff201 Mon Sep 17 00:00:00 2001 From: hilrob Date: Wed, 16 May 2018 15:49:54 +0200 Subject: [PATCH 03/16] Prepare v1.1.8 --- RELEASE_NOTES.txt | 3 +++ composer.json | 2 +- marketplace.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 931bb73..3a1aa36 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,3 +1,6 @@ +==== 1.1.8 ==== +Fixed discount calculation on virtual quotes + ==== 1.1.7 ==== Fixed minicart not empty after order success Fixed shipping calculation with free shipping diff --git a/composer.json b/composer.json index d8c968a..4de59b5 100755 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "type": "magento2-module", - "version": "1.1.7", + "version": "1.1.8", "license": [ "OSL-3.0" ], diff --git a/marketplace.json b/marketplace.json index 5565450..1b5448e 100755 --- a/marketplace.json +++ b/marketplace.json @@ -18,7 +18,7 @@ } ], "type": "magento2-module", - "version": "1.1.7", + "version": "1.1.8", "license": [ "OSL-3.0" ], From ef0aa0d6cfc5b611d4843d3963ce07910ecc9f5f Mon Sep 17 00:00:00 2001 From: hilrob Date: Tue, 11 Dec 2018 17:13:25 +0100 Subject: [PATCH 04/16] 2.26 and 2.3 compat. Reworked override to Plugin and CsrfValidation --- Controller/Order/Create.php | 16 ++- Controller/Webhooks/Index.php | 2 + Controller/Webhooks/Twothree.php | 42 ++++++++ Helper/Data.php | 66 ++++++++++--- Model/Api.php | 26 ++--- Model/ConfigProvider.php | 34 ++++--- Model/MethodList.php | 98 +------------------ Plugin/Payment/Model/MethodListPlugin.php | 67 +++++++++++++ .../Sales/Model/Order/PaymentPlugin.php | 4 +- etc/di.xml | 10 +- 10 files changed, 216 insertions(+), 149 deletions(-) create mode 100644 Controller/Webhooks/Twothree.php create mode 100644 Plugin/Payment/Model/MethodListPlugin.php rename Model/Plugin/AfterOrderPaymentGetExtensionAttributes.php => Plugin/Sales/Model/Order/PaymentPlugin.php (96%) diff --git a/Controller/Order/Create.php b/Controller/Order/Create.php index 13b8e46..532d81e 100755 --- a/Controller/Order/Create.php +++ b/Controller/Order/Create.php @@ -31,6 +31,7 @@ class Create extends \Magento\Framework\App\Action\Action { + const MAX_SEND_MAIL_VERSION = '2.2.6'; /** * @var \Psr\Log\LoggerInterface */ @@ -76,6 +77,11 @@ class Create extends \Magento\Framework\App\Action\Action */ protected $historyFactory; + /** + * @var \Magento\Framework\App\ProductMetadataInterface + */ + protected $productMetadata; + public function __construct( \Magento\Framework\App\Action\Context $context, \Psr\Log\LoggerInterface $logger, @@ -87,7 +93,8 @@ public function __construct( OrderSender $orderSender, OrderFactory $orderFactory, \Magento\Sales\Model\Order\Status\HistoryFactory $historyFactory, - Session $customerSession + Session $customerSession, + \Magento\Framework\App\ProductMetadataInterface $productMetadata ) { $this->logger = $logger; $this->checkoutSession = $checkoutSession; @@ -99,6 +106,7 @@ public function __construct( $this->orderSender = $orderSender; $this->orderFactory = $orderFactory; $this->historyFactory = $historyFactory; + $this->productMetadata = $productMetadata; parent::__construct($context); } @@ -121,7 +129,11 @@ public function execute() if ($orderId) { $order = $this->orderFactory->create()->load($orderId); - if ($order->getCanSendNewEmailFlag()) { + if ( + $order->getCanSendNewEmailFlag() + && version_compare($this->productMetadata->getVersion(), + self::MAX_SEND_MAIL_VERSION, '<') + ) { try { $this->orderSender->send($order); } catch (\Exception $e) { diff --git a/Controller/Webhooks/Index.php b/Controller/Webhooks/Index.php index a7c2665..9994bb0 100644 --- a/Controller/Webhooks/Index.php +++ b/Controller/Webhooks/Index.php @@ -78,5 +78,7 @@ public function execute() $this->_logger->critical($e); $this->getResponse()->setStatusHeader(503, '1.1', 'Service Unavailable')->sendResponse(); } + + return; } } diff --git a/Controller/Webhooks/Twothree.php b/Controller/Webhooks/Twothree.php new file mode 100644 index 0000000..b763784 --- /dev/null +++ b/Controller/Webhooks/Twothree.php @@ -0,0 +1,42 @@ +messageManager = $messageManager; $this->configResource = $configResource; $this->cacheTypeList = $cacheTypeList; + $this->productMetaData = $productMetaData; } + /** * Show Exception if debug mode. * @@ -105,20 +126,33 @@ public function handleException(\Exception $e) */ public function getWebhooksUrl() { + $version = $this->productMetaData->getVersion(); + if (version_compare($version, '2.3.0', '>=')) { + return str_replace( + 'http://', + 'https://', + $this->_getUrl( + 'paypalplus/webhooks/twothree/', + [ + '_forced_secure' => true, + '_nosid' => true, + ] + ) + ); + } return str_replace( 'http://', 'https://', $this->_getUrl( 'paypalplus/webhooks/index/', - array( + [ '_forced_secure' => true, '_nosid' => true, - ) + ] ) ); } - /** * Get url wrapper for security urls and form key * @@ -152,16 +186,16 @@ public function getDefaultCountryId() } /** - * Helper for saving store configuration programmatically - * + * Save Store Config * @param $key * @param $value - * @param $storeId - * @return boolean + * @param null $storeId + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function saveStoreConfig($key, $value, $storeId = null) { - if(!$storeId) { + if (!$storeId) { $storeId = $this->storeManager->getStore()->getId(); } $this->configResource->saveConfig( @@ -173,12 +207,14 @@ public function saveStoreConfig($key, $value, $storeId = null) $this->cacheTypeList->cleanType('config'); return true; } + /** * Reset web profile id * * @return boolean */ - public function resetWebProfileId() { + public function resetWebProfileId() + { foreach ($this->storeManager->getStores() as $store) { $this->configResource->saveConfig( 'iways_paypalplus/dev/web_profile_id', diff --git a/Model/Api.php b/Model/Api.php index 26b9e36..e195e75 100755 --- a/Model/Api.php +++ b/Model/Api.php @@ -113,7 +113,6 @@ class Api */ protected $backendSession; - /** * @var \Magento\Framework\App\Filesystem\DirectoryList */ @@ -191,10 +190,9 @@ public function __construct( } /** - * Set api context - * - * @param $website + * @param null $website * @return $this + * @throws \Magento\Framework\Exception\FileSystemException */ public function setApiContext($website = null) { @@ -289,15 +287,10 @@ public function createPayment($webProfile, $quote, $taxFailure = false) $transaction->setItemList($itemList); $redirectUrls = new RedirectUrls(); - $redirectUrls->setReturnUrl($this->urlBuilder->getUrl('paypalplus/order/create')) - ->setCancelUrl($this->urlBuilder->getUrl('paypalplus/checkout/cancel')); + $redirectUrls->setReturnUrl($this->urlBuilder->getUrl('paypalplus/order/create'))->setCancelUrl($this->urlBuilder->getUrl('paypalplus/checkout/cancel')); $payment = new PayPalPayment(); - $payment->setIntent("sale") - ->setExperienceProfileId($webProfile->getId()) - ->setPayer($payer) - ->setRedirectUrls($redirectUrls) - ->setTransactions(array($transaction)); + $payment->setIntent("sale")->setExperienceProfileId($webProfile->getId())->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions([$transaction]); try { $response = $payment->create($this->_apiContext); @@ -317,10 +310,9 @@ public function createPayment($webProfile, $quote, $taxFailure = false) } /** - * Adding shipping address to an existing payment. - * - * @param \Magento\Quote\Model\Quote $quote - * @return boolean + * @param $quote + * @return bool + * @throws \Exception */ public function patchPayment($quote) { @@ -525,7 +517,7 @@ public function createWebhook() { $webhook = new \PayPal\Api\Webhook(); $webhook->setUrl($this->payPalPlusHelper->getWebhooksUrl()); - $webhookEventTypes = array(); + $webhookEventTypes = []; foreach ($this->payPalPlusWebhookEventFactory->create()->getSupportedWebhookEvents() as $webhookEvent) { $webhookEventType = new \PayPal\Api\WebhookEventType(); $webhookEventType->setName($webhookEvent); @@ -767,7 +759,7 @@ protected function buildAmount($quote) ); if ($quote->isVirtual()) { - if($quote->getBillingAddress()->getDiscountAmount()) { + if ($quote->getBillingAddress()->getDiscountAmount()) { $details->setShippingDiscount( -( $quote->getBillingAddress()->getDiscountAmount() diff --git a/Model/ConfigProvider.php b/Model/ConfigProvider.php index 1ec7be4..5d544ed 100755 --- a/Model/ConfigProvider.php +++ b/Model/ConfigProvider.php @@ -11,6 +11,7 @@ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved. * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + namespace Iways\PayPalPlus\Model; use Magento\Checkout\Model\ConfigProviderInterface; @@ -65,15 +66,20 @@ class ConfigProvider implements ConfigProviderInterface /** * @var MethodList */ - protected $methodLost; + protected $methodList; /** + * ConfigProvider constructor. * @param PaymentHelper $paymentHelper * @param Escaper $escaper * @param \Iways\PayPalPlus\Helper\Data $payPalPlusHelper * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Payment\Model\Config $paymentConfig + * @param MethodList $methodList * @param \Magento\Framework\UrlInterface $urlBuilder + * @param LoggerInterface $logger + * @throws \Magento\Framework\Exception\LocalizedException */ public function __construct( PaymentHelper $paymentHelper, @@ -106,15 +112,11 @@ public function getConfig() 'payment' => [ 'iways_paypalplus_payment' => [ 'paymentExperience' => $this->payPalPlusHelper->getPaymentExperience(), - 'showPuiOnSandbox' => $this->scopeConfig->getValue('iways_paypalplus/dev/pui_sandbox', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE) ? true : false, - 'showLoadingIndicator' => $this->scopeConfig->getValue('payment/iways_paypalplus_payment/show_loading_indicator', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE) ? true : false, - 'mode' => $this->scopeConfig->getValue('iways_paypalplus/api/mode', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE), + 'showPuiOnSandbox' => $this->scopeConfig->getValue('iways_paypalplus/dev/pui_sandbox', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) ? true : false, + 'showLoadingIndicator' => $this->scopeConfig->getValue('payment/iways_paypalplus_payment/show_loading_indicator', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) ? true : false, + 'mode' => $this->scopeConfig->getValue('iways_paypalplus/api/mode', \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'country' => $this->getCountry(), - 'language' => $this->scopeConfig->getValue('general/locale/code', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE), + 'language' => $this->scopeConfig->getValue('general/locale/code', \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'thirdPartyPaymentMethods' => $this->getThirdPartyMethods() ], ], @@ -133,13 +135,14 @@ protected function getCountry() return $shippingAddress->getCountryId(); } - return $this->scopeConfig->getValue('paypal/general/merchant_country', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + return $this->scopeConfig->getValue('paypal/general/merchant_country', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); } protected function getThirdPartyMethods() { - $paymentMethods = $this->methodList->getAvailableMethods($this->checkoutSession->getQuote(), false); + $this->methodList->setCheckPPP(true); + $paymentMethods = $this->methodList->getAvailableMethods($this->checkoutSession->getQuote()); + $this->methodList->setCheckPPP(false); $allowedPPPMethods = explode( ',', $this->scopeConfig->getValue( @@ -149,13 +152,16 @@ protected function getThirdPartyMethods() ); $methods = []; foreach ($paymentMethods as $paymentMethod) { - if (strpos($paymentMethod->getCode(), 'paypal') === false && in_array($paymentMethod->getCode(), $allowedPPPMethods)) { + if ( + strpos($paymentMethod->getCode(), 'paypal') === false + && in_array($paymentMethod->getCode(), $allowedPPPMethods) + ) { $method = [ 'redirectUrl' => $this->urlBuilder->getUrl('checkout', ['_secure' => true]), 'methodName' => $paymentMethod->getTitle(), 'imageUrl' => '', 'description' => $this->scopeConfig->getValue( - 'payment/iways_paypalplus_section/third_party_modul_info/text_'.$paymentMethod->getCode(), + 'payment/iways_paypalplus_section/third_party_modul_info/text_' . $paymentMethod->getCode(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE ), ]; diff --git a/Model/MethodList.php b/Model/MethodList.php index 4eaa052..3de5f53 100755 --- a/Model/MethodList.php +++ b/Model/MethodList.php @@ -14,106 +14,18 @@ namespace Iways\PayPalPlus\Model; -use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Payment\Model\Method\Free; class MethodList extends \Magento\Payment\Model\MethodList { - const AMAZON_PAYMENT = 'amazon_payment'; + protected $checkPPP; - /** - * @var ScopeConfigInterface - */ - protected $scopeConfig; - - /** - * Construct - * - * @param \Magento\Payment\Helper\Data $paymentHelper - * @param \Magento\Payment\Model\Checks\SpecificationFactory $specificationFactory - */ - public function __construct( - \Magento\Payment\Helper\Data $paymentHelper, - \Magento\Payment\Model\Checks\SpecificationFactory $specificationFactory, - ScopeConfigInterface $scopeConfig - - ) { - $this->scopeConfig = $scopeConfig; - parent::__construct($paymentHelper, $specificationFactory); - } - - /** - * Get Available Methods - * - * @param \Magento\Quote\Api\Data\CartInterface $quote - * @param boolean $checkPPP - * @return \Magento\Payment\Model\MethodInterface[] - * @api - */ - public function getAvailableMethods(\Magento\Quote\Api\Data\CartInterface $quote = null, $checkPPP = true) + public function setCheckPPP($checkPPP) { - - $pppEnabled = $this->scopeConfig->getValue( - 'payment/iways_paypalplus_payment/active', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE); - - if ($checkPPP) { - $allowedPPPMethods = explode( - ',', - $this->scopeConfig->getValue( - 'payment/iways_paypalplus_payment/third_party_moduls', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) - ); - } - $store = $quote ? $quote->getStoreId() : null; - $methods = []; - $isFreeAdded = false; - foreach ($this->paymentHelper->getStoreMethods($store, $quote) as $method) { - if ($this->_canUseMethod($method, $quote)) { - $method->setInfoInstance($quote->getPayment()); - - if ($pppEnabled && strpos($method->getCode(), 'paypal_') === 0) { - continue; - } - - if ($checkPPP) { - if ( - ($method->getCode() == Payment::CODE - || $method->getCode() == self::AMAZON_PAYMENT - || !in_array($method->getCode(), $allowedPPPMethods)) - ) { - $methods[] = $method; - } - } else { - $methods[] = $method; - } - if ($method->getCode() == Free::PAYMENT_METHOD_FREE_CODE) { - $isFreeAdded = true; - } - } - } - if (!$isFreeAdded && !$quote->getGrandTotal()) { - $methods = $this->addFree($methods, $quote); - } - return $methods; + $this->checkPPP = $checkPPP; } - /** - * Adds Free Method - * - * @param \Magento\Payment\Model\MethodInterface[] $methods - * @param \Magento\Quote\Api\Data\CartInterface $quote - * @return \Magento\Payment\Model\MethodInterface[] $methods - */ - protected function addFree($methods, \Magento\Quote\Api\Data\CartInterface $quote) + public function getCheckPPP() { - /** @var \Magento\Payment\Model\Method\Free $freeMethod */ - $freeMethod = $this->paymentHelper->getMethodInstance(Free::PAYMENT_METHOD_FREE_CODE); - if ($freeMethod->isAvailableInConfig()) { - $freeMethod->setInfoInstance($quote->getPayment()); - $methods[] = $freeMethod; - } - return $methods; + return $this->checkPPP; } } diff --git a/Plugin/Payment/Model/MethodListPlugin.php b/Plugin/Payment/Model/MethodListPlugin.php new file mode 100644 index 0000000..01468bc --- /dev/null +++ b/Plugin/Payment/Model/MethodListPlugin.php @@ -0,0 +1,67 @@ +scopeConfig = $scopeConfig; + } + + /** + * @param MethodList $methodList + * @param $result + * @return array + */ + public function afterGetAvailableMethods(MethodList $methodList, $result) + { + $checkPPP = false; + if (method_exists($methodList, self::CHECK_PPP_FUNCTION_NAME)) { + $checkPPP = $methodList->{self::CHECK_PPP_FUNCTION_NAME}(); + } + + if (!$checkPPP) { + $allowedPPPMethods = explode( + ',', + $this->scopeConfig->getValue( + 'payment/iways_paypalplus_payment/third_party_moduls', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ); + $allowedMethods = []; + + foreach ($result as $method) { + if ( + $method->getCode() == Payment::CODE + || $method->getCode() == self::AMAZON_PAYMENT + || !in_array($method->getCode(), $allowedPPPMethods) + ) { + $allowedMethods[] = $method; + } + } + + return $allowedMethods; + } + return $result; + } +} \ No newline at end of file diff --git a/Model/Plugin/AfterOrderPaymentGetExtensionAttributes.php b/Plugin/Sales/Model/Order/PaymentPlugin.php similarity index 96% rename from Model/Plugin/AfterOrderPaymentGetExtensionAttributes.php rename to Plugin/Sales/Model/Order/PaymentPlugin.php index af7a607..9d24c71 100644 --- a/Model/Plugin/AfterOrderPaymentGetExtensionAttributes.php +++ b/Plugin/Sales/Model/Order/PaymentPlugin.php @@ -12,13 +12,13 @@ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Iways\PayPalPlus\Model\Plugin; +namespace Iways\PayPalPlus\Plugin\Sales\Model\Order; use Magento\Framework\Model\AbstractExtensibleModel; use Magento\Sales\Api\Data\OrderPaymentExtensionFactory; use Magento\Sales\Model\Order\Payment; -class AfterOrderPaymentGetExtensionAttributes +class PaymentPlugin { /** * @var \Magento\Sales\Api\Data\OrderPaymentExtensionInterface diff --git a/etc/di.xml b/etc/di.xml index f0947f4..6e89944 100755 --- a/etc/di.xml +++ b/etc/di.xml @@ -16,12 +16,10 @@ - - - Iways\PayPalPlus\Model\MethodList - - - + + + + From 9d37cfe137d5358d46bf86e764db8acd936cc780 Mon Sep 17 00:00:00 2001 From: hilrob Date: Wed, 12 Dec 2018 17:32:10 +0100 Subject: [PATCH 05/16] Better translation --- etc/adminhtml/system.xml | 2 +- i18n/de_DE.csv | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 26044ce..5b301a9 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -93,7 +93,7 @@ payment/iways_paypalplus_payment/specificcountry - + Iways\PayPalPlus\Model\System\Config\Source\ThirdPartyModuls 1 payment/iways_paypalplus_payment/third_party_moduls diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv index 21b187a..b17669b 100755 --- a/i18n/de_DE.csv +++ b/i18n/de_DE.csv @@ -45,4 +45,5 @@ "%1 has assigned the claim against you on basis of a factoring agreement to PayPal (Europe) S.à r.l. et Cie, S.C.A. You will only be released from your debt by paying to PayPal (Europe) S.à r.l. et Cie, S.C.A.","%1 hat die Forderung gegen Sie im Rahmen eines laufenden Factoringvertrages an die PayPal (Europe) S.àr.l. et Cie, S.C.A. abgetreten. Zahlungen mit schuldbefreiender Wirkung können nur an die PayPal (Europe) S.àr.l. et Cie, S.C.A. geleistet werden." "Cache access token","Zugriffstoken zwischenspeichern" "Reduces API calls","Reduziert die API-Aufrufe" -"Only available for merchants located in Germany. Please switch your merchant country to Germany. (Merchant Location -> Merchant Country -> Germany)","Nur verfügbar für Händler mit Standort in Deutschland. Bitte stellen Sie den Händlerstandort auf Deutschland. Händlerstandort -> Händlerland -> Deutschland" \ No newline at end of file +"Only available for merchants located in Germany. Please switch your merchant country to Germany. (Merchant Location -> Merchant Country -> Germany)","Nur verfügbar für Händler mit Standort in Deutschland. Bitte stellen Sie den Händlerstandort auf Deutschland. Händlerstandort -> Händlerland -> Deutschland" +"Add payment methods to PayPal-Plus frame","Zahlungsmethoden dem PayPal-Plus Frame hinzufügen" \ No newline at end of file From 1cbcb514770897176e12f7d9cf3db4253aaefd27 Mon Sep 17 00:00:00 2001 From: hilrob Date: Wed, 12 Dec 2018 17:48:30 +0100 Subject: [PATCH 06/16] Patch Itemlist --- Model/Api.php | 22 +++++++++++++--------- Model/PaymentInformationManagement.php | 2 -- composer.json | 6 +++--- marketplace.json | 6 +++--- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Model/Api.php b/Model/Api.php index e195e75..1c8da6b 100755 --- a/Model/Api.php +++ b/Model/Api.php @@ -336,6 +336,13 @@ public function patchPayment($quote) $payerInfoPatch->setValue($payerInfo); $patchRequest->addPatch($payerInfoPatch); + $itemList = $this->buildItemList($quote); + $itemListPatch = new Patch(); + $itemListPatch->setOp('replace'); + $itemListPatch->setPath('/transactions/0/item_list'); + $itemListPatch->setValue($itemList); + $patchRequest->addPatch($itemListPatch); + $amount = $this->buildAmount($quote); $amountPatch = new Patch(); $amountPatch->setOp('replace'); @@ -343,12 +350,8 @@ public function patchPayment($quote) $amountPatch->setValue($amount); $patchRequest->addPatch($amountPatch); - try { - $response = $payment->update( - $patchRequest, - $this->_apiContext - ); + $response = $payment->update($patchRequest, $this->_apiContext); return $response; } catch (\PayPal\Exception\PayPalConnectionException $ex) { $message = json_decode($ex->getData()); @@ -703,14 +706,15 @@ protected function buildFullName($address) } /** - * Build ItemList + * Build Item List * - * @param \Magento\Quote\Model\Quote $quote + * @param $quote + * @param bool $taxFailure * @return ItemList */ - protected function buildItemList($quote, $taxFailure) + protected function buildItemList($quote, $taxFailure = false) { - $itemArray = array(); + $itemArray = []; $itemList = new ItemList(); $currencyCode = $quote->getBaseCurrencyCode(); diff --git a/Model/PaymentInformationManagement.php b/Model/PaymentInformationManagement.php index e34c44f..a65f936 100755 --- a/Model/PaymentInformationManagement.php +++ b/Model/PaymentInformationManagement.php @@ -14,12 +14,10 @@ namespace Iways\PayPalPlus\Model; - use Magento\Quote\Model\Quote; class PaymentInformationManagement { - /** * @var ApiFactory */ diff --git a/composer.json b/composer.json index 4de59b5..0ee1a6a 100755 --- a/composer.json +++ b/composer.json @@ -6,9 +6,9 @@ {"type": "composer", "url": "https://repo.magento.com/"} ], "require": { - "php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0", + "php": "~7.0.0|~7.1.0|~7.2.0", "paypal/rest-api-sdk-php": "^1.6", - "magento/module-paypal": "100.0.*|100.1.*|100.2.*" + "magento/module-paypal": "100.0.*|100.1.*|100.2.*|100.3.*" }, "authors": [ { @@ -19,7 +19,7 @@ } ], "type": "magento2-module", - "version": "1.1.8", + "version": "1.2.0", "license": [ "OSL-3.0" ], diff --git a/marketplace.json b/marketplace.json index 1b5448e..ea813b1 100755 --- a/marketplace.json +++ b/marketplace.json @@ -5,9 +5,9 @@ { "type": "composer", "url": "https://packagist.org" } ], "require": { - "php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0", + "php": "~7.0.0|~7.1.0|~7.2.0", "paypal/rest-api-sdk-php": "^1.6", - "magento/module-paypal": "100.0.*|100.1.*|100.2.*" + "magento/module-paypal": "100.0.*|100.1.*|100.2.*|100.3.*" }, "authors": [ { @@ -18,7 +18,7 @@ } ], "type": "magento2-module", - "version": "1.1.8", + "version": "1.2.0", "license": [ "OSL-3.0" ], From 0c27c839a4568a09c92bc47d275e73b3b5b2ccee Mon Sep 17 00:00:00 2001 From: hilrob Date: Wed, 12 Dec 2018 18:02:13 +0100 Subject: [PATCH 07/16] Array Systax --- Model/Api.php | 14 +++++++------- Model/System/Config/Source/Mode.php | 12 ++++++------ Model/System/Config/Source/ThirdPartyModuls.php | 8 ++++---- Model/Webhook/Event.php | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Model/Api.php b/Model/Api.php index 1c8da6b..50f1c74 100755 --- a/Model/Api.php +++ b/Model/Api.php @@ -596,15 +596,15 @@ public function validateWebhook($rawBody) protected function buildShippingAddress($quote) { $address = $quote->getShippingAddress(); - $addressCheckerArray = array( + $addressCheckerArray = [ 'setRecipientName' => $this->buildFullName($address), 'setLine1' => implode(' ', $address->getStreet()), 'setCity' => $address->getCity(), 'setCountryCode' => $address->getCountryId(), 'setPostalCode' => $address->getPostcode(), 'setState' => $address->getRegion(), - ); - $allowedEmpty = array('setPhone', 'setState'); + ]; + $allowedEmpty = ['setPhone', 'setState']; $shippingAddress = new ShippingAddress(); foreach ($addressCheckerArray as $setter => $value) { if (empty($value) && !in_array($setter, $allowedEmpty)) { @@ -625,14 +625,14 @@ protected function buildShippingAddress($quote) protected function buildBillingAddress($quote) { $address = $quote->getBillingAddress(); - $addressCheckerArray = array( + $addressCheckerArray = [ 'setLine1' => implode(' ', $address->getStreet()), 'setCity' => $address->getCity(), 'setCountryCode' => $address->getCountryId(), 'setPostalCode' => $address->getPostcode(), 'setState' => $address->getRegion(), - ); - $allowedEmpty = array('setPhone', 'setState'); + ]; + $allowedEmpty = ['setPhone', 'setState']; $billingAddress = new Address(); foreach ($addressCheckerArray as $setter => $value) { if (empty($value) && !in_array($setter, $allowedEmpty)) { @@ -692,7 +692,7 @@ protected function buildPayerInfo($quote) */ protected function buildFullName($address) { - $name = array(); + $name = []; if ($address->getFirstname()) { $name[] = $address->getFirstname(); } diff --git a/Model/System/Config/Source/Mode.php b/Model/System/Config/Source/Mode.php index a281d40..934ad07 100755 --- a/Model/System/Config/Source/Mode.php +++ b/Model/System/Config/Source/Mode.php @@ -38,10 +38,10 @@ class Mode implements \Magento\Framework\Option\ArrayInterface */ public function toOptionArray() { - return array( - array('value' => self::LIVE, 'label' => __('Live')), - array('value' => self::SANDBOX, 'label' => __('Sandbox')), - ); + return [ + ['value' => self::LIVE, 'label' => __('Live')], + ['value' => self::SANDBOX, 'label' => __('Sandbox')], + ]; } /** @@ -51,9 +51,9 @@ public function toOptionArray() */ public function toArray() { - return array( + return [ self::SANDBOX => __('Sandbox'), self::LIVE => __('Live'), - ); + ]; } } diff --git a/Model/System/Config/Source/ThirdPartyModuls.php b/Model/System/Config/Source/ThirdPartyModuls.php index b9215a7..15d72f8 100755 --- a/Model/System/Config/Source/ThirdPartyModuls.php +++ b/Model/System/Config/Source/ThirdPartyModuls.php @@ -47,7 +47,7 @@ public function toOptionArray() { $payments = $this->_paymentConfig->getActiveMethods(); - $methods = array(array('value' => '', 'label' => __('--Please Select--'))); + $methods = [['value' => '', 'label' => __('--Please Select--')]]; foreach ($payments as $paymentCode => $paymentModel) { if (strpos($paymentCode, 'paypal') !== false) { @@ -58,10 +58,10 @@ public function toOptionArray() if (empty($paymentTitle)) { $paymentTitle = $paymentCode; } - $methods[$paymentCode] = array( + $methods[$paymentCode] = [ 'label' => $paymentTitle, 'value' => $paymentCode, - ); + ]; } return $methods; } @@ -75,7 +75,7 @@ public function toArray() { $payments = $this->_paymentConfig->getAllMethods(); - $methods = array(); + $methods = []; foreach ($payments as $paymentCode => $paymentModel) { if ($paymentCode == 'iways_paypalplus_payment') { diff --git a/Model/Webhook/Event.php b/Model/Webhook/Event.php index 65827b2..653cee9 100755 --- a/Model/Webhook/Event.php +++ b/Model/Webhook/Event.php @@ -90,13 +90,13 @@ public function processWebhookRequest(\PayPal\Api\WebhookEvent $webhookEvent) */ public function getSupportedWebhookEvents() { - return array( + return [ self::PAYMENT_SALE_COMPLETED, self::PAYMENT_SALE_PENDING, self::PAYMENT_SALE_REFUNDED, self::PAYMENT_SALE_REVERSED, self::RISK_DISPUTE_CREATED - ); + ]; } /** From 725c9e221716a2ba1728a244da8d7322adb8ad31 Mon Sep 17 00:00:00 2001 From: hilrob Date: Wed, 12 Dec 2018 18:14:53 +0100 Subject: [PATCH 08/16] Codeformating --- .../System/Config/ThirdPartyInfo.php | 22 +----- Block/PaymentInfo.php | 6 +- Controller/Order/Create.php | 7 +- Model/Api.php | 72 ++++++++----------- Model/Payment.php | 13 ++-- Model/PaymentInformationManagement.php | 2 - Model/Webhook/Event.php | 24 +++---- Observer/ValidateObserver.php | 10 +-- Plugin/Payment/Model/MethodListPlugin.php | 1 - Plugin/Sales/Model/Order/PaymentPlugin.php | 3 +- Setup/InstallSchema.php | 33 ++++++--- 11 files changed, 73 insertions(+), 120 deletions(-) diff --git a/Block/Adminhtml/System/Config/ThirdPartyInfo.php b/Block/Adminhtml/System/Config/ThirdPartyInfo.php index ab7f82f..ab2d94b 100755 --- a/Block/Adminhtml/System/Config/ThirdPartyInfo.php +++ b/Block/Adminhtml/System/Config/ThirdPartyInfo.php @@ -18,24 +18,11 @@ namespace Iways\PayPalPlus\Block\Adminhtml\System\Config; - -use Magento\Framework\App\Config\ScopeConfigInterface; - class ThirdPartyInfo extends \Magento\Config\Block\System\Config\Form\Fieldset { - /** - * @var - */ protected $_dummyElement; - /** - * @var - */ protected $_fieldRenderer; - /** - * @var - */ protected $_values; - /** * @var \Magento\Payment\Model\Config */ @@ -64,19 +51,14 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele $html = $this->_getHeaderHtml($element); $dummyField = $element->getElements()[0]; - $thirdPartyMethods = explode(',', - $this->_scopeConfig->getValue('payment/iways_paypalplus_payment/third_party_moduls')); + $thirdPartyMethods = explode(',', $this->_scopeConfig->getValue('payment/iways_paypalplus_payment/third_party_moduls')); foreach ($this->paymentConfig->getActiveMethods() as $paymentMethod) { if (in_array($paymentMethod->getCode(), $thirdPartyMethods)) { $thirdPartyMethod = $paymentMethod->getCode(); $field = clone $dummyField; $field->setData('name', str_replace('dummy', $thirdPartyMethod, $field->getName())); $field->setData('label', $paymentMethod->getTitle()); - $field->setData('value', - $this->_scopeConfig->getValue( - 'payment/iways_paypalplus_section/third_party_modul_info/text_' . $thirdPartyMethod - ) - ); + $field->setData('value', $this->_scopeConfig->getValue('payment/iways_paypalplus_section/third_party_modul_info/text_' . $thirdPartyMethod)); $fieldConfig = $field->getData('field_config'); $fieldConfig['id'] = 'text_' . $thirdPartyMethod; $fieldConfig['label'] = $paymentMethod->getTitle(); diff --git a/Block/PaymentInfo.php b/Block/PaymentInfo.php index b920b80..030b74d 100755 --- a/Block/PaymentInfo.php +++ b/Block/PaymentInfo.php @@ -38,9 +38,9 @@ public function toPdf() /** * Prepare information specific to current payment method - * - * @param \Magento\Framework\DataObject|array $transport + * @param null $transport * @return \Magento\Framework\DataObject + * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareSpecificInformation($transport = null) { @@ -65,8 +65,8 @@ protected function _prepareSpecificInformation($transport = null) /** * Checks if PayPal Plus payment is PUI - * * @return bool + * @throws \Magento\Framework\Exception\LocalizedException */ public function isPUI() { diff --git a/Controller/Order/Create.php b/Controller/Order/Create.php index 532d81e..e6f3923 100755 --- a/Controller/Order/Create.php +++ b/Controller/Order/Create.php @@ -16,7 +16,6 @@ use Magento\Customer\Model\Session; use Magento\Framework\DataObject; -use Magento\Quote\Model\QuoteIdMask; use Magento\Quote\Model\QuoteIdMaskFactory; use Magento\Sales\Model\Order\Email\Sender\OrderSender; use Magento\Sales\Model\OrderFactory; @@ -30,7 +29,6 @@ */ class Create extends \Magento\Framework\App\Action\Action { - const MAX_SEND_MAIL_VERSION = '2.2.6'; /** * @var \Psr\Log\LoggerInterface @@ -108,7 +106,6 @@ public function __construct( $this->historyFactory = $historyFactory; $this->productMetadata = $productMetadata; parent::__construct($context); - } /** @@ -131,8 +128,7 @@ public function execute() $order = $this->orderFactory->create()->load($orderId); if ( $order->getCanSendNewEmailFlag() - && version_compare($this->productMetadata->getVersion(), - self::MAX_SEND_MAIL_VERSION, '<') + && version_compare($this->productMetadata->getVersion(), self::MAX_SEND_MAIL_VERSION, '<') ) { try { $this->orderSender->send($order); @@ -160,7 +156,6 @@ public function execute() } } } catch (\Exception $e) { - } } $result->setData('success', true); diff --git a/Model/Api.php b/Model/Api.php index 50f1c74..c98b9ce 100755 --- a/Model/Api.php +++ b/Model/Api.php @@ -198,15 +198,12 @@ public function setApiContext($website = null) { $this->_apiContext = new ApiContext( new OAuthTokenCredential( - $this->scopeConfig->getValue('iways_paypalplus/api/client_id', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $website), - $this->scopeConfig->getValue('iways_paypalplus/api/client_secret', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $website) + $this->scopeConfig->getValue('iways_paypalplus/api/client_id', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $website), + $this->scopeConfig->getValue('iways_paypalplus/api/client_secret', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $website) ) ); - $this->_mode = $this->scopeConfig->getValue('iways_paypalplus/api/mode', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $website); + $this->_mode = $this->scopeConfig->getValue('iways_paypalplus/api/mode', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $website); $this->_apiContext->setConfig( [ @@ -218,8 +215,7 @@ public function setApiContext($website = null) $website ), 'mode' => $this->_mode, - 'log.LogEnabled' => $this->scopeConfig->getValue('iways_paypalplus/dev/debug', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $website), + 'log.LogEnabled' => $this->scopeConfig->getValue('iways_paypalplus/dev/debug', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $website), 'log.FileName' => $this->directoryList->getPath(DirectoryList::LOG) . '/PayPal.log', 'log.LogLevel' => 'INFO' ] @@ -230,8 +226,8 @@ public function setApiContext($website = null) /** * Get ApprovalLink for curretn Quote - * - * @return string + * @return bool|mixed|string|null + * @throws \Magento\Framework\Exception\LocalizedException */ public function getPaymentExperience() { @@ -376,12 +372,10 @@ public function patchPayment($quote) throw new \Exception($validationMessage); } } - } return false; } - /** * Patches invoice number to PayPal transaction * (Magento order increment id) @@ -402,8 +396,7 @@ public function patchInvoiceNumber($paymentId, $invoiceNumber) $invoiceNumberPatch->setValue($invoiceNumber); $patchRequest->addPatch($invoiceNumberPatch); - $response = $payment->update($patchRequest, - $this->_apiContext); + $response = $payment->update($patchRequest, $this->_apiContext); return $response; } @@ -432,11 +425,11 @@ public function executePayment($paymentId, $payerId) } /** - * Refund a payment - * - * @param string $paymentId - * @param string $amount + * Refund Payment + * @param $paymentId + * @param $amount * @return Refund + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function refundPayment($paymentId, $amount) { @@ -586,7 +579,6 @@ public function validateWebhook($rawBody) } } - /** * Build ShippingAddress from quote * @@ -795,20 +787,17 @@ protected function buildAmount($quote) return $amount; } - /** - * Build WebProfile - * - * @return boolean|WebProfile + * Build WebProfil + * @return bool|\PayPal\Api\CreateProfileResponse|WebProfile + * @throws \Magento\Framework\Exception\LocalizedException */ protected function buildWebProfile() { $webProfile = new WebProfile(); - if ($this->scopeConfig->getValue('iways_paypalplus/dev/web_profile_id', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + if ($this->scopeConfig->getValue('iways_paypalplus/dev/web_profile_id', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) ) { - $webProfile->setId($this->scopeConfig->getValue('iways_paypalplus/dev/web_profile_id', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); + $webProfile->setId($this->scopeConfig->getValue('iways_paypalplus/dev/web_profile_id', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); return $webProfile; } try { @@ -827,9 +816,9 @@ protected function buildWebProfile() } /** - * Build presentation - * + * Build Web Profile Presentation * @return Presentation + * @throws \Magento\Framework\Exception\LocalizedException */ protected function buildWebProfilePresentation() { @@ -852,11 +841,9 @@ protected function buildWebProfilePresentation() */ protected function getHeaderImage() { - if ($this->scopeConfig->getValue('iways_paypalplus/api/hdrimg', - \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE) + if ($this->scopeConfig->getValue('iways_paypalplus/api/hdrimg', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE) ) { - return $this->scopeConfig->getValue('iways_paypalplus/api/hdrimg', - \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE); + return $this->scopeConfig->getValue('iways_paypalplus/api/hdrimg', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE); } $folderName = \Magento\Config\Model\Config\Backend\Image\Logo::UPLOAD_DIR; $storeLogoPath = $this->scopeConfig->getValue( @@ -865,11 +852,9 @@ protected function getHeaderImage() ); if ($storeLogoPath) { $path = $folderName . '/' . $storeLogoPath; - return $this->urlBuilder - ->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]) . $path; + return $this->urlBuilder->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]) . $path; } return $this->assetRepo->getUrlWithParams('images/logo.svg', ['_secure' => true]); - } /** @@ -884,9 +869,9 @@ public function resetWebProfileId() /** * Save WebProfileId - * - * @param string $id - * @return boolean + * @param $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException */ protected function saveWebProfileId($id) { @@ -895,9 +880,9 @@ protected function saveWebProfileId($id) /** * Save WebhookId - * - * @param string $id - * @return boolean + * @param $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException */ protected function saveWebhookId($id) { @@ -916,11 +901,10 @@ protected function getQuote() /** * Check if PayPal credentails are valid for given configuration. - * * Uses WebProfile::get_list() - * * @param $website * @return bool + * @throws \Magento\Framework\Exception\FileSystemException */ public function testCredentials($website) { diff --git a/Model/Payment.php b/Model/Payment.php index 7baaa30..b590030 100755 --- a/Model/Payment.php +++ b/Model/Payment.php @@ -130,12 +130,10 @@ public function __construct( $this->customerSession = $customerSession; $this->payPalPlusHelper = $payPalPlusHelper; $this->salesOrderPaymentTransactionFactory = $salesOrderPaymentTransactionFactory; - parent::__construct($context, $registry, $extensionFactory, $customAttributeFactory, $paymentData, $scopeConfig, - $logger, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $extensionFactory, $customAttributeFactory, $paymentData, $scopeConfig, $logger, $resource, $resourceCollection, $data); $this->ppLogger = $context->getLogger(); } - /** * Authorize payment method * @@ -152,8 +150,7 @@ public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount $paymentId = $this->request->getParam('paymentId'); $payerId = $this->request->getParam('PayerID'); try { - if ($this->scopeConfig->getValue('payment/iways_paypalplus_payment/transfer_reserved_order_id', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + if ($this->scopeConfig->getValue('payment/iways_paypalplus_payment/transfer_reserved_order_id', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) ) { $this->payPalPlusApiFactory->create()->patchInvoiceNumber( $paymentId, @@ -218,7 +215,6 @@ public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount } } } - } catch (\Exception $e) { $transactionId = $ppPayment->getId(); } @@ -241,11 +237,10 @@ public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount /** * Refund specified amount for payment - * * @param \Magento\Payment\Model\InfoInterface $payment * @param float $amount - * - * @return \Iways\PayPalPlus\Model\Payment + * @return $this|\Magento\Payment\Model\Method\AbstractMethod + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount) { diff --git a/Model/PaymentInformationManagement.php b/Model/PaymentInformationManagement.php index a65f936..eba3b9f 100755 --- a/Model/PaymentInformationManagement.php +++ b/Model/PaymentInformationManagement.php @@ -14,8 +14,6 @@ namespace Iways\PayPalPlus\Model; -use Magento\Quote\Model\Quote; - class PaymentInformationManagement { /** diff --git a/Model/Webhook/Event.php b/Model/Webhook/Event.php index 653cee9..6af9ab2 100755 --- a/Model/Webhook/Event.php +++ b/Model/Webhook/Event.php @@ -22,7 +22,6 @@ */ class Event { - /** * Payment sale completed event type code */ @@ -68,15 +67,15 @@ public function __construct( $this->salesOrderPaymentTransactionFactory = $salesOrderPaymentTransactionFactory; $this->salesOrderFactory = $salesOrderFactory; } + /** * Process the given $webhookEvent - * * @param \PayPal\Api\WebhookEvent $webhookEvent + * @throws \Exception */ public function processWebhookRequest(\PayPal\Api\WebhookEvent $webhookEvent) { - if ($webhookEvent->getEventType() !== null && in_array($webhookEvent->getEventType(), - $this->getSupportedWebhookEvents()) + if ($webhookEvent->getEventType() !== null && in_array($webhookEvent->getEventType(), $this->getSupportedWebhookEvents()) ) { $this->getOrder($webhookEvent); $this->{$this->eventTypeToHandler($webhookEvent->getEventType())}($webhookEvent); @@ -120,8 +119,8 @@ protected function eventTypeToHandler($eventType) /** * Mark transaction as completed - * * @param \PayPal\Api\WebhookEvent $webhookEvent + * @throws \Exception */ protected function paymentSaleCompleted(\PayPal\Api\WebhookEvent $webhookEvent) { @@ -148,10 +147,8 @@ protected function paymentSaleCompleted(\PayPal\Api\WebhookEvent $webhookEvent) 'Notified customer about invoice #%1.', $invoice->getIncrementId() ) - )->setIsCustomerNotified(true) - ->save(); + )->setIsCustomerNotified(true)->save(); } - } /** @@ -162,7 +159,6 @@ protected function paymentSaleCompleted(\PayPal\Api\WebhookEvent $webhookEvent) */ protected function paymentSaleRefunded(\PayPal\Api\WebhookEvent $webhookEvent) { - $paymentResource = $webhookEvent->getResource(); $parentTransactionId = $paymentResource->parent_payment; /** @var \Magento\Sales\Model\Order\Payment $payment */ @@ -195,8 +191,8 @@ protected function paymentSaleRefunded(\PayPal\Api\WebhookEvent $webhookEvent) /** * Mark transaction as pending - * * @param \PayPal\Api\WebhookEvent $webhookEvent + * @throws \Exception */ protected function paymentSalePending(\PayPal\Api\WebhookEvent $webhookEvent) { @@ -211,8 +207,8 @@ protected function paymentSalePending(\PayPal\Api\WebhookEvent $webhookEvent) /** * Mark transaction as reversed - * * @param \PayPal\Api\WebhookEvent $webhookEvent + * @throws \Exception */ protected function paymentSaleReversed(\PayPal\Api\WebhookEvent $webhookEvent) { @@ -234,13 +230,9 @@ protected function paymentSaleReversed(\PayPal\Api\WebhookEvent $webhookEvent) protected function riskDisputeCreated(\PayPal\Api\WebhookEvent $webhookEvent) { //Add IPN comment about registered dispute - $this->_order->addStatusHistoryComment($webhookEvent->getSummary()) - ->setIsCustomerNotified(false) - ->save(); - + $this->_order->addStatusHistoryComment($webhookEvent->getSummary())->setIsCustomerNotified(false)->save(); } - /** * Load and validate order, instantiate proper configuration * diff --git a/Observer/ValidateObserver.php b/Observer/ValidateObserver.php index 1361011..9642586 100755 --- a/Observer/ValidateObserver.php +++ b/Observer/ValidateObserver.php @@ -87,11 +87,9 @@ public function __construct( /** * Log out user and redirect to new admin custom url - * * @param \Magento\Framework\Event\Observer $observer - * @return void - * @SuppressWarnings(PHPMD.ExitExpression) - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @throws \Magento\Framework\Exception\FileSystemException + * @throws \Magento\Framework\Exception\LocalizedException */ public function execute(\Magento\Framework\Event\Observer $observer) { @@ -108,10 +106,8 @@ public function execute(\Magento\Framework\Event\Observer $observer) /** * Try to get default store id from observer - * * @param \Magento\Framework\Event\Observer $observer - * @return mixed - * @throws \Magento\Framework\Exception\LocalizedException + * @return object|null */ protected function getDefaultStoreId(\Magento\Framework\Event\Observer $observer) { diff --git a/Plugin/Payment/Model/MethodListPlugin.php b/Plugin/Payment/Model/MethodListPlugin.php index 01468bc..1c53244 100644 --- a/Plugin/Payment/Model/MethodListPlugin.php +++ b/Plugin/Payment/Model/MethodListPlugin.php @@ -8,7 +8,6 @@ namespace Iways\PayPalPlus\Plugin\Payment\Model; - use Iways\PayPalPlus\Model\Payment; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Payment\Model\MethodList; diff --git a/Plugin/Sales/Model/Order/PaymentPlugin.php b/Plugin/Sales/Model/Order/PaymentPlugin.php index 9d24c71..b5b0fac 100644 --- a/Plugin/Sales/Model/Order/PaymentPlugin.php +++ b/Plugin/Sales/Model/Order/PaymentPlugin.php @@ -26,7 +26,8 @@ class PaymentPlugin protected $orderPaymentExtensionFactory; /** - * @param OrderPaymentExtensionInterface $orderPaymentExtensionFactory + * PaymentPlugin constructor. + * @param OrderPaymentExtensionFactory $orderPaymentExtensionFactory */ public function __construct( OrderPaymentExtensionFactory $orderPaymentExtensionFactory diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php index e5d2930..e7a3fae 100644 --- a/Setup/InstallSchema.php +++ b/Setup/InstallSchema.php @@ -46,7 +46,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'nullable' => true, 'default' => null, 'comment' => 'PayPal Plus Reference Number' - ]); + ] + ); $connection->addColumn( $table, 'ppp_instruction_type', @@ -56,7 +57,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'nullable' => true, 'default' => null, 'comment' => 'PayPal Plus Instruction Type' - ]); + ] + ); $connection->addColumn( $table, 'ppp_payment_due_date', @@ -66,7 +68,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'nullable' => true, 'default' => null, 'comment' => 'PayPal Plus Payment Due Date' - ]); + ] + ); $connection->addColumn( $table, 'ppp_note', @@ -76,7 +79,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'nullable' => true, 'default' => null, 'comment' => 'PayPal Plus Note' - ]); + ] + ); $connection->addColumn( $table, 'ppp_bank_name', @@ -86,7 +90,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'nullable' => true, 'default' => null, 'comment' => 'PayPal Plus Bank Name' - ]); + ] + ); $connection->addColumn( $table, 'ppp_account_holder_name', @@ -96,7 +101,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'nullable' => true, 'default' => null, 'comment' => 'PayPal Plus Holder Name' - ]); + ] + ); $connection->addColumn( $table, 'ppp_international_bank_account_number', @@ -106,7 +112,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'nullable' => true, 'default' => null, 'comment' => 'PayPal Plus International Bank Account Number' - ]); + ] + ); $connection->addColumn( $table, 'ppp_bank_identifier_code', @@ -116,7 +123,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'nullable' => true, 'default' => null, 'comment' => 'PayPal Plus Bank Identifier Code' - ]); + ] + ); $connection->addColumn( $table, 'ppp_routing_number', @@ -126,7 +134,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'nullable' => true, 'default' => null, 'comment' => 'PayPal Plus Routing Number' - ]); + ] + ); $connection->addColumn( $table, 'ppp_amount', @@ -136,7 +145,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'nullable' => true, 'default' => null, 'comment' => 'PayPal Plus Amount' - ]); + ] + ); $connection->addColumn( $table, 'ppp_currency', @@ -146,7 +156,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'nullable' => true, 'default' => null, 'comment' => 'PayPal Plus Currency' - ]); + ] + ); $installer->endSetup(); } From 428a83391abe54282fe55719be7100038ebd5e62 Mon Sep 17 00:00:00 2001 From: hilrob Date: Wed, 12 Dec 2018 18:53:20 +0100 Subject: [PATCH 09/16] Release Notes v1.2.0 --- RELEASE_NOTES.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 3a1aa36..ce3eb0a 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,3 +1,8 @@ +==== 1.2.0 ==== +Compatibility with 2.2.6 and 2.3 +Renamed third party modules config +Added item list to patch + ==== 1.1.8 ==== Fixed discount calculation on virtual quotes From dfe5ce4433df3db243bf1c8c6e6c7a7cad741915 Mon Sep 17 00:00:00 2001 From: hilrob Date: Wed, 6 Mar 2019 10:25:58 +0100 Subject: [PATCH 10/16] Removed powered by PayPal --- i18n/de_DE.csv | 1 - view/frontend/templates/paypalplus/success.phtml | 2 -- 2 files changed, 3 deletions(-) diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv index b17669b..8145d9b 100755 --- a/i18n/de_DE.csv +++ b/i18n/de_DE.csv @@ -21,7 +21,6 @@ "The image at the top left of the checkout page. Max size is 750x90-pixel. https is highly encouraged.","Das Bild oben links auf der Bezahlseite. Max. 750px × 90px. https wird dringend empfohlen." "Please select an other payment method.","Bitte wählen Sie eine andere Zahlungsmethode." "Provided credentials not valid.","Ihre Zugangsdaten können nicht validiert werden." -"processed by PayPal","wurde von PayPal prozessiert" "Account holder","Kontobesitzer" "Bank","Bank" "IBAN","IBAN" diff --git a/view/frontend/templates/paypalplus/success.phtml b/view/frontend/templates/paypalplus/success.phtml index e69bac0..ba1b6e7 100755 --- a/view/frontend/templates/paypalplus/success.phtml +++ b/view/frontend/templates/paypalplus/success.phtml @@ -79,8 +79,6 @@ '%1 has assigned the claim against you on basis of a factoring agreement to PayPal (Europe) S.à r.l. et Cie, S.C.A. You will only be released from your debt by paying to PayPal (Europe) S.à r.l. et Cie, S.C.A.', $block->getStoreName() ); ?>

-isPPP()): ?> -
processed by PayPal');?>
isPPP()): ?>