Skip to content

Commit 4357b29

Browse files
authored
Merge pull request #315 from Wojdylak/SYL-4154-pay-pal-plugin-1.7-services
[Maintenance] Refactor services' ids according to the new convention
2 parents 470abc1 + 368b75d commit 4357b29

File tree

16 files changed

+526
-226
lines changed

16 files changed

+526
-226
lines changed

UPGRADE.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,99 @@
99
- `Sylius\PayPalPlugin\Form\Type\ChangePaymentMethodType`
1010
- `Sylius\PayPalPlugin\Form\Type\SelectPaymentType`
1111
- `Sylius\PayPalPlugin\Controller\PayPalOrderItemController`
12+
- `Sylius\PayPalPlugin\Resolver\CompleteOrderPaymentResolver`
13+
- `Sylius\PayPalPlugin\Resolver\CompleteOrderPaymentResolverInterface`
14+
15+
1. The definition of `Sylius\PayPalPlugin\Provider\PayPalOrderProviderInterface` has been removed because neither the interface nor the class exists in the codebase.
16+
17+
1. The definition of `Http\Discovery\Psr18Client` has been deprecated and will be removed in Sylius/PayPalPlugin 2.0. Use `sylius.http_client` service instead.
18+
19+
1. Aliases for the following services have been introduced to standardize service IDs and will replace the incorrect IDs
20+
in PayPalPlugin 2.0. The old service IDs are now deprecated and will be removed in PayPalPlugin 2.0.
21+
Please update your service definitions accordingly to ensure compatibility with next major version of PayPalPlugin.
22+
23+
| Old ID | New ID |
24+
|---------------------------------------------------------------------------|-------------------------------------------------------------------------|
25+
| `Sylius\PayPalPlugin\ApiPlatform\PayPalPayment` | `sylius_paypal.api_platform.paypal_payment` |
26+
| `Sylius\PayPalPlugin\Command\CompletePaidPaymentsCommand` | `sylius_paypal.console.command.complete_paid_payments` |
27+
| `Sylius\PayPalPlugin\Controller\CancelLastPayPalPaymentAction` | `sylius_paypal.controller.cancel_last_paypal_payment` |
28+
| `Sylius\PayPalPlugin\Controller\CancelPayPalCheckoutPaymentAction` | `sylius_paypal.controller.cancel_paypal_checkout_payment` |
29+
| `Sylius\PayPalPlugin\Controller\CancelPayPalOrderAction` | `sylius_paypal.controller.cancel_paypal_order` |
30+
| `Sylius\PayPalPlugin\Controller\CancelPayPalPaymentAction` | `sylius_paypal.controller.cancel_paypal_payment` |
31+
| `Sylius\PayPalPlugin\Controller\CompletePayPalOrderAction` | `sylius_paypal.controller.complete_paypal_order` |
32+
| `Sylius\PayPalPlugin\Controller\CompletePayPalOrderFromPaymentPageAction` | `sylius_paypal.controller.complete_paypal_order_from_payment_page` |
33+
| `Sylius\PayPalPlugin\Controller\CreatePayPalOrderAction` | `sylius_paypal.controller.create_paypal_order` |
34+
| `Sylius\PayPalPlugin\Controller\CreatePayPalOrderFromCartAction` | `sylius_paypal.controller.create_paypal_order_from_cart` |
35+
| `Sylius\PayPalPlugin\Controller\CreatePayPalOrderFromPaymentPageAction` | `sylius_paypal.controller.create_paypal_order_from_payment_page` |
36+
| `Sylius\PayPalPlugin\Controller\DownloadPayoutsReportAction` | `sylius_paypal.controller.download_payouts_report` |
37+
| `Sylius\PayPalPlugin\Controller\EnableSellerAction` | `sylius_paypal.controller.enable_seller` |
38+
| `Sylius\PayPalPlugin\Controller\PayPalButtonsController` | `sylius_paypal.controller.paypal_buttons` |
39+
| `Sylius\PayPalPlugin\Controller\PayPalPaymentOnErrorAction` | `sylius_paypal.controller.paypal_payment_on_error` |
40+
| `Sylius\PayPalPlugin\Controller\PayWithPayPalFormAction` | `sylius_paypal.controller.pay_with_paypal_form` |
41+
| `Sylius\PayPalPlugin\Controller\ProcessPayPalOrderAction` | `sylius_paypal.controller.process_paypal_order` |
42+
| `Sylius\PayPalPlugin\Controller\UpdatePayPalOrderAction` | `sylius_paypal.controller.update_paypal_order` |
43+
| `Sylius\PayPalPlugin\Controller\Webhook\RefundOrderAction` | `sylius_paypal.controller.webhook.refund_order` |
44+
| `Sylius\PayPalPlugin\EventListener\Workflow\CompletePayPalOrderListener` | `sylius_paypal.listener.workflow.complete_paypal_order` |
45+
| `Sylius\PayPalPlugin\EventListener\Workflow\RefundPaymentListener` | `sylius_paypal.listener.workflow.refund_payment` |
46+
| `Sylius\PayPalPlugin\Factory\PayPalPaymentMethodNewResourceFactory` | `sylius_paypal.factory.paypal_payment_method_new_resource` |
47+
| `Sylius\PayPalPlugin\Form\Type\PayPalConfigurationType` | `sylius_paypal.form.type.paypal_configuration` |
48+
| `Sylius\PayPalPlugin\Listener\PayPalPaymentMethodListener` | `sylius_paypal.listener.paypal_payment_method` |
49+
| `Sylius\PayPalPlugin\Payum\Action\AuthorizeAction` | `sylius_paypal.payum.action.authorize` |
50+
| `Sylius\PayPalPlugin\Payum\Action\CaptureAction` | `sylius_paypal.payum.action.capture` |
51+
| `Sylius\PayPalPlugin\Payum\Action\CompleteOrderAction` | `sylius_paypal.payum.action.complete_order` |
52+
| `Sylius\PayPalPlugin\Payum\Action\ResolveNextRouteAction` | `sylius_paypal.payum.action.resolve_next_route` |
53+
| `Sylius\PayPalPlugin\Processor\AfterCheckoutOrderPaymentProcessor` | `sylius_paypal.order_processing.order_payment_processor.after_checkout` |
54+
| `Sylius\PayPalPlugin\Processor\OrderPaymentProcessor` | `sylius_paypal.order_processing.order_payment_processor.checkout` |
55+
| `Sylius\PayPalPlugin\Processor\PayPalAddressProcessor` | `sylius_paypal.processor.paypal_address` |
56+
| `Sylius\PayPalPlugin\Processor\PayPalOrderCompleteProcessor` | `sylius_paypal.processor.paypal_order_complete` |
57+
| `Sylius\PayPalPlugin\Processor\UiPayPalPaymentRefundProcessor` | `sylius_paypal.processor.ui_paypal_payment_refund` |
58+
| `Sylius\PayPalPlugin\Resolver\PayPalDefaultPaymentMethodResolver` | `sylius_paypal.resolver.payment_method.paypal` |
59+
| `Sylius\PayPalPlugin\Resolver\PayPalPrioritisingPaymentMethodsResolver` | `sylius_paypal.resolver.payment_method.paypal_prioritising` |
60+
| `Sylius\PayPalPlugin\Twig\OrderAddressExtension` | `sylius_paypal.twig.extension.order_address` |
61+
| `Sylius\PayPalPlugin\Twig\PayPalExtension` | `sylius_paypal.twig.extension.paypal` |
62+
| `sylius.paypal.client.sftp` | `sylius_paypal.client.sftp` |
63+
| `sylius.plugin.pay_pal.gateway_factory_builder` | `sylius_paypal.gateway_factory_builder` |
64+
| `sylius_pay_pal_plugin.repository.pay_pal_credentials` | `sylius_paypal.repository.paypal_credentials` |
65+
66+
1. For the following services, new aliases have been added, these aliases will become the primary services IDs
67+
in PayPalPlugin 2.0, while the current service IDs will be converted into aliases:
68+
69+
| Current ID | New Alias |
70+
|-------------------------------------------------------------------------|-----------------------------------------------------|
71+
| `Sylius\PayPalPlugin\Api\AuthorizeClientApiInterface` | `sylius_paypal.api.authorize_client` |
72+
| `Sylius\PayPalPlugin\Api\CacheAuthorizeClientApiInterface` | `sylius_paypal.api.cache_authorize_client` |
73+
| `Sylius\PayPalPlugin\Api\CompleteOrderApiInterface` | `sylius_paypal.api.complete_order` |
74+
| `Sylius\PayPalPlugin\Api\CreateOrderApiInterface` | `sylius_paypal.api.create_order` |
75+
| `Sylius\PayPalPlugin\Api\GenericApiInterface` | `sylius_paypal.api.generic` |
76+
| `Sylius\PayPalPlugin\Api\IdentityApiInterface` | `sylius_paypal.api.identity` |
77+
| `Sylius\PayPalPlugin\Api\OrderDetailsApiInterface` | `sylius_paypal.api.order_details` |
78+
| `Sylius\PayPalPlugin\Api\RefundPaymentApiInterface` | `sylius_paypal.api.refund_payment` |
79+
| `Sylius\PayPalPlugin\Api\UpdateOrderApiInterface` | `sylius_paypal.api.update_order` |
80+
| `Sylius\PayPalPlugin\Api\WebhookApiInterface` | `sylius_paypal.api.webhook` |
81+
| `Sylius\PayPalPlugin\Client\PayPalClientInterface` | `sylius_paypal.client.paypal` |
82+
| `Sylius\PayPalPlugin\Downloader\ReportDownloaderInterface` | `sylius_paypal.downloader.report` |
83+
| `Sylius\PayPalPlugin\Enabler\PaymentMethodEnablerInterface` | `sylius_paypal.enabler.payment_method` |
84+
| `Sylius\PayPalPlugin\Generator\PayPalAuthAssertionGeneratorInterface` | `sylius_paypal.generator.paypal_auth_assertion` |
85+
| `Sylius\PayPalPlugin\Manager\PaymentStateManagerInterface` | `sylius_paypal.manager.payment_state` |
86+
| `Sylius\PayPalPlugin\Onboarding\Initiator\OnboardingInitiatorInterface` | `sylius_paypal.onboarding.initiator` |
87+
| `Sylius\PayPalPlugin\Onboarding\Processor\OnboardingProcessorInterface` | `sylius_paypal.onboarding.processor.basic` |
88+
| `Sylius\PayPalPlugin\Processor\PaymentCompleteProcessorInterface` | `sylius_paypal.processor.payment_complete` |
89+
| `Sylius\PayPalPlugin\Processor\LocaleProcessorInterface` | `sylius_paypal.processor.locale` |
90+
| `Sylius\PayPalPlugin\Processor\PaymentRefundProcessorInterface` | `sylius_paypal.processor.payment_refund` |
91+
| `Sylius\PayPalPlugin\Provider\AvailableCountriesProviderInterface` | `sylius_paypal.provider.available_countries` |
92+
| `Sylius\PayPalPlugin\Provider\OrderItemNonNeutralTaxProviderInterface` | `sylius_paypal.provider.order_item_non_neutral_tax` |
93+
| `Sylius\PayPalPlugin\Provider\OrderProviderInterface` | `sylius_paypal.provider.order` |
94+
| `Sylius\PayPalPlugin\Provider\PaymentProviderInterface` | `sylius_paypal.provider.payment` |
95+
| `Sylius\PayPalPlugin\Provider\PaymentReferenceNumberProviderInterface` | `sylius_paypal.provider.payment_reference_number` |
96+
| `Sylius\PayPalPlugin\Provider\PayPalConfigurationProviderInterface` | `sylius_paypal.provider.paypal_configuration` |
97+
| `Sylius\PayPalPlugin\Provider\PayPalItemDataProviderInterface` | `sylius_paypal.provider.paypal_item_data` |
98+
| `Sylius\PayPalPlugin\Provider\PayPalPaymentMethodProviderInterface` | `sylius_paypal.provider.paypal_payment_method` |
99+
| `Sylius\PayPalPlugin\Provider\PayPalRefundDataProviderInterface` | `sylius_paypal.provider.paypal_refund_data` |
100+
| `Sylius\PayPalPlugin\Provider\RefundReferenceNumberProviderInterface` | `sylius_paypal.provider.refund_reference_number` |
101+
| `Sylius\PayPalPlugin\Provider\UuidProviderInterface` | `sylius_paypal.provider.uuid` |
102+
| `Sylius\PayPalPlugin\Registrar\SellerWebhookRegistrarInterface` | `sylius_paypal.registrar.seller_webhook` |
103+
| `Sylius\PayPalPlugin\Resolver\CapturePaymentResolverInterface` | `sylius_paypal.resolver.capture_payment` |
104+
| `Sylius\PayPalPlugin\Updater\PaymentUpdaterInterface` | `sylius_paypal.updater.payment` |
12105

