Subida del módulo y tema de PrestaShop

This commit is contained in:
Kaloyan
2026-04-09 18:31:51 +02:00
parent 12c253296f
commit 16b3ff9424
39262 changed files with 7418797 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,101 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http;
use GuzzleHttp\Psr7\Request;
use Http\Client\Exception\HttpException;
use Http\Client\Exception\NetworkException;
use Http\Client\Exception\RequestException;
use Http\Client\Exception\TransferException;
use PsCheckout\Api\Http\Configuration\HttpClientConfigurationBuilderInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
class CheckoutHttpClient extends PsrHttpClientAdapter implements CheckoutHttpClientInterface
{
const SUFFIX_IDENTITY = '/v1/identity';
const SUFFIX_VAULT = '/v1/vault-merchant';
public function __construct(HttpClientConfigurationBuilderInterface $configurationBuilder)
{
parent::__construct($configurationBuilder->build());
}
/**
* @param RequestInterface $request
*
* @return ResponseInterface
*
* @throws HttpException|RequestException|TransferException|NetworkException
*/
public function sendRequest(RequestInterface $request): ResponseInterface
{
try {
return parent::sendRequest($request);
} catch (NetworkException $exception) {
// Thrown when the request cannot be completed because of network issues.
// No response here
throw $exception;
} catch (HttpException $exception) {
// Thrown when a response was received but the request itself failed.
// There a response here
throw $exception;
} catch (RequestException $exception) {
// No response here
throw $exception;
} catch (TransferException $exception) {
// others without response
throw $exception;
}
}
/**
* {@inheritdoc}
*/
public function getUserIdToken(string $merchantId, $payPalCustomerId = null): ResponseInterface
{
$payload = [
'payer_id' => $merchantId,
];
if ($payPalCustomerId) {
$payload['customer_id'] = $payPalCustomerId;
}
return $this->sendRequest(
new Request(
'POST',
self::SUFFIX_IDENTITY . '/oauth2/token',
[],
json_encode($payload)
)
);
}
/**
* {@inheritdoc}
*/
public function deletePaymentToken(string $merchantId, string $vaultId): ResponseInterface
{
return $this->sendRequest(new Request('DELETE', self::SUFFIX_VAULT . "/payment-token/$merchantId/$vaultId"));
}
}

View File

@@ -0,0 +1,42 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http;
use Psr\Http\Message\ResponseInterface;
interface CheckoutHttpClientInterface
{
/**
* @param string $merchantId
* @param string|null $payPalCustomerId
*
* @return ResponseInterface
*/
public function getUserIdToken(string $merchantId, $payPalCustomerId = null): ResponseInterface;
/**
* @param string $merchantId
* @param string $vaultId
*
* @return ResponseInterface
*/
public function deletePaymentToken(string $merchantId, string $vaultId): ResponseInterface;
}

View File

