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,
),
),
);