13106
1. The following old parameters have been deprecated and will be removed in PayPalPlugin 2.0. Use the corresponding new parameters instead:
14107

spec/Processor/PayPalPaymentCompleteProcessorSpec.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Sylius\Component\Core\Model\PaymentMethodInterface;
2323
use Sylius\PayPalPlugin\Payum\Request\CompleteOrder;
2424
use Sylius\PayPalPlugin\Processor\PaymentCompleteProcessorInterface;
25-
use Sylius\PayPalPlugin\Resolver\CompleteOrderPaymentResolverInterface;
2625

2726
final class PayPalPaymentCompleteProcessorSpec extends ObjectBehavior
2827
{
@@ -42,7 +41,6 @@ function it_completes_payment_in_pay_pal(
4241
PaymentMethodInterface $paymentMethod,
4342
GatewayConfigInterface $gatewayConfig,
4443
GatewayInterface $gateway,
45-
CompleteOrderPaymentResolverInterface $completeOrderPaymentResolver,
4644
): void {
4745
$payment->getDetails()->willReturn(['paypal_order_id' => '123123']);
4846

src/Command/CompletePaidPaymentsCommand.php

Lines changed: 12 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -13,95 +13,18 @@
1313

1414
namespace Sylius\PayPalPlugin\Command;
1515

16-
use Doctrine\Persistence\ObjectManager;
17-
use Payum\Core\Model\GatewayConfigInterface;
18-
use SM\Factory\FactoryInterface;
19-
use Sylius\Abstraction\StateMachine\StateMachineInterface;
20-
use Sylius\Abstraction\StateMachine\WinzouStateMachineAdapter;
21-
use Sylius\Component\Core\Model\PaymentInterface;
22-
use Sylius\Component\Core\Model\PaymentMethodInterface;
23-
use Sylius\Component\Core\Repository\PaymentRepositoryInterface;
24-
use Sylius\Component\Payment\PaymentTransitions;
25-
use Sylius\PayPalPlugin\Api\CacheAuthorizeClientApiInterface;
26-
use Sylius\PayPalPlugin\Api\OrderDetailsApiInterface;
27-
use Sylius\PayPalPlugin\DependencyInjection\SyliusPayPalExtension;
28-
use Sylius\PayPalPlugin\Payum\Action\StatusAction;
29-
use Symfony\Component\Console\Command\Command;
30-
use Symfony\Component\Console\Input\InputInterface;
31-
use Symfony\Component\Console\Output\OutputInterface;
32-
33-
final class CompletePaidPaymentsCommand extends Command
34-
{
35-
public function __construct(
36-
private readonly PaymentRepositoryInterface $paymentRepository,
37-
private readonly ObjectManager $paymentManager,
38-
private readonly CacheAuthorizeClientApiInterface $authorizeClientApi,
39-
private readonly OrderDetailsApiInterface $orderDetailsApi,
40-
private readonly FactoryInterface|StateMachineInterface $stateMachineFactory,
41-
) {
42-
parent::__construct();
43-
44-
if ($this->stateMachineFactory instanceof FactoryInterface) {
45-
trigger_deprecation(
46-
'sylius/paypal-plugin',
47-
'1.6',
48-
sprintf(
49-
'Passing an instance of "%s" as the fifth argument is deprecated and will be prohibited in 2.0. Use "%s" instead.',
50-
FactoryInterface::class,
51-
StateMachineInterface::class,
52-
),
53-
);
54-
}
55-
}
56-
57-
protected function configure(): void
58-
{
59-
$this
60-
->setName('sylius:pay-pal-plugin:complete-payments')
61-
->setDescription('Completes payments for completed PayPal orders')
62-
;
63-
}
64-
65-
protected function execute(InputInterface $input, OutputInterface $output): int
66-
{
67-
$payments = $this->paymentRepository->findBy(['state' => PaymentInterface::STATE_PROCESSING]);
68-
/** @var PaymentInterface $payment */
69-
foreach ($payments as $payment) {
70-
/** @var PaymentMethodInterface $paymentMethod */
71-
$paymentMethod = $payment->getMethod();
72-
/** @var GatewayConfigInterface $gatewayConfig */
73-
$gatewayConfig = $paymentMethod->getGatewayConfig();
74-
if ($gatewayConfig->getFactoryName() !== SyliusPayPalExtension::PAYPAL_FACTORY_NAME) {
75-
continue;
76-
}
77-
78-
/** @var string $payPalOrderId */
79-
$payPalOrderId = $payment->getDetails()['paypal_order_id'];
80-
81-
$token = $this->authorizeClientApi->authorize($paymentMethod);
82-
$details = $this->orderDetailsApi->get($token, $payPalOrderId);
83-
84-
if ($details['status'] === 'COMPLETED') {
85-
$this->getStateMachine()->apply($payment, PaymentTransitions::GRAPH, PaymentTransitions::TRANSITION_COMPLETE);
86-
87-
$paymentDetails = $payment->getDetails();
88-
$paymentDetails['status'] = StatusAction::STATUS_COMPLETED;
89-
90-
$payment->setDetails($paymentDetails);
91-
}
92-
}
93-
94-
$this->paymentManager->flush();
95-
96-
return 0;
97-
}
98-
99-
private function getStateMachine(): StateMachineInterface
16+
trigger_deprecation(
17+
'sylius/paypal-plugin',
18+
'1.7',
19+
'The "%s" class is deprecated and will be removed in Sylius/PayPalPlugin 2.0. Use "%s" instead.',
20+
CompletePaidPaymentsCommand::class,
21+
\Sylius\PayPalPlugin\Console\Command\CompletePaidPaymentsCommand::class,
22+
);
23+
24+
class_exists(\Sylius\PayPalPlugin\Console\Command\CompletePaidPaymentsCommand::class);
25+
26+
if (false) {
27+
final class CompletePaidPaymentsCommand
10028
{
101-
if ($this->stateMachineFactory instanceof FactoryInterface) {
102-
return new WinzouStateMachineAdapter($this->stateMachineFactory);
103-
}
104-
105-
return $this->stateMachineFactory;
10629
}
10730
}

0 commit comments

Comments
 (0)