Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 6.4.3 #388

Merged
merged 45 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
16f510d
refs #47377 removing deprecated files
bogdan202 Jul 31, 2024
0c94887
module version
bogdan202 Jul 31, 2024
b89b1f7
Merge pull request #357 from 202ecommerce/feature/47377-remove-deprec…
bogdan202 Aug 2, 2024
db83047
refs #47512 declaration warning
bogdan202 Aug 2, 2024
216a491
warning during upgrade
bogdan202 Aug 2, 2024
758f498
Merge pull request #358 from 202ecommerce/bugfix/47512-warning
bogdan202 Aug 2, 2024
a623694
refs #47377 removing redundant files
bogdan202 Aug 15, 2024
da3f481
refs #47377 error class not found during first upgrade
bogdan202 Aug 16, 2024
ebb158a
vendor/.htaccess
bogdan202 Aug 16, 2024
1e1677a
refs #47377 visibility of button "remove redundant files"
bogdan202 Aug 16, 2024
2faf6e6
texts
bogdan202 Aug 16, 2024
b8bdf04
small text modif
bogdan202 Aug 21, 2024
200e482
refs #47792 product availability in ps 1.7.3.1 and lower
bogdan202 Sep 4, 2024
6906e7a
Merge pull request #362 from 202ecommerce/bugfix/47792-products-unvai…
bogdan202 Sep 12, 2024
b4a8d7d
refs #46227 remove hosted fieldes
bogdan202 Sep 18, 2024
5530207
refs #47995 use precision according to an order currency
bogdan202 Sep 18, 2024
c83de7c
phpcs
bogdan202 Sep 18, 2024
0ff284f
webhook listener. response codes
bogdan202 Sep 18, 2024
0771af6
Merge pull request #363 from 202ecommerce/feature/46227-remove-hosted…
bogdan202 Sep 19, 2024
d82370e
Bump express from 4.19.2 to 4.21.0
dependabot[bot] Sep 21, 2024
9cb3deb
Merge pull request #364 from 202ecommerce/bugfix/47995-incorrect-prec…
bogdan202 Sep 27, 2024
24e44a1
refs #48672 removing guzzle lib
bogdan202 Oct 30, 2024
5a0bca1
refs #48596 sql error during install
bogdan202 Oct 30, 2024
3184d73
Bump symfony/process from 5.4.36 to 5.4.46
dependabot[bot] Nov 6, 2024
09943e2
refs #49000 vault actions
bogdan202 Nov 20, 2024
80bc1d4
Merge pull request #373 from 202ecommerce/bugfix/49000-vault-manage
bogdan202 Nov 27, 2024
a1c7a1e
refs #48993 displaying messaging configuration section
bogdan202 Nov 27, 2024
33e39ed
refs #48859 payment options
bogdan202 Nov 27, 2024
14fe751
refs #48852 MX/BR displaying paypal button
bogdan202 Nov 29, 2024
4a016e9
Merge pull request #375 from 202ecommerce/bugfix/48859-displaying-pay…
bogdan202 Dec 2, 2024
916c125
Merge pull request #369 from 202ecommerce/feature/48672-remove-guzzle
bogdan202 Dec 2, 2024
d972761
Merge pull request #374 from 202ecommerce/bugfix/48993-admin-page-mes…
bogdan202 Dec 2, 2024
cca834e
Merge pull request #370 from 202ecommerce/bugfix/48596-sql-error-install
bogdan202 Dec 2, 2024
9ea6a0a
Merge branch 'develop' into dependabot/composer/symfony/process-5.4.46
bogdan202 Dec 2, 2024
26573dd
Merge pull request #371 from 202ecommerce/dependabot/composer/symfony…
bogdan202 Dec 2, 2024
260a6a0
Merge pull request #366 from 202ecommerce/dependabot/npm_and_yarn/exp…
bogdan202 Dec 2, 2024
c36624d
Merge pull request #359 from 202ecommerce/feature/47377-remove_redund…
bogdan202 Dec 4, 2024
4a6c387
refs #49258 logging errors in webhook listener
bogdan202 Dec 4, 2024
9f19a59
Merge pull request #383 from 202ecommerce/bugfix/49258-webhook-handling
bogdan202 Dec 4, 2024
d441322
refs #49333 authorize mode for mx/br
bogdan202 Dec 10, 2024
6fc6bb0
refs #46227 small modification of appearance
bogdan202 Dec 11, 2024
b6a60fc
Merge pull request #384 from 202ecommerce/feature/46227-hosted-field-…
bogdan202 Dec 12, 2024
532d0bf
Merge pull request #376 from 202ecommerce/bugfix/48852-paypal-button-…
bogdan202 Dec 12, 2024
a47a012
refs #48596 logging an error during registering a hook
bogdan202 Dec 13, 2024
82dbadb
Merge pull request #385 from 202ecommerce/bugfix/48596-register_hooks
bogdan202 Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions 202/_dev/js/acdc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ const ACDC = function(conf) {
this.isMoveButtonAtEnd = conf['isMoveButtonAtEnd'] === undefined ? null : conf['isMoveButtonAtEnd'];

this.buttonForm = conf['buttonForm'] === undefined ? null : conf['buttonForm'];

this.isCardFields = conf['isCardFields'] === undefined ? false : conf['isCardFields'];
};