@@ -0,0 +1,135 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http\Configuration;
use GuzzleHttp\Event\Emitter;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Subscriber\Log\Formatter;
use GuzzleHttp\Subscriber\Log\LogSubscriber;
use GuzzleLogMiddleware\LogMiddleware;
use PsCheckout\Core\Settings\Configuration\LoggerConfiguration;
use PsCheckout\Infrastructure\Adapter\ConfigurationInterface;
use PsCheckout\Infrastructure\Adapter\LinkInterface;
use PsCheckout\Infrastructure\Environment\EnvInterface;
use PsCheckout\Infrastructure\Repository\PsAccountRepositoryInterface;
use Psr\Log\LoggerInterface;
class CheckoutClientConfigurationBuilder implements HttpClientConfigurationBuilderInterface
{
const TIMEOUT = 10;
/** @var string */
private $moduleVersion;
/** @var ConfigurationInterface */
private $configuration;
/** @var LinkInterface */
private $link;
/** @var EnvInterface */
private $env;
/** @var PsAccountRepositoryInterface */
private $psAccountRepository;
/** @var LoggerInterface */
private $logger;
public function __construct(
string $moduleVersion,
ConfigurationInterface $configuration,
LinkInterface $link,
EnvInterface $env,
PsAccountRepositoryInterface $psAccountRepository,
LoggerInterface $logger
) {
$this->moduleVersion = $moduleVersion;
$this->configuration = $configuration;
$this->link = $link;
$this->env = $env;
$this->psAccountRepository = $psAccountRepository;
$this->logger = $logger;
}
/**
* @return array
*/
public function build(): array
{
$configuration = [
'base_url' => $this->env->getCheckoutApiUrl(),
'verify' => $this->getVerify(),
'timeout' => self::TIMEOUT,
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . $this->psAccountRepository->getIdToken(), // Token we get from PsAccounts
'Checkout-Shop-Id' => $this->psAccountRepository->getShopUuid(), // Shop UUID we get from PsAccounts
'Checkout-Hook-Url' => $this->link->getModuleLink('DispatchWebHook'),
'Checkout-Bn-Code' => $this->env->getBnCode(),
'Checkout-Module-Version' => $this->moduleVersion,
'Checkout-Prestashop-Version' => _PS_VERSION_,
],
];
if (
$this->configuration->getInteger(LoggerConfiguration::PS_CHECKOUT_LOGGER_HTTP)
&& defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')
&& class_exists(HandlerStack::class)
&& class_exists(LogMiddleware::class)
) {
$handlerStack = HandlerStack::create();
$handlerStack->push(new LogMiddleware($this->logger));
$configuration['handler'] = $handlerStack;
} elseif (
$this->configuration->getInteger(LoggerConfiguration::PS_CHECKOUT_LOGGER_HTTP)
&& defined('\GuzzleHttp\ClientInterface::VERSION')
&& class_exists(Emitter::class)
&& class_exists(LogSubscriber::class)
&& class_exists(Formatter::class)
) {
$emitter = new Emitter();
$emitter->attach(new LogSubscriber(
$this->logger,
Formatter::DEBUG
));
$configuration['emitter'] = $emitter;
}
return $configuration;
}
/**
* @see https://docs.guzzlephp.org/en/5.3/clients.html#verify
*
* @return true|string
*/
protected function getVerify()
{
if (defined('_PS_CACHE_CA_CERT_FILE_') && file_exists(constant('_PS_CACHE_CA_CERT_FILE_'))) {
return constant('_PS_CACHE_CA_CERT_FILE_');
}
return true;
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http\Configuration;
interface HttpClientConfigurationBuilderInterface
{
/**
* @return array
*/
public function build(): array;
}

View File

@@ -0,0 +1,147 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http\Configuration;
use GuzzleHttp\Event\Emitter;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Subscriber\Log\Formatter;
use GuzzleHttp\Subscriber\Log\LogSubscriber;
use GuzzleLogMiddleware\LogMiddleware;
use PsCheckout\Core\Settings\Configuration\LoggerConfiguration;
use PsCheckout\Infrastructure\Adapter\ConfigurationInterface;
use PsCheckout\Infrastructure\Adapter\LinkInterface;
use PsCheckout\Infrastructure\Environment\EnvInterface;
use PsCheckout\Infrastructure\Repository\PsAccountRepository;
use Psr\Log\LoggerInterface;
class OrderHttpClientConfigurationBuilder implements HttpClientConfigurationBuilderInterface
{
const TIMEOUT = 10;
/**
* @var EnvInterface
*/
private $paymentEnv;
/**
* @var PsAccountRepository
*/
private $psAccountRepository;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var ConfigurationInterface
*/
private $configuration;
/**
* @var LinkInterface
*/
private $link;
/**
* @var string
*/
private $moduleVersion;
public function __construct(
EnvInterface $paymentEnv,
PsAccountRepository $psAccountRepository,
LoggerInterface $logger,
ConfigurationInterface $configuration,
LinkInterface $link,
string $moduleVersion
) {
$this->paymentEnv = $paymentEnv;
$this->psAccountRepository = $psAccountRepository;
$this->logger = $logger;
$this->configuration = $configuration;
$this->link = $link;
$this->moduleVersion = $moduleVersion;
}
/**
* @return array
*/
public function build(): array
{
$configuration = [
'base_url' => $this->paymentEnv->getPaymentApiUrl(),
'verify' => $this->getVerify(),
'timeout' => static::TIMEOUT,
'headers' => [
'Content-Type' => 'application/vnd.checkout.v1+json', // api version to use (psl side)
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . $this->psAccountRepository->getIdToken(), // Token we get from PsAccounts
'Shop-Id' => $this->psAccountRepository->getShopUuid(), // Shop UUID we get from PsAccounts
'Hook-Url' => $this->link->getModuleLink('DispatchWebHook'),
'Bn-Code' => $this->paymentEnv->getBnCode(),
'Module-Version' => $this->moduleVersion, // version of the module
'Prestashop-Version' => _PS_VERSION_, // prestashop version
],
];
if (
$this->configuration->getInteger(LoggerConfiguration::PS_CHECKOUT_LOGGER_HTTP)
&& defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')
&& class_exists(HandlerStack::class)
&& class_exists(LogMiddleware::class)
) {
$handlerStack = HandlerStack::create();
$handlerStack->push(new LogMiddleware($this->logger));
$configuration['handler'] = $handlerStack;
} elseif (
$this->configuration->getInteger(LoggerConfiguration::PS_CHECKOUT_LOGGER_HTTP)
&& defined('\GuzzleHttp\ClientInterface::VERSION')
&& class_exists(Emitter::class)
&& class_exists(LogSubscriber::class)
&& class_exists(Formatter::class)
) {
$emitter = new Emitter();
$emitter->attach(new LogSubscriber(
$this->logger,
Formatter::DEBUG
));
$configuration['emitter'] = $emitter;
}
return $configuration;
}
/**
* @see https://docs.guzzlephp.org/en/5.3/clients.html#verify
*
* @return true|string
*/
protected function getVerify()
{
if (defined('_PS_CACHE_CA_CERT_FILE_') && file_exists(constant('_PS_CACHE_CA_CERT_FILE_'))) {
return constant('_PS_CACHE_CA_CERT_FILE_');
}
return true;
}
}

View File

@@ -0,0 +1,120 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http\Configuration;
use GuzzleHttp\Event\Emitter;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Subscriber\Log\Formatter;
use GuzzleHttp\Subscriber\Log\LogSubscriber;
use GuzzleLogMiddleware\LogMiddleware;
use PsCheckout\Core\Settings\Configuration\LoggerConfiguration;
use PsCheckout\Infrastructure\Adapter\ConfigurationInterface;
use PsCheckout\Infrastructure\Adapter\LinkInterface;
use PsCheckout\Infrastructure\Environment\EnvInterface;
use PsCheckout\Infrastructure\Repository\PsAccountRepositoryInterface;
use Psr\Log\LoggerInterface;
class OrderShipmentTrackingConfigurationBuilder implements OrderShipmentTrackingConfigurationBuilderInterface
{
const TIMEOUT = 10;
/** @var string */
private $moduleVersion;
/** @var ConfigurationInterface */
private $configuration;
/** @var LinkInterface */
private $link;
/** @var EnvInterface */
private $env;
/** @var PsAccountRepositoryInterface */
private $psAccountRepository;
/** @var LoggerInterface */
private $logger;
public function __construct(
string $moduleVersion,
ConfigurationInterface $configuration,
LinkInterface $link,
EnvInterface $env,
PsAccountRepositoryInterface $psAccountRepository,
LoggerInterface $logger
) {
$this->moduleVersion = $moduleVersion;
$this->configuration = $configuration;
$this->link = $link;
$this->env = $env;
$this->psAccountRepository = $psAccountRepository;
$this->logger = $logger;
}
/**
* @return array
*/
public function build(): array
{
$configuration = [
'base_uri' => $this->env->getShipmentTrackingApiUrl(),
'timeout' => self::TIMEOUT,
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . $this->psAccountRepository->getIdToken(),
'Checkout-Shop-Id' => $this->psAccountRepository->getShopUuid(),
'Checkout-Hook-Url' => $this->link->getModuleLink('DispatchWebHook'),
'Checkout-Bn-Code' => $this->env->getBnCode(),
'Checkout-Module-Version' => $this->moduleVersion,
'Checkout-Prestashop-Version' => _PS_VERSION_,
],
];
if (
$this->configuration->getInteger(LoggerConfiguration::PS_CHECKOUT_LOGGER_HTTP)
&& defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')
&& class_exists(HandlerStack::class)
&& class_exists(LogMiddleware::class)
) {
$handlerStack = HandlerStack::create();
$handlerStack->push(new LogMiddleware($this->logger));
$configuration['handler'] = $handlerStack;
} elseif (
$this->configuration->getInteger(LoggerConfiguration::PS_CHECKOUT_LOGGER_HTTP)
&& defined('\GuzzleHttp\ClientInterface::VERSION')
&& class_exists(Emitter::class)
&& class_exists(LogSubscriber::class)
&& class_exists(Formatter::class)
) {
$emitter = new Emitter();
$emitter->attach(new LogSubscriber(
$this->logger,
Formatter::DEBUG
));
$configuration['emitter'] = $emitter;
}
return $configuration;
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http\Configuration;
interface OrderShipmentTrackingConfigurationBuilderInterface
{
public function build(): array;
}

View File

@@ -0,0 +1,30 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,374 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http\Exception;
use Http\Client\Exception\HttpException;
class PayPalError
{
/**
* @var string
*/
private $message;
/**
* @param string $message
*/
public function __construct($message)
{
$this->message = $message;
}
/**
* @param HttpException|null $previous
*
* @throws PayPalException
*/
public function throwException(HttpException $previous = null)
{
switch ($this->message) {
case 'ACTION_DOES_NOT_MATCH_INTENT':
throw new PayPalException('Order was created with an intent to CAPTURE, to complete the transaction, call capture payment for order or create an order with an intent of AUTHORIZE.', PayPalException::ACTION_DOES_NOT_MATCH_INTENT, $previous);
case 'AGREEMENT_ALREADY_CANCELLED':
throw new PayPalException('The requested agreement is already cancelled, the specified agreement ID cannot be used for this transaction.', PayPalException::AGREEMENT_ALREADY_CANCELLED, $previous);
case 'AMOUNT_CANNOT_BE_SPECIFIED':
throw new PayPalException('An authorization amount can only be specified if an order was saved. Save the order and try again.', PayPalException::AMOUNT_CANNOT_BE_SPECIFIED, $previous);
case 'AMOUNT_MISMATCH':
throw new PayPalException('The amount specified does not match the breakdown : amount must equal item_total + tax_total + shipping + handling + insurance - shipping_discount - discount.', PayPalException::AMOUNT_MISMATCH, $previous);
case 'AMOUNT_NOT_PATCHABLE':
throw new PayPalException('The amount cannot be updated as the payer has chosen and approved a specific financing offer for a given amount. Create an order with the updated order amount and have the payer approve the new payment terms.', PayPalException::AMOUNT_NOT_PATCHABLE, $previous);
case 'AUTH_CAPTURE_NOT_ENABLED':
throw new PayPalException('The authorization and capture feature is not enabled for the merchant. Make sure that the recipient of the funds is a verified business account.', PayPalException::AUTH_CAPTURE_NOT_ENABLED, $previous);
case 'AUTHENTICATION_FAILURE':
throw new PayPalException('The account validations failed for the user.', PayPalException::AUTHENTICATION_FAILURE, $previous);
case 'AUTHORIZATION_AMOUNT_EXCEEDED':
throw new PayPalException('The currency of the authorization must match the currency of the order that the payer created and approved. Check the currency_code and try the request again.', PayPalException::AUTHORIZATION_AMOUNT_EXCEEDED, $previous);
case 'BILLING_AGREEMENT_NOT_FOUND':
throw new PayPalException('The requested Billing Agreement token was not found. Verify the token and try the request again.', PayPalException::BILLING_AGREEMENT_NOT_FOUND, $previous);
case 'CANNOT_BE_NEGATIVE':
throw new PayPalException('Must be greater than or equal to zero. Try the request again with a different value.', PayPalException::CANNOT_BE_NEGATIVE, $previous);
case 'CANNOT_BE_ZERO_OR_NEGATIVE':
throw new PayPalException('Must be greater than zero. Try the request again with a different value.', PayPalException::CANNOT_BE_ZERO_OR_NEGATIVE, $previous);
case 'CARD_TYPE_NOT_SUPPORTED':
throw new PayPalException('Processing of this card type is not supported. Use another card type.', PayPalException::CARD_TYPE_NOT_SUPPORTED, $previous);
case 'INVALID_SECURITY_CODE_LENGTH':
throw new PayPalException('The security_code length is invalid for the specified card type.', PayPalException::INVALID_SECURITY_CODE_LENGTH, $previous);
case 'CITY_REQUIRED':
throw new PayPalException('The specified country requires a city (address.admin_area_2). Specify a city and try the request again.', PayPalException::CITY_REQUIRED, $previous);
case 'COMPLIANCE_VIOLATION':
throw new PayPalException('Transaction cannot be processed due to a possible compliance violation. To get more information about the transaction, call Customer Support.', PayPalException::COMPLIANCE_VIOLATION, $previous);
case 'CONSENT_NEEDED':
throw new PayPalException('Authorization failed due to insufficient permissions. To continue with this transaction, the payer must provide consent.', PayPalException::CONSENT_NEEDED, $previous);
case 'CURRENCY_NOT_SUPPORTED_FOR_COUNTRY':
throw new PayPalException('Currency code not supported for direct card payments in this country.', PayPalException::CURRENCY_NOT_SUPPORTED_FOR_COUNTRY, $previous);
case 'CURRENCY_NOT_SUPPORTED_FOR_CARD_TYPE':
throw new PayPalException('The currency code is not supported for direct card payments for this card type.', PayPalException::CURRENCY_NOT_SUPPORTED_FOR_CARD_TYPE, $previous);
case 'DECIMAL_PRECISION':
throw new PayPalException('The value of the field should not be more than two decimal places. Verify the number of decimal places and try the request again.', PayPalException::DECIMAL_PRECISION, $previous);
case 'DOMESTIC_TRANSACTION_REQUIRED':
throw new PayPalException('This transaction requires the payee and payer to be resident in the same country. To create this payment, a domestic transaction is required.', PayPalException::DOMESTIC_TRANSACTION_REQUIRED, $previous);
case 'DUPLICATE_INVOICE_ID':
throw new PayPalException('Duplicate Invoice ID detected. To avoid a duplicate transaction, verify that the invoice ID is unique for each transaction.', PayPalException::DUPLICATE_INVOICE_ID, $previous);
case 'DUPLICATE_REQUEST_ID':
throw new PayPalException('The value of PayPal-Request-Id header has already been used. Specify a different value and try the request again.', PayPalException::DUPLICATE_REQUEST_ID, $previous);
case 'FIELD_NOT_PATCHABLE':
throw new PayPalException('Field cannot be patched. You cannot update this field.', PayPalException::FIELD_NOT_PATCHABLE, $previous);
case 'INSTRUMENT_DECLINED':
throw new PayPalException('The funding instrument presented was either declined by the processor or bank. The specified funding instrument cannot be used for this payment.', PayPalException::INSTRUMENT_DECLINED, $previous);
case 'INTERNAL_SERVER_ERROR':
throw new PayPalException('An internal server error has occurred. Retry the request later.', PayPalException::INTERNAL_SERVER_ERROR, $previous);
case 'INTERNAL_SERVICE_ERROR':
throw new PayPalException('An internal service error has occurred.', PayPalException::INTERNAL_SERVICE_ERROR, $previous);
case 'INVALID_ACCOUNT_STATUS':
throw new PayPalException('Account validations failed for the user. To continue with this transaction, the payer must provide consent.', PayPalException::INVALID_ACCOUNT_STATUS, $previous);
case 'INVALID_ARRAY_MAX_ITEMS':
throw new PayPalException('The number of items in an array parameter is too large.', PayPalException::INVALID_ARRAY_MAX_ITEMS, $previous);
case 'INVALID_ARRAY_MIN_ITEMS':
throw new PayPalException('The number of items in an array parameter is too small.', PayPalException::INVALID_ARRAY_MIN_ITEMS, $previous);
case 'INVALID_COUNTRY_CODE':
throw new PayPalException('Country code is invalid.', PayPalException::INVALID_COUNTRY_CODE, $previous);
case 'INVALID_CURRENCY_CODE':
throw new PayPalException('Currency code is invalid or is not currently supported.', PayPalException::INVALID_CURRENCY_CODE, $previous);
case 'INVALID_JSON_POINTER_FORMAT':
throw new PayPalException('Path should be a valid JavaScript Object Notation (JSON) Pointer that references a location within the request where the operation is performed. The path is not valid.', PayPalException::INVALID_JSON_POINTER_FORMAT, $previous);
case 'INVALID_PARAMETER_SYNTAX':
throw new PayPalException('The value of a field does not conform to the expected format. Verify that the pattern is supported and try the request again.', PayPalException::INVALID_PARAMETER_SYNTAX, $previous);
case 'INVALID_PARAMETER_VALUE':
throw new PayPalException('The value of a field is invalid. Verify the parameter value and try the request again.', PayPalException::INVALID_PARAMETER_VALUE, $previous);
case 'INVALID_PARAMETER':
throw new PayPalException('Cannot be specified as part of the request. Check that the API supports this parameter and try the request again.', PayPalException::INVALID_PARAMETER, $previous);
case 'INVALID_PATCH_OPERATION':
throw new PayPalException('Request is not well-formed, syntactically incorrect, or violates schema. The operation cannot be honored. You cannot add a property that is already present. Instead, use replace. You cannot remove a property that is not present. Instead, use add. You cannot replace a property that is not present. Instead, use add.', PayPalException::INVALID_PATCH_OPERATION, $previous);
case 'INVALID_PAYER_ID':
throw new PayPalException('The payer ID is not valid. Verify the payer ID and try the request again.', PayPalException::INVALID_PAYER_ID, $previous);
case 'INVALID_RESOURCE_ID':
throw new PayPalException('Specified resource ID does not exist. Verify the resource ID and try the request again.', PayPalException::INVALID_RESOURCE_ID, $previous);
case 'INVALID_STRING_LENGTH':
throw new PayPalException('The value of a field is either too short or too long. Verify the minimum and maximum values and try the request again.', PayPalException::INVALID_STRING_LENGTH, $previous);
case 'ITEM_TOTAL_MISMATCH':
throw new PayPalException('Verify the corresponding values and try the request again. The item total should equal the sum of (unit_amount * quantity) across all items for a purchase_unit.', PayPalException::ITEM_TOTAL_MISMATCH, $previous);
case 'ITEM_TOTAL_REQUIRED':
throw new PayPalException('If item details are specified (items.unit_amount and items.quantity) corresponding amount.breakdown.item_total is required. The amount.breakdown.item_total value was not found.', PayPalException::ITEM_TOTAL_REQUIRED, $previous);
case 'MAX_AUTHORIZATION_COUNT_EXCEEDED':
throw new PayPalException('The maximum number of authorizations that are allowed for the order was reached. To increase your limit, contact Customer Support.', PayPalException::MAX_AUTHORIZATION_COUNT_EXCEEDED, $previous);
case 'MAX_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED':
throw new PayPalException('You have exceeded the maximum number of payment attempts. To review the maximum number of payment attempts allowed and retry this transaction, call Customer Support.', PayPalException::MAX_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED, $previous);
case 'MAX_VALUE_EXCEEDED':
throw new PayPalException('Should be less than or equal to 9999999.99 ; try the request again with a different value.', PayPalException::MAX_VALUE_EXCEEDED, $previous);
case 'MISSING_REQUIRED_PARAMETER':
throw new PayPalException('A required field or parameter is missing. Verify that you have specified all required parameters and try the request again.', PayPalException::MISSING_REQUIRED_PARAMETER, $previous);
case 'MISSING_SHIPPING_ADDRESS':
throw new PayPalException('The shipping address is required when shipping_preference=SET_PROVIDED_ADDRESS. Verify that you have provided the shipping address and try the request again.', PayPalException::MISSING_SHIPPING_ADDRESS, $previous);
case 'MULTI_CURRENCY_ORDER':
throw new PayPalException('Multiple differing values of currency_code are not supported. The entire order request must have the same currency code.', PayPalException::MULTI_CURRENCY_ORDER, $previous);
case 'MULTIPLE_SHIPPING_ADDRESS_NOT_SUPPORTED':
throw new PayPalException('Multiple shipping addresses are not supported. Try the request again with the same shipping_address.', PayPalException::MULTIPLE_SHIPPING_ADDRESS_NOT_SUPPORTED, $previous);
case 'MULTIPLE_SHIPPING_OPTION_SELECTED':
throw new PayPalException('Only one shipping.option can be set to selected = true.', PayPalException::MULTIPLE_SHIPPING_OPTION_SELECTED, $previous);
case 'INVALID_PICKUP_ADDRESS':
throw new PayPalException('Invalid shipping address. If the \'shipping_option.type\' is set as \'PICKUP\' then the \'shipping_detail.name.full_name\' should start with \'S2S\' meaning Ship To Store. Example: \'S2S My Store\'.', PayPalException::INVALID_PICKUP_ADDRESS, $previous);
case 'NOT_AUTHORIZED':
throw new PayPalException('Authorization failed due to insufficient permissions. To check that your application has sufficient permissions, log in to the PayPal Developer Portal.', PayPalException::NOT_AUTHORIZED, $previous);
case 'NOT_ENABLED_FOR_CARD_PROCESSING':
throw new PayPalException('The request fails. The API Caller account is not setup to be able to process card payments. Please contact PayPal customer support.', PayPalException::NOT_ENABLED_FOR_CARD_PROCESSING, $previous);
case 'NOT_PATCHABLE':
throw new PayPalException('Cannot be patched. You cannot update this field.', PayPalException::NOT_PATCHABLE, $previous);
case 'NOT_SUPPORTED':
throw new PayPalException('This field is not currently supported. Specify only supported parameters and try the request again.', PayPalException::NOT_SUPPORTED, $previous);
case 'ORDER_ALREADY_AUTHORIZED':
throw new PayPalException('Order already authorized. If intent=AUTHORIZE only one authorization per order is allowed. The order was already authorized and you can create only one authorization for an order.', PayPalException::ORDER_ALREADY_AUTHORIZED, $previous);
case 'ORDER_ALREADY_CAPTURED':
throw new PayPalException('Order already captured. If intent=CAPTURE only one capture per order is allowed. The order was already captured and you can capture only one payment for an order.', PayPalException::ORDER_ALREADY_CAPTURED, $previous);
case 'ORDER_ALREADY_COMPLETED':
throw new PayPalException('The order cannot be patched after it is completed.', PayPalException::ORDER_ALREADY_COMPLETED, $previous);
case 'ORDER_CANNOT_BE_SAVED':
throw new PayPalException('The option to save an order is only available if the intent is AUTHORIZE and the processing_instruction is ORDER_SAVED_EXPLICITLY. Change the intent to AUTHORIZE and the processing_instruction to ORDER_SAVED_EXPLICITLY and try the request again.', PayPalException::ORDER_CANNOT_BE_SAVED, $previous);
case 'ORDER_COMPLETED_OR_VOIDED':
throw new PayPalException('Order is voided or completed and hence cannot be authorized.', PayPalException::ORDER_COMPLETED_OR_VOIDED, $previous);
case 'ORDER_EXPIRED':
throw new PayPalException('Order is expired and hence cannot be authorized. Please contact Customer Support if you need to increase your order validity period.', PayPalException::ORDER_EXPIRED, $previous);
case 'ORDER_NOT_APPROVED':
throw new PayPalException('Payer has not yet approved the Order for payment. The payer has not yet approved payment for the order. Redirect the payer to the rel:approve URL that was returned in the HATEOAS links in the create order response or provide a valid payment_source in the request.', PayPalException::ORDER_NOT_APPROVED, $previous);
case 'ORDER_NOT_SAVED':
throw new PayPalException('Please save the order or alternately, If you do not intend to save the order, PATCH the order to update the value of processing_instruction to NO_INSTRUCTION.', PayPalException::ORDER_NOT_SAVED, $previous);
case 'ORDER_PREVIOUSLY_VOIDED':
throw new PayPalException('This order has been previously voided and cannot be voided again. Verify the order id and try again.', PayPalException::ORDER_PREVIOUSLY_VOIDED, $previous);
case 'PARAMETER_VALUE_NOT_SUPPORTED':
throw new PayPalException('The value specified for this field is not currently supported. The specified parameter value is not supported.', PayPalException::PARAMETER_VALUE_NOT_SUPPORTED, $previous);
case 'PATCH_PATH_REQUIRED':
throw new PayPalException('Specify a path for the field for which the operation needs to be performed. To complete the operation for this field, specify a path for the field.', PayPalException::PATCH_PATH_REQUIRED, $previous);
case 'PATCH_VALUE_REQUIRED':
throw new PayPalException('Please specify a value to for the field that is being patched.', PayPalException::PATCH_VALUE_REQUIRED, $previous);
case 'PAYEE_ACCOUNT_INVALID':
throw new PayPalException('Payee account specified is invalid. Please check the payee.email_address or payee.merchant_id specified and try again. Ensure that either payee.merchant_id or payee.email_address is specified. Specify either payee.merchant_id or payee.email_address.', PayPalException::PAYEE_ACCOUNT_INVALID, $previous);
case 'PAYEE_ACCOUNT_LOCKED_OR_CLOSED':
throw new PayPalException('Payee account is locked or closed. To get more information about the status of the account, call Customer Support.', PayPalException::PAYEE_ACCOUNT_LOCKED_OR_CLOSED, $previous);
case 'PAYEE_ACCOUNT_RESTRICTED':
throw new PayPalException('The merchant account is restricted. To get more information about the status of the account, call Customer Support.', PayPalException::PAYEE_ACCOUNT_RESTRICTED, $previous);
case 'PAYEE_BLOCKED_TRANSACTION':
throw new PayPalException('The fraud settings for this seller are such that this payment cannot be executed. Verify the fraud settings. Then, retry the transaction.', PayPalException::PAYEE_BLOCKED_TRANSACTION, $previous);
case 'PAYER_ACCOUNT_LOCKED_OR_CLOSED':
throw new PayPalException('Payer account is locked or closed. To get more information about the status of the account, call Customer Support.', PayPalException::PAYER_ACCOUNT_LOCKED_OR_CLOSED, $previous);
case 'PAYER_ACCOUNT_RESTRICTED':
throw new PayPalException('Payer account is restricted. To get more information about the status of the account, call Customer Support.', PayPalException::PAYER_ACCOUNT_RESTRICTED, $previous);
case 'PAYER_CANNOT_PAY':
throw new PayPalException('Payer cannot pay for this transaction. Please contact the payer to find other ways to pay for this transaction.', PayPalException::PAYER_CANNOT_PAY, $previous);
case 'PAYER_CONSENT_REQUIRED':
throw new PayPalException('The payer has not provided appropriate consent to proceed with this transaction. To proceed with the transaction, you must get payer consent.', PayPalException::PAYER_CONSENT_REQUIRED, $previous);
case 'PAYER_COUNTRY_NOT_SUPPORTED':
throw new PayPalException('Payer Country is not supported. The Payer country is not supported. Redirect the payer to select another funding source.', PayPalException::PAYER_COUNTRY_NOT_SUPPORTED, $previous);
case 'PAYEE_NOT_ENABLED_FOR_CARD_PROCESSING':
throw new PayPalException('The API Caller account is not setup to be able to process card payments. Please contact PayPal customer support.', PayPalException::PAYEE_NOT_ENABLED_FOR_CARD_PROCESSING, $previous);
case 'PAYMENT_INSTRUCTION_REQUIRED':
throw new PayPalException('You must provide the payment instruction when you capture an authorized payment for intent=AUTHORIZE. For details, see Capture authorization. For intent=CAPTURE, send the payment instruction when you create the order.', PayPalException::PAYMENT_INSTRUCTION_REQUIRED, $previous);
case 'PERMISSION_DENIED':
throw new PayPalException('You do not have permission to access or perform operations on this resource. If you make API calls on behalf of a merchant or payee, ensure that you have been granted appropriate permissions to continue with this request.', PayPalException::PERMISSION_DENIED, $previous);
case 'POSTAL_CODE_REQUIRED':
throw new PayPalException('The specified country requires a postal code. Specify a postal code and try the request again.', PayPalException::POSTAL_CODE_REQUIRED, $previous);
case 'PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH':
throw new PayPalException('The amount provided in the preferred shipping option should match the amount provided in amount breakdown.', PayPalException::PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH, $previous);
case 'REDIRECT_PAYER_FOR_ALTERNATE_FUNDING':
throw new PayPalException('Transaction failed. Redirect the payer to select another funding source.', PayPalException::REDIRECT_PAYER_FOR_ALTERNATE_FUNDING, $previous);
case 'REFERENCE_ID_NOT_FOUND':
throw new PayPalException('Filter expression value is incorrect. Check the value of the reference_id and try the request again.', PayPalException::REFERENCE_ID_NOT_FOUND, $previous);
case 'REFERENCE_ID_REQUIRED':
throw new PayPalException('\'reference_id\' is required for each \'purchase_unit\' if multiple \'purchase_unit\' are provided. Provide a unique value for reference_id for each purchase_unit and try the request again.', PayPalException::REFERENCE_ID_REQUIRED, $previous);
case 'DUPLICATE_REFERENCE_ID':
throw new PayPalException('reference_id must be unique if multiple purchase_unit are provided. Provide a unique value for reference_id for each purchase_unit and try the request again.', PayPalException::DUPLICATE_REFERENCE_ID, $previous);
case 'SHIPPING_ADDRESS_INVALID':
throw new PayPalException('Provided shipping address is invalid.', PayPalException::SHIPPING_ADDRESS_INVALID, $previous);
case 'SHIPPING_OPTION_NOT_SELECTED':
throw new PayPalException('At least one of the shipping.option values must be selected = true.', PayPalException::SHIPPING_OPTION_NOT_SELECTED, $previous);
case 'SHIPPING_OPTIONS_NOT_SUPPORTED':
throw new PayPalException('Shipping options are not supported when application_context.shipping_preference is set as NO_SHIPPING or SET_PROVIDED_ADDRESS.', PayPalException::SHIPPING_OPTIONS_NOT_SUPPORTED, $previous);
case 'TAX_TOTAL_MISMATCH':
throw new PayPalException('Should equal sum of (tax * quantity) across all items for a given purchase_unit. The tax total must equal the sum of (tax * quantity) across all items for a purchase_unit.', PayPalException::TAX_TOTAL_MISMATCH, $previous);
case 'TAX_TOTAL_REQUIRED':
throw new PayPalException('If item details are specified (items.tax_total and items.quantity), the corresponding amount.breakdown.tax_total is required. The amount.breakdown.tax_total is a required field.', PayPalException::TAX_TOTAL_REQUIRED, $previous);
case 'TRANSACTION_AMOUNT_EXCEEDS_MONTHLY_MAX_LIMIT':
throw new PayPalException('The transaction amount exceeds monthly maximum limit. To review the monthly transaction limits and retry this transaction, call Customer Support.', PayPalException::TRANSACTION_AMOUNT_EXCEEDS_MONTHLY_MAX_LIMIT, $previous);
case 'TRANSACTION_BLOCKED_BY_PAYEE':
throw new PayPalException('The transaction was blocked by the payees Fraud Protection settings.', PayPalException::TRANSACTION_BLOCKED_BY_PAYEE, $previous);
case 'TRANSACTION_LIMIT_EXCEEDED':
throw new PayPalException('Total payment amount exceeded transaction limit. To review the transaction limit and retry this transaction, call Customer Support.', PayPalException::TRANSACTION_LIMIT_EXCEEDED, $previous);
case 'TRANSACTION_RECEIVING_LIMIT_EXCEEDED':
throw new PayPalException('The transaction exceeds the payee\'s receiving limit. To review the transaction limit and retry this transaction, call Customer Support.', PayPalException::TRANSACTION_RECEIVING_LIMIT_EXCEEDED, $previous);
case 'TRANSACTION_REFUSED':
throw new PayPalException('The transaction was refused. Verify the transaction and try the request again.', PayPalException::TRANSACTION_REFUSED, $previous);
case 'UNSUPPORTED_INTENT':
throw new PayPalException('intent=AUTHORIZE is not supported for multiple purchase units. Only intent=CAPTURE is supported.', PayPalException::UNSUPPORTED_INTENT, $previous);
case 'UNSUPPORTED_PATCH_PARAMETER_VALUE':
throw new PayPalException('The value specified for this field is not currently supported. Try the request again with a different value.', PayPalException::UNSUPPORTED_PATCH_PARAMETER_VALUE, $previous);
case 'UNSUPPORTED_PAYMENT_INSTRUCTION':
throw new PayPalException('Only supported when the intent=CAPTURE. If intent is AUTHORIZE, you must provide a payment_instruction when you capture payment for the authorization.', PayPalException::UNSUPPORTED_PAYMENT_INSTRUCTION, $previous);
case 'PAYEE_ACCOUNT_NOT_SUPPORTED':
throw new PayPalException('Payee does not have an account with PayPal. Your current setup requires the \'payee\' to have a verified account with PayPal before you can process transactions on their behalf.', PayPalException::PAYEE_ACCOUNT_NOT_SUPPORTED, $previous);
case 'PAYEE_ACCOUNT_NOT_VERIFIED':
throw new PayPalException('Payee has not verified their account with PayPal. Your current setup requires the \'payee\' to have an account with PayPal before you can process transactions on their behalf.', PayPalException::PAYEE_ACCOUNT_NOT_VERIFIED, $previous);
case 'PAYEE_NOT_CONSENTED':
throw new PayPalException('Payee does not have appropriate consent to allow the API caller to process this type of transaction on their behalf. Your current setup requires the \'payee\' to provide a consent before this transaction can be processed successfully.', PayPalException::PAYEE_NOT_CONSENTED, $previous);
case 'AUTH_CAPTURE_CURRENCY_MISMATCH':
throw new PayPalException('Currency of capture must be the same as currency of authorization. Verify the currency of the capture and try the request again.', PayPalException::AUTH_CAPTURE_CURRENCY_MISMATCH, $previous);
case 'AUTHORIZATION_ALREADY_CAPTURED':
throw new PayPalException('Authorization has already been captured. If final_capture is set to to true, additional captures are not possible against the authorization.', PayPalException::AUTHORIZATION_ALREADY_CAPTURED, $previous);
case 'AUTHORIZATION_DENIED':
throw new PayPalException('A denied authorization cannot be captured. You cannot capture a denied authorization.', PayPalException::AUTHORIZATION_DENIED, $previous);
case 'AUTHORIZATION_EXPIRED':
throw new PayPalException('An expired authorization cannot be captured. You cannot capture an expired authorization.', PayPalException::AUTHORIZATION_EXPIRED, $previous);
case 'AUTHORIZATION_VOIDED':
throw new PayPalException('A voided authorization cannot be captured or reauthorized. You cannot capture or reauthorize a voided authorization.', PayPalException::AUTHORIZATION_VOIDED, $previous);
case 'CANNOT_BE_VOIDED':
throw new PayPalException('A reauthorization cannot be voided. Please void the original parent authorization. You cannot void a reauthorized payment. You must void the original parent authorized payment.', PayPalException::CANNOT_BE_VOIDED, $previous);
case 'REFUND_NOT_PERMITTED_DUE_TO_CHARGEBACK':
throw new PayPalException('Refunds not allowed on this capture due to a chargeback on the card or bank. Please contact the payee to resolve the chargeback.', PayPalException::REFUND_NOT_PERMITTED_DUE_TO_CHARGEBACK, $previous);
case 'CAPTURE_DISPUTED_PARTIAL_REFUND_NOT_ALLOWED':
throw new PayPalException('Refund for an amount less than the remaining transaction amount cannot be processed at this time because of an open dispute on the capture. Please visit the PayPal Resolution Center to view the details.', PayPalException::CAPTURE_DISPUTED_PARTIAL_REFUND_NOT_ALLOWED, $previous);
case 'CAPTURE_FULLY_REFUNDED':
throw new PayPalException('The capture has already been fully refunded. You cannot capture additional refunds against this capture.', PayPalException::CAPTURE_FULLY_REFUNDED, $previous);
case 'DECIMALS_NOT_SUPPORTED':
throw new PayPalException('Currency does not support decimals.', PayPalException::DECIMALS_NOT_SUPPORTED, $previous);
case 'INVALID_PAYEE_ACCOUNT':
throw new PayPalException('Payee account is invalid. Verify the payee account information and try the request again.', PayPalException::INVALID_PAYEE_ACCOUNT, $previous);
case 'INVALID_PLATFORM_FEES_AMOUNT':
throw new PayPalException('The platform_fees amount cannot be greater than the capture amount. Verify the platform_fees amount and try the request again.', PayPalException::INVALID_PLATFORM_FEES_AMOUNT, $previous);
case 'INVALID_STRING_MAX_LENGTH':
throw new PayPalException('The value of a field is too long. The parameter string is too long.', PayPalException::INVALID_STRING_MAX_LENGTH, $previous);
case 'MAX_CAPTURE_AMOUNT_EXCEEDED':
throw new PayPalException('Capture amount exceeds allowable limit. Please contact customer service or your account manager to request the change to your overage limit. The default overage limit is 115%, which allows the sum of all captures to be up to 115% of the authorization amount. Specify a different amount and try the request again. Alternately, contact Customer Support to increase your limits.', PayPalException::MAX_CAPTURE_AMOUNT_EXCEEDED, $previous);
case 'MAX_CAPTURE_COUNT_EXCEEDED':
throw new PayPalException('Maximum number of allowable captures has been reached. No additional captures are possible for this authorization. Please contact customer service or your account manager to change the number of captures that be made for a given authorization. You cannot make additional captures.', PayPalException::MAX_CAPTURE_COUNT_EXCEEDED, $previous);
case 'MAX_NUMBER_OF_REFUNDS_EXCEEDED':
throw new PayPalException('You have exceeded the number of refunds that can be processed per capture. Please contact customer support or your account manager to review the number of refunds that can be processed per capture.', PayPalException::MAX_NUMBER_OF_REFUNDS_EXCEEDED, $previous);
case 'PARTIAL_REFUND_NOT_ALLOWED':
throw new PayPalException('You cannot do a refund for an amount less than the original capture amount. Specify an amount equal to the capture amount or omit the amount object from the request. Then, try the request again.', PayPalException::PARTIAL_REFUND_NOT_ALLOWED, $previous);
case 'PENDING_CAPTURE':
throw new PayPalException('Cannot initiate a refund as the capture is pending. Capture is typically pending when the payer has funded the transaction by using an e-check or bank account.', PayPalException::PENDING_CAPTURE, $previous);
case 'PERMISSION_NOT_GRANTED':
throw new PayPalException('Payee of the authorization has not granted permission to perform capture on the authorization. To make API calls on behalf of a merchant, ensure that you have sufficient permissions to capture the authorization.', PayPalException::PERMISSION_NOT_GRANTED, $previous);
case 'PREVIOUSLY_CAPTURED':
throw new PayPalException('Authorization has been previously captured and hence cannot be voided. This authorized payment was already captured. You cannot capture it again.', PayPalException::PREVIOUSLY_CAPTURED, $previous);
case 'PREVIOUSLY_VOIDED':
throw new PayPalException('Authorization has been previously voided and hence cannot be voided again. This authorized payment was already voided. You cannot void it again.', PayPalException::PREVIOUSLY_VOIDED, $previous);
case 'REFUND_AMOUNT_EXCEEDED':
throw new PayPalException('The refund amount must be less than or equal to the capture amount that has not yet been refunded. Verify the refund amount and try the request again.', PayPalException::REFUND_AMOUNT_EXCEEDED, $previous);
case 'REFUND_CAPTURE_CURRENCY_MISMATCH':
throw new PayPalException('Refund must be in the same currency as the capture. Verify the currency of the refund and try the request again.', PayPalException::REFUND_CAPTURE_CURRENCY_MISMATCH, $previous);
case 'REFUND_FAILED_INSUFFICIENT_FUNDS':
throw new PayPalException('Capture could not be refunded due to insufficient funds. Verify that either you have sufficient funds in your PayPal account or the bank account that is linked to your PayPal account is verified and has sufficient funds.', PayPalException::REFUND_FAILED_INSUFFICIENT_FUNDS, $previous);
case 'REFUND_NOT_ALLOWED':
throw new PayPalException('Full refund refused - partial refund has already been done on this payment. You cannot refund this capture.', PayPalException::REFUND_NOT_ALLOWED, $previous);
case 'REFUND_TIME_LIMIT_EXCEEDED':
throw new PayPalException('You are over the time limit to perform a refund on this capture. The refund cannot be issued at this time.', PayPalException::REFUND_TIME_LIMIT_EXCEEDED, $previous);
case 'NO_EXTERNAL_FUNDING_DETAILS_FOUND':
throw new PayPalException('External funding details not found.', PayPalException::NO_EXTERNAL_FUNDING_DETAILS_FOUND, $previous);
case 'PAYMENT_DENIED':
throw new PayPalException('Payment denied.', PayPalException::PAYMENT_DENIED, $previous);
case 'CARD_BRAND_NOT_SUPPORTED':
throw new PayPalException('Processing of this card brand is not supported. Use another type of card.', PayPalException::CARD_BRAND_NOT_SUPPORTED, $previous);
case 'RESOURCE_NOT_FOUND':
throw new PayPalException('The specified resource does not exist.', PayPalException::RESOURCE_NOT_FOUND, $previous);
case 'PAYMENT_SOURCE_CANNOT_BE_USED':
throw new PayPalException('The provided payment source cannot be used to pay for the order. Please try again with a different payment source by creating a new order.', PayPalException::PAYMENT_SOURCE_CANNOT_BE_USED, $previous);
case 'PAYPAL_REQUEST_ID_REQUIRED':
throw new PayPalException('A PayPal-Request-Id is required if you are trying to process payment for an Order. Please specify a PayPal-Request-Id or Create the Order without a payment_source specified.', PayPalException::PAYPAL_REQUEST_ID_REQUIRED, $previous);
case 'MALFORMED_REQUEST_JSON':
throw new PayPalException('The request JSON is not well formed.', PayPalException::MALFORMED_REQUEST_JSON, $previous);
case 'PERMISSION_DENIED_FOR_DONATION_ITEMS':
throw new PayPalException('The API caller or payee have not been granted appropriate permissions to send items.category as DONATION. Speak to your account manager if you want to process these type of items.', PayPalException::PERMISSION_DENIED_FOR_DONATION_ITEMS, $previous);
case 'MALFORMED_REQUEST':
throw new PayPalException('You\'ve sent a request that our server could not understand.', PayPalException::MALFORMED_REQUEST, $previous);
case 'BILLING_ADDRESS_INVALID':
throw new PayPalException('Provided billing address is invalid.', PayPalException::BILLING_ADDRESS_INVALID, $previous);
case 'CARD_EXPIRED':
throw new PayPalException('The payment card provided is expired.', PayPalException::CARD_EXPIRED, $previous);
case 'DONATION_ITEMS_NOT_SUPPORTED':
throw new PayPalException('If "purchase_unit" has "DONATION" as the "items.category" then the Order can at most have one purchase_unit. Multiple purchase_units are not supported if either of them have at least one items with category as "DONATION".', PayPalException::DONATION_ITEMS_NOT_SUPPORTED, $previous);
case 'MISSING_PICKUP_ADDRESS':
throw new PayPalException('A pickup address (shipping.address) is required for the provided shipping.type. Possible error location: /purchase_units/0/shipping/type', PayPalException::MISSING_PICKUP_ADDRESS, $previous);
case 'MULTIPLE_ITEM_CATEGORIES':
throw new PayPalException('For a given purchase unit, the items.category could be either PHYSICAL_GOODS and\/or DIGITAL_GOODS or just DONATION. items.category as DONATION cannot be combined with items with either PHYSICAL_GOODS or DIGITAL_GOODS.', PayPalException::MULTIPLE_ITEM_CATEGORIES, $previous);
case 'MULTIPLE_SHIPPING_TYPE_NOT_SUPPORTED':
throw new PayPalException('Different shipping.type are not supported across purchase units.', PayPalException::MULTIPLE_SHIPPING_TYPE_NOT_SUPPORTED, $previous);
case 'PAYMENT_SOURCE_DECLINED_BY_PROCESSOR':
throw new PayPalException('The provided payment source is declined by the processor. Please try again with a different payment source by creating a new order.', PayPalException::PAYMENT_SOURCE_DECLINED_BY_PROCESSOR, $previous);
case 'PAYMENT_SOURCE_INFO_CANNOT_BE_VERIFIED':
throw new PayPalException('The provided payment source is declined by the processor. Please try again with a different payment source by creating a new order.', PayPalException::PAYMENT_SOURCE_INFO_CANNOT_BE_VERIFIED, $previous);
case 'SHIPPING_TYPE_NOT_SUPPORTED_FOR_CLIENT':
throw new PayPalException('The API Caller account is not setup to be able to support a shipping.type=PICKUP_IN_PERSON. This feature is only supported for PayPal Commerce Platform for Platforms and Marketplaces.', PayPalException::SHIPPING_TYPE_NOT_SUPPORTED_FOR_CLIENT, $previous);
case 'UNSUPPORTED_SHIPPING_TYPE':
throw new PayPalException('The provided shipping.type is only supported for application_context.shipping_preference=SET_PROVIDED_ADDRESS or NO_SHIPPING. Possible error location: /purchase_units/0/shipping/type.', PayPalException::UNSUPPORTED_SHIPPING_TYPE, $previous);
case 'CARD_CLOSED':
throw new PayPalException('The card is closed with the issuer.', PayPalException::CARD_CLOSED, $previous);
case 'SAVE_ORDER_NOT_SUPPORTED':
throw new PayPalException('The API caller account is setup in a way that does not allow it to be used for saving the order. This functionality is not available for PayPal Commerce Platform for Platforms & Marketplaces.', PayPalException::SAVE_ORDER_NOT_SUPPORTED, $previous);
case 'PUI_DUPLICATE_ORDER':
throw new PayPalException('A Pay Upon Invoice (Rechnungskauf) order with the same payload has already been successfully processed in the last few seconds. To process a new order, please try again in a few seconds.', PayPalException::PUI_DUPLICATE_ORDER, $previous);
case 'CANNOT_PROCESS_REFUNDS':
throw new PayPalException('We can\'t process any refund at this moment due to technical reasons. Please try again later.', PayPalException::CANNOT_PROCESS_REFUNDS, $previous);
case 'INVALID_REFUND_AMOUNT':
throw new PayPalException('The refund amount is invalid. Please check the refund amount and try again.', PayPalException::INVALID_REFUND_AMOUNT, $previous);
case 'NOT_ENABLED_TO_VAULT_PAYMENT_SOURCE':
throw new PayPalException('The API caller or the merchant on whose behalf the API call is initiated is not allowed to vault the given source. Please contact PayPal customer support for assistance.', PayPalException::NOT_ENABLED_TO_VAULT_PAYMENT_SOURCE, $previous);
case 'SETUP_TOKEN_ALREADY_TOKENIZED':
throw new PayPalException('The setup token has been used previously to generate a payment token.', PayPalException::SETUP_TOKEN_ALREADY_TOKENIZED, $previous);
case 'TOKEN_NOT_FOUND':
throw new PayPalException('The specified token id does not exist.', PayPalException::TOKEN_NOT_FOUND, $previous);
case 'PAYPAL_REQUEST_ID_PREVIOUSLY_USED':
throw new PayPalException('The PayPal-Request-ID has already been used for another request.', PayPalException::PAYPAL_REQUEST_ID_PREVIOUSLY_USED, $previous);
case 'OPERATION_NOT_SUPPORTED':
throw new PayPalException('Specified operation not supported on any fields.', PayPalException::OPERATION_NOT_SUPPORTED, $previous);
case 'INVALID_SECURITY_CODE':
throw new PayPalException('The security code provided does not conform to the card number provided.', PayPalException::INVALID_SECURITY_CODE, $previous);
case 'INVALID_INTEGER_MIN_VALUE':
throw new PayPalException('The integer value of a field is too small.', PayPalException::INVALID_INTEGER_MIN_VALUE, $previous);
case 'INVALID_EXPIRY_DATE':
throw new PayPalException('Expiry date is invalid. Expiry date should be a date in future and within the threshold for the payment source.', PayPalException::INVALID_EXPIRY_DATE, $previous);
case 'EXACTLY_ONE_FIELD_REQUIRED':
throw new PayPalException('Exactly one payment source is required.', PayPalException::EXACTLY_ONE_FIELD_REQUIRED, $previous);
case 'CREDIT_CARD_NUMBER_IS_INVALID':
throw new PayPalException('Credit card number is invalid.', PayPalException::CREDIT_CARD_NUMBER_IS_INVALID, $previous);
case 'CARD_EXPIRATION_YEAR_IS_INVALID':
throw new PayPalException('Expiration year outside of acceptable range.', PayPalException::CARD_EXPIRATION_YEAR_IS_INVALID, $previous);
default:
throw new PayPalException($this->message, PayPalException::UNKNOWN, $previous);
}
}
}

View File

@@ -0,0 +1,350 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http\Exception;
use PsCheckout\Core\Exception\PsCheckoutException;
class PayPalException extends PsCheckoutException
{
const ACTION_DOES_NOT_MATCH_INTENT = 1;
const AGREEMENT_ALREADY_CANCELLED = 2;
const AMOUNT_CANNOT_BE_SPECIFIED = 3;
const AMOUNT_MISMATCH = 4;
const AMOUNT_NOT_PATCHABLE = 5;
const AUTH_CAPTURE_NOT_ENABLED = 6;
const AUTHENTICATION_FAILURE = 7;
const AUTHORIZATION_AMOUNT_EXCEEDED = 8;
const PAYEE_NOT_CONSENTED = 9;
const PAYEE_ACCOUNT_NOT_VERIFIED = 10;
const PAYEE_ACCOUNT_NOT_SUPPORTED = 11;
const UNSUPPORTED_PAYMENT_INSTRUCTION = 12;
const UNSUPPORTED_PATCH_PARAMETER_VALUE = 13;
const UNSUPPORTED_INTENT = 14;
const TRANSACTION_REFUSED = 15;
const TRANSACTION_RECEIVING_LIMIT_EXCEEDED = 16;
const TRANSACTION_LIMIT_EXCEEDED = 17;
const TRANSACTION_BLOCKED_BY_PAYEE = 18;
const TRANSACTION_AMOUNT_EXCEEDS_MONTHLY_MAX_LIMIT = 19;
const TAX_TOTAL_REQUIRED = 20;
const TAX_TOTAL_MISMATCH = 21;
const SHIPPING_OPTIONS_NOT_SUPPORTED = 22;
const SHIPPING_OPTION_NOT_SELECTED = 23;
const SHIPPING_ADDRESS_INVALID = 24;
const DUPLICATE_REFERENCE_ID = 25;
const REFERENCE_ID_REQUIRED = 26;
const REFERENCE_ID_NOT_FOUND = 27;
const REDIRECT_PAYER_FOR_ALTERNATE_FUNDING = 28;
const PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH = 29;
const POSTAL_CODE_REQUIRED = 30;
const PERMISSION_DENIED = 31;
const PAYMENT_INSTRUCTION_REQUIRED = 32;
const PAYEE_NOT_ENABLED_FOR_CARD_PROCESSING = 33;
const PAYER_COUNTRY_NOT_SUPPORTED = 34;
const PAYER_CONSENT_REQUIRED = 35;
const PAYER_CANNOT_PAY = 36;
const PAYER_ACCOUNT_RESTRICTED = 37;
const PAYER_ACCOUNT_LOCKED_OR_CLOSED = 38;
const PAYEE_BLOCKED_TRANSACTION = 39;
const PAYEE_ACCOUNT_RESTRICTED = 40;
const PAYEE_ACCOUNT_LOCKED_OR_CLOSED = 41;
const PAYEE_ACCOUNT_INVALID = 42;
const PATCH_VALUE_REQUIRED = 43;
const PATCH_PATH_REQUIRED = 44;
const PARAMETER_VALUE_NOT_SUPPORTED = 45;
const ORDER_PREVIOUSLY_VOIDED = 46;
const ORDER_NOT_SAVED = 47;
const ORDER_NOT_APPROVED = 48;
const ORDER_EXPIRED = 49;
const ORDER_COMPLETED_OR_VOIDED = 50;
const ORDER_CANNOT_BE_SAVED = 51;
const ORDER_ALREADY_COMPLETED = 52;
const ORDER_ALREADY_CAPTURED = 53;
const ORDER_ALREADY_AUTHORIZED = 54;
const NOT_SUPPORTED = 55;
const NOT_PATCHABLE = 56;
const NOT_ENABLED_FOR_CARD_PROCESSING = 57;
const NOT_AUTHORIZED = 58;
const INVALID_PICKUP_ADDRESS = 59;
const MULTIPLE_SHIPPING_OPTION_SELECTED = 60;
const MULTIPLE_SHIPPING_ADDRESS_NOT_SUPPORTED = 61;
const MULTI_CURRENCY_ORDER = 62;
const MISSING_SHIPPING_ADDRESS = 63;
const MISSING_REQUIRED_PARAMETER = 64;
const MAX_VALUE_EXCEEDED = 65;
const MAX_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED = 66;
const MAX_AUTHORIZATION_COUNT_EXCEEDED = 67;
const ITEM_TOTAL_REQUIRED = 68;
const ITEM_TOTAL_MISMATCH = 69;
const INVALID_STRING_LENGTH = 70;
const INVALID_RESOURCE_ID = 71;
const INVALID_PAYER_ID = 72;
const INVALID_PATCH_OPERATION = 73;
const INVALID_PARAMETER = 74;
const INVALID_PARAMETER_VALUE = 75;
const INVALID_PARAMETER_SYNTAX = 76;
const INVALID_JSON_POINTER_FORMAT = 77;
const INVALID_CURRENCY_CODE = 78;
const INVALID_COUNTRY_CODE = 79;
const INVALID_ARRAY_MIN_ITEMS = 80;
const INVALID_ARRAY_MAX_ITEMS = 81;
const INVALID_ACCOUNT_STATUS = 82;
const INTERNAL_SERVICE_ERROR = 83;
const INTERNAL_SERVER_ERROR = 84;
const INSTRUMENT_DECLINED = 85;
const FIELD_NOT_PATCHABLE = 86;
const DUPLICATE_REQUEST_ID = 87;
const DUPLICATE_INVOICE_ID = 88;
const DOMESTIC_TRANSACTION_REQUIRED = 89;
const DECIMAL_PRECISION = 90;
const CURRENCY_NOT_SUPPORTED_FOR_COUNTRY = 91;
const CONSENT_NEEDED = 92;
const COMPLIANCE_VIOLATION = 93;
const CITY_REQUIRED = 94;
const INVALID_SECURITY_CODE_LENGTH = 95;
const CARD_TYPE_NOT_SUPPORTED = 96;
const CANNOT_BE_ZERO_OR_NEGATIVE = 97;
const CANNOT_BE_NEGATIVE = 98;
const BILLING_AGREEMENT_NOT_FOUND = 99;
const REFUND_TIME_LIMIT_EXCEEDED = 100;
const REFUND_NOT_ALLOWED = 101;
const REFUND_FAILED_INSUFFICIENT_FUNDS = 102;
const REFUND_CAPTURE_CURRENCY_MISMATCH = 103;
const REFUND_AMOUNT_EXCEEDED = 104;
const PREVIOUSLY_VOIDED = 105;
const PREVIOUSLY_CAPTURED = 106;
const PERMISSION_NOT_GRANTED = 107;
const PENDING_CAPTURE = 108;
const PARTIAL_REFUND_NOT_ALLOWED = 109;
const MAX_NUMBER_OF_REFUNDS_EXCEEDED = 110;
const MAX_CAPTURE_COUNT_EXCEEDED = 111;
const MAX_CAPTURE_AMOUNT_EXCEEDED = 112;
const INVALID_STRING_MAX_LENGTH = 113;
const INVALID_PLATFORM_FEES_AMOUNT = 114;
const INVALID_PAYEE_ACCOUNT = 115;
const DECIMALS_NOT_SUPPORTED = 116;
const CAPTURE_FULLY_REFUNDED = 117;
const CAPTURE_DISPUTED_PARTIAL_REFUND_NOT_ALLOWED = 118;
const REFUND_NOT_PERMITTED_DUE_TO_CHARGEBACK = 119;
const CANNOT_BE_VOIDED = 120;
const AUTHORIZATION_VOIDED = 121;
const AUTHORIZATION_EXPIRED = 122;
const AUTHORIZATION_DENIED = 123;
const AUTHORIZATION_ALREADY_CAPTURED = 124;
const AUTH_CAPTURE_CURRENCY_MISMATCH = 125;
const CURRENCY_NOT_SUPPORTED_FOR_CARD_TYPE = 126;
const NO_EXTERNAL_FUNDING_DETAILS_FOUND = 127;
const PAYMENT_DENIED = 128;
const CARD_BRAND_NOT_SUPPORTED = 129;
const RESOURCE_NOT_FOUND = 130;
const PAYMENT_SOURCE_CANNOT_BE_USED = 131;
const CANNOT_PROCESS_REFUNDS = 132;
const INVALID_REFUND_AMOUNT = 133;
const PUI_DUPLICATE_ORDER = 134;
const SAVE_ORDER_NOT_SUPPORTED = 135;
const CARD_CLOSED = 136;
const UNSUPPORTED_SHIPPING_TYPE = 137;
const SHIPPING_TYPE_NOT_SUPPORTED_FOR_CLIENT = 138;
const PAYMENT_SOURCE_INFO_CANNOT_BE_VERIFIED = 139;
const PAYMENT_SOURCE_DECLINED_BY_PROCESSOR = 140;
const MULTIPLE_SHIPPING_TYPE_NOT_SUPPORTED = 141;
const MULTIPLE_ITEM_CATEGORIES = 142;
const MISSING_PICKUP_ADDRESS = 143;
const DONATION_ITEMS_NOT_SUPPORTED = 144;
const CARD_EXPIRED = 145;
const BILLING_ADDRESS_INVALID = 146;
const MALFORMED_REQUEST = 147;
const PERMISSION_DENIED_FOR_DONATION_ITEMS = 148;
const MALFORMED_REQUEST_JSON = 149;
const PAYPAL_REQUEST_ID_REQUIRED = 150;
const NOT_ENABLED_TO_VAULT_PAYMENT_SOURCE = 151;
const SETUP_TOKEN_ALREADY_TOKENIZED = 152;
const TOKEN_NOT_FOUND = 153;
const PAYPAL_REQUEST_ID_PREVIOUSLY_USED = 154;
const OPERATION_NOT_SUPPORTED = 155;
const INVALID_SECURITY_CODE = 156;
const INVALID_INTEGER_MIN_VALUE = 157;
const INVALID_EXPIRY_DATE = 158;
const EXACTLY_ONE_FIELD_REQUIRED = 159;
const CREDIT_CARD_NUMBER_IS_INVALID = 160;
const CARD_EXPIRATION_YEAR_IS_INVALID = 161;
const ORDER_REQUIRES_ASYNC_CAPTURE = 162;
}

View File

@@ -0,0 +1,30 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,50 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http;
use Http\Client\Exception\HttpException;
use Http\Client\Exception\NetworkException;
use Http\Client\Exception\RequestException;
use Http\Client\Exception\TransferException;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
/**
* Interface HttpClientInterface
*
* This interface provides a PSR-18 compliant implementation for PHP 5.6
*/
interface HttpClientInterface
{
/**
* Sends a PSR-7 request and returns a PSR-7 response.
*
* @param RequestInterface $request
*
* @return ResponseInterface
*
* @throws NetworkException
* @throws HttpException
* @throws RequestException
* @throws TransferException
*/
public function sendRequest(RequestInterface $request): ResponseInterface;
}

View File

@@ -0,0 +1,132 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http;
use GuzzleHttp\Psr7\Request;
use Http\Client\Exception\HttpException;
use PsCheckout\Api\Http\Configuration\HttpClientConfigurationBuilderInterface;
use PsCheckout\Api\Http\Exception\PayPalError;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
class OrderHttpClient extends PsrHttpClientAdapter implements OrderHttpClientInterface
{
public function __construct(HttpClientConfigurationBuilderInterface $configurationBuilder)
{
parent::__construct($configurationBuilder->build());
}
/**
* {@inheritdoc}
*/
public function sendRequest(RequestInterface $request): ResponseInterface
{
try {
return parent::sendRequest($request);
} catch (HttpException $exception) {
$response = $exception->getResponse();
$body = json_decode($response->getBody(), true);
$message = $this->extractMessage($body);
if ($message) {
(new PayPalError($message))->throwException($exception);
}
throw $exception;
}
}
/**
* {@inheritdoc}
*/
public function createOrder(array $payload, array $headers = []): ResponseInterface
{
return $this->sendRequest(new Request('POST', '/payments/order/create', $headers, json_encode($payload)));
}
/**
* {@inheritdoc}
*/
public function fetchOrder(array $payload): ResponseInterface
{
return $this->sendRequest(new Request('POST', '/payments/order/fetch', [], json_encode($payload)));
}
/**
* {@inheritdoc}
*/
public function captureOrder(array $payload): ResponseInterface
{
return $this->sendRequest(new Request('POST', '/payments/order/capture', [], json_encode($payload)));
}
/**
* @inheritDoc
*/
public function updateOrder(array $payload): ResponseInterface
{
return $this->sendRequest(new Request('POST', '/payments/order/update', [], json_encode($payload)));
}
/**
* {@inheritdoc}
*/
public function refundOrder(array $payload): ResponseInterface
{
return $this->sendRequest(new Request('POST', '/payments/order/refund', [], json_encode($payload)));
}
/**
* {@inheritdoc}
*/
public function getShopSignature(array $payload): array
{
$response = $this->sendRequest(new Request('POST', '/payments/shop/verify_webhook_signature', [], json_encode($payload)));
return json_decode($response->getBody(), true);
}
/**
* @param array $body
*
* @return string
*/
private function extractMessage(array $body): string
{
if (isset($body['details'][0]['issue']) && preg_match('/^[0-9A-Z_]+$/', $body['details'][0]['issue']) === 1) {
return $body['details'][0]['issue'];
}
if (isset($body['error']) && preg_match('/^[0-9A-Z_]+$/', $body['error']) === 1) {
return $body['error'];
}
if (isset($body['message']) && preg_match('/^[0-9A-Z_]+$/', $body['message']) === 1) {
return $body['message'];
}
if (isset($body['name']) && preg_match('/^[0-9A-Z_]+$/', $body['name']) === 1) {
return $body['name'];
}
return '';
}
}

View File

@@ -0,0 +1,86 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http;
use Psr\Http\Message\ResponseInterface;
use Http\Client\Exception\NetworkException;
use Http\Client\Exception\HttpException;
use Http\Client\Exception\RequestException;
use Http\Client\Exception\TransferException;
use PsCheckout\Api\Http\Exception\PayPalException;
interface OrderHttpClientInterface
{
/**
* @param array $payload
* @param array $headers
*
* @return ResponseInterface
*
* @throws NetworkException|HttpException|RequestException|TransferException|PayPalException
*/
public function createOrder(array $payload, array $headers = []): ResponseInterface;
/**
* @param array $payload
*
* @return ResponseInterface
*
* @throws NetworkException|HttpException|RequestException|TransferException|PayPalException
*/
public function fetchOrder(array $payload): ResponseInterface;
/**
* @param array $payload
*
* @return ResponseInterface
*
* @throws NetworkException|HttpException|RequestException|TransferException|PayPalException
*/
public function captureOrder(array $payload): ResponseInterface;
/**
* @param array $payload
*
* @return ResponseInterface
*
* @throws NetworkException|HttpException|RequestException|TransferException|PayPalException
*/
public function updateOrder(array $payload): ResponseInterface;
/**
* @param array $payload
*
* @return ResponseInterface
*
* @throws NetworkException|HttpException|RequestException|TransferException|PayPalException
*/
public function refundOrder(array $payload): ResponseInterface;
/**
* Tells if the webhook came from the PSL
*
* @param array $payload
*
* @return array
*/
public function getShopSignature(array $payload): array;
}

View File

@@ -0,0 +1,102 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http;
use GuzzleHttp\Psr7\Request;
use Http\Client\Exception\HttpException;
use PsCheckout\Api\Http\Configuration\OrderShipmentTrackingConfigurationBuilderInterface;
use PsCheckout\Api\Http\Exception\PayPalError;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
class OrderShipmentTrackingHttpClient extends PsrHttpClientAdapter implements OrderShipmentTrackingHttpClientInterface
{
public function __construct(OrderShipmentTrackingConfigurationBuilderInterface $configurationBuilder)
{
parent::__construct($configurationBuilder->build());
}
/**
* {@inheritdoc}
*/
public function sendRequest(RequestInterface $request): ResponseInterface
{
try {
return parent::sendRequest($request);
} catch (HttpException $exception) {
$response = $exception->getResponse();
$body = json_decode($response->getBody(), true);
$message = $this->extractMessage($body ?? []);
if ($message) {
(new PayPalError($message))->throwException($exception);
}
throw $exception;
}
}
/**
* {@inheritdoc}
*/
public function addTracking(array $payload): ResponseInterface
{
return $this->sendRequest(new Request('POST', "trackers", [], json_encode($payload)));
}
/**
* {@inheritdoc}
*/
public function updateTracking(string $trackerId, array $payload): ResponseInterface
{
return $this->sendRequest(new Request('PATCH', "trackers/{$trackerId}", [], json_encode($payload)));
}
/**
* @param array $body
*
* @return string
*/
private function extractMessage(array $body): string
{
if (isset($body['details'][0]['issue']) && preg_match('/^[0-9A-Z_]+$/', $body['details'][0]['issue']) === 1) {
return $body['details'][0]['issue'];
}
if (isset($body['error']) && preg_match('/^[0-9A-Z_]+$/', $body['error']) === 1) {
return $body['error'];
}
if (isset($body['message'])) {
$message = is_array($body['message']) ? reset($body['message']) : $body['message'];
if (is_string($message) && preg_match('/^[a-zA-Z0-9_-]+$/', $message) === 1) {
return $message;
}
}
if (isset($body['name']) && preg_match('/^[0-9A-Z_]+$/', $body['name']) === 1) {
return $body['name'];
}
return '';
}
}

View File

@@ -0,0 +1,30 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http;
use Psr\Http\Message\ResponseInterface;
interface OrderShipmentTrackingHttpClientInterface
{
public function addTracking(array $payload): ResponseInterface;
public function updateTracking(string $trackerId, array $payload): ResponseInterface;
}

View File

@@ -0,0 +1,70 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\Http;
use GuzzleHttp\Ring\Exception\ConnectException;
use GuzzleHttp\Ring\Exception\RingException;
use Http\Client\Exception\HttpException;
use Http\Client\Exception\NetworkException;
use Http\Client\Exception\TransferException;
use Prestashop\ModuleLibGuzzleAdapter\ClientFactory;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
class PsrHttpClientAdapter implements HttpClientInterface
{
/**
* @var ClientInterface
*/
private $client;
/**
* @param array $configuration
*/
public function __construct(array $configuration)
{
$this->client = (new ClientFactory())->getClient($configuration);
}
/**
* {@inheritdoc}
*/
public function sendRequest(RequestInterface $request): ResponseInterface
{
try {
$response = $this->client->sendRequest($request);
} catch (ConnectException $exception) { // @phpstan-ignore-line
// Guzzle 5.3 use RingPHP for the low level connection
throw new NetworkException($exception->getMessage(), $request, $exception); // @phpstan-ignore-line
} catch (RingException $exception) { // @phpstan-ignore-line
// Guzzle 5.3 use RingPHP for the low level connection
throw new TransferException($exception->getMessage(), 0, $exception); // @phpstan-ignore-line
}
// Guzzle 5.3 does not throw exceptions on 4xx and 5xx status codes
if ($response->getStatusCode() >= 400) {
throw new HttpException($response->getReasonPhrase(), $request, $response);
}
return $response;
}
}

View File

@@ -0,0 +1,30 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,318 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\ValueObject;
class PayPalOrderResponse
{
/**
* @var string
*/
private $id;
/**
* @var string
*/
private $status;
/**
* @var string
*/
private $intent;
/**
* @var string|null
*/
private $payer;
/**
* @var array|null
*/
private $paymentSource;
/**
* @var array
*/
private $purchaseUnits;
/**
* @var array
*/
private $links;
/**
* Constructor to initialize PayPalOrderResponse properties
*/
public function __construct(
string $id,
string $status,
string $intent,
$payer,
$paymentSource,
array $purchaseUnits,
array $links
) {
$this->id = $id;
$this->status = $status;
$this->intent = $intent;
$this->payer = $payer;
$this->paymentSource = $paymentSource;
$this->purchaseUnits = $purchaseUnits;
$this->links = $links;
}
/**
* @return string
*/
public function getId(): string
{
return $this->id;
}
/**
* @return string
*/
public function getStatus(): string
{
return $this->status;
}
/**
* @return string
*/
public function getIntent(): string
{
return $this->intent;
}
/**
* @return string|null
*/
public function getPayer()
{
return $this->payer;
}
/**
* @return array|null
*/
public function getPaymentSource()
{
return $this->paymentSource;
}
/**
* @return array
*/
public function getPurchaseUnits(): array
{
return $this->purchaseUnits;
}
/**
* @return array
*/
public function getLinks(): array
{
return $this->links;
}
/**
* @return array|null
*/
public function getAuthenticationResult()
{
$fundingSource = key($this->getPaymentSource());
return $this->getPaymentSource()[$fundingSource]['authentication_result'] ?? null;
}
/**
* @return string|null
*/
public function getFundingSource()
{
return key($this->getPaymentSource());
}
/**
* @return array|null
*/
public function getCapture()
{
return $this->getPurchaseUnits()[0]['payments']['captures'][0] ?? null;
}
/**
* @return array|null
*/
public function getRefunds()
{
return $this->getPurchaseUnits()[0]['payments']['refunds'] ?? null;
}
/**
* @return array|null
*/
public function getAuthorization()
{
return $this->getPurchaseUnits()[0]['payments']['authorizations'][0] ?? null;
}
/**
* @return array|null
*/
public function getCard()
{
return $this->getPaymentSource()['card'] ?? null;
}
/**
* @return string|null
*/
public function getLiabilityShift()
{
return $this->getAuthenticationResult()['liability_shift'] ?? null;
}
/**
* @return array|null
*/
public function get3dSecure()
{
return $this->getAuthenticationResult()['three_d_secure'] ?? null;
}
/**
* @return string|null
*/
public function get3dSecureAuthenticationStatus()
{
return $this->get3dSecure()['authentication_status'] ?? null;
}
/**
* @return string|null
*/
public function get3dSecureEnrollmentStatus()
{
return $this->get3dSecure()['enrollment_status'] ?? null;
}
/**
* @return array
*/
public function getOrderAmount(): array
{
return $this->getPurchaseUnits()[0]['amount'] ?? [];
}
/**
* @return string|null
*/
public function getOrderAmountValue()
{
return $this->getPurchaseUnits()[0]['amount']['value'] ?? null;
}
/**
* @return array|null
*/
public function getVault()
{
return $this->getPaymentSource()[key($this->getPaymentSource())]['attributes']['vault'] ?? null;
}
/**
* @return string|null
*/
public function getCustomerId()
{
return $this->getPaymentSource()[key($this->getPaymentSource())]['attributes']['vault']['customer']['id'] ?? null;
}
/**
* @return string
*/
public function getTransactionStatus(): string
{
return $this->getPurchaseUnits()[0]['payments']['captures'][0]['status'] ?? '';
}
/**
* @return string
*/
public function getTransactionId(): string
{
return $this->getPurchaseUnits()[0]['payments']['captures'][0]['id'] ?? '';
}
/**
* @return string
*/
public function getTotalAmount(): string
{
return $this->getPurchaseUnits()[0]['payments']['captures'][0]['amount']['value'] ?? '';
}
/**
* @return string
*/
public function getCurrencyCode(): string
{
return $this->getPurchaseUnits()[0]['payments']['captures'][0]['amount']['currency_code'] ?? '';
}
/**
* @return string
*/
public function getApprovalLink(): string
{
foreach ($this->getLinks() as $link) {
if ('approve' === $link['rel']) {
return $link['href'];
}
}
return '';
}
/**
* @return array
*/
public function getItems(): array
{
return $this->getPurchaseUnits()[0]['items'] ?? [];
}
/**
* @return string
*/
public function getPayerActionLink(): string
{
foreach ($this->getLinks() as $link) {
if ('payer-action' === $link['rel']) {
return $link['href'];
}
}
return '';
}
}

View File

@@ -0,0 +1,183 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Api\ValueObject;
class TrackingResponse
{
/**
* @var string
*/
private $trackerId;
/**
* @var string
*/
private $status;
/**
* @var array
*/
private $links;
/**
* @var string
*/
private $createTime;
/**
* @var string
*/
private $updateTime;
/**
* Constructor to initialize TrackingResponse properties
*/
public function __construct(
string $trackerId,
string $status,
array $links,
string $createTime = '',
string $updateTime = ''
) {
$this->trackerId = $trackerId;
$this->status = $status;
$this->links = $links;
$this->createTime = $createTime;
$this->updateTime = $updateTime;
}
/**
* @return string
*/
public function getTrackerId(): string
{
return $this->trackerId;
}
/**
* @return string
*/
public function getStatus(): string
{
return $this->status;
}
/**
* @return array
*/
public function getLinks(): array
{
return $this->links;
}
/**
* @return string
*/
public function getCreateTime(): string
{
return $this->createTime;
}
/**
* @return string
*/
public function getUpdateTime(): string
{
return $this->updateTime;
}
/**
* Create TrackingResponse from API response data
*
* @param array $responseData
*
* @return TrackingResponse
*/
public static function createFromResponse(array $responseData): TrackingResponse
{
// Handle middleware response format where tracker info is nested
$trackerId = '';
$trackerStatus = 'UNKNOWN';
$trackerLinks = [];
// Check if this is a middleware response with nested tracker data
if (isset($responseData['purchase_units'][0]['shipping']['trackers'][0])) {
$tracker = $responseData['purchase_units'][0]['shipping']['trackers'][0];
$trackerId = $tracker['id'] ?? '';
$trackerStatus = $tracker['status'] ?? 'UNKNOWN';
$trackerLinks = $tracker['links'] ?? [];
} else {
// Fallback to direct response format (if used)
$trackerId = $responseData['tracker_id'] ?? '';
$trackerStatus = $responseData['status'] ?? 'UNKNOWN';
$trackerLinks = $responseData['links'] ?? [];
}
return new self(
$trackerId,
$trackerStatus,
$trackerLinks,
$responseData['create_time'] ?? '',
$responseData['update_time'] ?? ''
);
}
/**
* Get self link for this tracker
*
* @return string
*/
public function getSelfLink(): string
{
foreach ($this->getLinks() as $link) {
if ('self' === $link['rel']) {
return $link['href'];
}
}
return '';
}
/**
* Check if tracking was successfully created
*
* @return bool
*/
public function isSuccessful(): bool
{
// Must have a tracker ID
if (empty($this->trackerId)) {
return false;
}
// Accept various successful status values from middleware
$successfulStatuses = [
'SHIPPED', // PayPal standard
'ON_HOLD', // PayPal standard
'DELIVERED', // PayPal standard
'COMPLETED', // Middleware status
'SUCCESS', // Generic success
'CREATED' // Tracking created
];
return in_array($this->status, $successfulStatuses);
}
}

View File

@@ -0,0 +1,30 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,30 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,24 @@
<?php
putenv('COMPOSER_VENDOR_DIR=' . __DIR__);
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
throw new RuntimeException($err);
}
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit0b3fc41d2d79c7a9615154199514651f::getLoader();

View File

@@ -0,0 +1,579 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see https://www.php-fig.org/psr/psr-0/
* @see https://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
/** @var \Closure(string):void */
private static $includeFile;
/** @var string|null */
private $vendorDir;
// PSR-4
/**
* @var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array<string, list<string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var list<string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* List of PSR-0 prefixes
*
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
*
* @var array<string, array<string, list<string>>>
*/
private $prefixesPsr0 = array();
/**
* @var list<string>
*/
private $fallbackDirsPsr0 = array();
/** @var bool */
private $useIncludePath = false;
/**
* @var array<string, string>
*/
private $classMap = array();
/** @var bool */
private $classMapAuthoritative = false;
/**
* @var array<string, bool>
*/
private $missingClasses = array();
/** @var string|null */
private $apcuPrefix;
/**
* @var array<string, self>
*/
private static $registeredLoaders = array();
/**
* @param string|null $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
self::initializeIncludeClosure();
}
/**
* @return array<string, list<string>>
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}
return array();
}
/**
* @return array<string, list<string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
/**
* @return list<string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
/**
* @return list<string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
/**
* @return array<string, string> Array of classname => path
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array<string, string> $classMap Class to filename map
*
* @return void
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
$paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
$paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
$paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
$paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
$paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
$paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 base directories
*
* @return void
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*
* @return void
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*
* @return void
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*
* @return void
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*
* @return void
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
if (null === $this->vendorDir) {
return;
}
if ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
self::$registeredLoaders[$this->vendorDir] = $this;
}
}
/**
* Unregisters this instance as an autoloader.
*
* @return void
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return true|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
$includeFile = self::$includeFile;
$includeFile($file);
return true;
}
return null;
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
/**
* Returns the currently registered loaders keyed by their corresponding vendor directories.
*
* @return array<string, self>
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}
/**
* @param string $class
* @param string $ext
* @return string|false
*/
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
*/
self::$includeFile = \Closure::bind(static function($file) {
include $file;
}, null, null);
}
}

