Skip to content

Commit 78378bb

Browse files
authored
Merge pull request #453 from 202ecommerce/develop
Release 6.5.1
2 parents dcbefe5 + b577ce4 commit 78378bb

19 files changed

Lines changed: 154 additions & 69 deletions

File tree

202/build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<property name="src-dir" value="${basedir}" />
3232
<property name="TARGETNAME" value="paypal" />
3333
<property name="TARGETBRANCH" value="${env.GIT_BRANCH}" />
34-
<property name="TARGETVERSION" value="6.5.0" />
34+
<property name="TARGETVERSION" value="6.5.1" />
3535
<property name="PHPVERSION" value="5.6" />
3636
<property name="PSVERSION" value="1.7.5.2" />
3737

classes/API/Response/Error.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,17 @@ public function setErrorCode($errorCode)
5757

5858
public function setMessage($message)
5959
{
60-
$this->message = $message;
60+
if (is_string($message)) {
61+
$this->message = $message;
62+
63+
return $this;
64+
}
65+
66+
$stringMessage = json_encode($message);
67+
68+
if ($stringMessage) {
69+
$this->message = $stringMessage;
70+
}
6171

6272
return $this;
6373
}

classes/AbstractMethodPaypal.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ protected function completePayment()
371371

372372
$response->setScaState($scaState);
373373

