Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 10 additions & 0 deletions api/src/Http/Configuration/CheckoutClientConfigurationBuilder.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function build(): array
'Checkout-Bn-Code' => $this->env->getBnCode(),
'Checkout-Module-Version' => $this->moduleVersion,
'Checkout-Prestashop-Version' => _PS_VERSION_,
'Checkout-Request-Id' => $this->generate_uuid(),
],
];

Expand Down Expand Up @@ -132,4 +133,13 @@ protected function getVerify()

return true;
}

protected function generate_uuid()
{
$b = random_bytes(16);
$b[6] = chr(ord($b[6]) & 0x0f | 0x40);
$b[8] = chr(ord($b[8]) & 0x3f | 0x80);

return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($b), 4));
}
}
10 changes: 10 additions & 0 deletions api/src/Http/Configuration/OrderHttpClientConfigurationBuilder.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function build(): array
'Checkout-Hook-Url' => $this->link->getModuleLink('DispatchWebHook'),
'Checkout-Module-Version' => $this->moduleVersion, // version of the module
'Checkout-Prestashop-Version' => _PS_VERSION_, // prestashop version
'Checkout-Request-Id' => $this->generate_uuid(),
'PayPal-Merchant-Id' => $this->configuration->get(PayPalConfiguration::PS_CHECKOUT_PAYPAL_ID_MERCHANT)
],
];
Expand Down Expand Up @@ -145,4 +146,13 @@ protected function getVerify()

return true;
}

protected function generate_uuid()
{
$b = random_bytes(16);
$b[6] = chr(ord($b[6]) & 0x0f | 0x40);
$b[8] = chr(ord($b[8]) & 0x3f | 0x80);

return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($b), 4));
}
}
10 changes: 10 additions & 0 deletions api/src/Http/Configuration/OrderShipmentTrackingConfigurationBuilder.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function build(): array
'Checkout-Bn-Code' => $this->env->getBnCode(),
'Checkout-Module-Version' => $this->moduleVersion,
'Checkout-Prestashop-Version' => _PS_VERSION_,
'Checkout-Request-Id' => $this->generate_uuid(),
],
];

Expand Down Expand Up @@ -117,4 +118,13 @@ public function build(): array

return $configuration;
}

protected function generate_uuid()
{
$b = random_bytes(16);
$b[6] = chr(ord($b[6]) & 0x0f | 0x40);
$b[8] = chr(ord($b[8]) & 0x3f | 0x80);

return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($b), 4));
}
}
10 changes: 10 additions & 0 deletions api/src/Http/Configuration/PaymentHttpClientConfigurationBuilder.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function build(): array
'Checkout-Hook-Url' => $this->link->getModuleLink('DispatchWebHook'),
'Checkout-Module-Version' => $this->moduleVersion, // version of the module
'Checkout-Prestashop-Version' => _PS_VERSION_, // prestashop version
'Checkout-Request-Id' => $this->generate_uuid(),
'PayPal-Merchant-Id' => $this->configuration->get(PayPalConfiguration::PS_CHECKOUT_PAYPAL_ID_MERCHANT)
],
];
Expand Down Expand Up @@ -145,4 +146,13 @@ protected function getVerify()

return true;
}

protected function generate_uuid()
{
$b = random_bytes(16);
$b[6] = chr(ord($b[6]) & 0x0f | 0x40);
$b[8] = chr(ord($b[8]) & 0x3f | 0x80);

return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($b), 4));
}
}
10 changes: 10 additions & 0 deletions api/src/Http/Configuration/WebhookHttpClientConfigurationBuilder.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function build(): array
'Checkout-Hook-Url' => $this->link->getModuleLink('DispatchWebHook'),
'Checkout-Module-Version' => $this->moduleVersion, // version of the module
'Checkout-Prestashop-Version' => _PS_VERSION_, // prestashop version
'Checkout-Request-Id' => $this->generate_uuid(),
'PayPal-Merchant-Id' => $this->configuration->get(PayPalConfiguration::PS_CHECKOUT_PAYPAL_ID_MERCHANT)
],
];
Expand Down Expand Up @@ -145,4 +146,13 @@ protected function getVerify()

