diff --git a/Block/Adminhtml/System/Config/ThirdPartyInfo.php b/Block/Adminhtml/System/Config/ThirdPartyInfo.php
index 1f0937d..ab7f82f 100755
--- a/Block/Adminhtml/System/Config/ThirdPartyInfo.php
+++ b/Block/Adminhtml/System/Config/ThirdPartyInfo.php
@@ -15,6 +15,7 @@
/**
* Config form fieldset renderer
*/
+
namespace Iways\PayPalPlus\Block\Adminhtml\System\Config;
@@ -40,7 +41,6 @@ class ThirdPartyInfo extends \Magento\Config\Block\System\Config\Form\Fieldset
*/
protected $paymentConfig;
-
public function __construct(
\Magento\Payment\Model\Config $paymentConfig,
\Magento\Backend\Block\Context $context,
@@ -55,7 +55,7 @@ public function __construct(
/**
* Render fieldset html
*
- * @param AbstractElement $element
+ * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
@@ -64,18 +64,25 @@ 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)) {
+ 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['id'] = 'text_' . $thirdPartyMethod;
$fieldConfig['label'] = $paymentMethod->getTitle();
- $fieldConfig['config_path'] = 'payment/iways_paypalplus_section/third_party_modul_info/text_'.$thirdPartyMethod;
+ $fieldConfig['config_path'] =
+ 'payment/iways_paypalplus_section/third_party_modul_info/text_' . $thirdPartyMethod;
+
$field->setData('field_config', $fieldConfig);
$field->setData('html_id', str_replace('dummy', $thirdPartyMethod, $field->getData('html_id')));
$html .= $field->toHtml();
diff --git a/Block/Config/System/Config/Form/Comment.php b/Block/Config/System/Config/Form/Comment.php
new file mode 100644
index 0000000..e8728bc
--- /dev/null
+++ b/Block/Config/System/Config/Form/Comment.php
@@ -0,0 +1,28 @@
+_decorateRowHtml($element, __($element->getComment()));
+ }
+}
\ No newline at end of file
diff --git a/Block/Onepage/Success.php b/Block/Onepage/Success.php
index 7f7476e..4efbbe4 100644
--- a/Block/Onepage/Success.php
+++ b/Block/Onepage/Success.php
@@ -30,20 +30,20 @@ class Success extends \Magento\Framework\View\Element\Template
* Checkout session
* @var \Magento\Checkout\Model\Session
*/
- protected $_checkoutSession;
+ protected $checkoutSession;
/**
* Order
* @var Order
*/
- protected $_order;
+ protected $order;
/**
* Construct
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession
- * @param array $data
+ * @param [] $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
@@ -51,8 +51,8 @@ public function __construct(
array $data = []
) {
parent::__construct($context, $data);
- $this->_checkoutSession = $checkoutSession;
- $this->_order = $this->_checkoutSession->getLastRealOrder();
+ $this->checkoutSession = $checkoutSession;
+ $this->order = $this->checkoutSession->getLastRealOrder();
}
/**
@@ -61,7 +61,7 @@ public function __construct(
*/
public function isPPP()
{
- if ($this->_order->getPayment()->getMethodInstance()->getCode() == Payment::CODE) {
+ if ($this->order->getPayment()->getMethodInstance()->getCode() == Payment::CODE) {
return true;
}
return false;
@@ -77,7 +77,7 @@ public function isPUI()
return (
$this->isPPP()
&& (
- $this->_order->getPayment()->getData('ppp_instruction_type')
+ $this->order->getPayment()->getData('ppp_instruction_type')
== Payment::PPP_INSTRUCTION_TYPE
)
) ? true : false;
@@ -90,7 +90,7 @@ public function isPUI()
*/
public function hasPaymentInstruction()
{
- return ($this->isPPP() && $this->_order->getPayment()->getData('ppp_instruction_type')) ? true : false;
+ return ($this->isPPP() && $this->order->getPayment()->getData('ppp_instruction_type')) ? true : false;
}
/**
@@ -101,7 +101,7 @@ public function hasPaymentInstruction()
*/
public function getAdditionalInformation($key)
{
- return $this->_order->getPayment()->getData($key);
+ return $this->order->getPayment()->getData($key);
}
/**
diff --git a/Controller/Order/Create.php b/Controller/Order/Create.php
index a67950a..13b8e46 100755
--- a/Controller/Order/Create.php
+++ b/Controller/Order/Create.php
@@ -105,6 +105,7 @@ public function __construct(
/**
* Execute
+ * @return void
*/
public function execute()
{
diff --git a/Controller/Webhooks/Index.php b/Controller/Webhooks/Index.php
index 21adb45..a7c2665 100644
--- a/Controller/Webhooks/Index.php
+++ b/Controller/Webhooks/Index.php
@@ -70,15 +70,13 @@ public function execute()
$data = file_get_contents('php://input');
/** @var \PayPal\Api\WebhookEvent $webhookEvent */
$webhookEvent = $this->_apiFactory->create()->validateWebhook($data);
- if(!$webhookEvent) {
+ if (!$webhookEvent) {
throw new LocalizedException(__('Event not found.'));
}
$this->_webhookEventFactory->create()->processWebhookRequest($webhookEvent);
- } catch (\Exception $e) {
+ } catch (\Exception $e) {
$this->_logger->critical($e);
$this->getResponse()->setStatusHeader(503, '1.1', 'Service Unavailable')->sendResponse();
- /** @todo eliminate usage of exit statement */
- exit;
}
}
}
diff --git a/Model/Api.php b/Model/Api.php
index 6524f49..d98e80c 100755
--- a/Model/Api.php
+++ b/Model/Api.php
@@ -11,11 +11,13 @@
* 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\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Encryption\EncryptorInterface;
use Magento\Quote\Model\Quote;
+use PayPal\Api\Refund;
use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;
use PayPal\Api\Address;
@@ -100,9 +102,9 @@ class Api
protected $payPalPlusWebhookEventFactory;
/**
- * @var \Magento\Checkout\Model\Type\Onepage
+ * @var \Magento\Checkout\Model\Session
*/
- protected $checkoutTypeOnepage;
+ protected $checkoutSession;
/**
* @var \Magento\Backend\Model\Session
@@ -145,7 +147,7 @@ class Api
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param Webhook\EventFactory $payPalPlusWebhookEventFactory
- * @param \Magento\Checkout\Model\Type\Onepage $checkoutTypeOnepage
+ * @param \Magento\Checkout\Model\Session $session
* @param \Magento\Backend\Model\Session $backendSession
* @param DirectoryList $directoryList
* @param \Magento\Framework\Message\ManagerInterface $messageManager
@@ -161,7 +163,7 @@ public function __construct(
\Psr\Log\LoggerInterface $logger,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Iways\PayPalPlus\Model\Webhook\EventFactory $payPalPlusWebhookEventFactory,
- \Magento\Checkout\Model\Type\Onepage $checkoutTypeOnepage,
+ \Magento\Checkout\Model\Session $checkoutSession,
\Magento\Backend\Model\Session $backendSession,
\Magento\Framework\App\Filesystem\DirectoryList $directoryList,
\Magento\Framework\Message\ManagerInterface $messageManager,
@@ -176,7 +178,7 @@ public function __construct(
$this->logger = $logger;
$this->storeManager = $storeManager;
$this->payPalPlusWebhookEventFactory = $payPalPlusWebhookEventFactory;
- $this->checkoutTypeOnepage = $checkoutTypeOnepage;
+ $this->checkoutSession = $checkoutSession;
$this->backendSession = $backendSession;
$this->directoryList = $directoryList;
$this->messageManager = $messageManager;
@@ -207,7 +209,7 @@ public function setApiContext($website = null)
\Magento\Store\Model\ScopeInterface::SCOPE_STORE, $website);
$this->_apiContext->setConfig(
- array(
+ [
'http.ConnectionTimeOut' => 30,
'http.Retry' => 1,
'cache.enabled' => $this->scopeConfig->getValue(
@@ -220,7 +222,7 @@ public function setApiContext($website = null)
\Magento\Store\Model\ScopeInterface::SCOPE_STORE, $website),
'log.FileName' => $this->directoryList->getPath(DirectoryList::LOG) . '/PayPal.log',
'log.LogLevel' => 'INFO'
- )
+ ]
);
$this->_apiContext->addRequestHeader('PayPal-Partner-Attribution-Id', 'Magento_Cart_PayPalPlusMagento2');
return $this;
@@ -251,7 +253,7 @@ public function getPaymentExperience()
* Get a payment
*
* @param string $paymentId
- * @return Payment
+ * @return \PayPal\Api\Payment
*/
public function getPayment($paymentId)
{
@@ -317,7 +319,7 @@ public function patchPayment($quote)
$payment = PayPalPayment::get($this->customerSession->getPayPalPaymentId(), $this->_apiContext);
$patchRequest = new PatchRequest();
- if(!$quote->isVirtual()) {
+ if (!$quote->isVirtual()) {
$shippingAddress = $this->buildShippingAddress($quote);
$addressPatch = new Patch();
$addressPatch->setOp(self::PATCH_ADD);
@@ -354,8 +356,8 @@ public function patchPayment($quote)
* Patches invoice number to PayPal transaction
* (Magento order increment id)
*
- * @param $paymentId
- * @param $invoiceNumber
+ * @param string $paymentId
+ * @param string $invoiceNumber
* @return bool
*/
public function patchInvoiceNumber($paymentId, $invoiceNumber)
@@ -381,7 +383,7 @@ public function patchInvoiceNumber($paymentId, $invoiceNumber)
*
* @param string $paymentId
* @param string $payerId
- * @return boolean
+ * @return boolean|\PayPal\Api\Payment
*/
public function executePayment($paymentId, $payerId)
{
@@ -403,9 +405,9 @@ public function executePayment($paymentId, $payerId)
/**
* Refund a payment
*
- * @param type $paymentId
- * @param type $amount
- * @return type
+ * @param string $paymentId
+ * @param string $amount
+ * @return Refund
*/
public function refundPayment($paymentId, $amount)
{
@@ -739,10 +741,15 @@ protected function buildAmount($quote)
);
}
+ $total = $quote->getBaseGrandTotal();
+ if((float)$quote->getShippingAddress()->getBaseShippingAmount() == 0 && (float)$quote->getShippingAddress()->getBaseShippingInclTax() >= 0) {
+ $total = (float)$total - (float)$quote->getShippingAddress()->getBaseShippingInclTax();
+ }
+
$amount = new Amount();
$amount->setCurrency($quote->getBaseCurrencyCode())
->setDetails($details)
- ->setTotal($quote->getBaseGrandTotal());
+ ->setTotal($total);
return $amount;
}
@@ -791,8 +798,7 @@ protected function buildWebProfilePresentation()
$presentation->setLocaleCode(
substr(
$this->scopeConfig->getValue('general/locale/code', \Magento\Store\Model\ScopeInterface::SCOPE_STORE),
- 3,
- 2
+ -2
)
);
return $presentation;
@@ -864,7 +870,7 @@ protected function saveWebhookId($id)
*/
protected function getQuote()
{
- return $this->checkoutTypeOnepage->getQuote();
+ return $this->checkoutSession->getQuote();
}
/**
@@ -891,5 +897,4 @@ public function testCredentials($website)
return false;
}
}
-
}
\ No newline at end of file
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index c1aab14..a012430 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,3 +1,11 @@
+==== 1.1.4 ====
+Changed locale_code parsing
+Added workaround for broken shipping cost calculation in checkout
+Fixed magento/module-paypal requirement to support Magento 2.2.X
+
+==== 1.1.3 ====
+Added notice to configuration if merchant country is not set to Germany
+
==== 1.1.2 ====
Fix JS Script error on empty third party method array
Fix for missing ShippingAddress on virtual orders
diff --git a/composer.json b/composer.json
index fcb4e8a..4a8ec15 100755
--- a/composer.json
+++ b/composer.json
@@ -7,7 +7,8 @@
],
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0",
- "paypal/rest-api-sdk-php": "^1.6"
+ "paypal/rest-api-sdk-php": "^1.6",
+ "magento/module-paypal": "100.0.*|100.1.*|100.2.*"
},
"authors": [
{
@@ -18,7 +19,7 @@
}
],
"type": "magento2-module",
- "version": "1.1.2",
+ "version": "1.1.4",
"license": [
"OSL-3.0"
],
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index c4bb644..26044ce 100755
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -15,6 +15,16 @@
-->
+
+
+
+
+
+ Merchant Country -> Germany)]]>
+ Iways\PayPalPlus\Block\Config\System\Config\Form\Comment
+
+
+
@@ -22,6 +32,11 @@
1
complex paypalplus-section
Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Group
+
+
+
+ Iways\PayPalPlus\Block\Config\System\Config\Form\Comment
+
How to retrieve your PayPal API credentials.]]>
diff --git a/etc/config.xml b/etc/config.xml
index 14b52f2..5f18cc5 100755
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -32,6 +32,7 @@
processing
0
-1
+ paypal
diff --git a/etc/module.xml b/etc/module.xml
index dc5be08..a7c6afa 100755
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -16,12 +16,7 @@
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv
index bd65e99..21b187a 100755
--- a/i18n/de_DE.csv
+++ b/i18n/de_DE.csv
@@ -44,4 +44,5 @@
"Payment could not be executed.","Zahlung konnte nicht durchgeführt werden."
"%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"
\ No newline at end of file
+"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
diff --git a/marketplace.json b/marketplace.json
new file mode 100755
index 0000000..b662300
--- /dev/null
+++ b/marketplace.json
@@ -0,0 +1,31 @@
+{
+ "name": "iwaysgmbh/module-pay-pal-plus",
+ "description": "PayPal Plus for Magento 2",
+ "repositories": [
+ { "type": "composer", "url": "https://packagist.org" }
+ ],
+ "require": {
+ "php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0",
+ "paypal/rest-api-sdk-php": "^1.6",
+ "magento/module-paypal": "100.0.*|100.1.*|100.2.*"
+ },
+ "authors": [
+ {
+ "name": "Robert Hillebrand",
+ "email": "hillebrand@i-ways.net",
+ "homepage": "https://www.i-ways.net",
+ "role": "Senior Software Developer"
+ }
+ ],
+ "type": "magento2-module",
+ "version": "1.1.4",
+ "license": [
+ "OSL-3.0"
+ ],
+ "autoload": {
+ "files": [ "registration.php" ],
+ "psr-4": {
+ "Iways\\PayPalPlus\\": ""
+ }
+ }
+}
\ No newline at end of file