374-
if ($this->getIntent() == 'CAPTURE') {
374+
if ($this->getIntent() == self::SALE) {
375375
if (empty($response->getData()->result->purchase_units[0]->payments->captures)) {
376376
$error = new Error();
377377
$error
@@ -761,12 +761,8 @@ public function isCorrectCart(\Cart $cart, $paymentId)
761761
/**
762762
* @return int id of the order status
763763
**/
764-
public function getOrderStatus($captureState = \PayPal::CAPTURE_STATUS_COMPLETED)
764+
public function getOrderStatus($captureState = \PayPal::CAPTURE_STATUS_PENDING)
765765
{
766-
if ($this->getWebhookOption()->isEnable() && $this->getWebhookOption()->isAvailable()) {
767-
return $this->getStatusMapping()->getWaitValidationStatus();
768-
}
769-
770766
if ($this->getStatusMapping()->isModeSale() == false) {
771767
return $this->getStatusMapping()->getWaitValidationStatus();
772768
}

classes/Form/CheckoutForm.php

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -106,28 +106,26 @@ public function getDescription()
106106
];
107107
}
108108

109-
if (in_array($this->method, ['EC', 'MB'])) {
110-
$fields[PaypalConfigurations::INTENT] = [
111-
'type' => 'select',
112-
'label' => $this->module->l('Payment action', 'AdminPayPalSetupController'),
113-
'name' => PaypalConfigurations::INTENT,
114-
'options' => [
115-
[
116-
'value' => 'sale',
117-
'title' => $this->module->l('Sale', 'AdminPayPalSetupController'),
118-
],
119-
[
120-
'value' => 'authorize',
121-
'title' => $this->module->l('Authorize', 'AdminPayPalSetupController'),
122-
],
109+
$fields[PaypalConfigurations::INTENT] = [
110+
'type' => 'select',
111+
'label' => $this->module->l('Payment action', 'AdminPayPalSetupController'),
112+
'name' => PaypalConfigurations::INTENT,
113+
'options' => [
114+
[
115+
'value' => 'sale',
116+
'title' => $this->module->l('Sale', 'AdminPayPalSetupController'),
123117
],
124-
'value' => \Configuration::get(PaypalConfigurations::INTENT),
125-
'variant' => 'primary',
126-
];
118+
[
119+
'value' => 'authorize',
120+
'title' => $this->module->l('Authorize', 'AdminPayPalSetupController'),
121+
],
122+
],
123+
'value' => \Configuration::get(PaypalConfigurations::INTENT),
124+
'variant' => 'primary',
125+
];
127126

128-
if ($this->method == 'MB') {
129-
$fields[PaypalConfigurations::INTENT]['label'] = $this->module->l('Payment action (for PayPal Express Checkout only)', 'AdminPayalSetupController');
130-
}
127+
if ($this->method == 'MB') {
128+
$fields[PaypalConfigurations::INTENT]['label'] = $this->module->l('Payment action (for PayPal Express Checkout only)', 'AdminPayalSetupController');
131129
}
132130

133131
$fields[PaypalConfigurations::EXPRESS_CHECKOUT_IN_CONTEXT] = [

classes/InstallmentBanner/ConfigurationMap.php

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -110,42 +110,25 @@ public static function getColorGradient($color)
110110
*/
111111
public static function getAllowedCountries()
112112
{
113-
return ['fr', 'de', 'gb', 'us', 'au', 'it', 'es'];
113+
return ['fr', 'de', 'gb', 'us', 'au', 'it', 'es', 'ca'];
114114
}
115115

116116
public static function getBnplAvailableCountries()
117117
{
118-
return ['fr', 'de', 'gb', 'us', 'au', 'it', 'es'];
118+
return ['fr', 'de', 'gb', 'us', 'au', 'it', 'es', 'ca'];
119119
}
120120

121+
/**
122+
* @deprecated
123+
*/
121124
public static function getLanguageCurrencyMap()
122125
{
123-
return [
124-
['fr' => 'eur'],
125-
['fr' => 'gbp'],
126-
['fr' => 'usd'],
127-
['fr' => 'aud'],
128-
['de' => 'eur'],
129-
['de' => 'gbp'],
130-
['de' => 'aud'],
131-
['de' => 'usd'],
132-
['gb' => 'gbp'],
133-
['gb' => 'usd'],
134-
['gb' => 'aud'],
135-
['gb' => 'eur'],
136-
['en' => 'gbp'],
137-
['en' => 'usd'],
138-
['en' => 'aud'],
139-
['en' => 'eur'],
140-
['it' => 'eur'],
141-
['it' => 'gbp'],
142-
['it' => 'usd'],
143-
['it' => 'aud'],
144-
['es' => 'eur'],
145-
['es' => 'gbp'],
146-
['es' => 'usd'],
147-
['es' => 'aud'],
148-
];
126+
@trigger_error(
127+
self::class . '::getLanguageCurrencyMap() is deprecated. Use ' . self::class . '::getBnplLanguageCurrencyMap() instead.',
128+
E_USER_DEPRECATED
129+
);
130+
131+
return self::getBnplLanguageCurrencyMap();
149132
}
150133

151134
public static function getBnplLanguageCurrencyMap()
@@ -159,6 +142,11 @@ public static function getBnplLanguageCurrencyMap()
159142
['au' => 'aud'],
160143
['it' => 'eur'],
161144
['es' => 'eur'],
145+
['fr' => 'cad'],
146+
['en' => 'cad'],
147+
['gb' => 'cad'],
148+
['us' => 'cad'],
149+
['ca' => 'cad'],
162150
];
163151
}
164152

classes/MethodPPP.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,12 @@ public function getConfig(PayPal $module)
164164
*/
165165
public function confirmCapture($orderPayPal)
166166
{
167-
return null;
167+
return $this->paypalApiManager->getCaptureAuthorizeRequest($orderPayPal)->execute();
168168
}
169169

170170
public function void($orderPayPal)
171171
{
172+
return $this->paypalApiManager->getAuthorizationVoidRequest($orderPayPal)->execute();
172173
}
173174

174175
/**
@@ -278,7 +279,7 @@ public function getSecret($sandbox = null)
278279

279280
public function getIntent()
280281
{
281-
return self::SALE;
282+
return Configuration::get('PAYPAL_API_INTENT') == 'sale' ? self::SALE : self::AUTHORIZE;
282283
}
283284

284285
public function getReturnUrl()

classes/PUI/PuiFunctionality.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public function __construct()
4747

4848
public function isAvailable($refresh = true)
4949
{
50+
if ($this->method->getIntent() === AbstractMethodPaypal::AUTHORIZE) {
51+
return false;
52+
}
53+
5054
$isAvailable = (int) \Configuration::get(PUI::CONFIGURATION_IS_AVAILABLE);
5155

5256
if ($refresh == false && in_array($isAvailable, [PUI::IS_AVAILABLE, PUI::IS_UNAVAILABLE])) {

classes/SEPA/SepaFunctionality.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
namespace PaypalAddons\classes\SEPA;
3030

31+
use PaypalAddons\classes\AbstractMethodPaypal;
3132
use PaypalAddons\classes\Constants\PaypalConfigurations;
3233

3334
if (!defined('_PS_VERSION_')) {
@@ -36,8 +37,21 @@
3637

3738
class SepaFunctionality
3839
{
40+
/** @var \MethodPPP */
41+
protected $method;
42+
43+
public function __construct()
44+
{
45+
$this->method = AbstractMethodPaypal::load('PPP');
46+
}
47+
3948
public function isEnabled()
4049
{
4150
return (int) \Configuration::get(PaypalConfigurations::SEPA_ENABLED);
4251
}
52+
53+
public function isAvailable()
54+
{
55+
return $this->method->getIntent() === AbstractMethodPaypal::SALE;
56+
}
4357
}

classes/Webhook/WebhookAvailability.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function check()
4646
$response = new Response();
4747
$curl = curl_init((new WebhookHandlerUrl())->getCheckAvailabilityUrl());
4848
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
49-
curl_setopt($curl, CURLOPT_SSLVERSION, 6);
49+
curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
5050
curl_exec($curl);
5151
$info = curl_getinfo($curl);
5252

controllers/admin/AdminPaypalDiagnostic.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function initPageHeaderToolbar()
4444
{
4545
parent::initPageHeaderToolbar();
4646
$this->context->smarty->clearAssign('help_link');
47+
$this->page_header_toolbar_title = sprintf($this->module->l('Diagnostic %s'), 'PayPal');
4748
}
4849

4950
public function initContent()

0 commit comments

Comments
 (0)