return true;
}

protected function generate_uuid()
{
$b = random_bytes(16);
$b[6] = chr(ord($b[6]) & 0x0f | 0x40);
$b[8] = chr(ord($b[8]) & 0x3f | 0x80);

return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($b), 4));
}
}
Empty file modified core/src/Order/Builder/Node/ApplicationContextNodeBuilder.php
100644 → 100755
Empty file.
Empty file.
19 changes: 18 additions & 1 deletion core/src/Order/Builder/Node/PayPalPaymentSourceNodeBuilder.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class PayPalPaymentSourceNodeBuilder implements PayPalPaymentSourceNodeBuilderIn
*/
private $link;

/**
* @var bool
*/
private $isVirtualCart;

public function __construct(
ConfigurationInterface $configuration,
LinkInterface $link
Expand Down Expand Up @@ -87,7 +92,9 @@ public function build(): array

$data['experience_context'] = [
'brand_name' => $this->configuration->get('PS_SHOP_NAME'),
'shipping_preference' => $this->isExpressCheckout ? 'GET_FROM_FILE' : 'SET_PROVIDED_ADDRESS',
'shipping_preference' => $this->isVirtualCart ?
'NO_SHIPPING'
: ($this->isExpressCheckout ? 'GET_FROM_FILE' : 'SET_PROVIDED_ADDRESS'),
'return_url' => $this->link->getModuleLink('validate'),
'cancel_url' => $this->link->getModuleLink('cancel'),
];
Expand Down Expand Up @@ -135,4 +142,14 @@ public function setExpressCheckout(bool $expressCheckout): self

return $this;
}

/**
* {@inheritDoc}
*/
public function setIsVirtualCart(bool $isVirtualCart): self
{
$this->isVirtualCart = $isVirtualCart;

return $this;
}
}
22 changes: 9 additions & 13 deletions core/src/Order/Builder/OrderPayloadBuilder.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -166,30 +166,25 @@ private function buildOptionalPayload(bool $isFullPayload): array
}

if (!$this->expressCheckout || $this->isUpdate) {
$optionalPayload[] = $this->shippingNodeBuilder->setCart($this->cart)->build();
$this->payload['purchase_units'][0] = array_replace_recursive($this->payload['purchase_units'][0], $this->shippingNodeBuilder->setCart($this->cart)->build());
}

if (!$this->expressCheckout && !$this->isUpdate) {
$optionalPayload[] = $this->payerNodeBuilder->setCart($this->cart)->build();
}

if (!$this->isUpdate) {
$optionalPayload[] = $this->applicationContextNodeBuilder
->setIsExpressCheckout($this->expressCheckout)
->setIsVirtualCart($this->cart['cart']['is_virtual'])
->build();
}