View File

@@ -0,0 +1,396 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer;
use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;
/**
* This class is copied in every Composer installed project and available to all
*
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
*
* To require its presence, you can require `composer-runtime-api ^2.0`
*
* @final
*/
class InstalledVersions
{
/**
* @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
* @internal
*/
private static $selfDir = null;
/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
*/
private static $installed;
/**
* @var bool
*/
private static $installedIsLocalDir;
/**
* @var bool|null
*/
private static $canGetVendors;
/**
* @var array[]
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
private static $installedByVendor = array();
/**
* Returns a list of all package names which are present, either by being installed, replaced or provided
*
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackages()
{
$packages = array();
foreach (self::getInstalled() as $installed) {
$packages[] = array_keys($installed['versions']);
}
if (1 === \count($packages)) {
return $packages[0];
}
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
}
/**
* Returns a list of all package names with a specific type e.g. 'library'
*
* @param string $type
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackagesByType($type)
{
$packagesByType = array();
foreach (self::getInstalled() as $installed) {
foreach ($installed['versions'] as $name => $package) {
if (isset($package['type']) && $package['type'] === $type) {
$packagesByType[] = $name;
}
}
}
return $packagesByType;
}
/**
* Checks whether the given package is installed
*
* This also returns true if the package name is provided or replaced by another package
*
* @param string $packageName
* @param bool $includeDevRequirements
* @return bool
*/
public static function isInstalled($packageName, $includeDevRequirements = true)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
}
}
return false;
}
/**
* Checks whether the given package satisfies a version constraint
*
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
*
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
*
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
* @param string $packageName
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
* @return bool
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints((string) $constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
}
/**
* Returns a version constraint representing all the range(s) which are installed for a given package
*
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
* whether a given version of a package is installed, and not just whether it exists
*
* @param string $packageName
* @return string Version constraint usable with composer/semver
*/
public static function getVersionRanges($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
$ranges = array();
if (isset($installed['versions'][$packageName]['pretty_version'])) {
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
}
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
}
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
}
if (array_key_exists('provided', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
}
return implode(' || ', $ranges);
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['version'])) {
return null;
}
return $installed['versions'][$packageName]['version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getPrettyVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
return null;
}
return $installed['versions'][$packageName]['pretty_version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
*/
public static function getReference($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['reference'])) {
return null;
}
return $installed['versions'][$packageName]['reference'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
*/
public static function getInstallPath($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @return array
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
*/
public static function getRootPackage()
{
$installed = self::getInstalled();
return $installed[0]['root'];
}
/**
* Returns the raw installed.php data for custom implementations
*
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
* @return array[]
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
*/
public static function getRawData()
{
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = include __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
return self::$installed;
}
/**
* Returns the raw data of all installed.php which are currently loaded for custom implementations
*
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
public static function getAllRawData()
{
return self::getInstalled();
}
/**
* Lets you reload the static array from another file
*
* This is only useful for complex integrations in which a project needs to use
* this class but then also needs to execute another project's autoloader in process,
* and wants to ensure both projects have access to their version of installed.php.
*
* A typical case would be PHPUnit, where it would need to make sure it reads all
* the data it needs from this class, then call reload() with
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
* the project in which it runs can then also use this class safely, without
* interference between PHPUnit's dependencies and the project's dependencies.
*
* @param array[] $data A vendor/composer/installed.php data set
* @return void
*
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
*/
public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
// so we have to assume it does not, and that may result in duplicate data being returned when listing
// all installed packages for example
self::$installedIsLocalDir = false;
}
/**
* @return string
*/
private static function getSelfDir()
{
if (self::$selfDir === null) {
self::$selfDir = strtr(__DIR__, '\\', '/');
}
return self::$selfDir;
}
/**
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
private static function getInstalled()
{
if (null === self::$canGetVendors) {
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
}
$installed = array();
$copiedLocalDir = false;
if (self::$canGetVendors) {
$selfDir = self::getSelfDir();
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
$vendorDir = strtr($vendorDir, '\\', '/');
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
self::$installedByVendor[$vendorDir] = $required;
$installed[] = $required;
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
self::$installed = $required;
self::$installedIsLocalDir = true;
}
}
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
$copiedLocalDir = true;
}
}
}
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require __DIR__ . '/installed.php';
self::$installed = $required;
} else {
self::$installed = array();
}
}
if (self::$installed !== array() && !$copiedLocalDir) {
$installed[] = self::$installed;
}
return $installed;
}
}

View File

@@ -0,0 +1,21 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,27 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir));
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
'PsCheckout\\Api\\Http\\CheckoutHttpClient' => $baseDir . '/api/src/Http/CheckoutHttpClient.php',
'PsCheckout\\Api\\Http\\CheckoutHttpClientInterface' => $baseDir . '/api/src/Http/CheckoutHttpClientInterface.php',
'PsCheckout\\Api\\Http\\Configuration\\CheckoutClientConfigurationBuilder' => $baseDir . '/api/src/Http/Configuration/CheckoutClientConfigurationBuilder.php',
'PsCheckout\\Api\\Http\\Configuration\\HttpClientConfigurationBuilderInterface' => $baseDir . '/api/src/Http/Configuration/HttpClientConfigurationBuilderInterface.php',
'PsCheckout\\Api\\Http\\Configuration\\OrderHttpClientConfigurationBuilder' => $baseDir . '/api/src/Http/Configuration/OrderHttpClientConfigurationBuilder.php',
'PsCheckout\\Api\\Http\\Configuration\\OrderShipmentTrackingConfigurationBuilder' => $baseDir . '/api/src/Http/Configuration/OrderShipmentTrackingConfigurationBuilder.php',
'PsCheckout\\Api\\Http\\Configuration\\OrderShipmentTrackingConfigurationBuilderInterface' => $baseDir . '/api/src/Http/Configuration/OrderShipmentTrackingConfigurationBuilderInterface.php',
'PsCheckout\\Api\\Http\\Exception\\PayPalError' => $baseDir . '/api/src/Http/Exception/PayPalError.php',
'PsCheckout\\Api\\Http\\Exception\\PayPalException' => $baseDir . '/api/src/Http/Exception/PayPalException.php',
'PsCheckout\\Api\\Http\\HttpClientInterface' => $baseDir . '/api/src/Http/HttpClientInterface.php',
'PsCheckout\\Api\\Http\\OrderHttpClient' => $baseDir . '/api/src/Http/OrderHttpClient.php',
'PsCheckout\\Api\\Http\\OrderHttpClientInterface' => $baseDir . '/api/src/Http/OrderHttpClientInterface.php',
'PsCheckout\\Api\\Http\\OrderShipmentTrackingHttpClient' => $baseDir . '/api/src/Http/OrderShipmentTrackingHttpClient.php',
'PsCheckout\\Api\\Http\\OrderShipmentTrackingHttpClientInterface' => $baseDir . '/api/src/Http/OrderShipmentTrackingHttpClientInterface.php',
'PsCheckout\\Api\\Http\\PsrHttpClientAdapter' => $baseDir . '/api/src/Http/PsrHttpClientAdapter.php',
'PsCheckout\\Api\\ValueObject\\PayPalOrderResponse' => $baseDir . '/api/src/ValueObject/PayPalOrderResponse.php',
'PsCheckout\\Api\\ValueObject\\TrackingResponse' => $baseDir . '/api/src/ValueObject/TrackingResponse.php',
);

View File

@@ -0,0 +1,9 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir));
return array(
);

View File

@@ -0,0 +1,10 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir));
return array(
'PsCheckout\\Api\\' => array($baseDir . '/api/src'),
);

View File

@@ -0,0 +1,36 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit0b3fc41d2d79c7a9615154199514651f
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit0b3fc41d2d79c7a9615154199514651f', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit0b3fc41d2d79c7a9615154199514651f', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit0b3fc41d2d79c7a9615154199514651f::getInitializer($loader));
$loader->register(true);
return $loader;
}
}

View File

@@ -0,0 +1,53 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit0b3fc41d2d79c7a9615154199514651f
{
public static $prefixLengthsPsr4 = array (
'P' =>
array (
'PsCheckout\\Api\\' => 15,
),
);
public static $prefixDirsPsr4 = array (
'PsCheckout\\Api\\' =>
array (
0 => __DIR__ . '/../../..' . '/api/src',
),
);
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'PsCheckout\\Api\\Http\\CheckoutHttpClient' => __DIR__ . '/../../..' . '/api/src/Http/CheckoutHttpClient.php',
'PsCheckout\\Api\\Http\\CheckoutHttpClientInterface' => __DIR__ . '/../../..' . '/api/src/Http/CheckoutHttpClientInterface.php',
'PsCheckout\\Api\\Http\\Configuration\\CheckoutClientConfigurationBuilder' => __DIR__ . '/../../..' . '/api/src/Http/Configuration/CheckoutClientConfigurationBuilder.php',
'PsCheckout\\Api\\Http\\Configuration\\HttpClientConfigurationBuilderInterface' => __DIR__ . '/../../..' . '/api/src/Http/Configuration/HttpClientConfigurationBuilderInterface.php',
'PsCheckout\\Api\\Http\\Configuration\\OrderHttpClientConfigurationBuilder' => __DIR__ . '/../../..' . '/api/src/Http/Configuration/OrderHttpClientConfigurationBuilder.php',
'PsCheckout\\Api\\Http\\Configuration\\OrderShipmentTrackingConfigurationBuilder' => __DIR__ . '/../../..' . '/api/src/Http/Configuration/OrderShipmentTrackingConfigurationBuilder.php',
'PsCheckout\\Api\\Http\\Configuration\\OrderShipmentTrackingConfigurationBuilderInterface' => __DIR__ . '/../../..' . '/api/src/Http/Configuration/OrderShipmentTrackingConfigurationBuilderInterface.php',
'PsCheckout\\Api\\Http\\Exception\\PayPalError' => __DIR__ . '/../../..' . '/api/src/Http/Exception/PayPalError.php',
'PsCheckout\\Api\\Http\\Exception\\PayPalException' => __DIR__ . '/../../..' . '/api/src/Http/Exception/PayPalException.php',
'PsCheckout\\Api\\Http\\HttpClientInterface' => __DIR__ . '/../../..' . '/api/src/Http/HttpClientInterface.php',
'PsCheckout\\Api\\Http\\OrderHttpClient' => __DIR__ . '/../../..' . '/api/src/Http/OrderHttpClient.php',
'PsCheckout\\Api\\Http\\OrderHttpClientInterface' => __DIR__ . '/../../..' . '/api/src/Http/OrderHttpClientInterface.php',
'PsCheckout\\Api\\Http\\OrderShipmentTrackingHttpClient' => __DIR__ . '/../../..' . '/api/src/Http/OrderShipmentTrackingHttpClient.php',
'PsCheckout\\Api\\Http\\OrderShipmentTrackingHttpClientInterface' => __DIR__ . '/../../..' . '/api/src/Http/OrderShipmentTrackingHttpClientInterface.php',
'PsCheckout\\Api\\Http\\PsrHttpClientAdapter' => __DIR__ . '/../../..' . '/api/src/Http/PsrHttpClientAdapter.php',
'PsCheckout\\Api\\ValueObject\\PayPalOrderResponse' => __DIR__ . '/../../..' . '/api/src/ValueObject/PayPalOrderResponse.php',
'PsCheckout\\Api\\ValueObject\\TrackingResponse' => __DIR__ . '/../../..' . '/api/src/ValueObject/TrackingResponse.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit0b3fc41d2d79c7a9615154199514651f::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit0b3fc41d2d79c7a9615154199514651f::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit0b3fc41d2d79c7a9615154199514651f::$classMap;
}, null, ClassLoader::class);
}
}

View File

@@ -0,0 +1,34 @@
<?php return array(
'root' => array(
'name' => 'ps_checkout/prestashop',
'pretty_version' => 'v5.1.1',
'version' => '5.1.1.0',
'reference' => '5846da751d8542e6814651626eacd7fe5470c270',
'type' => 'prestashop-module',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev' => true,
),
'versions' => array(
'beberlei/composer-monorepo-plugin' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '47a2612a09e81d741b3eeb99852590b13b64eddd',
'type' => 'composer-plugin',
'install_path' => __DIR__ . '/../beberlei/composer-monorepo-plugin',
'aliases' => array(
0 => '9999999-dev',
),
'dev_requirement' => true,
),
'ps_checkout/prestashop' => array(
'pretty_version' => 'v5.1.1',
'version' => '5.1.1.0',
'reference' => '5846da751d8542e6814651626eacd7fe5470c270',
'type' => 'prestashop-module',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
),
);

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,83 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Customer\Action;
use Exception;
use PsCheckout\Core\Customer\Request\ValueObject\ExpressCheckoutRequest;
use PsCheckout\Core\Exception\PsCheckoutException;
use PsCheckout\Infrastructure\Action\CreateOrUpdateAddressActionInterface;
use PsCheckout\Infrastructure\Action\CustomerAuthenticationActionInterface;
use PsCheckout\Infrastructure\Adapter\ContextInterface;
class ExpressCheckoutAction implements ExpressCheckoutActionInterface
{
/**
* @var ContextInterface
*/
private $context;
/**
* @var CustomerAuthenticationActionInterface
*/
private $customerAuthenticationAction;
/**
* @var CreateOrUpdateAddressActionInterface
*/
private $createOrUpdateAddressAction;
public function __construct(
ContextInterface $context,
CustomerAuthenticationActionInterface $customerAuthenticationAction,
CreateOrUpdateAddressActionInterface $createOrUpdateAddressAction
) {
$this->context = $context;
$this->customerAuthenticationAction = $customerAuthenticationAction;
$this->createOrUpdateAddressAction = $createOrUpdateAddressAction;
}
public function execute(ExpressCheckoutRequest $expressCheckoutRequest)
{
$customer = $this->context->getCustomer();
if (!$customer->isLogged()) {
$customer->is_guest = true;
$customer->email = $expressCheckoutRequest->getPayerEmail();
$customer->firstname = $expressCheckoutRequest->getPayerFirstName();
$customer->lastname = $expressCheckoutRequest->getPayerLastName();
$customer->passwd = md5(time() . _COOKIE_KEY_);
try {
$customer->save();
} catch (Exception $exception) {
throw new PsCheckoutException($exception->getMessage(), PsCheckoutException::PSCHECKOUT_EXPRESS_CHECKOUT_CANNOT_SAVE_CUSTOMER, $exception);
}
$this->context->updateCustomer($customer);
}
$this->context->setPayPalEmail($expressCheckoutRequest->getPayerEmail());
$this->context->resetContextCartAddresses();
$this->createOrUpdateAddressAction->execute($expressCheckoutRequest);
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Customer\Action;
use PsCheckout\Core\Customer\Request\ValueObject\ExpressCheckoutRequest;
interface ExpressCheckoutActionInterface
{
/**
* @param ExpressCheckoutRequest $expressCheckoutRequest
*
* @return void
*/
public function execute(ExpressCheckoutRequest $expressCheckoutRequest);
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,146 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Customer\Request\ValueObject;
class ExpressCheckoutRequest
{
/**
* @var array
*/
private $data;
public function __construct(array $data)
{
$this->data = $data;
}
/**
* @return string|null
*/
public function getOrderId()
{
return $this->data['orderID'] ?? null;
}
/**
* @return string|null
*/
public function getFundingSource()
{
return $this->data['fundingSource'] ?? null;
}
/**
* @return string|null
*/
public function getPayerEmail()
{
return $this->data['order']['payer']['email_address'] ?? null;
}
/**
* @return string|null
*/
public function getPayerFirstName()
{
return $this->data['order']['payer']['name']['given_name'] ?? null;
}
/**
* @return string|null
*/
public function getPayerLastName()
{
return $this->data['order']['payer']['name']['surname'] ?? null;
}
/**
* @return string|null
*/
public function getPayerPhone()
{
return $this->data['order']['payer']['phone']['phone_number']['national_number'] ?? null;
}
/**
* @return array|null
*/
public function getShippingAddress()
{
return $this->data['order']['shipping']['address'] ?? [];
}
/**
* @return string|null
*/
public function getShippingStreet()
{
return $this->getShippingAddress()['address_line_1'] ?? null;
}
/**
* @return string|null
*/
public function getShippingStreet2()
{
return $this->getShippingAddress()['address_line_2'] ?? '';
}
/**
* @return string|null
*/
public function getShippingPostalCode()
{
return $this->getShippingAddress()['postal_code'] ?? null;
}
/**
* @return string|null
*/
public function getShippingState()
{
return $this->getShippingAddress()['admin_area_1'] ?? null;
}
/**
* @return string|null
*/
public function getShippingCity()
{
return $this->getShippingAddress()['admin_area_2'] ?? null;
}
/**
* @return string|null
*/
public function getShippingCountryCode()
{
return $this->getShippingAddress()['country_code'] ?? null;
}
/**
* @return array
*/
public function getPayload(): array
{
return $this->data;
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,144 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Exception;
class PsCheckoutException extends \Exception
{
const UNKNOWN = 0;
const ORDER_NOT_FOUND = 2;
const PRESTASHOP_REFUND_ALREADY_SAVED = 3;
const PRESTASHOP_REFUND_TOTAL_AMOUNT_REACHED = 4;
const PRESTASHOP_ORDER_STATE_ERROR = 5;
const PRESTASHOP_CONTEXT_INVALID = 6;
const PRESTASHOP_PAYMENT_UNAVAILABLE = 7;
const PSACCOUNT_TOKEN_MISSING = 8;
const PSACCOUNT_REFRESH_TOKEN_MISSING = 9;
const PSCHECKOUT_LOCALE_DECODE_ERROR = 10;
const PSCHECKOUT_MERCHANT_IDENTIFIER_MISSING = 11;
const PSCHECKOUT_ORDER_MATRIX_ERROR = 12;
const PSCHECKOUT_WEBHOOK_HEADER_EMPTY = 13;
const PSCHECKOUT_WEBHOOK_SHOP_ID_EMPTY = 14;
const PSCHECKOUT_WEBHOOK_MERCHANT_ID_EMPTY = 15;
const PSCHECKOUT_WEBHOOK_PSX_ID_EMPTY = 16;
const PSCHECKOUT_WEBHOOK_BODY_EMPTY = 17;
const PSCHECKOUT_WEBHOOK_EVENT_TYPE_EMPTY = 18;
const PSCHECKOUT_WEBHOOK_CATEGORY_EMPTY = 19;
const PSCHECKOUT_WEBHOOK_RESOURCE_EMPTY = 20;
const PSCHECKOUT_WEBHOOK_AMOUNT_EMPTY = 21;
const PSCHECKOUT_WEBHOOK_AMOUNT_INVALID = 22;
const PSCHECKOUT_WEBHOOK_CURRENCY_EMPTY = 23;
const PSCHECKOUT_WEBHOOK_ORDER_ID_EMPTY = 24;
const PSCHECKOUT_WEBHOOK_PSL_SIGNATURE_INVALID = 25;
const PSCHECKOUT_WEBHOOK_SHOP_ID_INVALID = 26;
const PAYPAL_ORDER_IDENTIFIER_MISSING = 27;
const PAYPAL_PAYMENT_METHOD_MISSING = 28;
const PAYPAL_PAYMENT_CARD_ERROR = 29;
const PAYPAL_PAYMENT_CAPTURE_DECLINED = 30;
const PRESTASHOP_ORDER_ID_MISSING = 31;
const PSCHECKOUT_BAD_STATIC_TOKEN = 32;
const PSCHECKOUT_EXPRESS_CHECKOUT_CANNOT_SAVE_CUSTOMER = 33;
const PSCHECKOUT_EXPRESS_CHECKOUT_CANNOT_SAVE_ADDRESS = 34;
const PSCHECKOUT_HTTP_EXCEPTION = 35;
const PSCHECKOUT_LOGGER_FILE_READER_NOT_FOUND = 36;
const PSCHECKOUT_LOGGER_FILE_READER_NOT_READABLE = 37;
const PSCHECKOUT_VALIDATE_BODY_EMPTY = 38;
const PSCHECKOUT_UPDATE_ORDER_HANDLE_ERROR = 39;
const PRESTASHOP_VALIDATE_ORDER = 40;
const PRESTASHOP_ORDER_PAYMENT = 41;
const PRESTASHOP_CART_NOT_FOUND = 42;
const DIFFERENCE_BETWEEN_TRANSACTION_AND_CART = 43;
const PSL_TIMEOUT = 44;
const MISSING_PAYPAL_CLIENT_TOKEN = 46;
const PAYPAL_PAYMENT_CARD_SCA_UNKNOWN = 50;
const PAYPAL_PAYMENT_CARD_SCA_FAILURE = 51;
const PAYPAL_PAYMENT_CARD_SCA_CANCELED = 52;
const INVALID_CAPTURE_EVENT = 53;
const CART_PRODUCT_MISSING = 54;
const CART_PRODUCT_UNAVAILABLE = 55;
const CART_ADDRESS_INVOICE_INVALID = 56;
const CART_ADDRESS_DELIVERY_INVALID = 57;
const CART_DELIVERY_OPTION_INVALID = 58;
const PSCHECKOUT_HTTP_UNAUTHORIZED = 59;
const PAYPAL_ORDER_ALREADY_CAPTURED = 60;
const PAYPAL_ORDER_NOT_FOUND = 61;
const PRESTASHOP_ORDER_ALREADY_EXISTS = 62;
const UPDATE_FAILED = 63;
const FAILED_ADD_PAYMENT = 64;
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,70 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\FundingSource\Constraint;
class FundingSourceConstraint
{
/**
* Get eligible countries to PayPal funding sources
*
* @param string $fundingSourceName
*
* @return array
*/
public static function getCountries(string $fundingSourceName): array
{
$countries = [
'bancontact' => ['BE'],
'blik' => ['PL'],
'eps' => ['AT'],
'ideal' => ['NL'],
'mybank' => ['IT'],
'p24' => ['PL'],
'paylater' => ['AU', 'DE', 'ES', 'FR', 'GB', 'IT', 'US'],
'google_pay' => ['AU', 'AT', 'BE', 'BG', 'CA', 'CN', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HK', 'HU', 'IE', 'IT', 'JP', 'LV', 'LI', 'LT', 'LU', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SG', 'SK', 'SI', 'ES', 'SE', 'GB', 'US'],
'apple_pay' => ['AU', 'AT', 'BE', 'BG', 'CA', 'CN', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HK', 'HU', 'IE', 'IT', 'JP', 'LV', 'LI', 'LT', 'LU', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SG', 'SK', 'SI', 'ES', 'SE', 'GB', 'US'],
'venmo' => ['US'],
'pay_upon_invoice' => ['DE'],
];
return isset($countries[$fundingSourceName]) ? $countries[$fundingSourceName] : [];
}
/**
* Get eligible currencies for PayPal funding sources
*
* @param string $fundingSourceName
*
* @return array
*/
public static function getCurrencies(string $fundingSourceName): array
{
$currencies = [
'google_pay' => ['AUD', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PHP', 'PLN', 'SEK', 'SGD', 'THB', 'TWD', 'USD'],
'apple_pay' => ['AUD', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PHP', 'PLN', 'SEK', 'SGD', 'THB', 'TWD', 'USD'],
'paylater' => ['EUR', 'USD', 'AUD', 'GBP'],
'venmo' => ['USD'],
'pay_upon_invoice' => ['EUR'],
];
return isset($currencies[$fundingSourceName]) ? $currencies[$fundingSourceName] : [];
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,84 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\FundingSource\Factory;
use PsCheckout\Core\FundingSource\ValueObject\FundingSourceToken;
use PsCheckout\Core\PaymentToken\ValueObject\PaymentToken;
use PsCheckout\Presentation\Presenter\FundingSource\FundingSourceTranslationProviderInterface;
use PsCheckout\Presentation\Presenter\FundingSource\LogoPresenterInterface;
class FundingSourceTokenFactory implements FundingSourceTokenFactoryInterface
{
/**
* @var FundingSourceTranslationProviderInterface
*/
private $fundingSourceTranslationProvider;
/**
* @var LogoPresenterInterface
*/
private $logoPresenter;
public function __construct(
FundingSourceTranslationProviderInterface $fundingSourceTranslationProvider,
LogoPresenterInterface $logoPresenter
) {
$this->fundingSourceTranslationProvider = $fundingSourceTranslationProvider;
$this->logoPresenter = $logoPresenter;
}
/**
* {@inheritdoc}
*/
public function createFromPaymentToken(PaymentToken $paymentToken): FundingSourceToken
{
$paymentSource = $paymentToken->getData()['payment_source'][$paymentToken->getPaymentSource()];
$label = $this->getLabel($paymentToken, $paymentSource);
return new FundingSourceToken(
'token-' . $paymentToken->getId(),
$label,
$paymentToken->getPaymentSource(),
$paymentToken->isFavorite(),
$this->logoPresenter->getLogoByPaymentSource($paymentToken->getData()['payment_source'])
);
}
/**
* @param PaymentToken $paymentToken
* @param array $paymentSource
*
* @return string
*/
private function getLabel(PaymentToken $paymentToken, array $paymentSource): string
{
if ($paymentToken->getPaymentSource() === 'card') {
return $this->fundingSourceTranslationProvider->getVaultedPaymentMethodName(
(isset($paymentSource['brand']) ? $paymentSource['brand'] : '') .
(isset($paymentSource['last_digits']) ? ' *' . $paymentSource['last_digits'] : '')
);
}
return $this->fundingSourceTranslationProvider->getVaultedPaymentMethodName(
isset($paymentSource['email_address']) ? $paymentSource['email_address'] : ''
);
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\FundingSource\Factory;
use PsCheckout\Core\FundingSource\ValueObject\FundingSourceToken;
use PsCheckout\Core\PaymentToken\ValueObject\PaymentToken;
interface FundingSourceTokenFactoryInterface
{
/**
* @param PaymentToken $paymentToken
*
* @return FundingSourceToken
*/
public function createFromPaymentToken(PaymentToken $paymentToken): FundingSourceToken;
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,72 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\FundingSource\Repository;
interface FundingSourceRepositoryInterface
{
/**
* Get one funding source by key value criteria
*
* @param array $keyValueCriteria an associative array of key-value pairs where
* the key represents the column name and the value
* represents the value to search for
*
* @return array|null
*/
public function getOneBy(array $keyValueCriteria);
/**
* Get all funding sources for a specific shop
*
* @param int $shopId
*
* @return array
*/
public function getAllForSpecificShop(int $shopId): array;
/**
* Get all active funding sources for a specific shop
*
* @param int $shopId
*
* @return array
*/
public function getAllActiveForSpecificShop(int $shopId): array;
/**
* @param array $data
* @param int $shopId
*
* @return bool
*
* @throws \PrestaShopDatabaseException
*/
public function upsert(array $data, int $shopId): bool;
/**
* Populate funding sources table with default values
*
* @param int $shopId
*
* @return void
*/
public function populateWithDefaultValues(int $shopId);
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,129 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\FundingSource\ValueObject;
use PsCheckout\Core\FundingSource\Constraint\FundingSourceConstraint;
class FundingSource implements \JsonSerializable
{
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $label;
/**
* @var int
*/
private $position;
/**
* @var array
*/
private $countries;
/**
* @var bool
*/
private $isEnabled;
/**
* @var bool
*/
private $isToggleable;
/**
* @var string|null
*/
private $customMark;
public function __construct(
$name,
$label,
$position,
$isEnabled,
$customMark
) {
$this->name = $name;
$this->label = $label;
$this->position = $position;
$this->countries = FundingSourceConstraint::getCountries($name);
$this->isEnabled = $isEnabled;
$this->isToggleable = !($this->name === 'paypal');
$this->customMark = $customMark;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @return string
*/
public function getLabel(): string
{
return $this->label;
}
/**
* @return bool
*/
public function getIsEnabled(): bool
{
return $this->isEnabled;
}
/**
* @return string|null
*/
public function getCustomMark()
{
return $this->customMark;
}
/**
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize(): array
{
$json = [
'name' => $this->name,
'label' => $this->label,
'position' => $this->position,
'countries' => $this->countries,
'isEnabled' => $this->isEnabled,
'isToggleable' => $this->isToggleable,
];
return array_filter($json, function ($val) {
return $val !== null;
});
}
}

View File

@@ -0,0 +1,116 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\FundingSource\ValueObject;
class FundingSourceToken implements \JsonSerializable
{
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $label;
/**
* @var string
*/
private $paymentSource;
/**
* @var bool
*/
private $isFavorite;
/**
* @var string
*/
private $customMark;
public function __construct($name, $label, $paymentSource, $isFavorite, $customMark)
{
$this->name = $name;
$this->label = $label;
$this->paymentSource = $paymentSource;
$this->isFavorite = $isFavorite;
$this->customMark = $customMark;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @return string
*/
public function getLabel(): string
{
return $this->label;
}
/**
* @return string
*/
public function getPaymentSource(): string
{
return $this->paymentSource;
}
/**
* @return bool
*/
public function isFavorite(): bool
{
return $this->isFavorite;
}
/**
* @return string
*/
public function getCustomMark(): string
{
return $this->customMark;
}
/**
* @return array
*/
public function jsonSerialize(): array
{
$json = [
'name' => $this->getName(),
'label' => $this->getLabel(),
'paymentSource' => $this->getPaymentSource(),
'isFavorite' => $this->isFavorite(),
'customMark' => $this->getCustomMark(),
];
return array_filter($json, function ($val) {
return $val !== null;
});
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,91 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Action;
use PsCheckout\Api\ValueObject\PayPalOrderResponse;
use PsCheckout\Core\Exception\PsCheckoutException;
use PsCheckout\Core\PayPal\Order\Repository\PayPalOrderMatrixRepositoryInterface;
use PsCheckout\Infrastructure\Adapter\ContextInterface;
use PsCheckout\Infrastructure\Repository\OrderRepositoryInterface;
class CreateOrderAction implements CreateOrderActionInterface
{
/**
* @var ContextInterface
*/
private $context;
/**
* @var CreateValidateOrderDataActionInterface
*/
private $createValidateOrderDataAction;
/**
* @var ValidateOrderActionInterface
*/
private $validateOrderAction;
/**
* @var OrderRepositoryInterface
*/
private $orderRepository;
/**
* @var PayPalOrderMatrixRepositoryInterface
*/
private $orderMatrixRepository;
public function __construct(
ContextInterface $context,
CreateValidateOrderDataActionInterface $createValidateOrderDataAction,
ValidateOrderActionInterface $validateOrderAction,
OrderRepositoryInterface $orderRepository,
PayPalOrderMatrixRepositoryInterface $orderMatrixRepository
) {
$this->context = $context;
$this->createValidateOrderDataAction = $createValidateOrderDataAction;
$this->validateOrderAction = $validateOrderAction;
$this->orderRepository = $orderRepository;
$this->orderMatrixRepository = $orderMatrixRepository;
}
/**
* {@inheritDoc}
*/
public function execute(PayPalOrderResponse $payPalOrder)
{
try {
$validateOrderData = $this->createValidateOrderDataAction->execute($payPalOrder);
$this->validateOrderAction->execute($validateOrderData);
$orders = $this->orderRepository->getAllBy(['id_cart' => $this->context->getCart()->id]);
foreach ($orders as $order) {
$this->orderMatrixRepository->upsert((int) $order->id, (int) $this->context->getCart()->id);
}
} catch (PsCheckoutException $exception) {
throw $exception;
} catch (\Exception $exception) {
throw new PsCheckoutException($exception->getMessage(), PsCheckoutException::UNKNOWN);
}
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Action;
use PsCheckout\Api\ValueObject\PayPalOrderResponse;
interface CreateOrderActionInterface
{
/**
* @param PayPalOrderResponse $payPalOrder
*
* @return void
*/
public function execute(PayPalOrderResponse $payPalOrder);
}

View File

@@ -0,0 +1,135 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Action;
use DateTime;
use DateTimeZone;
use PsCheckout\Api\ValueObject\PayPalOrderResponse;
use PsCheckout\Core\Exception\PsCheckoutException;
use PsCheckout\Core\Order\Exception\OrderException;
use PsCheckout\Core\PayPal\Order\Repository\PayPalOrderRepositoryInterface;
use PsCheckout\Infrastructure\Adapter\ConfigurationInterface;
use PsCheckout\Infrastructure\Adapter\CurrencyInterface;
use PsCheckout\Infrastructure\Repository\OrderRepositoryInterface;
use PsCheckout\Presentation\Presenter\FundingSource\FundingSourceTranslationProviderInterface;
class CreateOrderPaymentAction implements CreateOrderPaymentActionInterface
{
/**
* @var OrderRepositoryInterface
*/
private $orderRepository;
/**
* @var PayPalOrderRepositoryInterface
*/
private $payPalOrderRepository;
/**
* @var FundingSourceTranslationProviderInterface
*/
private $fundingSourceTranslationProvider;
/**
* @var ConfigurationInterface
*/
private $configuration;
/**
* @var CurrencyInterface
*/
private $currency;
public function __construct(
OrderRepositoryInterface $orderRepository,
PayPalOrderRepositoryInterface $payPalOrderRepository,
FundingSourceTranslationProviderInterface $fundingSourceTranslationProvider,
ConfigurationInterface $configuration,
CurrencyInterface $currency
) {
$this->orderRepository = $orderRepository;
$this->payPalOrderRepository = $payPalOrderRepository;
$this->fundingSourceTranslationProvider = $fundingSourceTranslationProvider;
$this->configuration = $configuration;
$this->currency = $currency;
}
/**
* {@inheritDoc}
*/
public function execute(PayPalOrderResponse $payPalOrderResponse)
{
$payPalOrder = $this->payPalOrderRepository->getOneBy(['id' => $payPalOrderResponse->getId()]);
/** @var \Order $order */
$order = $this->orderRepository->getOneBy(['id_cart' => $payPalOrder->getIdCart()]);
if (!$order) {
throw new PsCheckoutException('No PrestaShop Order associated to this PayPal Order at this time.');
}
/** @var \OrderPayment[] $orderPayments */
$orderPayments = $order->getOrderPaymentCollection();
$capture = $payPalOrderResponse->getCapture();
foreach ($orderPayments as $orderPayment) {
if (
sprintf('%01.2f', $orderPayment->amount) === sprintf('%01.2f', $capture['amount']['value'])
&& empty($orderPayment->transaction_id)
) {
$orderPayment->transaction_id = $capture['id'];
$orderPayment->save();
return;
}
if ($orderPayment->transaction_id === $capture['id']) {
return;
}
}
$currency = $this->currency->getCurrencyInstance($order->id_currency);
$orderHasInvoice = $order->hasInvoice();
$orderInvoice = $orderHasInvoice ? $order->getNotPaidInvoicesCollection()->getFirst() : null;
if ($orderHasInvoice && !$orderInvoice->id) {
$orderInvoice = null;
}
$date = new DateTime($capture['create_time']);
$date->setTimezone(
new DateTimeZone($this->configuration->get('PS_TIMEZONE') ?? date_default_timezone_get())
);
$paymentAdded = $order->addOrderPayment(
$capture['amount']['value'],
$this->fundingSourceTranslationProvider->getFundingSourceName($payPalOrder->getFundingSource()),
$capture['id'],
$currency,
$date->format('Y-m-d H:i:s'),
$orderInvoice
);
if (!$paymentAdded) {
throw new OrderException(sprintf('Failed to add a payment to Order #%s.', $payPalOrderResponse->getId()), PsCheckoutException::FAILED_ADD_PAYMENT);
}
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Action;
use PsCheckout\Api\ValueObject\PayPalOrderResponse;
interface CreateOrderPaymentActionInterface
{
/**
* @param PayPalOrderResponse $payPalOrderResponse
*
* @return void
*/
public function execute(PayPalOrderResponse $payPalOrderResponse);
}

View File

@@ -0,0 +1,137 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Action;
use PsCheckout\Api\ValueObject\PayPalOrderResponse;
use PsCheckout\Core\Order\Validator\OrderAmountValidator;
use PsCheckout\Core\Order\Validator\OrderAmountValidatorInterface;
use PsCheckout\Core\Order\ValueObject\ValidateOrderData;
use PsCheckout\Core\OrderState\Configuration\OrderStateConfiguration;
use PsCheckout\Core\OrderState\OrderStateException;
use PsCheckout\Core\OrderState\Service\OrderStateMapperInterface;
use PsCheckout\Core\PayPal\Order\Repository\PayPalOrderRepositoryInterface;
use PsCheckout\Infrastructure\Adapter\ContextInterface;
use PsCheckout\Infrastructure\Repository\CurrencyRepositoryInterface;
class CreateValidateOrderDataAction implements CreateValidateOrderDataActionInterface
{
/**
* @var ContextInterface
*/
private $context;
/**
* @var OrderStateMapperInterface
*/
private $orderStateMapper;
/**
* @var CurrencyRepositoryInterface
*/
private $currencyRepository;
/**
* @var OrderAmountValidatorInterface
*/
private $orderAmountValidator;
/**
* @var PayPalOrderRepositoryInterface
*/
private $payPalOrderRepository;
public function __construct(
ContextInterface $context,
OrderStateMapperInterface $orderStateMapper,
CurrencyRepositoryInterface $currencyRepository,
OrderAmountValidatorInterface $orderAmountValidator,
PayPalOrderRepositoryInterface $payPalOrderRepository
) {
$this->context = $context;
$this->orderStateMapper = $orderStateMapper;
$this->currencyRepository = $currencyRepository;
$this->orderAmountValidator = $orderAmountValidator;
$this->payPalOrderRepository = $payPalOrderRepository;
}
/**
* {@inheritDoc}
*/
public function execute(PayPalOrderResponse $payPalOrderResponse): ValidateOrderData
{
$payPalOrder = $this->payPalOrderRepository->getOneBy(['id' => $payPalOrderResponse->getId()]);
$fundingSource = $payPalOrder->getFundingSource();
$cart = $this->context->getCart();
$paidAmount = '';
$transactionId = '';
$orderStateId = '';
$currencyId = (int) $this->context->getCart()->id_currency;
$capture = $payPalOrderResponse->getCapture();
if ($capture) {
$transactionId = $capture['id'];
$paidAmount = $capture['status'] === 'COMPLETED' ? $capture['amount']['value'] : '';
$currencyId = $this->currencyRepository->getIdByIsoCode($capture['amount']['currency_code'], (int) $this->context->getCart()->id_shop);
}
try {
if ($paidAmount) {
switch ($this->orderAmountValidator->validate((string) $paidAmount, (string) $this->context->getCart()->getOrderTotal(true, \Cart::BOTH))) {
case OrderAmountValidator::ORDER_NOT_FULL_PAID:
$orderStateId = $this->orderStateMapper->getIdByKey(OrderStateConfiguration::PS_CHECKOUT_STATE_PARTIALLY_PAID);
break;
case OrderAmountValidator::ORDER_FULL_PAID:
$orderStateId = $this->orderStateMapper->getIdByKey(OrderStateConfiguration::PS_CHECKOUT_STATE_COMPLETED);
break;
case OrderAmountValidator::ORDER_TO_MUCH_PAID:
$orderStateId = $this->orderStateMapper->getIdByKey(OrderStateConfiguration::PS_CHECKOUT_STATE_COMPLETED);
}
} else {
$orderStateId = $this->orderStateMapper->getIdByKey(OrderStateConfiguration::PS_CHECKOUT_STATE_PENDING);
}
} catch (OrderStateException $exception) {
$orderStateId = $this->orderStateMapper->getIdByKey(OrderStateConfiguration::PS_CHECKOUT_STATE_PENDING);
}
$extraVars = [];
// Transaction identifier is needed only when an OrderPayment will be created
// It requires a positive paid amount and an OrderState that's consider the associated order as validated.
if ($paidAmount && $transactionId) {
$extraVars['transaction_id'] = $transactionId;
}
return ValidateOrderData::create(
$cart->id,
$orderStateId,
(float) $paidAmount,
$extraVars,
$currencyId,
$cart->secure_key,
$fundingSource
);
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Action;
use PsCheckout\Api\ValueObject\PayPalOrderResponse;
use PsCheckout\Core\Order\ValueObject\ValidateOrderData;
interface CreateValidateOrderDataActionInterface
{
/**
* @param PayPalOrderResponse $payPalOrderResponse
*
* @return ValidateOrderData
*/
public function execute(PayPalOrderResponse $payPalOrderResponse): ValidateOrderData;
}

View File

@@ -0,0 +1,70 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Action;
use Exception;
use Ps_Checkout;
use PsCheckout\Core\Order\Exception\OrderException;
use PsCheckout\Core\Order\ValueObject\ValidateOrderData;
use PsCheckout\Presentation\Presenter\FundingSource\FundingSourceTranslationProviderInterface;
class ValidateOrderAction implements ValidateOrderActionInterface
{
/**
* @var FundingSourceTranslationProviderInterface
*/
private $fundingSourceTranslationProvider;
/**
* @var Ps_Checkout
*/
private $module;
public function __construct(
FundingSourceTranslationProviderInterface $fundingSourceTranslationProvider,
Ps_Checkout $module
) {
$this->fundingSourceTranslationProvider = $fundingSourceTranslationProvider;
$this->module = $module;
}
/**
* {@inheritDoc}
*/
public function execute(ValidateOrderData $orderData)
{
try {
$this->module->validateOrder(
(int) $orderData->getCartId(),
$orderData->getOrderStateId(),
$orderData->getPaidAmount(),
$this->fundingSourceTranslationProvider->getFundingSourceName($orderData->getFundingSource()),
null,
$orderData->getExtraVars(),
$orderData->getCurrencyId(),
false,
$orderData->getSecureKey()
);
} catch (Exception $exception) {
throw new OrderException(sprintf('Failed to create order from Cart #%s.', var_export($orderData->getCartId(), true)), OrderException::FAILED_ADD_ORDER, $exception);
}
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Action;
use PsCheckout\Core\Order\ValueObject\ValidateOrderData;
interface ValidateOrderActionInterface
{
/**
* @return void
*/
public function execute(ValidateOrderData $orderData);
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,157 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
use PsCheckout\Utility\Common\NumberUtility;
use PsCheckout\Utility\Common\StringUtility;
class AmountBreakdownNode implements AmountBreakdownNodeInterface
{
/**
* @var array
*/
private $cart;
/**
* @var string|null
*/
private $fundingSource;
/**
* {@inheritDoc}
*/
public function build(): array
{
$node = [];
$currencyIsoCode = $this->cart['currency']['iso_code'];
$amountTotal = $this->cart['cart']['totals']['total_including_tax']['amount'];
$breakdownItemTotal = 0;
$breakdownTaxTotal = 0;
$breakdownShipping = $this->cart['cart']['shipping_cost'];
$breakdownHandling = 0;
$breakdownDiscount = 0;
foreach ($this->cart['products'] as $product => $value) {
$sku = '';
$totalWithoutTax = $value['total'];
$totalWithTax = $value['total_wt'];
$totalTax = $totalWithTax - $totalWithoutTax;
$quantity = (string) $value['quantity'];
$unitPriceWithoutTax = NumberUtility::formatAmount($totalWithoutTax / $quantity, $currencyIsoCode);
$unitTax = NumberUtility::formatAmount($totalTax / $quantity, $currencyIsoCode);
$breakdownItemTotal += $unitPriceWithoutTax * $quantity;
$breakdownTaxTotal += $unitTax * $quantity;
$sku = !empty($value['reference']) ? $value['reference'] : (int) $value['id_product'] . '-' . (int) $value['id_product_attribute'];
$paypalItem = [];
$paypalItem['name'] = StringUtility::truncate($value['name'], 127);
$paypalItem['description'] = !empty($value['attributes']) ? StringUtility::truncate($value['attributes'], 127) : '';
$paypalItem['sku'] = StringUtility::truncate($sku, 127);
$paypalItem['unit_amount']['currency_code'] = $currencyIsoCode;
$paypalItem['unit_amount']['value'] = $unitPriceWithoutTax;
$paypalItem['tax']['currency_code'] = $currencyIsoCode;
$paypalItem['tax']['value'] = $unitTax;
$paypalItem['quantity'] = $quantity;
$paypalItem['category'] = $value['is_virtual'] === '1' ? 'DIGITAL_GOODS' : 'PHYSICAL_GOODS';
if ($this->fundingSource === 'pay_upon_invoice' && isset($value['rate'])) {
$paypalItem['tax_rate'] = NumberUtility::formatAmount($value['rate'], $currencyIsoCode);
}
$node['items'][] = $paypalItem;
}
$node['amount']['breakdown'] = [
'item_total' => [
'currency_code' => $currencyIsoCode,
'value' => NumberUtility::formatAmount($breakdownItemTotal, $currencyIsoCode),
],
'shipping' => [
'currency_code' => $currencyIsoCode,
'value' => NumberUtility::formatAmount($breakdownShipping, $currencyIsoCode),
],
'tax_total' => [
'currency_code' => $currencyIsoCode,
'value' => NumberUtility::formatAmount($breakdownTaxTotal, $currencyIsoCode),
],
'insurance' => [
'currency_code' => $currencyIsoCode,
'value' => '0.00',
],
'shipping_discount' => [
'currency_code' => $currencyIsoCode,
'value' => '0.00',
],
];
// set handling cost id needed -> principally used in case of gift_wrapping
if (!empty($this->cart['cart']['subtotals']['gift_wrapping']['amount'])) {
$breakdownHandling += $this->cart['cart']['subtotals']['gift_wrapping']['amount'];
}
$remainderValue = $amountTotal - $breakdownItemTotal - $breakdownTaxTotal - $breakdownShipping - $breakdownHandling;
// In case of rounding issue, if remainder value is negative we use discount value to deduct remainder and if remainder value is positive we use handling value to add remainder
if ($remainderValue < 0) {
$breakdownDiscount += abs($remainderValue);
} else {
$breakdownHandling += $remainderValue;
}
$node['amount']['breakdown']['discount'] = [
'currency_code' => $currencyIsoCode,
'value' => NumberUtility::formatAmount($breakdownDiscount, $currencyIsoCode),
];
$node['amount']['breakdown']['handling'] = [
'currency_code' => $currencyIsoCode,
'value' => NumberUtility::formatAmount($breakdownHandling, $currencyIsoCode),
];
return $node;
}
/**
* {@inheritDoc}
*/
public function setCart(array $cart): self
{
$this->cart = $cart;
return $this;
}
/**
* Set the funding source to determine if tax_rate is required
*
* @param string|null $fundingSource
*
* @return $this
*/
public function setFundingSource($fundingSource): self
{
$this->fundingSource = $fundingSource;
return $this;
}
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
interface AmountBreakdownNodeInterface
{
/**
* Breakdowns cart products and calculates order total
*
* @return array
*/
public function build(): array;
/**
* @param array $cart
*
* @return $this
*/
public function setCart(array $cart): AmountBreakdownNode;
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
use PsCheckout\Infrastructure\Adapter\ConfigurationInterface;
use PsCheckout\Infrastructure\Adapter\LinkInterface;
class ApplicationContextNodeBuilder implements ApplicationContextNodeBuilderInterface
{
/**
* @var bool
*/
private $isExpressCheckout;
/**
* @var bool
*/
private $isVirtualCart;
/**
* @var ConfigurationInterface
*/
private $configuration;
/**
* @var LinkInterface
*/
private $link;
public function __construct(
ConfigurationInterface $configuration,
LinkInterface $link
) {
$this->configuration = $configuration;
$this->link = $link;
}
/**
* {@inheritDoc}
*/
public function build(): array
{
$node['application_context'] = [
'brand_name' => $this->configuration->get('PS_SHOP_NAME'),
'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'),
];
return $node;
}
/**
* {@inheritDoc}
*/
public function setIsExpressCheckout(bool $isExpressCheckout): ApplicationContextNodeBuilder
{
$this->isExpressCheckout = $isExpressCheckout;
return $this;
}
/**
* {@inheritDoc}
*/
public function setIsVirtualCart(bool $isVirtualCart): ApplicationContextNodeBuilder
{
$this->isVirtualCart = $isVirtualCart;
return $this;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
interface ApplicationContextNodeBuilderInterface
{
/**
* @return array
*/
public function build(): array;
/**
* @param bool $isExpressCheckout
*
* @return $this
*/
public function setIsExpressCheckout(bool $isExpressCheckout): ApplicationContextNodeBuilder;
/**
* @param bool $isVirtualCart
*
* @return $this
*/
public function setIsVirtualCart(bool $isVirtualCart): ApplicationContextNodeBuilder;
}

View File

@@ -0,0 +1,137 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
use PsCheckout\Core\Settings\Configuration\PayPalConfiguration;
use PsCheckout\Infrastructure\Adapter\ConfigurationInterface;
use PsCheckout\Utility\Common\NumberUtility;
use PsCheckout\Utility\Common\StringUtility;
class BaseNodeBuilder implements BaseNodeBuilderInterface
{
/**
* @var ConfigurationInterface
*/
private $configuration;
/**
* @var array
*/
private $cart;
/**
* @var bool
*/
private $isVault;
/**
* @var bool
*/
private $isUpdate;
/**
* @var string
*/
private $paypalOrderId;
public function __construct(
ConfigurationInterface $configuration
) {
$this->configuration = $configuration;
}
/**
* {@inheritDoc}
*/
public function build(): array
{
$shopName = $this->configuration->get('PS_SHOP_NAME');
$merchantId = $this->configuration->get(PayPalConfiguration::PS_CHECKOUT_PAYPAL_ID_MERCHANT);
$node = [
'intent' => $this->configuration->get(PayPalConfiguration::PS_CHECKOUT_INTENT) ?? 'CAPTURE',
'custom_id' => (string) $this->cart['cart']['id'],
'invoice_id' => '',
'description' => StringUtility::truncate(
'Checking out with your cart #' . $this->cart['cart']['id'] . ' from ' . $shopName,
127
),
'amount' => [
'currency_code' => $this->cart['currency']['iso_code'],
'value' => NumberUtility::formatAmount($this->cart['cart']['totals']['total_including_tax']['amount'], $this->cart['currency']['iso_code']),
],
'payee' => [
'merchant_id' => $merchantId,
],
'vault' => $this->isVault,
];
if ($this->isUpdate) {
$node['id'] = $this->paypalOrderId;
} else {
$roundType = $this->configuration->get(PayPalConfiguration::PS_ROUND_TYPE);
$roundMode = $this->configuration->get(PayPalConfiguration::PS_PRICE_ROUND_MODE);
$node['roundingConfig'] = $roundType . '-' . $roundMode;
}
return $node;
}
/**
* {@inheritdoc}
*/
public function setCart(array $cart): self
{
$this->cart = $cart;
return $this;
}
/**
* {@inheritdoc}
*/
public function setIsVault(bool $isVault): self
{
$this->isVault = $isVault;
return $this;
}
/**
* {@inheritDoc}
*/
public function setIsUpdate(bool $isUpdate): self
{
$this->isUpdate = $isUpdate;
return $this;
}
/**
* {@inheritDoc}
*/
public function setPaypalOrderId($paypalOrderId): self
{
$this->paypalOrderId = $paypalOrderId;
return $this;
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
interface BaseNodeBuilderInterface
{
/**
* @return array
*/
public function build(): array;
/**
* @param array $cart
*
* @return self
*/
public function setCart(array $cart): BaseNodeBuilder;
/**
* @param bool $isVault
*
* @return self
*/
public function setIsVault(bool $isVault): BaseNodeBuilder;
/**
* @param bool $isUpdate
*
* @return self
*/
public function setIsUpdate(bool $isUpdate): BaseNodeBuilder;
/**
* @param string|null $paypalOrderId
*
* @return self
*/
public function setPaypalOrderId($paypalOrderId): BaseNodeBuilder;
}

View File

@@ -0,0 +1,159 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
use PsCheckout\Core\Settings\Configuration\PayPalConfiguration;
use PsCheckout\Infrastructure\Repository\CountryRepositoryInterface;
use PsCheckout\Infrastructure\Repository\StateRepositoryInterface;
use PsCheckout\Utility\Payload\OrderPayloadUtility;
class CardPaymentSourceNodeBuilder implements CardPaymentSourceNodeBuilderInterface
{
/**
* @var array
*/
private $cart;
/**
* @var string
*/
private $paypalVaultId;
/**
* @var string
*/
private $paypalCustomerId;
/**
* @var bool
*/
private $savePaymentMethod;
/**
* @var PayPalConfiguration
*/
private $paypalConfiguration;
/**
* @var CountryRepositoryInterface
*/
private $countryRepository;
/**
* @var StateRepositoryInterface
*/
private $stateRepository;
public function __construct(
PayPalConfiguration $paypalConfiguration,
CountryRepositoryInterface $countryRepository,
StateRepositoryInterface $stateRepository
) {
$this->paypalConfiguration = $paypalConfiguration;
$this->countryRepository = $countryRepository;
$this->stateRepository = $stateRepository;
}
/**
* {@inheritDoc}
*/
public function build(): array
{
$address = $this->cart['addresses']['invoice'];
$countryIso = $this->countryRepository->getCountryIsoCodeById($address->id_country);
$stateName = $countryIso === 'US' ?
$this->stateRepository->getIsoById($address->id_state)
: $this->stateRepository->getNameById($address->id_state);
$node = [
'payment_source' => [
'card' => [
'name' => $this->cart['addresses']['invoice']->firstname . ' ' . $this->cart['addresses']['invoice']->lastname,
'billing_address' => OrderPayloadUtility::getAddressPortable($address, $countryIso, $stateName),
],
],
];
if ($this->paypalConfiguration->is3dSecureEnabled()) {
$node['payment_source']['card']['attributes']['verification']['method'] = $this->paypalConfiguration->getCardFieldsContingencies();
}
if ($this->paypalVaultId) {
unset($node['payment_source']['card']['billing_address']);
$node['payment_source']['card']['vault_id'] = $this->paypalVaultId;
}
if ($this->paypalCustomerId) {
$node['payment_source']['card']['attributes']['customer'] = [
'id' => $this->paypalCustomerId,
];
}
if ($this->savePaymentMethod) {
$node['payment_source']['card']['attributes']['vault'] = [
'store_in_vault' => 'ON_SUCCESS',
];
}
return $node;
}
/**
* {@inheritDoc}
*/
public function setCart(array $cart): self
{
$this->cart = $cart;
return $this;
}
/**
* {@inheritDoc}
*/
public function setPaypalVaultId($paypalVaultId): self
{
$this->paypalVaultId = $paypalVaultId;
return $this;
}
/**
* {@inheritDoc}
*/
public function setPaypalCustomerId($paypalCustomerId): self
{
$this->paypalCustomerId = $paypalCustomerId;
return $this;
}
/**
* {@inheritDoc}
*/
public function setSavePaymentMethod(bool $savePaymentMethod): self
{
$this->savePaymentMethod = $savePaymentMethod;
return $this;
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
interface CardPaymentSourceNodeBuilderInterface
{
/**
* @return array
*/
public function build(): array;
/**
* @param array $cart
*
* @return self
*/
public function setCart(array $cart);
/**
* @param string|null $paypalVaultId
*
* @return self
*/
public function setPaypalVaultId($paypalVaultId);
/**
* @param string|null $paypalCustomerId
*
* @return self
*/
public function setPaypalCustomerId($paypalCustomerId);
/**
* @param bool $savePaymentMethod
*
* @return self
*/
public function setSavePaymentMethod(bool $savePaymentMethod);
}

View File

@@ -0,0 +1,58 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
use PsCheckout\Core\Settings\Configuration\PayPalConfiguration;
class GooglePayPaymentSourceNodeBuilder implements GooglePayPaymentSourceNodeBuilderInterface
{
/**
* @var PayPalConfiguration
*/
private $payPalConfiguration;
public function __construct(PayPalConfiguration $payPalConfiguration)
{
$this->payPalConfiguration = $payPalConfiguration;
}
/**
* {@inheritDoc}
*/
public function build(): array
{
if (!$this->payPalConfiguration->is3dSecureEnabled()) {
return [];
}
return [
'payment_source' => [
'google_pay' => [
'attributes' => [
'verification' => [
'method' => $this->payPalConfiguration->getCardFieldsContingencies(),
],
],
],
],
];
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
interface GooglePayPaymentSourceNodeBuilderInterface
{
/**
* @return array
*/
public function build(): array;
}

View File

@@ -0,0 +1,96 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
class PayPalPaymentSourceNodeBuilder implements PayPalPaymentSourceNodeBuilderInterface
{
/**
* @var string
*/
private $paypalVaultId;
/**
* @var string
*/
private $paypalCustomerId;
/**
* @var bool
*/
private $savePaymentMethod;
/**
* {@inheritDoc}
*/
public function build(): array
{
$data = [];
if ($this->savePaymentMethod) {
$data['attributes']['vault'] = [
'store_in_vault' => 'ON_SUCCESS',
'usage_pattern' => 'IMMEDIATE',
'usage_type' => 'MERCHANT',
'customer_type' => 'CONSUMER',
'permit_multiple_payment_tokens' => false,
];
if ($this->paypalCustomerId) {
$data['attributes']['customer'] = [
'id' => $this->paypalCustomerId,
];
}
}
if (empty($data)) {
return [];
}
return [
'payment_source' => [
'paypal' => $data,
],
];
}
/** {@inheritDoc} */
public function setPaypalVaultId($paypalVaultId): self
{
$this->paypalVaultId = $paypalVaultId;
return $this;
}
/** {@inheritDoc} */
public function setPaypalCustomerId($paypalCustomerId): self
{
$this->paypalCustomerId = $paypalCustomerId;
return $this;
}
/** {@inheritDoc} */
public function setSavePaymentMethod(bool $savePaymentMethod): self
{
$this->savePaymentMethod = $savePaymentMethod;
return $this;
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
interface PayPalPaymentSourceNodeBuilderInterface
{
/**
* @return array
*/
public function build(): array;
/**
* @param string|null $paypalVaultId
*
* @return PayPalPaymentSourceNodeBuilder
*/
public function setPaypalVaultId($paypalVaultId): PayPalPaymentSourceNodeBuilder;
/**
* @param string|null $paypalCustomerId
*
* @return PayPalPaymentSourceNodeBuilder
*/
public function setPaypalCustomerId($paypalCustomerId): PayPalPaymentSourceNodeBuilder;
/**
* @param bool $savePaymentMethod
*
* @return PayPalPaymentSourceNodeBuilder
*/
public function setSavePaymentMethod(bool $savePaymentMethod): PayPalPaymentSourceNodeBuilder;
}

View File

@@ -0,0 +1,176 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
use libphonenumber\PhoneNumberType;
use libphonenumber\PhoneNumberUtil;
use PsCheckout\Infrastructure\Adapter\ValidateInterface;
use PsCheckout\Infrastructure\Repository\CountryRepositoryInterface;
use PsCheckout\Infrastructure\Repository\StateRepositoryInterface;
use PsCheckout\Utility\Payload\OrderPayloadUtility;
use Psr\Log\LoggerInterface;
class PayerNodeBuilder implements PayerNodeBuilderInterface
{
/**
* @var array
*/
private $cart;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var ValidateInterface
*/
private $validate;
/**
* @var CountryRepositoryInterface
*/
private $countryRepository;
/**
* @var StateRepositoryInterface
*/
private $stateRepository;
public function __construct(
LoggerInterface $logger,
ValidateInterface $validate,
CountryRepositoryInterface $countryRepository,
StateRepositoryInterface $stateRepository
) {
$this->logger = $logger;
$this->validate = $validate;
$this->countryRepository = $countryRepository;
$this->stateRepository = $stateRepository;
}
/**
* {@inheritDoc}
*/
public function build()
{
$node = [];
// Ensure address exists before accessing properties
if (!isset($this->cart['addresses']['invoice'])) {
$this->logger->warning('Invoice address is missing in the cart.');
return $node;
}
$invoiceAddress = $this->cart['addresses']['invoice'];
$payerCountryIsoCode = isset($invoiceAddress->id_country)
? $this->countryRepository->getCountryIsoCodeById($invoiceAddress->id_country)
: '';
if (isset($invoiceAddress->id_state)) {
$stateName = $payerCountryIsoCode === 'US' ?
$this->stateRepository->getIsoById($invoiceAddress->id_state)
: $this->stateRepository->getNameById($invoiceAddress->id_state);
} else {
$stateName = '';
}
$node['payer'] = [
'name' => [
'given_name' => isset($invoiceAddress->firstname) ? (string) $invoiceAddress->firstname : '',
'surname' => isset($invoiceAddress->lastname) ? (string) $invoiceAddress->lastname : '',
],
'address' => OrderPayloadUtility::getAddressPortable(
$invoiceAddress,
$payerCountryIsoCode,
$stateName
),
];
// Validate email
if (isset($this->cart['customer']->email) && $this->validate->isEmail($this->cart['customer']->email)) {
$node['payer']['email_address'] = (string) $this->cart['customer']->email;
}
// Add optional birthdate if provided
if (!empty($this->cart['customer']->birthday) && $this->cart['customer']->birthday !== '0000-00-00') {
$node['payer']['birth_date'] = (string) $this->cart['customer']->birthday;
}
// Get phone number (prioritize landline, then mobile)
$phone = !empty($invoiceAddress->phone) ? $invoiceAddress->phone : (!empty($invoiceAddress->phone_mobile) ? $invoiceAddress->phone_mobile : '');
if (!empty($phone)) {
try {
$phoneUtil = PhoneNumberUtil::getInstance();
$parsedPhone = $phoneUtil->parse($phone, $payerCountryIsoCode);
if ($phoneUtil->isValidNumber($parsedPhone)) {
$node['payer']['phone'] = [
'phone_number' => [
'national_number' => $parsedPhone->getNationalNumber(),
],
'phone_type' => $this->getPhoneType($phoneUtil->getNumberType($parsedPhone)),
];
}
} catch (\libphonenumber\NumberParseException $exception) {
$this->logger->warning('Invalid phone number format.', [
'id_cart' => isset($this->cart['cart']['id']) ? (int) $this->cart['cart']['id'] : null,
'address_id' => isset($invoiceAddress->id) ? (int) $invoiceAddress->id : null,
'phone' => $phone,
'exception' => $exception,
]);
} catch (\Exception $exception) {
$this->logger->warning('Unexpected error formatting phone number.', [
'id_cart' => isset($this->cart['cart']['id']) ? (int) $this->cart['cart']['id'] : null,
'address_id' => isset($invoiceAddress->id) ? (int) $invoiceAddress->id : null,
'phone' => $phone,
'exception' => $exception,
]);
}
}
return $node;
}
/**
* {@inheritDoc}
*/
public function setCart(array $cart)
{
$this->cart = $cart;
return $this;
}
private function getPhoneType($phoneType)
{
switch ($phoneType) {
case PhoneNumberType::MOBILE:
return 'MOBILE';
case PhoneNumberType::PAGER:
return 'PAGER';
default:
return 'OTHER';
}
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
interface PayerNodeBuilderInterface
{
public function build();
/**
* @param array $cart
*
* @return $this
*/
public function setCart(array $cart);
}

View File

@@ -0,0 +1,111 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node\PaymentSource;
use PsCheckout\Core\Settings\Configuration\PayPalConfiguration;
class VenmoPaymentSourceNodeBuilder implements VenmoPaymentSourceNodeBuilderInterface
{
/**
* @var string
*/
private $paypalVaultId;
/**
* @var string
*/
private $paypalCustomerId;
/**
* @var bool
*/
private $savePaymentMethod;
/**
* @var array
*/
private $cart;
/**
* {@inheritDoc}
*/
public function build(): array
{
$data = ['email_address' => (string) $this->cart['customer']->email];
if ($this->savePaymentMethod) {
$data['attributes']['vault'] = [
'store_in_vault' => 'ON_SUCCESS',
'usage_pattern' => 'IMMEDIATE',
'usage_type' => 'MERCHANT',
'customer_type' => 'CONSUMER',
'permit_multiple_payment_tokens' => false,
];
if ($this->paypalCustomerId) {
$data['attributes']['customer'] = [
'id' => $this->paypalCustomerId,
];
}
}
if ($this->paypalVaultId) {
$data['vault_id'] = $this->paypalVaultId;
}
return [
'payment_source' => [
'venmo' => $data,
],
];
}
/** {@inheritDoc} */
public function setPaypalVaultId($paypalVaultId): self
{
$this->paypalVaultId = $paypalVaultId;
return $this;
}
/** {@inheritDoc} */
public function setPaypalCustomerId($paypalCustomerId): self
{
$this->paypalCustomerId = $paypalCustomerId;
return $this;
}
/** {@inheritDoc} */
public function setSavePaymentMethod(bool $savePaymentMethod): self
{
$this->savePaymentMethod = $savePaymentMethod;
return $this;
}
/** {@inheritDoc} */
public function setCart(array $cart)
{
$this->cart = $cart;
return $this;
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node\PaymentSource;
interface VenmoPaymentSourceNodeBuilderInterface
{
/**
* @return array
*/
public function build(): array;
/**
* @param string|null $paypalVaultId
*
* @return VenmoPaymentSourceNodeBuilder
*/
public function setPaypalVaultId($paypalVaultId): VenmoPaymentSourceNodeBuilder;
/**
* @param string|null $paypalCustomerId
*
* @return VenmoPaymentSourceNodeBuilder
*/
public function setPaypalCustomerId($paypalCustomerId): VenmoPaymentSourceNodeBuilder;
/**
* @param bool $savePaymentMethod
*
* @return VenmoPaymentSourceNodeBuilder
*/
public function setSavePaymentMethod(bool $savePaymentMethod): VenmoPaymentSourceNodeBuilder;
/**
* @param array $cart
*
* @return $this
*/
public function setCart(array $cart);
}

View File

@@ -0,0 +1,224 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
use libphonenumber\PhoneNumberUtil;
use PsCheckout\Infrastructure\Adapter\ValidateInterface;
use PsCheckout\Infrastructure\Repository\CountryRepositoryInterface;
use PsCheckout\Utility\Payload\OrderPayloadUtility;
use Psr\Log\LoggerInterface;
class PuiPaymentSourceNodeBuilder implements PuiPaymentSourceNodeBuilderInterface
{
/**
* @var array
*/
private $cart;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var ValidateInterface
*/
private $validate;
/**
* @var CountryRepositoryInterface
*/
private $countryRepository;
/**
* @var null|string
*/
private $birthDate;
public function __construct(
LoggerInterface $logger,
ValidateInterface $validate,
CountryRepositoryInterface $countryRepository
) {
$this->logger = $logger;
$this->validate = $validate;
$this->countryRepository = $countryRepository;
}
/**
* {@inheritDoc}
*/
public function build(): array
{
if (!isset($this->cart['addresses']['invoice'])) {
$this->logger->warning('Invoice address is missing in the cart for PUI payment.');
return [];
}
$invoiceAddress = $this->cart['addresses']['invoice'];
$customer = $this->cart['customer'] ?? null;
if (!$customer) {
$this->logger->warning('Customer is missing in the cart for PUI payment.');
return [];
}
$countryIsoCode = isset($invoiceAddress->id_country)
? $this->countryRepository->getCountryIsoCodeById($invoiceAddress->id_country)
: '';
$puiData = [];
$puiData['name'] = [
'given_name' => isset($invoiceAddress->firstname) ? (string) $invoiceAddress->firstname : '',
'surname' => isset($invoiceAddress->lastname) ? (string) $invoiceAddress->lastname : '',
];
if (isset($customer->email) && $this->validate->isEmail($customer->email)) {
$puiData['email'] = (string) $customer->email;
} else {
$this->logger->warning('Valid email is required for PUI payment.');
return [];
}
$phone = !empty($invoiceAddress->phone) ? $invoiceAddress->phone : (!empty($invoiceAddress->phone_mobile) ? $invoiceAddress->phone_mobile : '');
if (!empty($phone)) {
try {
$phoneUtil = PhoneNumberUtil::getInstance();
$parsedPhone = $phoneUtil->parse($phone, $countryIsoCode);
if ($phoneUtil->isValidNumber($parsedPhone)) {
$puiData['phone'] = [
'national_number' => (string) $parsedPhone->getNationalNumber(),
'country_code' => (string) $parsedPhone->getCountryCode(),
];
}
} catch (\libphonenumber\NumberParseException $exception) {
$this->logger->warning('Invalid phone number format for PUI payment.', [
'id_cart' => isset($this->cart['cart']['id']) ? (int) $this->cart['cart']['id'] : null,
'phone' => $phone,
'exception' => $exception,
]);
return [];
} catch (\Exception $exception) {
$this->logger->warning('Unexpected error formatting phone number for PUI payment.', [
'id_cart' => isset($this->cart['cart']['id']) ? (int) $this->cart['cart']['id'] : null,
'phone' => $phone,
'exception' => $exception,
]);
return [];
}
} else {
$this->logger->warning('Phone number is required for PUI payment.');
return [];
}
$billingAddress = OrderPayloadUtility::getAddressPortable(
$invoiceAddress,
$countryIsoCode,
''
);
unset($billingAddress['admin_area_1']);
if (empty($billingAddress)) {
$this->logger->warning('Billing address is required for PUI payment.');
return [];
}
$puiData['billing_address'] = $billingAddress;
if (isset($this->birthDate) && !empty($this->birthDate)) {
$birthDate = $this->birthDate;
if (is_string($birthDate) && preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $birthDate, $matches)) {
$puiData['birth_date'] = $birthDate;
} else {
$this->logger->warning('Invalid birth_date format for PUI payment. Expected YYYY-MM-DD.', [
'id_cart' => isset($this->cart['cart']['id']) ? (int) $this->cart['cart']['id'] : null,
'birth_date' => $birthDate,
]);
}
}
$experienceContext = [];
if (isset($puiData['phone']['national_number']) && isset($puiData['phone']['country_code'])) {
$experienceContext['customer_service_instructions'] = [
sprintf('Customer service phone is +%s %s.', $puiData['phone']['country_code'], $puiData['phone']['national_number']),
];
}
$locale = $this->getLocale();
if (!empty($locale)) {
$experienceContext['locale'] = $locale;
}
if (!empty($experienceContext)) {
$puiData['experience_context'] = $experienceContext;
}
return [
'payment_source' => [
'pay_upon_invoice' => $puiData,
],
];
}
/**
* {@inheritDoc}
*/
public function setCart(array $cart)
{
$this->cart = $cart;
return $this;
}
public function setBirthDate($birthDate): self
{
$this->birthDate = $birthDate;
return $this;
}
/**
* @return string
*/
private function getLocale(): string
{
if (isset($this->cart['language']->locale) && !empty($this->cart['language']->locale)) {
return $this->cart['language']->locale;
}
$this->logger->warning('Language locale is missing in the cart for PUI payment.');
return '';
}
}

View File

@@ -0,0 +1,42 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
interface PuiPaymentSourceNodeBuilderInterface
{
/**
* Build the Pay upon Invoice payment source node
*
* @return array
*/
public function build(): array;
/**
* Set the cart data
*
* @param array $cart
*
* @return self
*/
public function setCart(array $cart);
public function setBirthDate($birthDate);
}

View File

@@ -0,0 +1,94 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
use PsCheckout\Core\Exception\PsCheckoutException;
use PsCheckout\Infrastructure\Repository\CountryRepositoryInterface;
use PsCheckout\Infrastructure\Repository\GenderRepositoryInterface;
use PsCheckout\Infrastructure\Repository\StateRepositoryInterface;
use PsCheckout\Utility\Payload\OrderPayloadUtility;
class ShippingNodeBuilder implements ShippingNodeBuilderInterface
{
/**
* @var CountryRepositoryInterface
*/
private $countryRepository;
/**
* @var StateRepositoryInterface
*/
private $stateRepository;
/**
* @var array
*/
private $cart;
public function __construct(
CountryRepositoryInterface $countryRepository,
StateRepositoryInterface $stateRepository
) {
$this->countryRepository = $countryRepository;
$this->stateRepository = $stateRepository;
}
/**
* {@inheritDoc}
*/
public function build(): array
{
if (null === $this->cart || !isset($this->cart['addresses']['shipping'])) {
throw new PsCheckoutException('Cart data must be set before building order payload');
}
if ($this->cart['cart']['is_virtual']) {
return [];
}
$address = $this->cart['addresses']['shipping'];
$countryIso = $this->countryRepository->getCountryIsoCodeById($address->id_country);
$stateName = $countryIso === 'US' ?
$this->stateRepository->getIsoById($address->id_state)
: $this->stateRepository->getNameById($address->id_state);
return [
'shipping' => [
'name' => [
'full_name' => $this->cart['addresses']['shipping']->firstname . ' ' . $this->cart['addresses']['shipping']->lastname,
],
'address' => OrderPayloadUtility::getAddressPortable($address, $countryIso, $stateName),
],
];
}
/**
* {@inheritDoc}
*/
public function setCart(array $cart): self
{
$this->cart = $cart;
return $this;
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
interface ShippingNodeBuilderInterface
{
/**
* @return array
*/
public function build(): array;
/**
* @param array $cart
*
* @return self
*/
public function setCart(array $cart): ShippingNodeBuilder;
}

View File

@@ -0,0 +1,115 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
use PsCheckout\Infrastructure\Repository\CountryRepositoryInterface;
use PsCheckout\Infrastructure\Repository\StateRepositoryInterface;
use PsCheckout\Utility\Payload\OrderPayloadUtility;
class SupplementaryDataNodeBuilder implements SupplementaryDataNodeBuilderInterface
{
/**
* @var array
*/
private $cart;
/**
* @var CountryRepositoryInterface
*/
private $countryRepository;
/**
* @var StateRepositoryInterface
*/
private $stateRepository;
public function __construct(
CountryRepositoryInterface $countryRepository,
StateRepositoryInterface $stateRepository
) {
$this->countryRepository = $countryRepository;
$this->stateRepository = $stateRepository;
}
/**
* @var array
*/
private $payload;
/**
* {@inheritDoc}
*/
public function build()
{
$address = $this->cart['addresses']['invoice'];
$countryIso = $this->countryRepository->getCountryIsoCodeById($address->id_country);
$stateName = $countryIso === 'US' ?
$this->stateRepository->getIsoById($address->id_state)
: $this->stateRepository->getNameById($address->id_state);
$node = [
'supplementary_data' => [
'card' => [
'level_2' => [
'tax_total' => $this->payload['amount']['breakdown']['tax_total'],
],
'level_3' => [
'duty_amount' => [
'currency_code' => $this->payload['amount']['currency_code'],
'value' => $this->payload['amount']['value'],
],
'discount_amount' => $this->payload['amount']['breakdown']['discount'],
'line_items' => $this->payload['items'],
],
],
],
];
if (!$this->cart['cart']['is_virtual']) {
$node['supplementary_data']['card']['level_3']['shipping_address'] = OrderPayloadUtility::getAddressPortable($address, $countryIso, $stateName);
$node['supplementary_data']['card']['level_3']['shipping_amount'] = $this->payload['amount']['breakdown']['shipping'];
}
return $node;
}
/**
* {@inheritDoc}
*/
public function setPayload(array $payload): self
{
$this->payload = $payload;
return $this;
}
/**
* {@inheritDoc}
*/
public function setCart(array $cart): self
{
$this->cart = $cart;
return $this;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder\Node;
interface SupplementaryDataNodeBuilderInterface
{
/**
* @return array
*/
public function build();
/**
* @param array $payload
*
* @return SupplementaryDataNodeBuilder
*/
public function setPayload(array $payload): SupplementaryDataNodeBuilder;
/**
* @param array $cart
*
* @return SupplementaryDataNodeBuilder
*/
public function setCart(array $cart): SupplementaryDataNodeBuilder;
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,391 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder;
use PsCheckout\Core\Exception\PsCheckoutException;
use PsCheckout\Core\Order\Builder\Node\AmountBreakdownNodeInterface;
use PsCheckout\Core\Order\Builder\Node\ApplicationContextNodeBuilderInterface;
use PsCheckout\Core\Order\Builder\Node\BaseNodeBuilderInterface;
use PsCheckout\Core\Order\Builder\Node\CardPaymentSourceNodeBuilderInterface;
use PsCheckout\Core\Order\Builder\Node\GooglePayPaymentSourceNodeBuilderInterface;
use PsCheckout\Core\Order\Builder\Node\PayerNodeBuilderInterface;
use PsCheckout\Core\Order\Builder\Node\PaymentSource\VenmoPaymentSourceNodeBuilderInterface;
use PsCheckout\Core\Order\Builder\Node\PayPalPaymentSourceNodeBuilderInterface;
use PsCheckout\Core\Order\Builder\Node\PuiPaymentSourceNodeBuilderInterface;
use PsCheckout\Core\Order\Builder\Node\ShippingNodeBuilderInterface;
use PsCheckout\Core\Order\Builder\Node\SupplementaryDataNodeBuilderInterface;
class OrderPayloadBuilder implements OrderPayloadBuilderInterface
{
/** @var array */
private $cart;
/** @var string */
private $fundingSource;
/** @var string */
private $paypalOrderId;
/** @var string */
private $paypalCustomerId;
/** @var string */
private $paypalVaultId;
/** @var bool */
private $savePaymentMethod = false;
/** @var bool */
private $isUpdate = false;
/** @var bool */
private $expressCheckout = false;
/** @var bool */
private $isVault = false;
/** @var bool */
private $isCard = false;
/** @var array */
private $payload = [];
/** @var BaseNodeBuilderInterface */
private $baseNodeBuilder;
/** @var AmountBreakdownNodeInterface */
private $amountBreakdownNodeBuilder;
/** @var ShippingNodeBuilderInterface */
private $shippingNodeBuilder;
/** @var PayerNodeBuilderInterface */
private $payerNodeBuilder;
/** @var ApplicationContextNodeBuilderInterface */
private $applicationContextNodeBuilder;
/** @var CardPaymentSourceNodeBuilderInterface */
private $cardPaymentSourceNodeBuilder;
/** @var SupplementaryDataNodeBuilderInterface */
private $supplementaryDataNodeBuilder;
/** @var PayPalPaymentSourceNodeBuilderInterface */
private $payPalPaymentSourceNodeBuilder;
/** @var GooglePayPaymentSourceNodeBuilderInterface */
private $googlePayPaymentSourceNodeBuilder;
/** @var VenmoPaymentSourceNodeBuilderInterface */
private $venmoPaymentSourceNodeBuilder;
/** @var PuiPaymentSourceNodeBuilderInterface */
private $puiPaymentSourceNodeBuilder;
/** @var PuiPaymentSourceNodeBuilderInterface */
private $birthDate;
public function __construct(
BaseNodeBuilderInterface $baseNodeBuilder,
AmountBreakdownNodeInterface $amountBreakdownNodeBuilder,
ShippingNodeBuilderInterface $shippingNodeBuilder,
PayerNodeBuilderInterface $payerNodeBuilder,
CardPaymentSourceNodeBuilderInterface $cardPaymentSourceNodeBuilder,
SupplementaryDataNodeBuilderInterface $supplementaryDataNodeBuilder,
ApplicationContextNodeBuilderInterface $applicationContextNodeBuilder,
PayPalPaymentSourceNodeBuilderInterface $payPalPaymentSourceNodeBuilder,
GooglePayPaymentSourceNodeBuilderInterface $googlePayPaymentSourceNodeBuilder,
VenmoPaymentSourceNodeBuilderInterface $venmoPaymentSourceNodeBuilder,
PuiPaymentSourceNodeBuilderInterface $puiPaymentSourceNodeBuilder
) {
$this->baseNodeBuilder = $baseNodeBuilder;
$this->amountBreakdownNodeBuilder = $amountBreakdownNodeBuilder;
$this->shippingNodeBuilder = $shippingNodeBuilder;
$this->payerNodeBuilder = $payerNodeBuilder;
$this->cardPaymentSourceNodeBuilder = $cardPaymentSourceNodeBuilder;
$this->supplementaryDataNodeBuilder = $supplementaryDataNodeBuilder;
$this->applicationContextNodeBuilder = $applicationContextNodeBuilder;
$this->payPalPaymentSourceNodeBuilder = $payPalPaymentSourceNodeBuilder;
$this->googlePayPaymentSourceNodeBuilder = $googlePayPaymentSourceNodeBuilder;
$this->venmoPaymentSourceNodeBuilder = $venmoPaymentSourceNodeBuilder;
$this->puiPaymentSourceNodeBuilder = $puiPaymentSourceNodeBuilder;
}
/** {@inheritDoc} */
public function build(bool $isFullPayload = true): array
{
$this->checkPaypalOrderIdWhenUpdate();
// Build the base payload
$this->payload = $this->buildBasePayload();
// Prepare optional payload elements
$optionalPayload = $this->buildOptionalPayload($isFullPayload);
// Merge the optional payload elements into the main payload
$this->mergePayload($optionalPayload);
return $this->payload;
}
/**
* Builds the base payload using initial settings.
*
* @return array the base payload array
*/
private function buildBasePayload(): array
{
return $this->baseNodeBuilder
->setCart($this->cart)
->setIsVault($this->isVault)
->setIsUpdate($this->isUpdate)
->setPaypalOrderId($this->paypalOrderId)
->build();
}
/**
* Builds the optional payload elements based on various conditions.
*
* @param bool $isFullPayload whether to include the full payload or not
*
* @return array the optional payload elements
*/
private function buildOptionalPayload(bool $isFullPayload): array
{
$optionalPayload = [];
if ($isFullPayload) {
$amountBreakdown = $this->amountBreakdownNodeBuilder
->setCart($this->cart)
->setFundingSource($this->fundingSource)
->build();
if (!empty($amountBreakdown)) {
$this->payload = array_replace_recursive($this->payload, $amountBreakdown);
}
}
if (!$this->expressCheckout || $this->isUpdate) {
$optionalPayload[] = $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) {
$optionalPayload[] = $this->buildCardPaymentSource();
$optionalPayload[] = $this->buildSupplementaryData();
}
if ($isFullPayload) {
$optionalPayload[] = $this->buildPaymentSource();
}
// Add processing_instruction for PUI orders
if ($this->fundingSource === 'pay_upon_invoice' && !$this->isUpdate) {
$optionalPayload[] = [
'processing_instruction' => 'ORDER_COMPLETE_ON_PAYMENT_APPROVAL'];
}
return $optionalPayload;
}
/**
* Builds the card payment source payload element.
*
* @return array the card payment source payload
*/
private function buildCardPaymentSource(): array
{
return $this->cardPaymentSourceNodeBuilder
->setCart($this->cart)
->setPaypalVaultId($this->paypalVaultId)
->setPaypalCustomerId($this->paypalCustomerId)
->setSavePaymentMethod($this->savePaymentMethod)
->build();
}
/**
* Builds the supplementary data payload element.
*
* @return array the supplementary data payload
*/
private function buildSupplementaryData(): array
{
return $this->supplementaryDataNodeBuilder
->setCart($this->cart)
->setPayload($this->payload)
->build();
}
/**
* Merges optional payload elements into the main payload.
*
* @param array $optionalPayload the optional payload elements to merge
*/
private function mergePayload(array $optionalPayload)
{
foreach ($optionalPayload as $node) {
if (!empty($node)) {
$this->payload = array_replace_recursive($this->payload, $node);
}
}
}
/**
* Ensures PayPal order ID is set when updating.
*
* @throws PsCheckoutException
*/
private function checkPaypalOrderIdWhenUpdate()
{
if ($this->isUpdate && empty($this->paypalOrderId)) {
throw new PsCheckoutException('PayPal order ID is required when building payload for updating an order');
}
}
/**
* Builds the payment source node based on the funding source.
*
* @return array|null the payment source node
*/
private function buildPaymentSource()
{
switch ($this->fundingSource) {
case 'google_pay':
return $this->googlePayPaymentSourceNodeBuilder->build();
case 'paypal':
$this->payPalPaymentSourceNodeBuilder->setSavePaymentMethod($this->savePaymentMethod)
->setPaypalCustomerId($this->paypalCustomerId)
->setPaypalVaultId($this->paypalVaultId);
return $this->payPalPaymentSourceNodeBuilder->build();
case 'venmo':
return $this->venmoPaymentSourceNodeBuilder->setSavePaymentMethod($this->savePaymentMethod)
->setCart($this->cart)
->setPaypalCustomerId($this->paypalCustomerId)
->setPaypalVaultId($this->paypalVaultId)
->build();
case 'pay_upon_invoice':
return $this->puiPaymentSourceNodeBuilder->setCart($this->cart)
->setBirthDate($this->birthDate)
->build();
}
return null;
}
/** {@inheritDoc} */
public function setCart(array $cart): self
{
$this->cart = $cart;
return $this;
}
/** {@inheritDoc} */
public function setIsUpdate(bool $isUpdate): self
{
$this->isUpdate = $isUpdate;
return $this;
}
/** {@inheritDoc} */
public function setIsExpressCheckout(bool $isExpressCheckout): self
{
$this->expressCheckout = $isExpressCheckout;
return $this;
}
/** {@inheritDoc} */
public function setSavePaymentMethod(bool $savePaymentMethod): self
{
$this->savePaymentMethod = $savePaymentMethod;
return $this;
}
/** {@inheritDoc} */
public function setFundingSource(string $fundingSource): self
{
$this->fundingSource = $fundingSource;
return $this;
}
/** {@inheritDoc} */
public function setPaypalCustomerId(string $paypalCustomerId): self
{
$this->paypalCustomerId = $paypalCustomerId;
return $this;
}
/** {@inheritDoc} */
public function setPaypalVaultId(string $paypalVaultId): self
{
$this->paypalVaultId = $paypalVaultId;
return $this;
}
/** {@inheritDoc} */
public function setPaypalOrderId(string $paypalOrderId): self
{
$this->paypalOrderId = $paypalOrderId;
return $this;
}
/** {@inheritDoc} */
public function setIsVault(bool $isVault): self
{
$this->isVault = $isVault;
return $this;
}
/** {@inheritDoc} */
public function setIsCard(bool $isCard): self
{
$this->isCard = $isCard;
return $this;
}
/** {@inheritDoc} */
public function setCustomerBirthDay($birthDate): self
{
$this->birthDate = $birthDate;
return $this;
}
}

View File

@@ -0,0 +1,94 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Builder;
use PsCheckout\Core\Exception\PsCheckoutException;
interface OrderPayloadBuilderInterface
{
/**
* Builds the order payload.
*
* @param bool $isFullPayload whether to build a full payload (true) or minimal payload (false)
*
* @return array the constructed payload
*
* @throws PsCheckoutException if required fields are missing
*/
public function build(bool $isFullPayload = true): array;
/**
* @param array $cart
*/
public function setCart(array $cart);
/**
* @param bool $isUpdate
*/
public function setIsUpdate(bool $isUpdate);
/**
* @param bool $isExpressCheckout
*
* @return OrderPayloadBuilder
*/
public function setIsExpressCheckout(bool $isExpressCheckout): OrderPayloadBuilder;
/**
* @param bool $savePaymentMethod
*/
public function setSavePaymentMethod(bool $savePaymentMethod): OrderPayloadBuilder;
/**
* @param string $fundingSource
*/
public function setFundingSource(string $fundingSource): OrderPayloadBuilder;
/**
* @param string $paypalCustomerId
*/
public function setPaypalCustomerId(string $paypalCustomerId): OrderPayloadBuilder;
/**
* @param string $paypalVaultId
*/
public function setPaypalVaultId(string $paypalVaultId): OrderPayloadBuilder;
/**
* @param string $paypalOrderId
*/
public function setPaypalOrderId(string $paypalOrderId): OrderPayloadBuilder;
/**
* @param bool $isCard
*/
public function setIsCard(bool $isCard): OrderPayloadBuilder;
/**
* @param bool $isVault
*/
public function setIsVault(bool $isVault): OrderPayloadBuilder;
/**
* @param ?string $birthDate
*/
public function setCustomerBirthDay($birthDate): OrderPayloadBuilder;
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,295 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Exception\Handler;
use PsCheckout\Api\Http\Exception\PayPalException;
use PsCheckout\Core\Exception\PsCheckoutException;
use PsCheckout\Infrastructure\Action\CustomerNotifyActionInterface;
use PsCheckout\Presentation\TranslatorInterface;
use Psr\Log\LoggerInterface;
class OrderCreationExceptionHandler implements OrderCreationExceptionHandlerInterface
{
/**
* @var TranslatorInterface
*/
private $translator;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var CustomerNotifyActionInterface
*/
private $customerNotifyAction;
public function __construct(
TranslatorInterface $translator,
LoggerInterface $logger,
CustomerNotifyActionInterface $customerNotifyAction
) {
$this->translator = $translator;
$this->logger = $logger;
$this->customerNotifyAction = $customerNotifyAction;
}
/**
* {@inheritDoc}
*/
public function handle(\Exception $exception, string $paypalOrderId)
{
$exceptionMessageForCustomer = $this->translator->trans('Error processing payment, you could have been charged. Please check your order history in your account to check the status of the order or please contact our customer service to know more.');
$notifyCustomerService = true;
$exceptionClass = get_class($exception);
$httpCode = 500;
if (PsCheckoutException::class === $exceptionClass) {
switch ($exception->getCode()) {
case PsCheckoutException::PAYPAL_PAYMENT_CARD_ERROR:
$exceptionMessageForCustomer = $this->translator->trans('The transaction failed. Please try a different card.');
$notifyCustomerService = false;
break;
case PsCheckoutException::PAYPAL_PAYMENT_CAPTURE_DECLINED:
$exceptionMessageForCustomer = $this->translator->trans('The transaction was refused.');
$notifyCustomerService = false;
break;
case PsCheckoutException::PRESTASHOP_PAYMENT_UNAVAILABLE:
$exceptionMessageForCustomer = $this->translator->trans('This payment method is unavailable');
break;
case PsCheckoutException::PSCHECKOUT_HTTP_EXCEPTION:
$exceptionMessageForCustomer = $this->translator->trans('Unable to call API');
break;
case PsCheckoutException::PAYPAL_ORDER_IDENTIFIER_MISSING:
$exceptionMessageForCustomer = $this->translator->trans('PayPal order identifier is missing');
$notifyCustomerService = false;
break;
case PsCheckoutException::PAYPAL_PAYMENT_METHOD_MISSING:
$exceptionMessageForCustomer = $this->translator->trans('PayPal payment method is missing');
$notifyCustomerService = false;
break;
case PsCheckoutException::PRESTASHOP_CONTEXT_INVALID:
$exceptionMessageForCustomer = $this->translator->trans('Cart is invalid');
$notifyCustomerService = false;
break;
case PsCheckoutException::PRESTASHOP_VALIDATE_ORDER:
$exceptionMessageForCustomer = $this->translator->trans('Order cannot be saved');
break;
case PsCheckoutException::PRESTASHOP_ORDER_STATE_ERROR:
$exceptionMessageForCustomer = $this->translator->trans('OrderState cannot be saved');
break;
case PsCheckoutException::PRESTASHOP_ORDER_PAYMENT:
$exceptionMessageForCustomer = $this->translator->trans('OrderPayment cannot be saved');
break;
case PsCheckoutException::DIFFERENCE_BETWEEN_TRANSACTION_AND_CART:
$exceptionMessageForCustomer = $this->translator->trans('The transaction amount doesn\'t match with the cart amount.');
$notifyCustomerService = false;
break;
case PsCheckoutException::PAYPAL_PAYMENT_CARD_SCA_FAILURE:
$exceptionMessageForCustomer = $this->translator->trans('Card holder authentication failed, please choose another payment method or try again.');
$notifyCustomerService = false;
break;
case PsCheckoutException::PAYPAL_PAYMENT_CARD_SCA_UNKNOWN:
$exceptionMessageForCustomer = $this->translator->trans('Card holder authentication cannot be checked, please choose another payment method or try again.');
$notifyCustomerService = false;
break;
case PsCheckoutException::PAYPAL_PAYMENT_CARD_SCA_CANCELED:
$exceptionMessageForCustomer = $this->translator->trans('Card holder authentication canceled, please choose another payment method or try again.');
$notifyCustomerService = false;
break;
case PsCheckoutException::CART_PRODUCT_MISSING:
$exceptionMessageForCustomer = $this->translator->trans('Cart doesn\'t contains product.');
$notifyCustomerService = false;
break;
case PsCheckoutException::CART_PRODUCT_UNAVAILABLE:
$exceptionMessageForCustomer = $this->translator->trans('Cart contains product unavailable.');
$notifyCustomerService = false;
break;
case PsCheckoutException::CART_ADDRESS_INVOICE_INVALID:
$exceptionMessageForCustomer = $this->translator->trans('Cart invoice address is invalid.');
$notifyCustomerService = false;
break;
case PsCheckoutException::CART_ADDRESS_DELIVERY_INVALID:
$exceptionMessageForCustomer = $this->translator->trans('Cart delivery address is invalid.');
$notifyCustomerService = false;
break;
case PsCheckoutException::CART_DELIVERY_OPTION_INVALID:
$exceptionMessageForCustomer = $this->translator->trans('Cart delivery option is unavailable.');
$notifyCustomerService = false;
break;
}
} elseif (PayPalException::class === $exceptionClass) {
switch ($exception->getCode()) {
case PayPalException::CARD_BRAND_NOT_SUPPORTED:
case PayPalException::CARD_TYPE_NOT_SUPPORTED:
$exceptionMessageForCustomer = $this->translator->trans('Processing of this card type is not supported. Use another card type.');
$notifyCustomerService = false;
break;
case PayPalException::INVALID_SECURITY_CODE_LENGTH:
$exceptionMessageForCustomer = $this->translator->trans('The CVC code length is invalid for the specified card type.');
$notifyCustomerService = false;
break;
case PayPalException::CURRENCY_NOT_SUPPORTED_FOR_CARD_TYPE:
$exceptionMessageForCustomer = $this->translator->trans('Your card cannot be used to pay in this currency, please try another payment method.');
$notifyCustomerService = false;
break;
case PayPalException::CURRENCY_NOT_SUPPORTED_FOR_COUNTRY:
$exceptionMessageForCustomer = $this->translator->trans('Your card cannot be used to pay in our country, please try another payment method.');
$notifyCustomerService = false;
break;
case PayPalException::COMPLIANCE_VIOLATION:
case PayPalException::INSTRUMENT_DECLINED:
$exceptionMessageForCustomer = $this->translator->trans('This payment method declined transaction, please try another.');
$notifyCustomerService = false;
break;
case PayPalException::MAX_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED:
$exceptionMessageForCustomer = $this->translator->trans('You have exceeded the maximum number of payment attempts.');
$notifyCustomerService = false;
break;
case PayPalException::PAYER_ACCOUNT_LOCKED_OR_CLOSED:
$exceptionMessageForCustomer = $this->translator->trans('Your PayPal account is locked or closed, please try another.');
$notifyCustomerService = false;
break;
case PayPalException::PAYER_ACCOUNT_RESTRICTED:
$exceptionMessageForCustomer = $this->translator->trans('You are not allowed to pay with this PayPal account, please try another.');
$notifyCustomerService = false;
break;
case PayPalException::PAYER_CANNOT_PAY:
$exceptionMessageForCustomer = $this->translator->trans('You are not allowed to pay with this payment method, please try another.');
$notifyCustomerService = false;
break;
case PayPalException::PAYER_COUNTRY_NOT_SUPPORTED:
$exceptionMessageForCustomer = $this->translator->trans('Your country is not supported by this payment method, please try to select another.');
$notifyCustomerService = false;
break;
case PayPalException::REDIRECT_PAYER_FOR_ALTERNATE_FUNDING:
$exceptionMessageForCustomer = $this->translator->trans('The transaction failed. Please try a different payment method.');
$notifyCustomerService = false;
break;
case PayPalException::TRANSACTION_BLOCKED_BY_PAYEE:
$exceptionMessageForCustomer = $this->translator->trans('The transaction was blocked by Fraud Protection settings.');
$notifyCustomerService = false;
break;
case PayPalException::TRANSACTION_REFUSED:
$exceptionMessageForCustomer = $this->translator->trans('The transaction was refused.');
$notifyCustomerService = false;
break;
case PayPalException::NO_EXTERNAL_FUNDING_DETAILS_FOUND:
$exceptionMessageForCustomer = $this->translator->trans('This payment method seems not working currently, please try another.');
$notifyCustomerService = false;
break;
case PayPalException::ORDER_ALREADY_CAPTURED:
$exceptionMessageForCustomer = $this->translator->trans('Order is already captured.');
break;
case PayPalException::PAYMENT_DENIED:
$exceptionMessageForCustomer = $this->translator->trans('This payment method has been refused by the payment platform, please use another payment method.');
$notifyCustomerService = false;
break;
case PayPalException::NOT_ENABLED_FOR_CARD_PROCESSING:
case PayPalException::PAYEE_NOT_ENABLED_FOR_CARD_PROCESSING:
$exceptionMessageForCustomer = $this->translator->trans('Card payment cannot be processed at the moment, please use another payment method.');
$notifyCustomerService = false;
break;
case PayPalException::RESOURCE_NOT_FOUND:
$exceptionMessageForCustomer = $this->translator->trans('Transaction expired, please try again.');
$notifyCustomerService = false;
break;
case PayPalException::PAYMENT_SOURCE_CANNOT_BE_USED:
$exceptionMessageForCustomer = $this->translator->trans('The selected payment method does not support this type of transaction. Please choose another payment method or contact support for assistance.');
$notifyCustomerService = false;
break;
}
}
if ($notifyCustomerService) {
$this->customerNotifyAction->execute($exception, $paypalOrderId);
$this->logger->error(
'ValidateOrder - Exception ' . $exception->getCode(),
[
'exception' => $exception,
'paypal_order' => $paypalOrderId,
]
);
} else {
$this->logger->notice(
'ValidateOrder - Exception ' . $exception->getCode(),
[
'exception' => $exception,
'paypal_order' => $paypalOrderId,
]
);
$httpCode = 400; // Change HTTP code for non-critical errors
}
return [
'status' => false,
'httpCode' => $httpCode,
'body' => [
'error' => [
'message' => $exceptionMessageForCustomer,
'code' => (int) $exception->getCode() < 400 && $exception->getPrevious() !== null
? (int) $exception->getPrevious()->getCode()
: (int) $exception->getCode(),
],
],
];
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Exception\Handler;
use Exception;
interface OrderCreationExceptionHandlerInterface
{
/**
* @param Exception $exception
*
* @return array
*/
public function handle(Exception $exception, string $paypalOrderId);
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,56 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Exception;
use PsCheckout\Core\Exception\PsCheckoutException;
class OrderException extends PsCheckoutException
{
const INVALID_ID = 1;
const ORDER_NOT_FOUND = 2;
const INVALID_CURRENCY = 3;
const FAILED_ADD_PAYMENT = 4;
const INVALID_INVOICE = 5;
const FAILED_ADD_ORDER = 6;
const ORDER_HAS_ALREADY_THIS_STATUS = 7;
const FAILED_UPDATE_ORDER_STATUS = 8;
const ORDER_STATUS_NOT_FOUND = 9;
const MODULE_INSTANCE_NOT_FOUND = 10;
const ORDER_MATRIX_ERROR = 11;
const ORDER_CHECK_AMOUNT_BAD_PARAMETER = 12;
const STATUS_CHECK_AVAILABLE_BAD_PARAMETER = 13;
const INVALID_PAYPAL_ORDER_STATE = 14;
const TRANSITION_NOT_ALLOWED = 15;
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,199 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Processor;
use Cart;
use PsCheckout\Api\Http\Exception\PayPalException;
use PsCheckout\Core\Exception\PsCheckoutException;
use PsCheckout\Core\Order\Action\CreateOrderActionInterface;
use PsCheckout\Core\Order\Request\ValueObject\ValidateOrderRequest;
use PsCheckout\Core\Order\Validator\CheckoutValidatorInterface;
use PsCheckout\Core\Order\Validator\OrderAuthorizationValidatorInterface;
use PsCheckout\Core\PaymentToken\Action\DeletePaymentTokenActionInterface;
use PsCheckout\Core\PaymentToken\Action\SavePaymentTokenActionInterface;
use PsCheckout\Core\PayPal\Order\Action\CapturePayPalOrderActionInterface;
use PsCheckout\Core\PayPal\Order\Configuration\PayPalOrderStatus;
use PsCheckout\Core\PayPal\Order\Provider\PayPalOrderProviderInterface;
use PsCheckout\Core\PayPal\Order\Repository\PayPalOrderRepositoryInterface;
use PsCheckout\Infrastructure\Adapter\ContextInterface;
use PsCheckout\Infrastructure\Repository\CartRepositoryInterface;
class CreateOrderProcessor implements CreateOrderProcessorInterface
{
/**
* @var OrderAuthorizationValidatorInterface
*/
private $orderAuthorizationValidator;
/**
* @var CreateOrderActionInterface
*/
private $createOrderAction;
/**
* @var CartRepositoryInterface
*/
private $cartRepository;
/**
* @var ContextInterface
*/
private $context;
/**
* @var CheckoutValidatorInterface
*/
private $checkoutValidator;
/**
* @var CapturePayPalOrderActionInterface
*/
private $capturePayPalOrderAction;
/**
* @var SavePaymentTokenActionInterface
*/
private $savePaymentTokenAction;
/**
* @var PayPalOrderProviderInterface
*/
private $payPalOrderProvider;
/**
* @var PayPalOrderRepositoryInterface
*/
private $payPalOrderRepository;
/**
* @var DeletePaymentTokenActionInterface
*/
private $deletePaymentTokenAction;
public function __construct(
OrderAuthorizationValidatorInterface $orderAuthorizationValidator,
CreateOrderActionInterface $createOrderAction,
CartRepositoryInterface $cartRepository,
ContextInterface $context,
CheckoutValidatorInterface $checkoutValidator,
CapturePayPalOrderActionInterface $capturePayPalOrderAction,
SavePaymentTokenActionInterface $savePaymentTokenAction,
PayPalOrderProviderInterface $payPalOrderProvider,
PayPalOrderRepositoryInterface $payPalOrderRepository,
DeletePaymentTokenActionInterface $deletePaymentTokenAction
) {
$this->orderAuthorizationValidator = $orderAuthorizationValidator;
$this->createOrderAction = $createOrderAction;
$this->cartRepository = $cartRepository;
$this->context = $context;
$this->checkoutValidator = $checkoutValidator;
$this->capturePayPalOrderAction = $capturePayPalOrderAction;
$this->savePaymentTokenAction = $savePaymentTokenAction;
$this->payPalOrderProvider = $payPalOrderProvider;
$this->payPalOrderRepository = $payPalOrderRepository;
$this->deletePaymentTokenAction = $deletePaymentTokenAction;
}
/**
* {@inheritDoc}
*/
public function run(ValidateOrderRequest $request)
{
try {
$this->checkoutValidator->validate($request->getOrderId(), $request->getCartId());
} catch (PsCheckoutException $exception) {
if ($exception->getCode() === PsCheckoutException::PRESTASHOP_ORDER_ALREADY_EXISTS) {
return;
}
throw $exception;
} catch (\Exception $exception) {
throw new PsCheckoutException('Unknown error', PsCheckoutException::UNKNOWN);
}
/** @var Cart $cart */
$cart = $this->cartRepository->getOneBy([
'id_cart' => $request->getCartId(),
]);
$this->context->setCurrentCart($cart);
try {
$payPalOrderResponse = $this->payPalOrderProvider->getById($request->getOrderId());
$this->orderAuthorizationValidator->validate($cart->id, $payPalOrderResponse);
} catch (PsCheckoutException $exception) {
if ($exception->getCode() === PsCheckoutException::PAYPAL_ORDER_ALREADY_CAPTURED) {
$this->createOrderAction->execute($payPalOrderResponse);
return;
}
throw $exception;
}
try {
if (!$this->orderNeedsCapture($request)) {
throw new PayPalException('Order doesn\'t need capture', PayPalException::ORDER_REQUIRES_ASYNC_CAPTURE);
}
$capturedOrderResponse = $this->capturePayPalOrderAction->execute($payPalOrderResponse);
$this->savePaymentTokenAction->execute($capturedOrderResponse);
} catch (PayPalException $exception) {
switch ($exception->getCode()) {
case PayPalException::ORDER_NOT_APPROVED:
case PayPalException::ORDER_REQUIRES_ASYNC_CAPTURE:
$this->createOrderAction->execute($payPalOrderResponse);
return;
case PayPalException::RESOURCE_NOT_FOUND:
$payPalOrder = $this->payPalOrderRepository->getOneBy(['id' => $request->getOrderId()]);
if ($payPalOrder) {
$payPalOrder->setStatus(PayPalOrderStatus::CANCELED);
$this->payPalOrderRepository->save($payPalOrder);
}
throw $exception;
case PayPalException::ORDER_ALREADY_CAPTURED:
$capturedOrderResponse = $this->payPalOrderProvider->getById($request->getOrderId());
$this->createOrderAction->execute($capturedOrderResponse);
return;
case PayPalException::CARD_CLOSED:
$capturedOrderResponse = $this->payPalOrderProvider->getById($request->getOrderId());
$this->deletePaymentTokenAction->execute(
$capturedOrderResponse->getVault()['id'],
$this->context->getCustomer()->id
);
// no break
default:
throw $exception;
}
}
}
private function orderNeedsCapture(ValidateOrderRequest $request): bool
{
return $request->getFundingSource() !== 'pay_upon_invoice';
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Processor;
use PsCheckout\Core\Order\Request\ValueObject\ValidateOrderRequest;
interface CreateOrderProcessorInterface
{
/**
* @param ValidateOrderRequest $request
*
* @return void
*/
public function run(ValidateOrderRequest $request);
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,113 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PsCheckout\Core\Order\Request\ValueObject;
class ValidateOrderRequest
{
/**
* @var int|null
*/
private $cartId;
/**
* @var string|null
*/
private $orderId;
/**
* @var string|null
*/
private $payerId;
/**
* @var string|null
*/
private $fundingSource;
/**
* @var bool
*/
private $isExpressCheckout;
/**
* @var bool
*/
private $isCardFields;
public function __construct(array $request, int $cartId)
{
// Initialize values from the provided request array
$this->cartId = $cartId ?? null;
$this->orderId = $request['orderID'] ?? null;
$this->payerId = $request['payerID'] ?? null;
$this->fundingSource = $request['fundingSource'] ?? $request['paypalFundingSource'] ?? null;
$this->isExpressCheckout = $request['isExpressCheckout'] ?? $request['isExpressCheckoutFromCart'] ?? false;
$this->isCardFields = $request['isHostedFields'] ?? $request['isHostedFieldsFromCart'] ?? false;
}
/**
* @return int|null
*/
public function getCartId()
{
return $this->cartId;
}
/**
* @return string|null
*/
public function getOrderId()
{
return $this->orderId;
}
/**
* @return string|null
*/
public function getPayerId()
{
return $this->payerId;
}
/**
* @return string|null
*/
public function getFundingSource()
{
return $this->fundingSource;
}
/**
* @return bool
*/
public function isExpressCheckout()
{
return $this->isExpressCheckout;
}
/**
* @return bool
*/
public function isCardFields()
{
return $this->isCardFields;
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

Some files were not shown because too many files have changed in this diff Show More