ACDC.prototype.initButton = function() {
Expand Down Expand Up @@ -71,7 +69,7 @@ ACDC.prototype.getIdOrder = function() {
headers: {
'content-type': 'application/json;charset=utf-8'
},
body: JSON.stringify({page: 'cart', addAddress: 1, sca_verification: (this.isCardFields ? 'SCA_WHEN_REQUIRED' : '')}),
body: JSON.stringify({page: 'cart', addAddress: 1, sca_verification: 'SCA_WHEN_REQUIRED'}),
}).then(function(res) {
return res.json();
}).then(function(data) {
Expand Down Expand Up @@ -111,11 +109,7 @@ ACDC.prototype.getPaypalButtonsContainer = function() {
};

ACDC.prototype.initFields = function() {
if (this.isCardFields) {
this.initCardFields();
} else {
this.initHostedFields();
}
this.initCardFields();
};

ACDC.prototype.initCardFields = function() {
Expand Down
2 changes: 1 addition & 1 deletion 202/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<property name="src-dir" value="${basedir}" />
<property name="TARGETNAME" value="paypal" />
<property name="TARGETBRANCH" value="${env.GIT_BRANCH}" />
<property name="TARGETVERSION" value="6.4.2" />
<property name="TARGETVERSION" value="6.4.3" />
<property name="PHPVERSION" value="5.6" />
<property name="PSVERSION" value="1.7.5.2" />

Expand Down
26 changes: 2 additions & 24 deletions classes/ACDC/AcdcPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

use Configuration;
use Context;
use PayPal;
use PaypalAddons\classes\AbstractMethodPaypal;
use PaypalAddons\classes\Constants\PaypalConfigurations;

Expand Down Expand Up @@ -66,11 +65,7 @@ public function render()

protected function getTemplatePath()
{
if ($this->isCardFields()) {
return 'module:paypal/views/templates/acdc/payment-option-card-fields.tpl';
} else {
return 'module:paypal/views/templates/acdc/payment-option.tpl';
}
return 'module:paypal/views/templates/acdc/payment-option.tpl';
}

protected function getTplVars()
Expand All @@ -79,7 +74,6 @@ protected function getTplVars()
'psPaypalDir' => _PS_MODULE_DIR_ . 'paypal',
'JSvars' => [
PaypalConfigurations::MOVE_BUTTON_AT_END => (int) Configuration::get(PaypalConfigurations::MOVE_BUTTON_AT_END),
'isCardFields' => $this->isCardFields(),
],
'JSscripts' => $this->getScripts(),
];
Expand All @@ -90,23 +84,12 @@ protected function getTplVars()
protected function getScripts()
{
$scripts = [];

if ($this->isCardFields()) {
$srcLib = $this->method->getUrlJsSdkLib(['components' => 'card-fields,marks']);
} else {
$srcLib = $this->method->getUrlJsSdkLib(['components' => 'hosted-fields,marks']);
}

$srcLib = $this->method->getUrlJsSdkLib(['components' => 'card-fields,marks']);
$scripts['tot-paypal-acdc-sdk'] = [
'src' => $srcLib,
'data-namespace' => 'totPaypalAcdcSdk',
'data-partner-attribution-id' => $this->getPartnerId(),
];

if (!$this->isCardFields()) {
$scripts['tot-paypal-acdc-sdk']['data-client-token'] = $this->getClientToken();
}

$scripts['acdc'] = [
'src' => __PS_BASE_URI__ . 'modules/paypal/views/js/acdc.js',
];
Expand All @@ -129,9 +112,4 @@ protected function getClientToken()

return '';
}

protected function isCardFields()
{
return (int) Configuration::get(PayPal::USE_CARD_FIELDS);
}
}
13 changes: 13 additions & 0 deletions classes/API/ExtensionSDK/AccessTokenRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class AccessTokenRequest implements HttpRequestInterface, WrapperInterface
*/
protected $paypalCustomerId;

protected $body = null;

public function __construct($paypalCustomerId = null)
{
$this->headers['Content-Type'] = 'application/x-www-form-urlencoded';
Expand Down Expand Up @@ -78,8 +80,19 @@ public function setHeaders($headers)
return $this;
}

public function setBody($body)
{
$this->body = $body;

return $this;
}

public function getBody()
{
if (false === empty($this->body)) {
return $this->body;
}

$body = [
'grant_type' => 'client_credentials',
];
Expand Down
93 changes: 93 additions & 0 deletions classes/API/ExtensionSDK/GetCredentialsRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
/*
* Since 2007 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author Since 2007 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*
*/

namespace PaypalAddons\classes\API\ExtensionSDK;

if (!defined('_PS_VERSION_')) {
exit;
}

use PaypalAddons\classes\API\HttpAdoptedResponse;
use PaypalAddons\classes\API\HttpResponse;
use PaypalAddons\classes\API\Request\HttpRequestInterface;
use PaypalAddons\classes\API\WrapperInterface;

class GetCredentialsRequest implements HttpRequestInterface, WrapperInterface
{
protected $headers = [];
/** @var string */
protected $partnerId;

public function __construct($partnerId)
{
$this->partnerId = (string) $partnerId;
}

public function getPath()
{
return sprintf('/v1/customer/partners/%s/merchant-integrations/credentials', $this->partnerId);
}

/** @return array*/
public function getHeaders()
{
return $this->headers;
}

/**
* @param array $headers
*
* @return self
*/
public function setHeaders($headers)
{
if (is_array($headers)) {
$this->headers = $headers;
}

return $this;
}

public function getMethod()
{
return 'GET';
}

public function wrap($object)
{
if ($object instanceof HttpResponse) {
return new HttpAdoptedResponse($object);
}

return $object;
}

public function getBody()
{
return null;
}
}
2 changes: 1 addition & 1 deletion classes/API/HttpJsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getHeaders()
return $this->response->getHeaders();
}

public function setHeaders($headers)
public function setHeaders(array $headers)
{
return $this->response->setHeaders($headers);
}
Expand Down
56 changes: 27 additions & 29 deletions classes/API/Onboarding/PaypalGetAuthToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
namespace PaypalAddons\classes\API\Onboarding;

use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;
use PaypalAddons\classes\AbstractMethodPaypal;
use PaypalAddons\classes\API\ExtensionSDK\AccessTokenRequest;
use PaypalAddons\classes\API\HttpAdoptedResponse;
use PaypalAddons\classes\API\PaypalClient;
use PaypalAddons\classes\API\Response\Error;
use PaypalAddons\classes\API\Response\ResponseGetAuthToken;
use Throwable;
Expand All @@ -40,8 +42,8 @@

class PaypalGetAuthToken
{
/** @var */
protected $httpClient;
/** @var PaypalClient */
protected $client;

/** @var string */
protected $authCode;
Expand All @@ -54,11 +56,9 @@ class PaypalGetAuthToken

public function __construct($authCode, $sharedId, $sellerNonce, $sandbox)
{
// Depending on the guzzle version, Client take 'base_uri' or 'base_url' parameter
$this->httpClient = new Client([
'base_uri' => $sandbox ? 'https://api.sandbox.paypal.com' : 'https://api.paypal.com',
'base_url' => $sandbox ? 'https://api.sandbox.paypal.com' : 'https://api.paypal.com',
]);
$method = AbstractMethodPaypal::load();
$method->setSandbox($sandbox);
$this->client = PaypalClient::get($method);
$this->authCode = $authCode;
$this->sharedId = $sharedId;
$this->sellerNonce = $sellerNonce;
Expand All @@ -70,38 +70,36 @@ public function __construct($authCode, $sharedId, $sellerNonce, $sandbox)
public function execute()
{
$returnResponse = new ResponseGetAuthToken();
$body = sprintf('grant_type=authorization_code&code=%s&code_verifier=%s', $this->authCode, $this->sellerNonce);
$request = new AccessTokenRequest();
$request->setBody(
sprintf('grant_type=authorization_code&code=%s&code_verifier=%s', $this->authCode, $this->sellerNonce)
);
$request->setHeaders([
'Content-Type' => 'text/plain',
'Authorization' => 'Basic ' . base64_encode($this->sharedId),
]);

try {
$response = $this->httpClient->post(
'/v1/oauth2/token',
[
RequestOptions::BODY => $body,
RequestOptions::HEADERS => [
'Content-Type' => 'text/plain',
'Authorization' => 'Basic ' . base64_encode($this->sharedId),
],
]
);

$responseDecode = json_decode($response->getBody()->getContents());
/** @var HttpAdoptedResponse $response */
$response = $this->client->execute($request);
$responseDecode = $response->getAdoptedResponse();
$returnResponse->setSuccess(true)
->setData($returnResponse)
->setAuthToken($responseDecode->access_token)
->setRefreshToken($responseDecode->refresh_token)
->setTokenType($responseDecode->token_type)
->setNonce($responseDecode->nonce);
->setData($response)
->setAuthToken($responseDecode->result->access_token)
->setRefreshToken($responseDecode->result->refresh_token)
->setTokenType($responseDecode->result->token_type)
->setNonce($responseDecode->result->nonce);
} catch (Throwable $e) {
$error = new Error();
$error
->setMessage($e->getMessage())
->setErrorCode(empty($e->statusCode) ? $e->getCode() : $e->statusCode);
->setErrorCode($e->getCode());
$returnResponse->setError($error)->setSuccess(false);
} catch (Exception $e) {
$error = new Error();
$error
->setMessage($e->getMessage())
->setErrorCode(empty($e->statusCode) ? $e->getCode() : $e->statusCode);
->setErrorCode($e->getCode());
$returnResponse->setError($error)->setSuccess(false);
}

Expand Down
Loading
Loading