if ($this->isCard) {
if ($this->isCard && !$this->isUpdate) {
$optionalPayload[] = $this->buildCardPaymentSource();
$this->payload['purchase_units'][0] = array_merge($this->payload['purchase_units'][0], $this->buildSupplementaryData());
}

if ($isFullPayload) {
$optionalPayload[] = $this->buildPaymentSource();
if (empty($optionalPayload['payment_source'][$this->fundingSource]['experience_context'])) {
if (!$this->isUpdate) {
$paymentSource = $this->buildPaymentSource();
$optionalPayload[] = $paymentSource;
if (empty($paymentSource['payment_source'][$this->fundingSource]['experience_context'])) {
$optionalPayload[] = $this->applicationContextNodeBuilder
->setIsExpressCheckout($this->expressCheckout)
->setIsVirtualCart($this->cart['cart']['is_virtual'])
->build();
}
}
Expand Down Expand Up @@ -265,7 +260,8 @@ private function buildPaymentSource()

$this->payPalPaymentSourceNodeBuilder->setSavePaymentMethod($this->savePaymentMethod)
->setPaypalCustomerId($this->paypalCustomerId)
->setPaypalVaultId($this->paypalVaultId);
->setPaypalVaultId($this->paypalVaultId)
->setIsVirtualCart($this->cart['cart']['is_virtual']);

return $this->payPalPaymentSourceNodeBuilder->build();
}
Expand Down
Empty file modified core/src/Order/Builder/OrderPayloadBuilderInterface.php
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

namespace Tests\PsCheckout\Core\Order\Builder\Node;

use PHPUnit\Framework\TestCase;
use PsCheckout\Core\Order\Builder\Node\AmountBreakdownNode;
use PsCheckout\Utility\Common\StringUtility;
Expand Down
2 changes: 2 additions & 0 deletions core/tests/Unit/Order/Builder/Node/BaseNodeBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

namespace Tests\PsCheckout\Core\Order\Builder\Node;

use PHPUnit\Framework\TestCase;
use PsCheckout\Core\Order\Builder\Node\BaseNodeBuilder;
use PsCheckout\Core\Settings\Configuration\PayPalConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

namespace Tests\PsCheckout\Core\Order\Builder\Node;

use Address;
use PHPUnit\Framework\TestCase;
use PsCheckout\Core\Order\Builder\Node\CardPaymentSourceNodeBuilder;
use PsCheckout\Core\Settings\Configuration\PayPalConfiguration;
Expand Down
8 changes: 7 additions & 1 deletion infrastructure/src/Logger/LoggerHandlerFactory.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,17 @@ public function __construct(ConfigurationInterface $configuration, ContextInterf
*/
public function build(): HandlerInterface
{
return new RotatingFileHandler(
$handler = new RotatingFileHandler(
$this->getPath() . $this->getFileName(),
$this->getMaxFiles(),
$this->getLoggerLevel()
);
$formatter = $handler->getFormatter();
if (method_exists($formatter, 'setMaxDepth')) {
$formatter->setMaxDepth(15);
}

return $handler;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ps17/.env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ TRACKING_API_URL_SANDBOX="https://api-sandbox.checkout.prestashop.com/tracking-a
ORDER_API_URL_LIVE="https://api-live.checkout.prestashop.com/order-api/v1/"
ORDER_API_URL_SANDBOX="https://api-sandbox.checkout.prestashop.com/order-api/v1/"
WEBHOOK_API_URL_LIVE="https://api-live.checkout.prestashop.com/webhook-api/v1/"
WEBHOOK_API_URL_SANDBOX="https://api-sandbox.checkout.prestashop.com/webhook-api/v1/"
WEBHOOK_API_URL_SANDBOX="https://api-sandbox.checkout.prestashop.com/webhook-api/v1/"
2 changes: 1 addition & 1 deletion ps17/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>ps_checkout</name>
<displayName><![CDATA[PrestaShop Checkout]]></displayName>
<version><![CDATA[7.5.0.4]]></version>
<version><![CDATA[7.5.1.0]]></version>
<description><![CDATA[Provide the most commonly used payment methods to your customers in this all-in-one module, and manage all your sales in a centralized interface.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
2 changes: 1 addition & 1 deletion ps8/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>ps_checkout</name>
<displayName><![CDATA[PrestaShop Checkout]]></displayName>
<version><![CDATA[8.5.0.4]]></version>
<version><![CDATA[8.5.1.0]]></version>
<description><![CDATA[Provide the most commonly used payment methods to your customers in this all-in-one module, and manage all your sales in a centralized interface.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
1 change: 0 additions & 1 deletion ps8/ps_checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public function __construct()
{
$this->name = 'ps_checkout';
$this->tab = 'payments_gateways';
$this->version = '8.5.0.4';
$this->version = '8.5.1.0';
$this->author = 'PrestaShop';

Expand Down
2 changes: 1 addition & 1 deletion ps9/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>ps_checkout</name>
<displayName><![CDATA[PrestaShop Checkout]]></displayName>
<version><![CDATA[9.5.0.4]]></version>
<version><![CDATA[9.5.1.0]]></version>
<description><![CDATA[Provide the most commonly used payment methods to your customers in this all-in-one module, and manage all your sales in a centralized interface.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down