From e0c6b141f8b986824232ee74a429360d51703d51 Mon Sep 17 00:00:00 2001 From: L3RAZ Date: Fri, 29 Nov 2024 16:46:35 +0200 Subject: [PATCH] merge changes --- .github/mktp-metadata.json | 1 - README.md | 2 +- _dev/js/front/src/service/paypal.service.js | 319 ------- config.xml | 2 +- config/common.yml | 846 ++++++------------ ps_checkout.php | 13 +- src/Builder/Payload/OrderPayloadBuilder.php | 166 +++- .../CreatePayPalOrderCommandHandler.php | 95 +- .../Order/PayPalOrderSummaryViewBuilder.php | 18 +- .../Query/GetPayPalOrderForAdminViewQuery.php | 6 - tests/Unit/Http/CheckoutHttpClientTest.php | 417 +++++++++ 11 files changed, 951 insertions(+), 934 deletions(-) delete mode 100644 _dev/js/front/src/service/paypal.service.js create mode 100644 tests/Unit/Http/CheckoutHttpClientTest.php diff --git a/.github/mktp-metadata.json b/.github/mktp-metadata.json index d7a2b3992..7b956e808 100644 --- a/.github/mktp-metadata.json +++ b/.github/mktp-metadata.json @@ -8,4 +8,3 @@ "compatible_from" : "1.7.4.0", "compatible_to" : "1.7.8.11" } - diff --git a/README.md b/README.md index 5ed7e4b7d..c8b53d37d 100755 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ There 3 main branches on the repository: Contributors **must** follow the following rules: -* Use the main branch `prestashop/8.x` +* Use the main branch `prestashop/1.7.x` * Do not update the module's version number. * Follow [the coding standards][1]. diff --git a/_dev/js/front/src/service/paypal.service.js b/_dev/js/front/src/service/paypal.service.js deleted file mode 100644 index 1133d892c..000000000 --- a/_dev/js/front/src/service/paypal.service.js +++ /dev/null @@ -1,319 +0,0 @@ -/** - * 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 3.0 (AFL-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 - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - */ - -/** - * @typedef PaypalButtonEvents - * @type {*} - * - * @property {function} onInit - * @property {function} onClick - * @property {function} onError - * @property {function} onApprove - * @property {function} onCancel - * @property {function} createOrder - */ - -/** - * @typedef PaypalPayLaterOfferStyle - * @type {*} - * - * @property {string} layout - * @property {string} color - * @property {string} ratio - * @property {object} logo - * @property {string} logo.type - * @property {string} logo.position - * @property {object} text - * @property {string} text.color - * @property {string} text.size - * @property {string} text.align - */ - -/** - * @typedef PayPayCardFieldsOptions - * @type {*} - * - * @property {function} createOrder - * @property {function} onApprove - * @property {function} onError - * @property {function} inputEvents - * @property {object} style - */ - -/** - * @typedef PaypalPayLaterOfferEvents - * @type {*} - * - * @property {function} onRender - * @property {function} onClick - * @property {function} onApply - */ - -/** - * @typedef PaypalMarks - * @type {*} - * - * @property {function} isEligible - * @property {function} render - */ - -import { BaseClass } from '../core/dependency-injection/base.class'; - -export class PayPalService extends BaseClass { - static Inject = { - configPayPal: 'PayPalSdkConfig', - configPrestaShop: 'PsCheckoutConfig', - sdk: 'PayPalSDK', - $: '$' - }; - - getOrderId() { - return this.configPrestaShop.orderId; - } - - getFundingSource() { - return this.configPrestaShop.fundingSource; - } - - /** - * @param {string} fundingSource - * @param {PaypalButtonEvents} events - */ - getButtonExpress(fundingSource, events) { - return this.sdk.Buttons({ - fundingSource: fundingSource, - style: this.getButtonCustomizationStyle(fundingSource), - commit: false, - ...events - }); - } - - /** - * @param {string} fundingSource - * @param {PaypalButtonEvents} events - */ - getButtonPayment(fundingSource, events) { - return this.sdk.Buttons({ - fundingSource: fundingSource, - style: this.getButtonCustomizationStyle(fundingSource), - ...events - }); - } - - /** - * @param {string} fundingSource - */ - getButtonCustomizationStyle(fundingSource) { - const style = { - ...{ label: 'pay', color: 'gold', shape: 'pill' }, - ...(this.configPayPal.buttonCustomization || {}), - ...(window.ps_checkout.PayPalButtonCustomization || {}) - }; - - if (fundingSource === 'paypal') { - return style; - } else if (fundingSource === 'paylater') { - return { shape: style.shape, color: style.color }; - } - - return {}; - } - - /** - * @param {*} fieldSelectors - * @param {string} fieldSelectors.name - * @param {string} fieldSelectors.number - * @param {string} fieldSelectors.cvv - * @param {string} fieldSelectors.expiry - * - * @param {PayPayCardFieldsOptions} options - * - * @returns {PayPalSdk.CardFields} - */ - async getCardFields(fieldSelectors, options) { - const cardFields = this.sdk.CardFields(options); - - const nameField = cardFields.NameField({ - placeholder: this.$('paypal.hosted-fields.placeholder.card-name') - }); - const numberField = cardFields.NumberField({ - placeholder: this.$('paypal.hosted-fields.placeholder.card-number') - }); - const expiryField = cardFields.ExpiryField({ - placeholder: this.$('paypal.hosted-fields.placeholder.expiration-date') - }); - const cvvField = cardFields.CVVField({ - placeholder: this.$('paypal.hosted-fields.placeholder.cvv') - }); - - try { - await numberField.render(fieldSelectors.number); - await expiryField.render(fieldSelectors.expiry); - await cvvField.render(fieldSelectors.cvv); - await nameField.render(fieldSelectors.name); - } catch (e) { - return console.error('Failed to render CardFields', e); - } - - const nameLabel = document.querySelector( - `label[for="${fieldSelectors.name.id}"]` - ); - const numberLabel = document.querySelector( - `label[for="${fieldSelectors.number.id}"]` - ); - const cvvLabel = document.querySelector( - `label[for="${fieldSelectors.cvv.id}"]` - ); - const expirationDateLabel = document.querySelector( - `label[for="${fieldSelectors.expiry.id}"]` - ); - - nameLabel.innerHTML = this.$('paypal.hosted-fields.label.card-name'); - numberLabel.innerHTML = this.$('paypal.hosted-fields.label.card-number'); - cvvLabel.innerHTML = this.$('paypal.hosted-fields.label.cvv'); - expirationDateLabel.innerHTML = this.$( - 'paypal.hosted-fields.label.expiration-date' - ); - - return cardFields; - } - - getEligibleFundingSources(cache = false) { - if (!this.eligibleFundingSources || cache) { - const paypalFundingSources = this.sdk.getFundingSources(); - this.eligibleFundingSources = ( - this.configPrestaShop.fundingSourcesSorted || paypalFundingSources - ) - .filter((fundingSource) => paypalFundingSources.includes(fundingSource)) - .map((fundingSource) => ({ - name: fundingSource, - mark: this.sdk.Marks({ fundingSource }) - })) - .filter((fundingSource) => { - if ( - fundingSource.name === 'card' && - this.isCardFieldsEnabled() && - !this.isCardFieldsEligible() - ) { - console.warn( - 'Card Fields (CCF) eligibility is declined. Switching to PayPal branded card fields (SCF)' - ); - } - console.log(fundingSource.name, fundingSource.mark.isEligible()); - - return fundingSource.mark.isEligible(); - }); - } - - return this.eligibleFundingSources; - } - - isFundingEligible(fundingSource) { - return this.getEligibleFundingSources().contains(fundingSource); - } - - isCardFieldsEnabled() { - return this.sdk.CardFields && this.configPrestaShop.hostedFieldsEnabled; - } - - isCardFieldsEligible() { - return this.sdk.CardFields && this.sdk.CardFields().isEligible(); - } - - /** - * @param {string} placement - * @param {string} amount - * @param {PaypalPayLaterOfferEvents} events - */ - getPayLaterOfferMessage(placement, amount, events) { - const style = { - ...{ - layout: 'text', - logo: { - type: 'inline' - } - }, - ...(this.configPayPal.payLaterOfferMessageCustomization || {}), - ...(window.ps_checkout.payLaterOfferMessageCustomization || {}) - }; - return ( - this.sdk.Messages && - this.sdk.Messages({ - placement: placement, - amount: amount, - style: style, - ...events - }) - ); - } - - /** - * @param {string} placement - * @param {string} amount - * @param {PaypalPayLaterOfferEvents} events - */ - getPayLaterOfferBanner(placement, amount, events) { - const style = { - ...{ - layout: 'flex', - ratio: '20x1' - }, - ...(this.configPayPal.payLaterOfferBannerCustomization || {}), - ...(window.ps_checkout.payLaterOfferBannerCustomization || {}) - }; - return ( - this.sdk.Messages && - this.sdk.Messages({ - placement: placement, - amount: amount, - style: style, - ...events - }) - ); - } - - /** - * @param {string} fundingSource - * @param {object} fields - */ - getPaymentFields(fundingSource, fields = {}) { - return this.sdk.PaymentFields && this.sdk.PaymentFields({ - fundingSource: fundingSource, - style: this.getPaymentFieldsCustomizationStyle(fundingSource), - fields: fields - }); - } - - /** - * @returns {object} - */ - getPaymentFieldsCustomizationStyle() { - return { - ...(this.configPayPal.paymentFieldsCustomization || {}), - ...(window.ps_checkout.paymentFieldsCustomization || {}) - }; - } - - /** - * @returns {PaypalMarks} - */ - getMarks() { - return this.sdk.Marks && this.sdk.Marks(); - } -} diff --git a/config.xml b/config.xml index 04c4a7e81..be599c46f 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_checkout - + diff --git a/config/common.yml b/config/common.yml index dea9fc88d..75378254a 100644 --- a/config/common.yml +++ b/config/common.yml @@ -1,3 +1,11 @@ +imports: + - { resource: ./accounts.yml } + - { resource: ./cache.yml } + - { resource: ./command-handlers.yml } + - { resource: ./http-clients.yml } + - { resource: ./logger.yml } + - { resource: ./query-handlers.yml } + - { resource: ./repository.yml } services: # From PS 1.7.0 to PS 1.7.3, the bundled version of Symfony is 2.x on which the _defaults # key is invalid. To prevent error on these versions, each service has to be specifically @@ -15,6 +23,7 @@ services: ps_checkout.db: class: Db factory: [ 'Db', 'getInstance' ] + public: true ps_checkout.module.version: class: 'PrestaShop\Module\PrestashopCheckout\Version\Version' @@ -23,708 +32,419 @@ services: arguments: - '@=service("ps_checkout.module").version' - ps_checkout.context.prestashop: - class: 'PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext' + PrestaShop\Module\PrestashopCheckout\Environment\EnvLoader: + class: 'PrestaShop\Module\PrestashopCheckout\Environment\EnvLoader' public: true - ps_checkout.context.state.manager: - class: 'PrestaShop\Module\PrestashopCheckout\Context\ContextStateManager' + PrestaShop\Module\PrestashopCheckout\Environment\Env: + class: 'PrestaShop\Module\PrestashopCheckout\Environment\Env' public: true + arguments: + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration' - ps_checkout.context.shop: - class: 'PrestaShop\Module\PrestashopCheckout\ShopContext' + ps_checkout.tactician.bus: + class: 'League\Tactician\CommandBus' + factory: [ '@PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusFactory', "create" ] + + ps_checkout.bus.command: + class: 'PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusAdapter' public: true + arguments: + - "@ps_checkout.tactician.bus" - ps_checkout.shop.provider: - class: 'PrestaShop\Module\PrestashopCheckout\Shop\ShopProvider' + PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusFactory: + class: 'PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusFactory' + public: true + arguments: + - "@ps_checkout.module" + - "@ps_checkout.logger" + - PrestaShop\Module\PrestashopCheckout\Order\Command\AddOrderPaymentCommand: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\AddOrderPaymentCommandHandler' + PrestaShop\Module\PrestashopCheckout\Order\Command\CreateOrderCommand: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\CreateOrderCommandHandler' + PrestaShop\Module\PrestashopCheckout\Order\Command\UpdateOrderStatusCommand: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\UpdateOrderStatusCommandHandler' + PrestaShop\Module\PrestashopCheckout\Order\Matrice\Command\UpdateOrderMatriceCommand: 'PrestaShop\Module\PrestashopCheckout\Order\Matrice\CommandHandler\UpdateOrderMatriceCommandHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\CreatePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\CreatePayPalOrderCommandHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\UpdatePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\UpdatePayPalOrderCommandHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\CapturePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\CapturePayPalOrderCommandHandler' + PrestaShop\Module\PrestashopCheckout\Checkout\Command\CancelCheckoutCommand: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\CancelCheckoutCommandHandler' + PrestaShop\Module\PrestashopCheckout\Checkout\Command\SaveCheckoutCommand: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\SaveCheckoutCommandHandler' + PrestaShop\Module\PrestashopCheckout\Checkout\Command\SavePayPalOrderStatusCommand: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\SavePayPalOrderStatusCommandHandler' + PrestaShop\Module\PrestashopCheckout\Checkout\Command\UpdatePaymentMethodSelectedCommand: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\UpdatePaymentMethodSelectedCommandHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\Command\RefundPayPalCaptureCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\CommandHandler\RefundPayPalCaptureCommandHandler' + PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentCompletedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentCompletedQueryHandler' + PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentDeniedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentDeniedQueryHandler' + PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentPendingQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentPendingQueryHandler' + PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentRefundedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentRefundedQueryHandler' + PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentReversedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentReversedQueryHandler' + PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForApprovalReversedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForApprovalReversedQueryHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForCartIdQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderForCartIdQueryHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetCurrentPayPalOrderStatusQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetCurrentPayPalOrderStatusQueryHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderQueryHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForCheckoutCompletedQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderForCheckoutCompletedQueryHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForOrderConfirmationQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderForOrderConfirmationQueryHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Command\SavePaymentTokenCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\CommandHandler\SavePaymentTokenCommandHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Command\DeletePaymentTokenCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\CommandHandler\DeletePaymentTokenCommandHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Query\GetCustomerPaymentTokensQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Query\GetCustomerPaymentTokensQueryHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\Customer\Command\SavePayPalCustomerCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Customer\CommandHandler\SavePayPalCustomerCommandHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalGetUserIdTokenQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalGetUserIdTokenQueryHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\SavePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\SavePayPalOrderCommandHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\GooglePay\Query\GetGooglePayTransactionInfoQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\GooglePay\Query\GetGooglePayTransactionInfoQueryHandler' + PrestaShop\Module\PrestashopCheckout\PayPal\ApplePay\Query\GetApplePayPaymentRequestQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\ApplePay\Query\GetApplePayPaymentRequestQueryHandler' + + PrestaShop\Module\PrestashopCheckout\Event\SymfonyEventDispatcherFactory: + class: 'PrestaShop\Module\PrestashopCheckout\Event\SymfonyEventDispatcherFactory' public: true + arguments: + - "@ps_checkout.logger" + - '@PrestaShop\Module\PrestashopCheckout\Logger\LoggerConfiguration' - ps_checkout.configuration.options.resolver: - class: 'PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfigurationOptionsResolver' + PrestaShop\Module\PrestashopCheckout\Checkout\EventSubscriber\CheckoutEventSubscriber: + class: 'PrestaShop\Module\PrestashopCheckout\Checkout\EventSubscriber\CheckoutEventSubscriber' public: true arguments: - - '@=service("ps_checkout.shop.provider").getIdentifier()' + - '@PrestaShop\Module\PrestashopCheckout\Checkout\CheckoutChecker' + - '@ps_checkout.bus.command' + - '@PrestaShop\Module\PrestashopCheckout\Repository\PsCheckoutCartRepository' - ps_checkout.configuration: - class: 'PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration' + PrestaShop\Module\PrestashopCheckout\Order\EventSubscriber\OrderEventSubscriber: + class: 'PrestaShop\Module\PrestashopCheckout\Order\EventSubscriber\OrderEventSubscriber' public: true arguments: - - "@ps_checkout.configuration.options.resolver" + - '@PrestaShop\Module\PrestashopCheckout\Repository\PsCheckoutCartRepository' + - '@ps_checkout.module' - ps_checkout.logger.directory: - class: 'PrestaShop\Module\PrestashopCheckout\Logger\LoggerDirectory' + PrestaShop\Module\PrestashopCheckout\PayPal\Order\EventSubscriber\PayPalOrderEventSubscriber: + class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\EventSubscriber\PayPalOrderEventSubscriber' public: true arguments: - - !php/const _PS_VERSION_ - - !php/const _PS_ROOT_DIR_ + - "@ps_checkout.module" + - '@PrestaShop\Module\PrestashopCheckout\Repository\PsCheckoutCartRepository' + - "@ps_checkout.cache.paypal.order" + - '@PrestaShop\Module\PrestashopCheckout\Checkout\CheckoutChecker' + - '@PrestaShop\Module\PrestashopCheckout\PayPal\Order\CheckTransitionPayPalOrderStatusService' + - '@PrestaShop\Module\PrestashopCheckout\Order\State\Service\OrderStateMapper' + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository' - ps_checkout.logger.filename: - class: 'PrestaShop\Module\PrestashopCheckout\Logger\LoggerFilename' + PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Capture\EventSubscriber\PayPalCaptureEventSubscriber: + class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Capture\EventSubscriber\PayPalCaptureEventSubscriber' public: true arguments: - - '@=service("ps_checkout.module").name' - - '@=service("ps_checkout.shop.provider").getIdentifier()' + - '@ps_checkout.module' + - '@PrestaShop\Module\PrestashopCheckout\Order\Service\CheckOrderAmount' + - "@ps_checkout.cache.paypal.capture" + - "@ps_checkout.cache.paypal.order" + - '@PrestaShop\Module\PrestashopCheckout\Order\State\Service\OrderStateMapper' - ps_checkout.logger.configuration: - class: 'PrestaShop\Module\PrestashopCheckout\Logger\LoggerConfiguration' + PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\EventSubscriber\PayPalRefundEventSubscriber: + class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\EventSubscriber\PayPalRefundEventSubscriber' + arguments: + - '@ps_checkout.module' + - '@ps_checkout.cache.paypal.order' + - '@PrestaShop\Module\PrestashopCheckout\Order\State\Service\OrderStateMapper' + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalOrderProvider' + + PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\EventSubscriber\PaymentMethodTokenEventSubscriber: + class: 'PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\EventSubscriber\PaymentMethodTokenEventSubscriber' + arguments: + - '@ps_checkout.module' + - '@PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository' + - '@PrestaShop\Module\PrestashopCheckout\Repository\PaymentTokenRepository' + + ps_checkout.event.dispatcher.symfony: + class: 'Symfony\Component\EventDispatcher\EventDispatcherInterface' + factory: [ '@PrestaShop\Module\PrestashopCheckout\Event\SymfonyEventDispatcherFactory', "create" ] + arguments: + - [ + '@PrestaShop\Module\PrestashopCheckout\Checkout\EventSubscriber\CheckoutEventSubscriber', + '@PrestaShop\Module\PrestashopCheckout\Order\EventSubscriber\OrderEventSubscriber', + '@PrestaShop\Module\PrestashopCheckout\PayPal\Order\EventSubscriber\PayPalOrderEventSubscriber', + '@PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Capture\EventSubscriber\PayPalCaptureEventSubscriber', + '@PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\EventSubscriber\PayPalRefundEventSubscriber', + '@PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\EventSubscriber\PaymentMethodTokenEventSubscriber'] + + PrestaShop\Module\PrestashopCheckout\Event\SymfonyEventDispatcherAdapter: + class: 'PrestaShop\Module\PrestashopCheckout\Event\SymfonyEventDispatcherAdapter' public: true arguments: - - "@ps_checkout.configuration" + - "@ps_checkout.event.dispatcher.symfony" + + PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext: + class: 'PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext' + public: true - ps_checkout.logger.handler.factory: - class: 'PrestaShop\Module\PrestashopCheckout\Logger\LoggerHandlerFactory' + PrestaShop\Module\PrestashopCheckout\Context\ContextStateManager: + class: 'PrestaShop\Module\PrestashopCheckout\Context\ContextStateManager' + public: true + + PrestaShop\Module\PrestashopCheckout\ShopContext: + class: 'PrestaShop\Module\PrestashopCheckout\ShopContext' public: true arguments: - - '@=service("ps_checkout.logger.directory").getPath()' - - '@=service("ps_checkout.logger.filename").get()' - - '@=service("ps_checkout.logger.configuration").getMaxFiles()' - - '@=service("ps_checkout.logger.configuration").getLevel()' + - '@PrestaShop\Module\PrestashopCheckout\Environment\Env' - ps_checkout.logger.handler: - class: 'Monolog\Handler\HandlerInterface' + PrestaShop\Module\PrestashopCheckout\Shop\ShopProvider: + class: 'PrestaShop\Module\PrestashopCheckout\Shop\ShopProvider' public: true - factory: ["@ps_checkout.logger.handler.factory", "build"] - ps_checkout.logger.factory: - class: 'PrestaShop\Module\PrestashopCheckout\Logger\LoggerFactory' + PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfigurationOptionsResolver: + class: 'PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfigurationOptionsResolver' public: true arguments: - - '@=service("ps_checkout.module").name' - - "@ps_checkout.logger.handler" + - '@=service("PrestaShop\\Module\\PrestashopCheckout\\Shop\\ShopProvider").getIdentifier()' - ps_checkout.logger: - class: 'Psr\Log\LoggerInterface' + PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration: + class: 'PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration' public: true - factory: ["@ps_checkout.logger.factory", "build"] arguments: - - "@ps_checkout.logger.directory" + - '@PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfigurationOptionsResolver' - ps_checkout.paypal.configuration: + PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration: class: 'PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration' public: true arguments: - - "@ps_checkout.configuration" - - "@ps_checkout.repository.paypal.code" + - '@PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\Repository\PayPalCodeRepository' - ps_checkout.express_checkout.configuration: + PrestaShop\Module\PrestashopCheckout\ExpressCheckout\ExpressCheckoutConfiguration: class: 'PrestaShop\Module\PrestashopCheckout\ExpressCheckout\ExpressCheckoutConfiguration' public: true arguments: - - "@ps_checkout.configuration" + - '@PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration' - ps_checkout.pay_later.configuration: + PrestaShop\Module\PrestashopCheckout\PayPal\PayPalPayLaterConfiguration: class: 'PrestaShop\Module\PrestashopCheckout\PayPal\PayPalPayLaterConfiguration' public: true arguments: - - "@ps_checkout.configuration" + - '@PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration' - ps_checkout.sdk.paypal.configurationbuilder: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Sdk\PayPalSdkConfigurationBuilder' + PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfiguration: + class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfiguration' public: true arguments: - - "@ps_checkout.paypal.configuration" - - "@ps_checkout.pay_later.configuration" - - "@ps_checkout.funding_source.configuration.repository" - - "@ps_checkout.express_checkout.configuration" - - '@ps_checkout.context.shop' + - '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfigurationRepository' - ps_checkout.repository.prestashop.account: - class: 'PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository' + PrestaShop\Module\PrestashopCheckout\PayPal\Sdk\PayPalSdkConfigurationBuilder: + class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Sdk\PayPalSdkConfigurationBuilder' public: true arguments: - - "@ps_checkout.configuration" - - "@ps_accounts.facade" - - ps_checkout.store.module.paypal: + - '@ps_checkout.module' + - '@PrestaShop\Module\PrestashopCheckout\Environment\Env' + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalPayLaterConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfigurationRepository' + - '@PrestaShop\Module\PrestashopCheckout\ExpressCheckout\ExpressCheckoutConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\ShopContext' + - '@PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext' + - '@ps_checkout.logger' + - '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceEligibilityConstraint' + + PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\PaypalModule: class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\PaypalModule' public: true arguments: - - "@ps_checkout.paypal.configuration" + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration' - ps_checkout.store.module.configuration: + PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\ConfigurationModule: class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\ConfigurationModule' public: true arguments: - - "@ps_checkout.pay_later.configuration" - - "@ps_checkout.express_checkout.configuration" - - "@ps_checkout.paypal.configuration" - - "@ps_checkout.funding_source.provider" + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalPayLaterConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\ExpressCheckout\ExpressCheckoutConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceProvider' - "@ps_checkout.module" - ps_checkout.builder.module_link: + PrestaShop\Module\PrestashopCheckout\Builder\ModuleLink\ModuleLinkBuilder: class: 'PrestaShop\Module\PrestashopCheckout\Builder\ModuleLink\ModuleLinkBuilder' public: true - ps_checkout.step.live: + PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\LiveStep: class: 'PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\LiveStep' public: true arguments: - - "@ps_checkout.configuration" + - '@PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration' - ps_checkout.step.value: + PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\ValueBanner: class: 'PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\ValueBanner' public: true arguments: - - "@ps_checkout.configuration" + - '@PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration' - ps_checkout.translations.translations: + PrestaShop\Module\PrestashopCheckout\Translations\Translations: class: 'PrestaShop\Module\PrestashopCheckout\Translations\Translations' public: true arguments: - "@ps_checkout.module" - ps_checkout.store.module.context: + PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\ContextModule: class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\ContextModule' public: true arguments: - '@=service("ps_checkout.module").name' - '@=service("ps_checkout.module").module_key' - - "@ps_checkout.context.prestashop" - - "@ps_checkout.paypal.configuration" - - "@ps_checkout.step.live" - - "@ps_checkout.step.value" - - "@ps_checkout.translations.translations" - - "@ps_checkout.context.shop" - - "@ps_checkout.shop.provider" - - "@ps_checkout.builder.module_link" - - "@ps_checkout.repository.prestashop.account" - - ps_checkout.adapter.language: + - '@PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext' + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\LiveStep' + - '@PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\ValueBanner' + - '@PrestaShop\Module\PrestashopCheckout\Translations\Translations' + - '@PrestaShop\Module\PrestashopCheckout\ShopContext' + - '@PrestaShop\Module\PrestashopCheckout\Shop\ShopProvider' + - '@PrestaShop\Module\PrestashopCheckout\Builder\ModuleLink\ModuleLinkBuilder' + - '@PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository' + + PrestaShop\Module\PrestashopCheckout\Adapter\LanguageAdapter: class: 'PrestaShop\Module\PrestashopCheckout\Adapter\LanguageAdapter' public: true arguments: - - "@ps_checkout.context.shop" + - '@PrestaShop\Module\PrestashopCheckout\ShopContext' - ps_checkout.store.store: + PrestaShop\Module\PrestashopCheckout\Presenter\Store\StorePresenter: class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Store\StorePresenter' public: true arguments: - [ - "@ps_checkout.store.module.context", - "@ps_checkout.store.module.paypal", - "@ps_checkout.store.module.configuration", + '@PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\ContextModule', + '@PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\PaypalModule', + '@PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\ConfigurationModule', ] - ps_checkout.repository.pscheckoutcart: - class: 'PrestaShop\Module\PrestashopCheckout\Repository\PsCheckoutCartRepository' - public: true - arguments: - - "@ps_checkout.cache.pscheckoutcart" - - ps_checkout.funding_source.configuration.repository: - class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfigurationRepository' - public: true - arguments: - - "@ps_checkout.context.prestashop" - - ps_checkout.funding_source.configuration: - class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfiguration' - public: true - arguments: - - "@ps_checkout.funding_source.configuration.repository" - - ps_checkout.funding_source.eligibility_constraint: + PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceEligibilityConstraint: class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceEligibilityConstraint' public: true - ps_checkout.funding_source.collection.builder: + PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceCollectionBuilder: class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceCollectionBuilder' public: true arguments: - - "@ps_checkout.funding_source.configuration" - - "@ps_checkout.funding_source.eligibility_constraint" + - '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceEligibilityConstraint' - ps_checkout.funding_source.translation: + PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceTranslationProvider: class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceTranslationProvider' public: true arguments: - "@ps_checkout.module" - ps_checkout.repository.country: - class: 'PrestaShop\Module\PrestashopCheckout\Repository\CountryRepository' - public: true - - ps_checkout.funding_source.presenter: + PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourcePresenter: class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourcePresenter' public: true arguments: - - "@ps_checkout.funding_source.translation" - - "@ps_checkout.repository.country" + - '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceTranslationProvider' + - '@PrestaShop\Module\PrestashopCheckout\Repository\CountryRepository' + - '@PrestaShop\Module\PrestashopCheckout\Provider\PaymentMethodLogoProvider' - ps_checkout.funding_source.collection: + PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceCollection: class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceCollection' public: true arguments: - - '@=service("ps_checkout.funding_source.collection.builder").create()' + - '@=service("PrestaShop\\Module\\PrestashopCheckout\\FundingSource\\FundingSourceCollectionBuilder").create()' - ps_checkout.funding_source.provider: + PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceProvider: class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceProvider' public: true arguments: - - "@ps_checkout.funding_source.collection.builder" - - "@ps_checkout.funding_source.presenter" + - '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceCollectionBuilder' + - '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourcePresenter' + - '@PrestaShop\Module\PrestashopCheckout\Repository\PaymentTokenRepository' + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext' ps_checkout.repository.paypal.code: class: 'PrestaShop\Module\PrestashopCheckout\Repository\PayPalCodeRepository' public: true - ps_checkout.env_loader: - class: 'PrestaShop\Module\PrestashopCheckout\Environment\EnvLoader' - public: true - - ps_checkout.validator.merchant: + PrestaShop\Module\PrestashopCheckout\Validator\MerchantValidator: class: 'PrestaShop\Module\PrestashopCheckout\Validator\MerchantValidator' public: true arguments: - - "@ps_checkout.paypal.configuration" - - "@ps_checkout.repository.prestashop.account" - - "@ps_checkout.context.prestashop" + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository' + - '@PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext' - ps_checkout.validator.front_controller: + PrestaShop\Module\PrestashopCheckout\Validator\FrontControllerValidator: class: 'PrestaShop\Module\PrestashopCheckout\Validator\FrontControllerValidator' public: true arguments: - - "@ps_checkout.validator.merchant" - - "@ps_checkout.express_checkout.configuration" - - "@ps_checkout.pay_later.configuration" - - ps_checkout.validator.batch_configuration: - class: 'PrestaShop\Module\PrestashopCheckout\Validator\BatchConfigurationValidator' - public: true + - '@PrestaShop\Module\PrestashopCheckout\Validator\MerchantValidator' + - '@PrestaShop\Module\PrestashopCheckout\ExpressCheckout\ExpressCheckoutConfiguration' + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalPayLaterConfiguration' - ps_checkout.validator.batch_configuration: + PrestaShop\Module\PrestashopCheckout\Validator\BatchConfigurationValidator: class: 'PrestaShop\Module\PrestashopCheckout\Validator\BatchConfigurationValidator' public: true - ps_checkout.cache.directory: - class: 'PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider' - public: true - arguments: - - !php/const _PS_VERSION_ - - !php/const _PS_ROOT_DIR_ - - !php/const _PS_MODE_DEV_ - - ps_checkout.cache.array.paypal.order: - class: 'Symfony\Component\Cache\Simple\ArrayCache' - - ps_checkout.cache.filesystem.paypal.order: - class: 'Symfony\Component\Cache\Simple\FilesystemCache' - arguments: - - "paypal-orders" - - 3600 - - '@=service("ps_checkout.cache.directory").getPath()' - - ps_checkout.cache.paypal.order: - class: 'Symfony\Component\Cache\Simple\ChainCache' - public: true - arguments: - - [ - "@ps_checkout.cache.array.paypal.order", - "@ps_checkout.cache.filesystem.paypal.order", - ] - - ps_checkout.cache.array.paypal.capture: - class: 'Symfony\Component\Cache\Simple\ArrayCache' - - ps_checkout.cache.filesystem.paypal.capture: - class: 'Symfony\Component\Cache\Simple\FilesystemCache' - arguments: - - "paypal-capture" - - 3600 - - '@=service("ps_checkout.cache.directory").getPath()' - - ps_checkout.cache.paypal.capture: - class: 'Symfony\Component\Cache\Simple\ChainCache' - public: true - arguments: - - [ - "@ps_checkout.cache.array.paypal.capture", - "@ps_checkout.cache.filesystem.paypal.capture", - ] - - ps_checkout.cache.pscheckoutcart: - class: 'Symfony\Component\Cache\Simple\ArrayCache' - public: true - - ps_checkout.cache.order: - class: 'Symfony\Component\Cache\Simple\ArrayCache' - public: true - - ps_checkout.paypal.provider.order: + PrestaShop\Module\PrestashopCheckout\PayPal\PayPalOrderProvider: class: 'PrestaShop\Module\PrestashopCheckout\PayPal\PayPalOrderProvider' public: true arguments: - "@ps_checkout.cache.paypal.order" - ps_checkout.prestashop.router: + PrestaShop\Module\PrestashopCheckout\Routing\Router: class: 'PrestaShop\Module\PrestashopCheckout\Routing\Router' public: true - ps_checkout.paypal.order.translations: + PrestaShop\Module\PrestashopCheckout\PayPal\Order\PayPalOrderTranslationProvider: class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\PayPalOrderTranslationProvider' public: true arguments: - - '@ps_checkout.translations.translations' - - '@ps_checkout.funding_source.translation' + - '@PrestaShop\Module\PrestashopCheckout\Translations\Translations' + - '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceTranslationProvider' - ps_checkout.paypal.order.presenter: + PrestaShop\Module\PrestashopCheckout\PayPal\Order\PayPalOrderSummaryViewBuilder: class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\PayPalOrderSummaryViewBuilder' public: true arguments: - - '@ps_checkout.repository.pscheckoutcart' - - '@ps_checkout.paypal.provider.order' - - '@ps_checkout.prestashop.router' - - '@ps_checkout.paypal.order.translations' - - '@ps_checkout.context.shop' - - ps_checkout.paypal.builder.view_order_summary: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\PayPalOrderSummaryViewBuilder' - public: true - arguments: - - '@ps_checkout.repository.pscheckoutcart' - - '@ps_checkout.paypal.provider.order' - - '@ps_checkout.prestashop.router' - - '@ps_checkout.paypal.order.translations' - - '@ps_checkout.context.shop' + - '@PrestaShop\Module\PrestashopCheckout\Repository\PsCheckoutCartRepository' + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalOrderProvider' + - '@PrestaShop\Module\PrestashopCheckout\Routing\Router' + - '@PrestaShop\Module\PrestashopCheckout\PayPal\Order\PayPalOrderTranslationProvider' + - '@PrestaShop\Module\PrestashopCheckout\ShopContext' + - '@PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository' - ps_checkout.webhook.service.secret_token: + PrestaShop\Module\PrestashopCheckout\Webhook\WebhookSecretTokenService: class: 'PrestaShop\Module\PrestashopCheckout\Webhook\WebhookSecretTokenService' public: true arguments: - - "@ps_checkout.configuration" + - '@PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration' - ps_checkout.webhook.handler.event.configuration_updated: + PrestaShop\Module\PrestashopCheckout\Webhook\WebhookEventConfigurationUpdatedHandler: class: 'PrestaShop\Module\PrestashopCheckout\Webhook\WebhookEventConfigurationUpdatedHandler' public: true arguments: - - "@ps_checkout.configuration" + - '@PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration' - ps_checkout.order.service.check_order_amount: + PrestaShop\Module\PrestashopCheckout\Order\Service\CheckOrderAmount: class: 'PrestaShop\Module\PrestashopCheckout\Order\Service\CheckOrderAmount' public: true - ps_checkout.order.state.service.order_state_mapper: + PrestaShop\Module\PrestashopCheckout\Order\State\Service\OrderStateMapper: class: 'PrestaShop\Module\PrestashopCheckout\Order\State\Service\OrderStateMapper' public: true arguments: - - "@ps_checkout.configuration" + - '@PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration' - ps_checkout.paypal.order.service.paypal_order_status: + PrestaShop\Module\PrestashopCheckout\PayPal\Order\PayPalOrderStatus: class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\PayPalOrderStatus' public: true - ps_checkout.paypal.order.service.check_transition_paypal_order_status: + PrestaShop\Module\PrestashopCheckout\PayPal\Order\CheckTransitionPayPalOrderStatusService: class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CheckTransitionPayPalOrderStatusService' public: true - ps_checkout.webhook.handler: + PrestaShop\Module\PrestashopCheckout\Webhook\WebhookHandler: class: 'PrestaShop\Module\PrestashopCheckout\Webhook\WebhookHandler' public: true arguments: - - "@ps_checkout.webhook.service.secret_token" - - ["@ps_checkout.webhook.handler.event.configuration_updated"] + - '@PrestaShop\Module\PrestashopCheckout\Webhook\WebhookSecretTokenService' + - ['@PrestaShop\Module\PrestashopCheckout\Webhook\WebhookEventConfigurationUpdatedHandler'] - ps_checkout.configuration.batch_processor: + PrestaShop\Module\PrestashopCheckout\Configuration\BatchConfigurationProcessor: class: 'PrestaShop\Module\PrestashopCheckout\Configuration\BatchConfigurationProcessor' public: true arguments: - - '@ps_checkout.configuration' - - ps_checkout.configuration.batch_processor: - class: 'PrestaShop\Module\PrestashopCheckout\Configuration\BatchConfigurationProcessor' - public: true - arguments: - - '@ps_checkout.configuration' - - ps_accounts.installer: - class: 'PrestaShop\PsAccountsInstaller\Installer\Installer' - public: true - arguments: - - "4.0.0" - - ps_accounts.facade: - class: 'PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts' - public: true - arguments: - - "@ps_accounts.installer" - - ps_checkout.tactician.bus: - class: 'League\Tactician\CommandBus' - factory: ['@PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusFactory', "create"] - - ps_checkout.bus.command: - class: 'PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusAdapter' - public: true - arguments: - - "@ps_checkout.tactician.bus" - - PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusFactory: - class: 'PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusFactory' - public: true - arguments: - - "@ps_checkout.module" - - "@ps_checkout.logger" - - - PrestaShop\Module\PrestashopCheckout\Order\Command\AddOrderPaymentCommand: "ps_checkout.command.handler.order.add_order_payment" - PrestaShop\Module\PrestashopCheckout\Order\Command\CreateOrderCommand: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\CreateOrderCommandHandler' - PrestaShop\Module\PrestashopCheckout\Order\Command\UpdateOrderStatusCommand: "ps_checkout.command.handler.order.update_order_status" - PrestaShop\Module\PrestashopCheckout\Order\Matrice\Command\UpdateOrderMatriceCommand: "ps_checkout.command.handler.order.matrice.update_order_matrice" - PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\CreatePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\CreatePayPalOrderCommandHandler' - PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\UpdatePayPalOrderCommand: "ps_checkout.command.handler.paypal.order.update_paypal_order" - PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\CapturePayPalOrderCommand: "ps_checkout.command.handler.paypal.order.capture_paypal_order" - PrestaShop\Module\PrestashopCheckout\Checkout\Command\CancelCheckoutCommand: "ps_checkout.command.handler.checkout.cancel_checkout" - PrestaShop\Module\PrestashopCheckout\Checkout\Command\SaveCheckoutCommand: "ps_checkout.command.handler.checkout.save_checkout" - PrestaShop\Module\PrestashopCheckout\Checkout\Command\SavePayPalOrderStatusCommand: "ps_checkout.command.handler.checkout.save_paypal_order_status" - PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentCompletedQuery: "ps_checkout.query.handler.order.get_order_for_payment_completed" - PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentDeniedQuery: "ps_checkout.query.handler.order.get_order_for_payment_denied" - PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentPendingQuery: "ps_checkout.query.handler.order.get_order_for_payment_pending" - PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentRefundedQuery: "ps_checkout.query.handler.order.get_order_for_payment_refunded" - PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentReversedQuery: "ps_checkout.query.handler.order.get_order_for_payment_reversed" - PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForApprovalReversedQuery: "ps_checkout.query.handler.order.get_order_for_approval_reversed" - PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForCartIdQuery: "ps_checkout.query.handler.paypal.order.get_paypal_order_for_cart_id" - PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetCurrentPayPalOrderStatusQuery: "ps_checkout.query.handler.paypal.order.get_current_paypal_order_status" - PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderQuery: "ps_checkout.query.handler.paypal.order.get_paypal_order" - PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForCheckoutCompletedQuery: "ps_checkout.query.handler.paypal.order.get_paypal_order_for_checkout_completed" - PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForOrderConfirmationQuery: "ps_checkout.query.handler.paypal.order.get_paypal_order_for_order_confirmation" - PrestaShop\Module\PrestashopCheckout\Checkout\Command\UpdatePaymentMethodSelectedCommand: "ps_checkout.query.handler.checkout.update_payment_method_selected" - PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\Command\RefundPayPalCaptureCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\CommandHandler\RefundPayPalCaptureCommandHandler' - - ps_checkout.event.dispatcher.factory: - class: 'PrestaShop\Module\PrestashopCheckout\Event\SymfonyEventDispatcherFactory' - public: true - arguments: - - "@ps_checkout.logger" - - "@ps_checkout.logger.configuration" - - PrestaShop\Module\PrestashopCheckout\Checkout\EventSubscriber\CheckoutEventSubscriber: - class: 'PrestaShop\Module\PrestashopCheckout\Checkout\EventSubscriber\CheckoutEventSubscriber' - public: true - arguments: - - '@PrestaShop\Module\PrestashopCheckout\Checkout\CheckoutChecker' - - '@ps_checkout.bus.command' - - '@ps_checkout.repository.pscheckoutcart' - - PrestaShop\Module\PrestashopCheckout\Order\EventSubscriber\OrderEventSubscriber: - class: 'PrestaShop\Module\PrestashopCheckout\Order\EventSubscriber\OrderEventSubscriber' - public: true - arguments: - - "@ps_checkout.repository.pscheckoutcart" - - '@ps_checkout.bus.command' - - PrestaShop\Module\PrestashopCheckout\PayPal\Order\EventSubscriber\PayPalOrderEventSubscriber: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\EventSubscriber\PayPalOrderEventSubscriber' - public: true - arguments: - - "@ps_checkout.module" - - "@ps_checkout.repository.pscheckoutcart" - - "@ps_checkout.cache.paypal.order" - - '@PrestaShop\Module\PrestashopCheckout\Checkout\CheckoutChecker' - - "@ps_checkout.paypal.order.service.check_transition_paypal_order_status" - - "@ps_checkout.order.state.service.order_state_mapper" - - '@ps_checkout.paypal.configuration' - - '@PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository' - - PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Capture\EventSubscriber\PayPalCaptureEventSubscriber: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Capture\EventSubscriber\PayPalCaptureEventSubscriber' - public: true - arguments: - - "@ps_checkout.order.service.check_order_amount" - - "@ps_checkout.cache.paypal.capture" - - "@ps_checkout.cache.paypal.order" - - "@ps_checkout.order.state.service.order_state_mapper" - - "@ps_checkout.bus.command" - - PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\EventSubscriber\PayPalRefundEventSubscriber: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\EventSubscriber\PayPalRefundEventSubscriber' - arguments: - - '@ps_checkout.module' - - '@ps_checkout.order.service.check_order_amount' - - '@ps_checkout.cache.paypal.capture' - - '@ps_checkout.cache.paypal.order' - - '@ps_checkout.order.state.service.order_state_mapper' - - '@ps_checkout.paypal.provider.order' - - ps_checkout.event.dispatcher.symfony: - class: 'Symfony\Component\EventDispatcher\EventDispatcherInterface' - factory: ["@ps_checkout.event.dispatcher.factory", "create"] - arguments: - - [ - '@PrestaShop\Module\PrestashopCheckout\Checkout\EventSubscriber\CheckoutEventSubscriber', - '@PrestaShop\Module\PrestashopCheckout\Order\EventSubscriber\OrderEventSubscriber', - '@PrestaShop\Module\PrestashopCheckout\PayPal\Order\EventSubscriber\PayPalOrderEventSubscriber', - '@PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Capture\EventSubscriber\PayPalCaptureEventSubscriber', - '@PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\EventSubscriber\PayPalRefundEventSubscriber' - ] - - ps_checkout.event.dispatcher: - class: 'PrestaShop\Module\PrestashopCheckout\Event\SymfonyEventDispatcherAdapter' - public: true - arguments: - - "@ps_checkout.event.dispatcher.symfony" - - ps_checkout.command.handler.order.add_order_payment: - class: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\AddOrderPaymentCommandHandler' - public: true - arguments: - - "@ps_checkout.event.dispatcher" - - "@ps_checkout.funding_source.translation" - - "@ps_checkout.paypal.configuration" - - PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\CreateOrderCommandHandler: - class: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\CreateOrderCommandHandler' - public: true - arguments: - - "@ps_checkout.context.state.manager" - - "@ps_checkout.event.dispatcher" - - "@ps_checkout.repository.pscheckoutcart" - - "@ps_checkout.order.state.service.order_state_mapper" - - "@ps_checkout.module" - - "@ps_checkout.order.service.check_order_amount" - - '@ps_checkout.funding_source.translation' - - ps_checkout.command.handler.order.update_order_status: - class: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\UpdateOrderStatusCommandHandler' - public: true - arguments: - - "@ps_checkout.event.dispatcher" - - ps_checkout.command.handler.order.matrice.update_order_matrice: - class: 'PrestaShop\Module\PrestashopCheckout\Order\Matrice\CommandHandler\UpdateOrderMatriceCommandHandler' - public: true - arguments: - - "@ps_checkout.event.dispatcher" - - PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\CreatePayPalOrderCommandHandler: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\CreatePayPalOrderCommandHandler' - public: true - arguments: - - '@?' - - '@?' - - '@ps_checkout.event.dispatcher' - - '@PrestaShop\Module\PrestashopCheckout\Api\Payment\PaymentService' - - '@PrestaShop\Module\PrestashopCheckout\Serializer\ObjectSerializer' - - ps_checkout.command.handler.paypal.order.update_paypal_order: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\UpdatePayPalOrderCommandHandler' - public: true - arguments: - - "@ps_checkout.http.client.checkout" - - "@ps_checkout.event.dispatcher" - - "@ps_checkout.context.shop" - - ps_checkout.command.handler.paypal.order.capture_paypal_order: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\CapturePayPalOrderCommandHandler' - public: true - arguments: - - "@ps_checkout.http.client.checkout" - - "@ps_checkout.event.dispatcher" - - "@ps_checkout.cache.paypal.order" - - "@ps_checkout.repository.pscheckoutcart" - - '@ps_checkout.paypal.configuration' - - ps_checkout.query.handler.paypal.order.get_paypal_order: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderQueryHandler' - public: true - arguments: - - '@ps_checkout.cache.paypal.order' - - '@ps_checkout.repository.pscheckoutcart' - - ps_checkout.query.handler.paypal.order.get_current_paypal_order_status: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetCurrentPayPalOrderStatusQueryHandler' - public: true - arguments: - - "@ps_checkout.repository.pscheckoutcart" - - ps_checkout.query.handler.order.get_order_for_payment_completed: - class: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentCompletedQueryHandler' - public: true - arguments: - - "@ps_checkout.repository.pscheckoutcart" - - ps_checkout.query.handler.order.get_order_for_payment_denied: - class: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentDeniedQueryHandler' - public: true - arguments: - - "@ps_checkout.repository.pscheckoutcart" - - ps_checkout.query.handler.order.get_order_for_payment_pending: - class: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentPendingQueryHandler' - public: true - arguments: - - "@ps_checkout.repository.pscheckoutcart" - - ps_checkout.query.handler.order.get_order_for_payment_refunded: - class: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentRefundedQueryHandler' - public: true - arguments: - - "@ps_checkout.repository.pscheckoutcart" - - ps_checkout.query.handler.order.get_order_for_payment_reversed: - class: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentReversedQueryHandler' - public: true - arguments: - - "@ps_checkout.repository.pscheckoutcart" - - ps_checkout.query.handler.order.get_order_for_approval_reversed: - class: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForApprovalReversedQueryHandler' - public: true - arguments: - - "@ps_checkout.repository.pscheckoutcart" - - ps_checkout.query.handler.paypal.order.get_paypal_order_for_cart_id: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderForCartIdQueryHandler' - public: true - arguments: - - '@ps_checkout.cache.paypal.order' - - '@ps_checkout.repository.pscheckoutcart' - - ps_checkout.query.handler.paypal.order.get_paypal_order_for_checkout_completed: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderForCheckoutCompletedQueryHandler' - public: true - arguments: - - "@ps_checkout.cache.paypal.order" + - '@PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration' - ps_checkout.query.handler.paypal.order.get_paypal_order_for_order_confirmation: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderForOrderConfirmationQueryHandler' - public: true - arguments: - - "@ps_checkout.cache.paypal.order" - - ps_checkout.command.handler.checkout.save_checkout: - class: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\SaveCheckoutCommandHandler' - public: true - arguments: - - "@ps_checkout.repository.pscheckoutcart" - - ps_checkout.command.handler.checkout.cancel_checkout: - class: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\CancelCheckoutCommandHandler' - public: true - arguments: - - "@ps_checkout.repository.pscheckoutcart" - - ps_checkout.command.handler.checkout.save_paypal_order_status: - class: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\SavePayPalOrderStatusCommandHandler' - public: true - arguments: - - "@ps_checkout.repository.pscheckoutcart" - - ps_checkout.query.handler.checkout.update_payment_method_selected: - class: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\UpdatePaymentMethodSelectedCommandHandler' - public: true - arguments: - - "@ps_checkout.repository.pscheckoutcart" - - PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\CommandHandler\RefundPayPalCaptureCommandHandler: - class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\CommandHandler\RefundPayPalCaptureCommandHandler' - public: true - arguments: - - '@ps_checkout.http.client.checkout' - - '@ps_checkout.paypal.configuration' - - '@ps_checkout.configuration' - - '@ps_checkout.context.prestashop' - - '@ps_checkout.event.dispatcher' - - ps_checkout.paypal.capture.service.check_transition_paypal_capture_status: + PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Capture\CheckTransitionPayPalCaptureStatusService: class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Capture\CheckTransitionPayPalCaptureStatusService' public: true @@ -734,68 +454,34 @@ services: arguments: - "@ps_checkout.logger" - PrestaShop\Module\PrestashopCheckout\Environment\Env: - class: 'PrestaShop\Module\PrestashopCheckout\Environment\Env' - - PrestaShop\Module\PrestashopCheckout\Environment\PaymentEnv: - class: 'PrestaShop\Module\PrestashopCheckout\Environment\PaymentEnv' - - PrestaShop\Module\PrestashopCheckout\Builder\Configuration\PaymentClientConfigurationBuilder: - class: 'PrestaShop\Module\PrestashopCheckout\Builder\Configuration\PaymentClientConfigurationBuilder' - arguments: - - '@PrestaShop\Module\PrestashopCheckout\Environment\PaymentEnv' - - '@ps_checkout.prestashop.router' - - '@ps_checkout.context.shop' - - '@ps_checkout.repository.prestashop.account' - - '@ps_checkout.context.prestashop' - - "@ps_checkout.logger.configuration" - - "@ps_checkout.logger" - - PrestaShop\Module\PrestashopCheckout\Api\Payment\Client\PayPalOrderHttpClient: - class: 'PrestaShop\Module\PrestashopCheckout\Api\Payment\Client\PayPalOrderHttpClient' - arguments: - - '@PrestaShop\Module\PrestashopCheckout\Builder\Configuration\PaymentClientConfigurationBuilder' - - - PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository: - class: 'PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository' - arguments: - - '@ps_checkout.db' - - PrestaShop\Module\PrestashopCheckout\Api\Payment\PaymentService: - class: 'PrestaShop\Module\PrestashopCheckout\Api\Payment\PaymentService' + PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\PaymentMethodTokenService: + class: 'PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\PaymentMethodTokenService' + public: true arguments: - - '@PrestaShop\Module\PrestashopCheckout\Api\Payment\Client\PayPalOrderHttpClient' - - '@PrestaShop\Module\PrestashopCheckout\Serializer\ObjectSerializer' - - PrestaShop\Module\PrestashopCheckout\Serializer\ObjectSerializer: - class: 'PrestaShop\Module\PrestashopCheckout\Serializer\ObjectSerializer' + - '@?' + - '@PrestaShop\Module\PrestashopCheckout\Http\CheckoutHttpClient' + - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration' - ps_checkout.http.client.configuration: - class: 'PrestaShop\Module\PrestashopCheckout\Http\CheckoutHttpClientConfigurationBuilder' + PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\OAuthService: + class: 'PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\OAuthService' public: true arguments: - - '@PrestaShop\Module\PrestashopCheckout\Environment\PaymentEnv' - - "@ps_checkout.prestashop.router" - - "@ps_checkout.context.shop" - - "@ps_checkout.repository.prestashop.account" - - "@ps_checkout.context.prestashop" - - "@ps_checkout.logger.configuration" - - "@ps_checkout.logger" + - '@PrestaShop\Module\PrestashopCheckout\Http\CheckoutHttpClient' - ps_checkout.http.client.factory: - class: 'PrestaShop\Module\PrestashopCheckout\Http\HttpClientFactory' + PrestaShop\Module\PrestashopCheckout\Provider\PaymentMethodLogoProvider: + class: 'PrestaShop\Module\PrestashopCheckout\Provider\PaymentMethodLogoProvider' public: true + arguments: + - '@ps_checkout.module' - ps_checkout.http.client: - class: 'PrestaShop\Module\PrestashopCheckout\Http\HttpClientInterface' + PrestaShop\Module\PrestashopCheckout\PayPal\GooglePay\Builder\GooglePayTransactionInfoBuilder: + class: 'PrestaShop\Module\PrestashopCheckout\PayPal\GooglePay\Builder\GooglePayTransactionInfoBuilder' public: true - factory: ["@ps_checkout.http.client.factory", "create"] arguments: - - "@ps_checkout.http.client.configuration" + - '@PrestaShop\Module\PrestashopCheckout\Translations\Translations' - ps_checkout.http.client.checkout: - class: 'PrestaShop\Module\PrestashopCheckout\Http\CheckoutHttpClient' + PrestaShop\Module\PrestashopCheckout\PayPal\ApplePay\Builder\ApplePayPaymentRequestBuilder: + class: 'PrestaShop\Module\PrestashopCheckout\PayPal\ApplePay\Builder\ApplePayPaymentRequestBuilder' public: true arguments: - - "@ps_checkout.http.client" + - '@PrestaShop\Module\PrestashopCheckout\Translations\Translations' diff --git a/ps_checkout.php b/ps_checkout.php index 9c205c67d..a1af17bbb 100755 --- a/ps_checkout.php +++ b/ps_checkout.php @@ -46,7 +46,7 @@ class Ps_checkout extends PaymentModule 'actionObjectOrderPaymentUpdateAfter', 'displayPaymentReturn', 'displayOrderDetail', - 'moduleRoutes' + 'moduleRoutes', ]; /** @@ -116,9 +116,9 @@ class Ps_checkout extends PaymentModule // Needed in order to retrieve the module version easier (in api call headers) than instanciate // the module each time to get the version - const VERSION = '7.3.6.3'; + const VERSION = '7.4.2.1'; - const INTEGRATION_DATE = '2022-14-06'; + const INTEGRATION_DATE = '2024-04-01'; /** @var \Psr\Log\LoggerInterface */ private $logger; @@ -137,7 +137,7 @@ public function __construct() // We cannot use the const VERSION because the const is not computed by addons marketplace // when the zip is uploaded - $this->version = '7.3.6.3'; + $this->version = '7.4.2.1'; $this->author = 'PrestaShop'; $this->currencies = true; $this->currencies_mode = 'checkbox'; @@ -1013,7 +1013,6 @@ public function hookActionFrontControllerSetMedia() if (false !== $psCheckoutCart && $psCheckoutCart->isOrderAvailable()) { $payPalOrderId = $psCheckoutCart->getPaypalOrderId(); $cartFundingSource = $psCheckoutCart->getPaypalFundingSource(); - $payPalClientToken = $psCheckoutCart->getPaypalClientToken(); } // END To be refactored in services @@ -1805,9 +1804,9 @@ public function hookModuleRoutes() 'params' => [ 'fc' => 'module', 'module' => 'ps_checkout', - 'action' => 'getDomainAssociation' + 'action' => 'getDomainAssociation', ], - ] + ], ]; } } diff --git a/src/Builder/Payload/OrderPayloadBuilder.php b/src/Builder/Payload/OrderPayloadBuilder.php index f448a947b..7dfb6f8b5 100644 --- a/src/Builder/Payload/OrderPayloadBuilder.php +++ b/src/Builder/Payload/OrderPayloadBuilder.php @@ -70,6 +70,71 @@ class OrderPayloadBuilder extends Builder implements PayloadBuilderInterface */ private $isCard = false; + /** + * @var string + */ + private $fundingSource; + + /** + * @var string + */ + private $paypalCustomerId; + + /** + * @var string + */ + private $paypalVaultId; + + /** + * @var bool + */ + private $savePaymentMethod; + + /** + * @var bool + */ + private $vault = false; + + /** + * @param bool $savePaymentMethod + */ + public function setSavePaymentMethod($savePaymentMethod) + { + $this->savePaymentMethod = $savePaymentMethod; + } + + /** + * @param string $fundingSource + */ + public function setFundingSource($fundingSource) + { + $this->fundingSource = $fundingSource; + } + + /** + * @param string $paypalCustomerId + */ + public function setPaypalCustomerId($paypalCustomerId) + { + $this->paypalCustomerId = $paypalCustomerId; + } + + /** + * @param string $paypalVaultId + */ + public function setPaypalVaultId($paypalVaultId) + { + $this->paypalVaultId = $paypalVaultId; + } + + /** + * @param bool $vault + */ + public function setVault($vault) + { + $this->vault = $vault; + } + /** * @param array $cart * @param bool $isPatch @@ -109,9 +174,20 @@ public function buildFullPayload() } if ($this->isCard) { - $this->buildPaymentSourceNode(); + $this->buildCardPaymentSourceNode(); $this->buildSupplementaryDataNode(); } + + switch ($this->fundingSource) { + case 'paypal': + $this->buildPayPalPaymentSourceNode(); + break; + case 'google_pay': + $this->buildGooglePayPaymentSourceNode(); + break; + default: + break; + } } /** @@ -140,7 +216,7 @@ public function buildMinimalPayload() } if ($this->isCard) { - $this->buildPaymentSourceNode(); + $this->buildCardPaymentSourceNode(); $this->buildSupplementaryDataNode(); } } @@ -175,6 +251,7 @@ public function buildBaseNode() 'payee' => [ 'merchant_id' => $merchantId, ], + 'vault' => $this->vault, ]; if (true === $this->isUpdate) { @@ -295,6 +372,7 @@ public function buildApplicationContextNode() ), 'shipping_preference' => $this->expressCheckout ? 'GET_FROM_FILE' : 'SET_PROVIDED_ADDRESS', 'return_url' => $router->getCheckoutValidateLink(), + 'cancel_url' => $router->getCheckoutCancelLink(), ]; $this->getPayload()->addAndMergeItems($node); @@ -396,7 +474,7 @@ public function buildAmountBreakdownNode() $this->getPayload()->addAndMergeItems($node); } - private function buildPaymentSourceNode() + private function buildCardPaymentSourceNode() { /** @var \Ps_checkout $module */ $module = \Module::getInstanceByName('ps_checkout'); @@ -416,6 +494,23 @@ private function buildPaymentSourceNode() $node['payment_source']['card']['attributes']['verification']['method'] = $paypalConfiguration->getHostedFieldsContingencies(); } + if ($this->paypalVaultId) { + unset($node['payment_source']['card']['billing_address']); + $node['payment_source']['card']['vault_id'] = $this->paypalVaultId; + } + + if ($this->paypalCustomerId) { + $node['payment_source']['card']['attributes']['customer'] = [ + 'id' => $this->paypalCustomerId, + ]; + } + + if ($this->savePaymentMethod) { + $node['payment_source']['card']['attributes']['vault'] = [ + 'store_in_vault' => 'ON_SUCCESS', + ]; + } + $this->getPayload()->addAndMergeItems($node); } @@ -426,7 +521,6 @@ private function buildSupplementaryDataNode() 'supplementary_data' => [ 'card' => [ 'level_2' => [ -// 'invoice_id' => '', 'tax_total' => $payload['amount']['breakdown']['tax_total'], ], 'level_3' => [ @@ -606,4 +700,68 @@ public function getExpressCheckout() { return $this->expressCheckout; } + + private function buildPayPalPaymentSourceNode() + { + $data = []; + + if ($this->paypalVaultId) { + return; + // $data['vault_id'] = $this->paypalVaultId; + } + + if ($this->paypalCustomerId) { + $data['attributes']['customer'] = [ + 'id' => $this->paypalCustomerId, + ]; + } + + if ($this->savePaymentMethod) { + $data['attributes']['vault'] = [ + 'store_in_vault' => 'ON_SUCCESS', + 'usage_pattern' => 'IMMEDIATE', + 'usage_type' => 'MERCHANT', + 'customer_type' => 'CONSUMER', + 'permit_multiple_payment_tokens' => false, + ]; + } + + if (empty($data)) { + return; + } + + $node = [ + 'payment_source' => [ + 'paypal' => $data, + ], + ]; + + $this->getPayload()->addAndMergeItems($node); + } + + private function buildGooglePayPaymentSourceNode() + { + /** @var \Ps_checkout $module */ + $module = \Module::getInstanceByName('ps_checkout'); + /** @var PayPalConfiguration $paypalConfiguration */ + $paypalConfiguration = $module->getService(PayPalConfiguration::class); + + if (!$paypalConfiguration->is3dSecureEnabled()) { + return; + } + + $node = [ + 'payment_source' => [ + 'google_pay' => [ + 'attributes' => [ + 'verification' => [ + 'method' => $paypalConfiguration->getHostedFieldsContingencies(), + ], + ], + ], + ], + ]; + + $this->getPayload()->addAndMergeItems($node); + } } diff --git a/src/PayPal/Order/CommandHandler/CreatePayPalOrderCommandHandler.php b/src/PayPal/Order/CommandHandler/CreatePayPalOrderCommandHandler.php index 4cf0cddfb..3dd9fa832 100644 --- a/src/PayPal/Order/CommandHandler/CreatePayPalOrderCommandHandler.php +++ b/src/PayPal/Order/CommandHandler/CreatePayPalOrderCommandHandler.php @@ -20,41 +20,67 @@ namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler; +use Exception; use PrestaShop\Module\PrestashopCheckout\Builder\Payload\OrderPayloadBuilder; +use PrestaShop\Module\PrestashopCheckout\Cart\Exception\CartNotFoundException; +use PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext; +use PrestaShop\Module\PrestashopCheckout\Customer\ValueObject\CustomerId; use PrestaShop\Module\PrestashopCheckout\Event\EventDispatcherInterface; -use PrestaShop\Module\PrestashopCheckout\Exception\PayPalException; +use PrestaShop\Module\PrestashopCheckout\Exception\InvalidRequestException; +use PrestaShop\Module\PrestashopCheckout\Exception\NotAuthorizedException; use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException; -use PrestaShop\Module\PrestashopCheckout\Http\CheckoutHttpClient; +use PrestaShop\Module\PrestashopCheckout\Exception\UnprocessableEntityException; +use PrestaShop\Module\PrestashopCheckout\Http\MaaslandHttpClient; use PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\CreatePayPalOrderCommand; +use PrestaShop\Module\PrestashopCheckout\PayPal\Order\Entity\PayPalOrder; use PrestaShop\Module\PrestashopCheckout\PayPal\Order\Event\PayPalOrderCreatedEvent; use PrestaShop\Module\PrestashopCheckout\PayPal\Order\Exception\PayPalOrderException; use PrestaShop\Module\PrestashopCheckout\Presenter\Cart\CartPresenter; +use PrestaShop\Module\PrestashopCheckout\Repository\PaymentTokenRepository; +use PrestaShop\Module\PrestashopCheckout\Repository\PayPalCustomerRepository; use PrestaShop\Module\PrestashopCheckout\ShopContext; class CreatePayPalOrderCommandHandler { + /** + * @var MaaslandHttpClient + */ + private $maaslandHttpClient; /** * @var EventDispatcherInterface */ private $eventDispatcher; - /** - * @var CheckoutHttpClient + * @var PayPalCustomerRepository */ - private $httpClient; + private $payPalCustomerRepository; + /** + * @var PaymentTokenRepository + */ + private $paymentTokenRepository; /** * @var ShopContext */ private $shopContext; + /** + * @var PrestaShopContext + */ + private $prestaShopContext; public function __construct( - CheckoutHttpClient $httpClient, + MaaslandHttpClient $maaslandHttpClient, + ShopContext $shopContext, + PrestaShopContext $prestaShopContext, EventDispatcherInterface $eventDispatcher, - ShopContext $shopContext + PayPalCustomerRepository $payPalCustomerRepository, + PaymentTokenRepository $paymentTokenRepository ) { - $this->httpClient = $httpClient; - $this->eventDispatcher = $eventDispatcher; + $this->maaslandHttpClient = $maaslandHttpClient; $this->shopContext = $shopContext; + $this->eventDispatcher = $eventDispatcher; + $this->payPalCustomerRepository = $payPalCustomerRepository; + $this->paymentTokenRepository = $paymentTokenRepository; + $this->prestaShopContext = $prestaShopContext; } /** @@ -62,16 +88,47 @@ public function __construct( * * @return void * - * @throws PayPalException + * @throws CartNotFoundException * @throws PayPalOrderException + * @throws InvalidRequestException + * @throws NotAuthorizedException + * @throws UnprocessableEntityException + * @throws Exception * @throws PsCheckoutException */ public function handle(CreatePayPalOrderCommand $command) { $cartPresenter = (new CartPresenter())->present(); $builder = new OrderPayloadBuilder($cartPresenter); - $builder->setIsCard($command->getFundingSource() === 'card' && $command->isHostedFields()); + + try { + $customerId = $this->prestaShopContext->getCustomerId(); + $payPalCustomerId = $this->payPalCustomerRepository->findPayPalCustomerIdByCustomerId(new CustomerId($customerId)); + } catch (PsCheckoutException $exception) { + $payPalCustomerId = null; + } + + $customerIntent = []; + + if ($payPalCustomerId) { + $builder->setPaypalCustomerId($payPalCustomerId->getValue()); + } + + if ($command->getPaymentTokenId()) { + $customerIntent[] = PayPalOrder::CUSTOMER_INTENT_USES_VAULTING; + $paymentToken = $this->paymentTokenRepository->findById($command->getPaymentTokenId()); + + if (!$paymentToken || !$payPalCustomerId || $paymentToken->getPayPalCustomerId()->getValue() !== $payPalCustomerId->getValue()) { + throw new PsCheckoutException('Payment token does not belong to the customer'); + } + $builder->setPaypalVaultId($command->getPaymentTokenId()->getValue()); + } + + $builder->setIsCard($command->getFundingSource() === 'card' && ($command->isHostedFields() || $command->getPaymentTokenId())); $builder->setExpressCheckout($command->isExpressCheckout()); + $builder->setFundingSource($command->getFundingSource()); + $builder->setSavePaymentMethod($command->vault()); + $builder->setVault($command->getPaymentTokenId() || $command->vault()); if ($this->shopContext->isShop17()) { // Build full payload in 1.7 @@ -81,15 +138,27 @@ public function handle(CreatePayPalOrderCommand $command) $builder->buildMinimalPayload(); } - $response = $this->httpClient->createOrder($builder->presentPayload()->getArray()); + $response = $this->maaslandHttpClient->createOrder($builder->presentPayload()->getArray()); $order = json_decode($response->getBody(), true); + + if ($command->vault()) { + $customerIntent[] = PayPalOrder::CUSTOMER_INTENT_VAULT; + $customerIntent[] = PayPalOrder::CUSTOMER_INTENT_USES_VAULTING; + } + + if ($command->favorite()) { + $customerIntent[] = PayPalOrder::CUSTOMER_INTENT_FAVORITE; + } + $this->eventDispatcher->dispatch(new PayPalOrderCreatedEvent( $order['id'], $order, $command->getCartId()->getValue(), + $command->getFundingSource(), $command->isHostedFields(), $command->isExpressCheckout(), - $command->getFundingSource() + $customerIntent, + $command->getPaymentTokenId() )); } } diff --git a/src/PayPal/Order/PayPalOrderSummaryViewBuilder.php b/src/PayPal/Order/PayPalOrderSummaryViewBuilder.php index a78527f61..96fe7229b 100644 --- a/src/PayPal/Order/PayPalOrderSummaryViewBuilder.php +++ b/src/PayPal/Order/PayPalOrderSummaryViewBuilder.php @@ -24,8 +24,10 @@ use Order; use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException; use PrestaShop\Module\PrestashopCheckout\Order\OrderDataProvider; +use PrestaShop\Module\PrestashopCheckout\PayPal\Order\ValueObject\PayPalOrderId; use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalOrderProvider; use PrestaShop\Module\PrestashopCheckout\PsCheckoutDataProvider; +use PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository; use PrestaShop\Module\PrestashopCheckout\Repository\PsCheckoutCartRepository; use PrestaShop\Module\PrestashopCheckout\Routing\Router; use PrestaShop\Module\PrestashopCheckout\ShopContext; @@ -56,6 +58,10 @@ class PayPalOrderSummaryViewBuilder * @var ShopContext */ private $shopContext; + /** + * @var PayPalOrderRepository + */ + private $payPalOrderRepository; /** * @param PsCheckoutCartRepository $psCheckoutCartRepository @@ -69,13 +75,15 @@ public function __construct( PayPalOrderProvider $orderPayPalProvider, Router $router, PayPalOrderTranslationProvider $orderPayPalTranslationProvider, - ShopContext $shopContext + ShopContext $shopContext, + PayPalOrderRepository $payPalOrderRepository ) { $this->psCheckoutCartRepository = $psCheckoutCartRepository; $this->orderPayPalProvider = $orderPayPalProvider; $this->router = $router; $this->orderPayPalTranslationProvider = $orderPayPalTranslationProvider; $this->shopContext = $shopContext; + $this->payPalOrderRepository = $payPalOrderRepository; } /** @@ -97,6 +105,12 @@ public function build(Order $order) throw new PsCheckoutException('Unable to retrieve cart data'); } + try { + $payPalOrder = $this->payPalOrderRepository->getPayPalOrderById(new PayPalOrderId($psCheckoutCart->paypal_order)); + } catch (PsCheckoutException $exception) { + $payPalOrder = null; + } + try { $orderPayPal = $this->orderPayPalProvider->getById($psCheckoutCart->paypal_order); } catch (Exception $exception) { @@ -107,7 +121,7 @@ public function build(Order $order) throw new PsCheckoutException('Unable to retrieve PayPal order data'); } - $orderPayPalDataProvider = new PaypalOrderDataProvider($orderPayPal); + $orderPayPalDataProvider = new PaypalOrderDataProvider($orderPayPal, $payPalOrder); $checkoutDataProvider = new PsCheckoutDataProvider($psCheckoutCart); return new PayPalOrderSummaryView( diff --git a/src/PayPal/Order/Query/GetPayPalOrderForAdminViewQuery.php b/src/PayPal/Order/Query/GetPayPalOrderForAdminViewQuery.php index 11a742109..345fd6ac2 100644 --- a/src/PayPal/Order/Query/GetPayPalOrderForAdminViewQuery.php +++ b/src/PayPal/Order/Query/GetPayPalOrderForAdminViewQuery.php @@ -18,14 +18,8 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -<<<<<<<< HEAD:src/PayPal/Order/Query/GetPayPalOrderForAdminViewQuery.php namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query; class GetPayPalOrderForAdminViewQuery -======== -namespace PrestaShop\Module\PrestashopCheckout\Cart\Exception; - -class CartNotFoundException extends CartException ->>>>>>>> a34060bd (Refacto):src/Cart/Exception/CartNotFoundException.php { } diff --git a/tests/Unit/Http/CheckoutHttpClientTest.php b/tests/Unit/Http/CheckoutHttpClientTest.php new file mode 100644 index 000000000..3944e6b34 --- /dev/null +++ b/tests/Unit/Http/CheckoutHttpClientTest.php @@ -0,0 +1,417 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Tests\Unit\Http; + +use Http\Client\Exception\HttpException; +use PHPUnit\Framework\TestCase; +use PrestaShop\Module\PrestashopCheckout\Exception\PayPalException; +use PrestaShop\Module\PrestashopCheckout\Http\CheckoutHttpClient; +use PrestaShop\Module\PrestashopCheckout\Http\HttpClientInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; + +class CheckoutHttpClientTest extends TestCase +{ + /** + * @dataProvider invalidRequestErrorsProvider + * + * @throws PayPalException + */ + public function testInvalidRequestErrorsCreateOrder($errorName, $errorCode) + { + $this->handleTestErrorsCreateOrder(400, $errorName, $errorCode); + } + + /** + * @dataProvider notAuthorizedErrorsProvider + * + * @throws PayPalException + */ + public function testNotAuthorizedErrorsCreateOrder($errorName, $errorCode) + { + $this->handleTestErrorsCreateOrder(401, $errorName, $errorCode); + } + + /** + * @dataProvider unprocessableEntityErrorsProvider + * + * @throws PayPalException + */ + public function testUnprocessableEntityErrorsCreateOrder($errorName, $errorCode) + { + $this->handleTestErrorsCreateOrder(422, $errorName, $errorCode); + } + + /** + * @dataProvider notFoundErrorsProvider + * + * @throws PayPalException + */ + public function testNotFoundErrorsCreateOrder($errorName, $errorCode) + { + $this->handleTestErrorsCreateOrder(404, $errorName, $errorCode); + } + + /** + * @dataProvider invalidRequestErrorsProvider + * + * @throws PayPalException + */ + public function testInvalidRequestErrorsCreateOrderLegacy($errorName, $errorCode) + { + $this->handleTestErrorsCreateOrder(400, $errorName, $errorCode, true); + } + + /** + * @dataProvider notAuthorizedErrorsProvider + * + * @throws PayPalException + */ + public function testNotAuthorizedErrorsCreateOrderLegacy($errorName, $errorCode) + { + $this->handleTestErrorsCreateOrder(401, $errorName, $errorCode, true); + } + + /** + * @dataProvider unprocessableEntityErrorsProvider + * + * @throws PayPalException + */ + public function testUnprocessableEntityErrorsCreateOrderLegacy($errorName, $errorCode) + { + $this->handleTestErrorsCreateOrder(422, $errorName, $errorCode, true); + } + + /** + * @dataProvider notFoundErrorsProvider + * + * @throws PayPalException + */ + public function testNotFoundErrorsCreateOrderLegacy($errorName, $errorCode) + { + $this->handleTestErrorsCreateOrder(404, $errorName, $errorCode, true); + } + + /** + * @param int $statusCode + * @param string $errorName + * @param int $errorCode + * @param bool $legacy + * + * @throws PayPalException + */ + private function handleTestErrorsCreateOrder($statusCode, $errorName, $errorCode, $legacy = false) + { + $error = $this->getErrorResponse($statusCode, $errorName, $legacy); + $requestMock = $this->createMock(RequestInterface::class); + $streamMock = $this->createMock(StreamInterface::class); + $streamMock->method('__toString')->willReturn(json_encode($error)); + $responseMock = $this->createMock(ResponseInterface::class); + $responseMock->method('getStatusCode')->willReturn($statusCode); + $responseMock->method('getBody')->willReturn($streamMock); + $httpClient = $this->createMock(HttpClientInterface::class); + $httpClient->method('sendRequest')->willThrowException(new HttpException('An error occurred', $requestMock, $responseMock)); + $this->expectExceptionCode($errorCode); + $this->expectException(PayPalException::class); + $checkoutHttpClient = new CheckoutHttpClient($httpClient); + $checkoutHttpClient->createOrder([]); + } + + private function getInvalidRequestError($issueError) + { + return [ + 'name' => 'INVALID_REQUEST', + 'message' => 'Request is not well-formed, syntactically incorrect, or violates schema.', + 'debug_id' => 'b6b9a374802ea', + 'details' => [ + [ + 'field' => '', + 'value' => '', + 'location' => 'body', + 'issue' => $issueError, + 'description' => '', + ], + ], + 'links' => [ + [ + 'href' => 'https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_PARAMETER_VALUE', + 'rel' => 'information_link', + 'encType' => 'application/json', + ], + ], + ]; + } + + /** + * @param int $statusCode + * @param string $errorName + * @param bool $legacy + * + * @return array + */ + private function getErrorResponse($statusCode, $errorName, $legacy) + { + if ($legacy) { + switch ($statusCode) { + case 400: + return $this->getInvalidRequestErrorLegacy($errorName); + case 401: + return $this->getNotAuthorizedErrorLegacy($errorName); + case 404: + return $this->getNotFoundErrorLegacy($errorName); + case 422: + return $this->getUnprocessableEntityErrorLegacy($errorName); + } + } + + switch ($statusCode) { + case 400: + return $this->getInvalidRequestError($errorName); + case 401: + return $this->getNotAuthorizedError($errorName); + case 404: + return $this->getNotFoundError($errorName); + case 422: + return $this->getUnprocessableEntityError($errorName); + } + + return []; + } + + private function getInvalidRequestErrorLegacy($issueError) + { + return [ + 'statusCode' => 400, + 'error' => 'Bad Request', + 'message' => $issueError, + ]; + } + + private function getNotAuthorizedError($issueError) + { + return [ + 'name' => $issueError, + 'message' => 'Authentication failed due to invalid authentication credentials or a missing Authorization header.', + 'links' => [ + [ + 'href' => 'https://developer.paypal.com/docs/api/overview/#error', + 'rel' => 'information_link', + ], + ], + ]; + } + + private function getNotAuthorizedErrorLegacy($issueError) + { + return [ + 'statusCode' => 401, + 'error' => 'Unprocessable Entity', + 'message' => $issueError, + ]; + } + + private function getUnprocessableEntityError($issueError) + { + return [ + 'name' => 'UNPROCESSABLE_ENTITY', + 'details' => [ + [ + 'field' => '', + 'value' => '', + 'issue' => $issueError, + 'description' => '', + ], + ], + 'message' => 'The requested action could not be performed, semantically incorrect, or failed business validation.', + 'debug_id' => 'c9a75b43fc807', + 'links' => [ + [ + 'href' => 'https://developer.paypal.com/docs/api/orders/v2/#error-MAX_VALUE_EXCEEDED', + 'rel' => 'information_link', + 'method' => 'GET', + ], + ], + ]; + } + + private function getUnprocessableEntityErrorLegacy($issueError) + { + return [ + 'statusCode' => 422, + 'error' => 'Unprocessable Entity', + 'message' => $issueError, + ]; + } + + /** + * @param string $errorName + * + * @return array + */ + private function getNotFoundError($errorName) + { + return [ + 'name' => $errorName, + 'message' => 'The specified resource does not exist.', + 'debug_id' => 'b6b9a374802ea', + 'links' => [ + [ + 'href' => 'https://developer.paypal.com/docs/api/orders/v2/#error-' . $errorName, + 'rel' => 'information_link', + 'encType' => 'application/json', + ], + ], + ]; + } + + private function getNotFoundErrorLegacy($issueError) + { + return [ + 'statusCode' => 404, + 'error' => 'Not found', + 'message' => $issueError, + ]; + } + + public function notFoundErrorsProvider() + { + return [ + ['INVALID_RESOURCE_ID', PayPalException::INVALID_RESOURCE_ID], + ]; + } + + public function invalidRequestErrorsProvider() + { + return [ + ['INVALID_ARRAY_MAX_ITEMS', PayPalException::INVALID_ARRAY_MAX_ITEMS], + ['INVALID_ARRAY_MIN_ITEMS', PayPalException::INVALID_ARRAY_MIN_ITEMS], + ['INVALID_COUNTRY_CODE', PayPalException::INVALID_COUNTRY_CODE], + ['INVALID_PARAMETER_SYNTAX', PayPalException::INVALID_PARAMETER_SYNTAX], + ['INVALID_STRING_LENGTH', PayPalException::INVALID_STRING_LENGTH], + ['INVALID_PARAMETER_VALUE', PayPalException::INVALID_PARAMETER_VALUE], + ['MISSING_REQUIRED_PARAMETER', PayPalException::MISSING_REQUIRED_PARAMETER], + ['NOT_SUPPORTED', PayPalException::NOT_SUPPORTED], + ['PAYPAL_REQUEST_ID_REQUIRED', PayPalException::PAYPAL_REQUEST_ID_REQUIRED], + ['MALFORMED_REQUEST_JSON', PayPalException::MALFORMED_REQUEST_JSON], + ['FIELD_NOT_PATCHABLE', PayPalException::FIELD_NOT_PATCHABLE], + ['AMOUNT_NOT_PATCHABLE', PayPalException::AMOUNT_NOT_PATCHABLE], + ['INVALID_PATCH_OPERATION', PayPalException::INVALID_PATCH_OPERATION], + ]; + } + + public function notAuthorizedErrorsProvider() + { + return [ + ['PERMISSION_DENIED', PayPalException::PERMISSION_DENIED], + ['PERMISSION_DENIED_FOR_DONATION_ITEMS', PayPalException::PERMISSION_DENIED_FOR_DONATION_ITEMS], + ['MALFORMED_REQUEST', PayPalException::MALFORMED_REQUEST], + ['PAYEE_ACCOUNT_NOT_SUPPORTED', PayPalException::PAYEE_ACCOUNT_NOT_SUPPORTED], + ['PAYEE_ACCOUNT_NOT_VERIFIED', PayPalException::PAYEE_ACCOUNT_NOT_VERIFIED], + ['PAYEE_NOT_CONSENTED', PayPalException::PAYEE_NOT_CONSENTED], + ['CONSENT_NEEDED', PayPalException::CONSENT_NEEDED], + ['INVALID_ACCOUNT_STATUS', PayPalException::INVALID_ACCOUNT_STATUS], + ]; + } + + public function unprocessableEntityErrorsProvider() + { + return [ + ['AMOUNT_MISMATCH', PayPalException::AMOUNT_MISMATCH], + ['BILLING_ADDRESS_INVALID', PayPalException::BILLING_ADDRESS_INVALID], + ['CANNOT_BE_NEGATIVE', PayPalException::CANNOT_BE_NEGATIVE], + ['CANNOT_BE_ZERO_OR_NEGATIVE', PayPalException::CANNOT_BE_ZERO_OR_NEGATIVE], + ['CARD_EXPIRED', PayPalException::CARD_EXPIRED], + ['CITY_REQUIRED', PayPalException::CITY_REQUIRED], + ['DECIMAL_PRECISION', PayPalException::DECIMAL_PRECISION], + ['DONATION_ITEMS_NOT_SUPPORTED', PayPalException::DONATION_ITEMS_NOT_SUPPORTED], + ['DUPLICATE_REFERENCE_ID', PayPalException::DUPLICATE_REFERENCE_ID], + ['INVALID_CURRENCY_CODE', PayPalException::INVALID_CURRENCY_CODE], + ['INVALID_PAYER_ID', PayPalException::INVALID_PAYER_ID], + ['ITEM_TOTAL_MISMATCH', PayPalException::ITEM_TOTAL_MISMATCH], + ['ITEM_TOTAL_REQUIRED', PayPalException::ITEM_TOTAL_REQUIRED], + ['MAX_VALUE_EXCEEDED', PayPalException::MAX_VALUE_EXCEEDED], + ['MISSING_PICKUP_ADDRESS', PayPalException::MISSING_PICKUP_ADDRESS], + ['MULTIPLE_ITEM_CATEGORIES', PayPalException::MULTIPLE_ITEM_CATEGORIES], + ['MULTIPLE_SHIPPING_ADDRESS_NOT_SUPPORTED', PayPalException::MULTIPLE_SHIPPING_ADDRESS_NOT_SUPPORTED], + ['MULTIPLE_SHIPPING_TYPE_NOT_SUPPORTED', PayPalException::MULTIPLE_SHIPPING_TYPE_NOT_SUPPORTED], + ['PAYEE_ACCOUNT_INVALID', PayPalException::PAYEE_ACCOUNT_INVALID], + ['PAYEE_ACCOUNT_LOCKED_OR_CLOSED', PayPalException::PAYEE_ACCOUNT_LOCKED_OR_CLOSED], + ['PAYEE_ACCOUNT_RESTRICTED', PayPalException::PAYEE_ACCOUNT_RESTRICTED], + ['REFERENCE_ID_REQUIRED', PayPalException::REFERENCE_ID_REQUIRED], + ['PAYMENT_SOURCE_CANNOT_BE_USED', PayPalException::PAYMENT_SOURCE_CANNOT_BE_USED], + ['PAYMENT_SOURCE_DECLINED_BY_PROCESSOR', PayPalException::PAYMENT_SOURCE_DECLINED_BY_PROCESSOR], + ['PAYMENT_SOURCE_INFO_CANNOT_BE_VERIFIED', PayPalException::PAYMENT_SOURCE_INFO_CANNOT_BE_VERIFIED], + ['POSTAL_CODE_REQUIRED', PayPalException::POSTAL_CODE_REQUIRED], + ['SHIPPING_ADDRESS_INVALID', PayPalException::SHIPPING_ADDRESS_INVALID], + ['TAX_TOTAL_MISMATCH', PayPalException::TAX_TOTAL_MISMATCH], + ['TAX_TOTAL_REQUIRED', PayPalException::TAX_TOTAL_REQUIRED], + ['UNSUPPORTED_INTENT', PayPalException::UNSUPPORTED_INTENT], + ['UNSUPPORTED_PAYMENT_INSTRUCTION', PayPalException::UNSUPPORTED_PAYMENT_INSTRUCTION], + ['SHIPPING_TYPE_NOT_SUPPORTED_FOR_CLIENT', PayPalException::SHIPPING_TYPE_NOT_SUPPORTED_FOR_CLIENT], + ['UNSUPPORTED_SHIPPING_TYPE', PayPalException::UNSUPPORTED_SHIPPING_TYPE], + ['SHIPPING_OPTION_NOT_SELECTED', PayPalException::SHIPPING_OPTION_NOT_SELECTED], + ['SHIPPING_OPTIONS_NOT_SUPPORTED', PayPalException::SHIPPING_OPTIONS_NOT_SUPPORTED], + ['MULTIPLE_SHIPPING_OPTION_SELECTED', PayPalException::MULTIPLE_SHIPPING_OPTION_SELECTED], + ['PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH', PayPalException::PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH], + ['CARD_CLOSED', PayPalException::CARD_CLOSED], + ['ORDER_CANNOT_BE_SAVED', PayPalException::ORDER_CANNOT_BE_SAVED], + ['SAVE_ORDER_NOT_SUPPORTED', PayPalException::SAVE_ORDER_NOT_SUPPORTED], + ['PUI_DUPLICATE_ORDER', PayPalException::PUI_DUPLICATE_ORDER], + ['INVALID_JSON_POINTER_FORMAT', PayPalException::INVALID_JSON_POINTER_FORMAT], + ['INVALID_PARAMETER', PayPalException::INVALID_PARAMETER], + ['NOT_PATCHABLE', PayPalException::NOT_PATCHABLE], + ['UNSUPPORTED_PATCH_PARAMETER_VALUE', PayPalException::UNSUPPORTED_PATCH_PARAMETER_VALUE], + ['PATCH_VALUE_REQUIRED', PayPalException::PATCH_VALUE_REQUIRED], + ['PATCH_PATH_REQUIRED', PayPalException::PATCH_PATH_REQUIRED], + ['REFERENCE_ID_NOT_FOUND', PayPalException::REFERENCE_ID_NOT_FOUND], + ['MULTI_CURRENCY_ORDER', PayPalException::MULTI_CURRENCY_ORDER], + ['ORDER_ALREADY_COMPLETED', PayPalException::ORDER_ALREADY_COMPLETED], + ['AGREEMENT_ALREADY_CANCELLED', PayPalException::AGREEMENT_ALREADY_CANCELLED], + ['BILLING_AGREEMENT_NOT_FOUND', PayPalException::BILLING_AGREEMENT_NOT_FOUND], + ['COMPLIANCE_VIOLATION', PayPalException::COMPLIANCE_VIOLATION], + ['DOMESTIC_TRANSACTION_REQUIRED', PayPalException::DOMESTIC_TRANSACTION_REQUIRED], + ['DUPLICATE_INVOICE_ID', PayPalException::DUPLICATE_INVOICE_ID], + ['INSTRUMENT_DECLINED', PayPalException::INSTRUMENT_DECLINED], + ['ORDER_NOT_APPROVED', PayPalException::ORDER_NOT_APPROVED], + ['MAX_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED', PayPalException::MAX_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED], + ['PAYEE_BLOCKED_TRANSACTION', PayPalException::PAYEE_BLOCKED_TRANSACTION], + ['PAYER_ACCOUNT_LOCKED_OR_CLOSED', PayPalException::PAYER_ACCOUNT_LOCKED_OR_CLOSED], + ['PAYER_ACCOUNT_RESTRICTED', PayPalException::PAYER_ACCOUNT_RESTRICTED], + ['PAYER_CANNOT_PAY', PayPalException::PAYER_CANNOT_PAY], + ['TRANSACTION_LIMIT_EXCEEDED', PayPalException::TRANSACTION_LIMIT_EXCEEDED], + ['TRANSACTION_RECEIVING_LIMIT_EXCEEDED', PayPalException::TRANSACTION_RECEIVING_LIMIT_EXCEEDED], + ['TRANSACTION_REFUSED', PayPalException::TRANSACTION_REFUSED], + ['REDIRECT_PAYER_FOR_ALTERNATE_FUNDING', PayPalException::REDIRECT_PAYER_FOR_ALTERNATE_FUNDING], + ['ORDER_ALREADY_CAPTURED', PayPalException::ORDER_ALREADY_CAPTURED], + ['TRANSACTION_BLOCKED_BY_PAYEE', PayPalException::TRANSACTION_BLOCKED_BY_PAYEE], + ['ORDER_ALREADY_CAPTURED', PayPalException::ORDER_ALREADY_CAPTURED], + ['AUTH_CAPTURE_NOT_ENABLED', PayPalException::AUTH_CAPTURE_NOT_ENABLED], + ['NOT_ENABLED_FOR_CARD_PROCESSING', PayPalException::NOT_ENABLED_FOR_CARD_PROCESSING], + ['PAYEE_NOT_ENABLED_FOR_CARD_PROCESSING', PayPalException::PAYEE_NOT_ENABLED_FOR_CARD_PROCESSING], + ['INVALID_PICKUP_ADDRESS', PayPalException::INVALID_PICKUP_ADDRESS], + ['SHIPPING_ADDRESS_INVALID', PayPalException::SHIPPING_ADDRESS_INVALID], + ['CANNOT_PROCESS_REFUNDS', PayPalException::CANNOT_PROCESS_REFUNDS], + ['INVALID_REFUND_AMOUNT', PayPalException::INVALID_REFUND_AMOUNT], + ['PAYMENT_DENIED', PayPalException::PAYMENT_DENIED], + ]; + } +}