diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml
index a27d6a91..8411f1b8 100644
--- a/.github/workflows/analysis.yaml
+++ b/.github/workflows/analysis.yaml
@@ -19,7 +19,7 @@ jobs:
php:
- 8.2
symfony:
- - '6.2.*'
+ - '6.4.*'
env:
APP_ENV: test
steps:
@@ -38,7 +38,7 @@ jobs:
run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'
-
name: 'Composer - Set cache'
- uses: actions/cache@v2
+ uses: actions/cache@v4
with:
path: '${{ steps.composer-cache.outputs.dir }}'
key: 'php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles(''**/composer.json'') }}'
@@ -58,17 +58,12 @@ jobs:
id: end-of-setup
-
name: 'PHPStan - Run'
- run: 'if [ -f rulesets/phpstan.neon ]; then vendor/bin/phpstan analyse -c rulesets/phpstan.neon src/ ; else echo PHPStan rulesets file does not exist, skipping step ; fi'
- if: 'always() && steps.end-of-setup.outcome == ''success'''
- -
- name: 'PHPSpec - Run'
- run: 'if [ -f phpspec.yml.dist ]; then vendor/bin/phpspec run ; else echo PHPSpec config file does not exist, skipping step ; fi'
- if: 'always() && steps.end-of-setup.outcome == ''success'''
- -
- name: 'Checks security issues - Run'
- run: 'symfony security:check'
+ run: 'if [ -f ruleset/phpstan.neon ]; then vendor/bin/phpstan analyse -c ruleset/phpstan.neon src/ ; else echo PHPStan rulesets file does not exist, skipping step ; fi'
if: 'always() && steps.end-of-setup.outcome == ''success'''
+ # TODO: launch Grumphp
+
sonarcloud:
+ if: github.event.repository.fork != true
runs-on: ubuntu-latest
continue-on-error: true
steps:
diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml
index fbf898ac..9c388a86 100644
--- a/.github/workflows/sylius.yaml
+++ b/.github/workflows/sylius.yaml
@@ -20,11 +20,11 @@ jobs:
php:
- 8.2
sylius:
- - 1.12.0
+ - 2.1.0
symfony:
- - 6.2
+ - 6.4
node:
- - 14.x
+ - 18.x
env:
APP_ENV: test
package-name: payplug/sylius-payplug-plugin
@@ -54,7 +54,7 @@ jobs:
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'
-
name: 'Composer - Set cache'
- uses: actions/cache@v3
+ uses: actions/cache@v4
id: cache-composer
with:
path: '${{ steps.composer-cache.outputs.dir }}'
@@ -73,7 +73,7 @@ jobs:
run: 'echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT'
-
name: 'Yarn - Set Cache'
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: '${{ steps.yarn-cache.outputs.dir }}'
key: 'node-${{ matrix.node }}-yarn-${{ hashFiles(''**/package.json **/yarn.lock'') }}'
diff --git a/README.md b/README.md
index 4c4623db..5d2f4eea 100644
--- a/README.md
+++ b/README.md
@@ -85,6 +85,7 @@ In local environment, the plugin will not work properly because you will not be
namespace App\Entity\Customer;
use Doctrine\ORM\Mapping as ORM;
+ use PayPlug\SyliusPayPlugPlugin\Entity\CardsOwnerInterface;
use PayPlug\SyliusPayPlugPlugin\Entity\Traits\CustomerTrait;
use Sylius\Component\Core\Model\Customer as BaseCustomer;
@@ -94,7 +95,7 @@ In local environment, the plugin will not work properly because you will not be
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_customer')]
- class Customer extends BaseCustomer
+ class Customer extends BaseCustomer implements CardsOwnerInterface
{
use CustomerTrait;
}
diff --git a/composer.json b/composer.json
index 77a616df..7548a5a3 100755
--- a/composer.json
+++ b/composer.json
@@ -41,7 +41,6 @@
"php-parallel-lint/php-parallel-lint": "1.4.0",
"phpmd/phpmd": "^2.15.0",
"phpro/grumphp": "^2.12",
- "phpspec/phpspec": "7.5.0",
"phpstan/extension-installer": "1.4.3",
"phpstan/phpstan": "2.0.4",
"phpstan/phpstan-doctrine": "2.0.1",
diff --git a/phpspec.yml.dist b/phpspec.yml.dist
deleted file mode 100644
index cdbf5061..00000000
--- a/phpspec.yml.dist
+++ /dev/null
@@ -1,4 +0,0 @@
-suites:
- main:
- namespace: PayPlug\SyliusPayPlugPlugin
- psr4_prefix: PayPlug\SyliusPayPlugPlugin
diff --git a/ruleset/ecs.php b/ruleset/ecs.php
index 6c43f8fa..7de9449a 100644
--- a/ruleset/ecs.php
+++ b/ruleset/ecs.php
@@ -11,9 +11,9 @@
dirname(__DIR__, 1) . '/src',
dirname(__DIR__, 1) . '/tests/Behat',
dirname(__DIR__, 1) . '/tests/PHPUnit',
- dirname(__DIR__, 1) . '/spec',
]);
/** @phpstan-ignore-next-line */
$ecsConfig->rule(\SlevomatCodingStandard\Sniffs\Classes\RequireMultiLineMethodSignatureSniff::class);
-};
\ No newline at end of file
+ $ecsConfig->skip([\PhpCsFixer\Fixer\Basic\BracesFixer::class]);
+};
diff --git a/ruleset/ruleset.xml b/ruleset/ruleset.xml
index 95660985..72bffd83 100644
--- a/ruleset/ruleset.xml
+++ b/ruleset/ruleset.xml
@@ -3,7 +3,12 @@
xsi:noNamespaceSchemaLocation="../vendor/squizlabs/php_codesniffer/phpcs.xsd">
-
+
+
+
+
+
+
@@ -16,4 +21,4 @@
-
\ No newline at end of file
+
diff --git a/spec/Action/ConvertPaymentActionSpec.php b/spec/Action/ConvertPaymentActionSpec.php
deleted file mode 100644
index 4233cc03..00000000
--- a/spec/Action/ConvertPaymentActionSpec.php
+++ /dev/null
@@ -1,252 +0,0 @@
-beConstructedWith($paymentDataCreator);
- }
-
- public function it_is_initializable(): void
- {
- $this->shouldHaveType(ConvertPaymentAction::class);
- }
-
- public function it_implements_action_interface(): void
- {
- $this->shouldHaveType(ActionInterface::class);
- }
-
- public function it_executes(
- Convert $request,
- PaymentInterface $payment,
- OrderInterface $order,
- CustomerInterface $customer,
- AddressInterface $address,
- PayPlugPaymentDataCreator $paymentDataCreator,
- ): void {
- $this->setApi(new PayPlugApiClient('test', PayPlugGatewayFactory::FACTORY_NAME));
-
- $customer = $this->getCustomer($customer);
- $address = $this->getAddress($address);
- $order = $this->getOrder($order, $customer, $address, $address);
- $payment = $this->getPayment($payment, $order);
- $payment->getMethod();
-
- $request->getSource()->willReturn($payment);
- $request->getTo()->willReturn('array');
-
- $paymentDataCreator
- ->create($payment, PayPlugGatewayFactory::FACTORY_NAME)
- ->willReturn(new ArrayObject(['amount' => 100, 'currency' => 'EUR', 'metadata' => ['customer_id' => 1, 'order_number' => '000000001'], 'billing' => ['title' => null, 'first_name' => 'John', 'last_name' => 'Doe', 'company_name' => 'Bob', 'email' => 'test@test.pl', 'mobile_phone_number' => null, 'landline_phone_number' => null, 'address1' => 'test', 'address2' => null, 'postcode' => '97980', 'city' => 'City', 'state' => 'State', 'country' => 'US', 'language' => 'en'], 'shipping' => ['title' => null, 'first_name' => 'John', 'last_name' => 'Doe', 'company_name' => 'Bob', 'email' => 'test@test.pl', 'mobile_phone_number' => null, 'landline_phone_number' => null, 'address1' => 'test', 'address2' => null, 'postcode' => '97980', 'city' => 'City', 'state' => 'State', 'country' => 'US', 'language' => 'en', 'delivery_type' => 'BILLING']]))
- ;
-
- $request->setResult([
- 'amount' => 100,
- 'currency' => 'EUR',
- 'metadata' => [
- 'customer_id' => 1,
- 'order_number' => '000000001',
- ],
- 'billing' => [
- 'title' => null,
- 'first_name' => 'John',
- 'last_name' => 'Doe',
- 'company_name' => 'Bob',
- 'email' => 'test@test.pl',
- 'mobile_phone_number' => null,
- 'landline_phone_number' => null,
- 'address1' => 'test',
- 'address2' => null,
- 'postcode' => '97980',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'US',
- 'language' => 'en',
- ],
- 'shipping' => [
- 'title' => null,
- 'first_name' => 'John',
- 'last_name' => 'Doe',
- 'company_name' => 'Bob',
- 'email' => 'test@test.pl',
- 'mobile_phone_number' => null,
- 'landline_phone_number' => null,
- 'address1' => 'test',
- 'address2' => null,
- 'postcode' => '97980',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'US',
- 'language' => 'en',
- 'delivery_type' => 'BILLING',
- ],
- ])->shouldBeCalled();
-
- $this->execute($request);
- }
-
- public function it_executes_with_different_address(
- Convert $request,
- PaymentInterface $payment,
- OrderInterface $order,
- CustomerInterface $customer,
- AddressInterface $address,
- AddressInterface $otherAddress,
- PayPlugPaymentDataCreator $paymentDataCreator,
- ): void {
- $this->setApi(new PayPlugApiClient('test', PayPlugGatewayFactory::FACTORY_NAME));
-
- $customer = $this->getCustomer($customer);
- $address = $this->getAddress($address);
- $otherAddress = $this->getOtherAddress($otherAddress);
- $order = $this->getOrder($order, $customer, $address, $otherAddress);
- $payment = $this->getPayment($payment, $order);
- $payment->getMethod();
-
- $request->getSource()->willReturn($payment);
- $request->getTo()->willReturn('array');
-
- $paymentDataCreator
- ->create($payment, PayPlugGatewayFactory::FACTORY_NAME)
- ->willReturn(new ArrayObject(['amount' => 100, 'currency' => 'EUR', 'metadata' => ['customer_id' => 1, 'order_number' => '000000001'], 'billing' => ['title' => null, 'first_name' => 'John', 'last_name' => 'Doe', 'company_name' => 'Bob', 'email' => 'test@test.pl', 'mobile_phone_number' => null, 'landline_phone_number' => null, 'address1' => 'test', 'address2' => null, 'postcode' => '97980', 'city' => 'City', 'state' => 'State', 'country' => 'US', 'language' => 'en'], 'shipping' => ['title' => null, 'first_name' => 'Jean', 'last_name' => 'Bon', 'company_name' => 'Paris', 'email' => 'test@test.pl', 'mobile_phone_number' => null, 'landline_phone_number' => null, 'address1' => 'test', 'address2' => null, 'postcode' => '97980', 'city' => 'Paris', 'state' => 'Paris', 'country' => 'US', 'language' => 'en', 'delivery_type' => 'NEW']]))
- ;
-
- $request->setResult([
- 'amount' => 100,
- 'currency' => 'EUR',
- 'metadata' => [
- 'customer_id' => 1,
- 'order_number' => '000000001',
- ],
- 'billing' => [
- 'title' => null,
- 'first_name' => 'John',
- 'last_name' => 'Doe',
- 'company_name' => 'Bob',
- 'email' => 'test@test.pl',
- 'mobile_phone_number' => null,
- 'landline_phone_number' => null,
- 'address1' => 'test',
- 'address2' => null,
- 'postcode' => '97980',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'US',
- 'language' => 'en',
- ],
- 'shipping' => [
- 'title' => null,
- 'first_name' => 'Jean',
- 'last_name' => 'Bon',
- 'company_name' => 'Paris',
- 'email' => 'test@test.pl',
- 'mobile_phone_number' => null,
- 'landline_phone_number' => null,
- 'address1' => 'test',
- 'address2' => null,
- 'postcode' => '97980',
- 'city' => 'Paris',
- 'state' => 'Paris',
- 'country' => 'US',
- 'language' => 'en',
- 'delivery_type' => 'NEW',
- ],
- ])->shouldBeCalled();
-
- $this->execute($request);
- }
-
- public function it_supports_only_convert_request_payment_source_and_array_to(
- Convert $request,
- PaymentInterface $payment,
- ): void {
- $request->getSource()->willReturn($payment);
- $request->getTo()->willReturn('array');
- $this->supports($request)->shouldReturn(true);
- }
-
- private function getCustomer($customer)
- {
- $customer->getEmail()->willReturn('test@test.pl');
- $customer->getId()->willReturn(1);
- $customer->getGender()->willReturn('M');
-
- return $customer;
- }
-
- private function getAddress(AddressInterface $address)
- {
- $address->getId()->willReturn(1);
- $address->getFirstName()->willReturn('John');
- $address->getLastName()->willReturn('Doe');
- $address->getPhoneNumber()->willReturn('0606060606');
- $address->getCompany()->willReturn('Bob');
- $address->getPostcode()->willReturn('97980');
- $address->getStreet()->willReturn('test');
- $address->getCity()->willReturn('City');
- $address->getProvinceName()->willReturn('State');
- $address->getCountryCode()->willReturn('US');
-
- return $address;
- }
-
- private function getOtherAddress(AddressInterface $address)
- {
- $address->getId()->willReturn(2);
- $address->getFirstName()->willReturn('Jean');
- $address->getLastName()->willReturn('Bon');
- $address->getPhoneNumber()->willReturn('0606060606');
- $address->getCompany()->willReturn('Paris');
- $address->getPostcode()->willReturn('97980');
- $address->getStreet()->willReturn('test');
- $address->getCity()->willReturn('Paris');
- $address->getProvinceName()->willReturn('Paris');
- $address->getCountryCode()->willReturn('US');
-
- return $address;
- }
-
- private function getOrder(
- OrderInterface $order,
- CustomerInterface $customer,
- AddressInterface $billingAddress,
- AddressInterface $shippingAddress,
- ) {
- $order->getCustomer()->willReturn($customer);
- $order->getBillingAddress()->willReturn($billingAddress);
- $order->getShippingAddress()->willReturn($shippingAddress);
- $order->getNumber()->willReturn('000000001');
- $order->getLocaleCode()->willReturn('en_US');
-
- return $order;
- }
-
- private function getPayment(PaymentInterface $payment, OrderInterface $order)
- {
- $payment->getOrder()->willReturn($order);
- $payment->getDetails()->willReturn([]);
- $payment->getAmount()->willReturn(100);
- $payment->getCurrencyCode()->willReturn('EUR');
-
- return $payment;
- }
-}
diff --git a/spec/Action/NotifyActionSpec.php b/spec/Action/NotifyActionSpec.php
deleted file mode 100644
index d2224f61..00000000
--- a/spec/Action/NotifyActionSpec.php
+++ /dev/null
@@ -1,82 +0,0 @@
-beConstructedWith(
- $logger,
- $paymentNotificationHandler,
- $refundNotificationHandler,
- );
- }
-
- public function it_is_initializable(): void
- {
- $this->shouldHaveType(NotifyAction::class);
- }
-
- public function it_implements_action_interface(): void
- {
- $this->shouldHaveType(ActionInterface::class);
- }
-
- public function it_implements_api_aware_interface(): void
- {
- $this->shouldHaveType(ApiAwareInterface::class);
- }
-
- public function it_implements_gateway_aware_interface(): void
- {
- $this->shouldHaveType(GatewayAwareInterface::class);
- }
-
- public function it_executes(
- Notify $request,
- \ArrayObject $arrayObject,
- GatewayInterface $gateway,
- PayPlugApiClient $payPlugApiClient,
- ): void {
- $payment = \Mockery::mock('payment', Payment::class);
-
- $payment->is_paid = true;
-
- $this->setGateway($gateway);
- $this->setApi($payPlugApiClient);
-
- $request->getModel()->willReturn($arrayObject);
- $request->getFirstModel()->willReturn(new SyliusPayment());
- $payPlugApiClient->treat('')->willReturn($payment);
-
- $this->execute($request);
- }
-
- public function it_supports_only_notify_request_and_array_access(
- Notify $request,
- \ArrayAccess $arrayAccess,
- ): void {
- $request->getModel()->willReturn($arrayAccess);
- $this->supports($request)->shouldReturn(true);
- }
-}
diff --git a/spec/Action/StatusActionSpec.php b/spec/Action/StatusActionSpec.php
deleted file mode 100644
index b06a2c8f..00000000
--- a/spec/Action/StatusActionSpec.php
+++ /dev/null
@@ -1,67 +0,0 @@
-beConstructedWith($stateMachineFactory, $refundPaymentHandler, $paymentNotificationHandler, $requestStack);
- }
-
- public function it_is_initializable(): void
- {
- $this->shouldHaveType(StatusAction::class);
- }
-
- public function it_implements_action_interface(): void
- {
- $this->shouldHaveType(ActionInterface::class);
- }
-
- public function it_implements_gateway_aware_interface(): void
- {
- $this->shouldHaveType(GatewayAwareInterface::class);
- }
-
- public function it_executes(
- GetStatusInterface $request,
- PaymentInterface $payment,
- GatewayInterface $gateway,
- ): void {
- $this->setGateway($gateway);
-
- $payment->getDetails()->willReturn([]);
- $request->getModel()->willReturn($payment);
-
- $request->markNew()->shouldBeCalled();
-
- $this->execute($request);
- }
-
- public function it_supports_only_get_status_request_and_array_access(
- GetStatusInterface $request,
- PaymentInterface $payment,
- ): void {
- $request->getModel()->willReturn($payment);
- $this->supports($request)->shouldReturn(true);
- }
-}
diff --git a/spec/PaymentProcessing/RefundPaymentProcessorSpec.php b/spec/PaymentProcessing/RefundPaymentProcessorSpec.php
deleted file mode 100644
index 4dcbbd3a..00000000
--- a/spec/PaymentProcessing/RefundPaymentProcessorSpec.php
+++ /dev/null
@@ -1,67 +0,0 @@
-beConstructedWith(
- $requestStack,
- $logger,
- $translator,
- $refundPaymentRepository,
- $payplugRefundHistoryRepository,
- $apiClientFactory,
- );
- }
-
- public function it_is_initializable(): void
- {
- $this->shouldHaveType(RefundPaymentProcessor::class);
- }
-
- public function it_implements_payment_processor_interface(): void
- {
- $this->shouldHaveType(PaymentProcessorInterface::class);
- }
-
- public function it_processes(
- PaymentInterface $payment,
- PaymentMethodInterface $paymentMethod,
- GatewayConfigInterface $gatewayConfig,
- ): void {
- $gatewayConfig->getFactoryName()->willReturn(PayPlugGatewayFactory::FACTORY_NAME);
- $gatewayConfig->getConfig()->willReturn([
- 'secretKey' => 'test',
- ]);
- $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig);
- $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig);
- $payment->getMethod()->willReturn($paymentMethod);
- $payment->getDetails()->willReturn([
- 'payment_id' => 'test',
- ]);
- }
-}
diff --git a/src/ApiClient/PayPlugApiClientFactory.php b/src/ApiClient/PayPlugApiClientFactory.php
index 5a017598..b25872a5 100644
--- a/src/ApiClient/PayPlugApiClientFactory.php
+++ b/src/ApiClient/PayPlugApiClientFactory.php
@@ -4,7 +4,7 @@
namespace PayPlug\SyliusPayPlugPlugin\ApiClient;
-use Sylius\Component\Core\Model\PaymentMethodInterface;
+use Sylius\Component\Payment\Model\PaymentMethodInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Contracts\Cache\CacheInterface;
diff --git a/src/ApiClient/PayPlugApiClientFactoryInterface.php b/src/ApiClient/PayPlugApiClientFactoryInterface.php
index 5ce7d366..6031219c 100644
--- a/src/ApiClient/PayPlugApiClientFactoryInterface.php
+++ b/src/ApiClient/PayPlugApiClientFactoryInterface.php
@@ -4,10 +4,11 @@
namespace PayPlug\SyliusPayPlugPlugin\ApiClient;
-use Sylius\Component\Core\Model\PaymentMethodInterface;
+use Sylius\Component\Payment\Model\PaymentMethodInterface;
interface PayPlugApiClientFactoryInterface
{
public function create(string $factoryName, ?string $key = null): PayPlugApiClientInterface;
+
public function createForPaymentMethod(PaymentMethodInterface $paymentMethod): PayPlugApiClientInterface;
}
diff --git a/src/Command/Handler/CapturePaymentRequestHandler.php b/src/Command/Handler/CapturePaymentRequestHandler.php
index 3899d31d..262ea466 100644
--- a/src/Command/Handler/CapturePaymentRequestHandler.php
+++ b/src/Command/Handler/CapturePaymentRequestHandler.php
@@ -33,9 +33,14 @@ public function __invoke(CapturePaymentRequest $capturePaymentRequest): void
{
// Retrieve the current PaymentRequest based on the hash provided in the CapturePaymentRequest command
$paymentRequest = $this->paymentRequestProvider->provide($capturePaymentRequest);
+ /** @var \Sylius\Component\Core\Model\PaymentInterface $payment */
$payment = $paymentRequest->getPayment();
+ $method = $payment->getMethod();
+ if (null === $method) {
+ throw new \LogicException('Payment method is not set for the payment.');
+ }
- $client = $this->apiClientFactory->createForPaymentMethod($paymentRequest->getPayment()->getMethod());
+ $client = $this->apiClientFactory->createForPaymentMethod($method);
$data = $this->paymentDataCreator->create($payment)->getArrayCopy();
$returnUrl = $this->afterPayUrlProvider->getUrl($paymentRequest, UrlGeneratorInterface::ABSOLUTE_URL);
@@ -45,7 +50,7 @@ public function __invoke(CapturePaymentRequest $capturePaymentRequest): void
];
$notificationUrl = $this->urlGenerator->generate('sylius_payment_method_notify', ['code' => $payment->getMethod()?->getCode()], UrlGeneratorInterface::ABSOLUTE_URL);
- $details['notification_url'] = $notificationUrl;
+ $data['notification_url'] = $notificationUrl;
$paymentRequest->setPayload($data);
$payplugPayment = $client->createPayment($data);
@@ -54,18 +59,18 @@ public function __invoke(CapturePaymentRequest $capturePaymentRequest): void
...$payment->getDetails(),
'status' => PayPlugApiClientInterface::STATUS_CREATED,
'payment_id' => $payplugPayment->__get('id'),
- 'payplug_response' => $arrayPayplugPayment,
+ 'payplug_response' => $arrayPayplugPayment,
]);
$paymentRequest->setResponseData(array_merge($arrayPayplugPayment, [
'payment_id' => $payplugPayment->__get('id'),
- 'redirect_url' => $payplugPayment->hosted_payment->payment_url
+ 'redirect_url' => $payplugPayment->hosted_payment->payment_url, // @phpstan-ignore-line
]));
$this->stateMachine->apply(
$paymentRequest,
PaymentRequestTransitions::GRAPH,
- PaymentRequestTransitions::TRANSITION_COMPLETE
+ PaymentRequestTransitions::TRANSITION_COMPLETE,
);
}
}
diff --git a/src/Command/Handler/NotifyPaymentRequestHandler.php b/src/Command/Handler/NotifyPaymentRequestHandler.php
index 00d8cc6c..b510bdc4 100644
--- a/src/Command/Handler/NotifyPaymentRequestHandler.php
+++ b/src/Command/Handler/NotifyPaymentRequestHandler.php
@@ -5,7 +5,6 @@
namespace PayPlug\SyliusPayPlugPlugin\Command\Handler;
use Payplug\Resource\Payment;
-use PayPlug\SyliusPayPlugPlugin\ApiClient\PayPlugApiClientFactoryInterface;
use PayPlug\SyliusPayPlugPlugin\ApiClient\PayPlugApiClientInterface;
use PayPlug\SyliusPayPlugPlugin\Command\NotifyPaymentRequest;
use PayPlug\SyliusPayPlugPlugin\Handler\PaymentNotificationHandler;
@@ -22,28 +21,29 @@ class NotifyPaymentRequestHandler
public function __construct(
private PaymentRequestProviderInterface $paymentRequestProvider,
private StateMachineInterface $stateMachine,
- private PayPlugApiClientFactoryInterface $apiClientFactory,
private PaymentNotificationHandler $paymentNotificationHandler,
) {}
public function __invoke(NotifyPaymentRequest $notifyPaymentRequest): void
{
$paymentRequest = $this->paymentRequestProvider->provide($notifyPaymentRequest);
+ /** @var PaymentInterface $payment */
$payment = $paymentRequest->getPayment();
if ($payment->getState() !== PaymentInterface::STATE_COMPLETED) {
// If the payment is already completed, we do not need to notify again
$this->stateMachine->apply(
$paymentRequest,
PaymentRequestTransitions::GRAPH,
- PaymentRequestTransitions::TRANSITION_COMPLETE
+ PaymentRequestTransitions::TRANSITION_COMPLETE,
);
return;
}
- try {
+ try {
// Payload contains what's send by payplug, no need to retrieve it from PayPlug
- $payplugPayment = Payment::fromAttributes(json_decode($paymentRequest->getPayload()['http_request']['content'] ?? '{}', true));
+ // @phpstan-ignore-next-line - cannot access offset content / http_request on mixed
+ $payplugPayment = Payment::fromAttributes(json_decode($paymentRequest->getPayload()['http_request']['content'] ?? '{}', true, 512, \JSON_THROW_ON_ERROR));
$details = new \ArrayObject($payment->getDetails());
$this->paymentNotificationHandler->treat($payment, $payplugPayment, $details);
@@ -53,7 +53,7 @@ public function __invoke(NotifyPaymentRequest $notifyPaymentRequest): void
$this->stateMachine->apply(
$paymentRequest,
PaymentRequestTransitions::GRAPH,
- PaymentRequestTransitions::TRANSITION_COMPLETE
+ PaymentRequestTransitions::TRANSITION_COMPLETE,
);
} catch (\Throwable $e) {
$paymentRequest->setResponseData([
@@ -62,7 +62,7 @@ public function __invoke(NotifyPaymentRequest $notifyPaymentRequest): void
$this->stateMachine->apply(
$paymentRequest,
PaymentRequestTransitions::GRAPH,
- PaymentRequestTransitions::TRANSITION_FAIL
+ PaymentRequestTransitions::TRANSITION_FAIL,
);
}
}
@@ -78,7 +78,7 @@ private function updatePaymentState(PaymentInterface $payment): void
->apply($payment, PaymentTransitions::GRAPH, PaymentTransitions::TRANSITION_COMPLETE),
PayPlugApiClientInterface::FAILED => $this->stateMachine
->apply($payment, PaymentTransitions::GRAPH, PaymentTransitions::TRANSITION_FAIL),
- default => throw new \LogicException(sprintf('Unknown payment status "%s".', $payment->getDetails()['status'] ?? '')),
+ default => throw new \LogicException(sprintf('Unknown payment status "%s".', $payment->getDetails()['status'] ?? '')), // @phpstan-ignore-line - getDetails() return mixed
};
}
}
diff --git a/src/Command/Handler/StatusPaymentRequestHandler.php b/src/Command/Handler/StatusPaymentRequestHandler.php
index 3ddc21b6..4757f2ae 100644
--- a/src/Command/Handler/StatusPaymentRequestHandler.php
+++ b/src/Command/Handler/StatusPaymentRequestHandler.php
@@ -29,13 +29,21 @@ public function __construct(
public function __invoke(StatusPaymentRequest $statusPaymentRequest): void
{
$paymentRequest = $this->paymentRequestProvider->provide($statusPaymentRequest);
+ /** @var \Sylius\Component\Core\Model\PaymentInterface $payment */
$payment = $paymentRequest->getPayment();
if ('' !== $statusPaymentRequest->getForcedStatus()) {
$this->handleForcedStatus($statusPaymentRequest, $paymentRequest);
+
return;
}
+ $method = $payment->getMethod();
+ if (null === $method) {
+ throw new \LogicException('Payment method is not set for the payment.');
+ }
+
// We don't have a forced status, so we retrieve the payment status from PayPlug
- $client = $this->apiClientFactory->createForPaymentMethod($paymentRequest->getPayment()->getMethod());
+ $client = $this->apiClientFactory->createForPaymentMethod($method);
+ // @phpstan-ignore-next-line - getDetails() return mixed
$payplugPayment = $client->retrieve($payment->getDetails()['payment_id'] ?? throw new \LogicException('No PayPlug payment ID found in payment details.'));
$paymentRequest->setResponseData((array) $payplugPayment);
@@ -49,12 +57,14 @@ public function __invoke(StatusPaymentRequest $statusPaymentRequest): void
$this->stateMachine->apply(
$paymentRequest,
PaymentRequestTransitions::GRAPH,
- PaymentRequestTransitions::TRANSITION_COMPLETE
+ PaymentRequestTransitions::TRANSITION_COMPLETE,
);
}
- private function handleForcedStatus(StatusPaymentRequest $statusPaymentRequest, PaymentRequestInterface $paymentRequest): void
- {
+ private function handleForcedStatus(
+ StatusPaymentRequest $statusPaymentRequest,
+ PaymentRequestInterface $paymentRequest,
+ ): void {
$payment = $paymentRequest->getPayment();
$payment->setDetails([
@@ -68,7 +78,7 @@ private function handleForcedStatus(StatusPaymentRequest $statusPaymentRequest,
$this->stateMachine->apply(
$paymentRequest,
PaymentRequestTransitions::GRAPH,
- PaymentRequestTransitions::TRANSITION_COMPLETE
+ PaymentRequestTransitions::TRANSITION_COMPLETE,
);
}
@@ -83,7 +93,7 @@ private function updatePaymentState(PaymentInterface $payment): void
->apply($payment, PaymentTransitions::GRAPH, PaymentTransitions::TRANSITION_COMPLETE),
PayPlugApiClientInterface::FAILED => $this->stateMachine
->apply($payment, PaymentTransitions::GRAPH, PaymentTransitions::TRANSITION_FAIL),
- default => throw new \LogicException(sprintf('Unknown payment status "%s".', $payment->getDetails()['status'] ?? '')),
+ default => throw new \LogicException(sprintf('Unknown payment status "%s".', $payment->getDetails()['status'] ?? '')), // @phpstan-ignore-line - getDetails() return mixed
};
}
}
diff --git a/src/Command/Provider/CapturePaymentRequestCommandProvider.php b/src/Command/Provider/CapturePaymentRequestCommandProvider.php
index 495feb9f..1627b281 100644
--- a/src/Command/Provider/CapturePaymentRequestCommandProvider.php
+++ b/src/Command/Provider/CapturePaymentRequestCommandProvider.php
@@ -1,5 +1,7 @@
PaymentRequestInterface::ACTION_CAPTURE]
+ ['action' => PaymentRequestInterface::ACTION_CAPTURE],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.command_provider.payplug_oney',
- ['action' => PaymentRequestInterface::ACTION_CAPTURE]
+ ['action' => PaymentRequestInterface::ACTION_CAPTURE],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.command_provider.payplug_bancontact',
- ['action' => PaymentRequestInterface::ACTION_CAPTURE]
+ ['action' => PaymentRequestInterface::ACTION_CAPTURE],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.command_provider.payplug_american_express',
- ['action' => PaymentRequestInterface::ACTION_CAPTURE]
+ ['action' => PaymentRequestInterface::ACTION_CAPTURE],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.command_provider.payplug_apple_pay',
- ['action' => PaymentRequestInterface::ACTION_CAPTURE]
+ ['action' => PaymentRequestInterface::ACTION_CAPTURE],
)]
final class CapturePaymentRequestCommandProvider implements PaymentRequestCommandProviderInterface
{
diff --git a/src/Command/Provider/NotifyPaymentRequestCommandProvider.php b/src/Command/Provider/NotifyPaymentRequestCommandProvider.php
index f9acf444..0311f69b 100644
--- a/src/Command/Provider/NotifyPaymentRequestCommandProvider.php
+++ b/src/Command/Provider/NotifyPaymentRequestCommandProvider.php
@@ -1,5 +1,7 @@
PaymentRequestInterface::ACTION_NOTIFY]
+ ['action' => PaymentRequestInterface::ACTION_NOTIFY],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.command_provider.payplug_oney',
- ['action' => PaymentRequestInterface::ACTION_NOTIFY]
+ ['action' => PaymentRequestInterface::ACTION_NOTIFY],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.command_provider.payplug_bancontact',
- ['action' => PaymentRequestInterface::ACTION_NOTIFY]
+ ['action' => PaymentRequestInterface::ACTION_NOTIFY],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.command_provider.payplug_american_express',
- ['action' => PaymentRequestInterface::ACTION_NOTIFY]
+ ['action' => PaymentRequestInterface::ACTION_NOTIFY],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.command_provider.payplug_apple_pay',
- ['action' => PaymentRequestInterface::ACTION_NOTIFY]
+ ['action' => PaymentRequestInterface::ACTION_NOTIFY],
)]
final class NotifyPaymentRequestCommandProvider implements PaymentRequestCommandProviderInterface
{
diff --git a/src/Command/Provider/StatusPaymentRequestCommandProvider.php b/src/Command/Provider/StatusPaymentRequestCommandProvider.php
index 92518bd7..e75804b0 100644
--- a/src/Command/Provider/StatusPaymentRequestCommandProvider.php
+++ b/src/Command/Provider/StatusPaymentRequestCommandProvider.php
@@ -1,5 +1,7 @@
PaymentRequestInterface::ACTION_STATUS]
+ ['action' => PaymentRequestInterface::ACTION_STATUS],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.command_provider.payplug_oney',
- ['action' => PaymentRequestInterface::ACTION_STATUS]
+ ['action' => PaymentRequestInterface::ACTION_STATUS],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.command_provider.payplug_bancontact',
- ['action' => PaymentRequestInterface::ACTION_STATUS]
+ ['action' => PaymentRequestInterface::ACTION_STATUS],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.command_provider.payplug_american_express',
- ['action' => PaymentRequestInterface::ACTION_STATUS]
+ ['action' => PaymentRequestInterface::ACTION_STATUS],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.command_provider.payplug_apple_pay',
- ['action' => PaymentRequestInterface::ACTION_STATUS]
+ ['action' => PaymentRequestInterface::ACTION_STATUS],
)]
final class StatusPaymentRequestCommandProvider implements PaymentRequestCommandProviderInterface
{
diff --git a/src/Command/StatusPaymentRequest.php b/src/Command/StatusPaymentRequest.php
index 5271bcad..1c3692c3 100644
--- a/src/Command/StatusPaymentRequest.php
+++ b/src/Command/StatusPaymentRequest.php
@@ -4,18 +4,18 @@
namespace PayPlug\SyliusPayPlugPlugin\Command;
-use Sylius\Bundle\PaymentBundle\Command\PaymentRequestHashAwareInterface;
use Sylius\Bundle\PaymentBundle\Command\PaymentRequestHashAwareTrait;
class StatusPaymentRequest extends AbstractPayplugPaymentRequest
{
use PaymentRequestHashAwareTrait;
- public function __construct(protected ?string $hash, private string $forcedStatus = '') {
+ public function __construct(protected ?string $hash, private string $forcedStatus = '')
+ {
parent::__construct($hash);
}
- public function getForcedStatus() : string
+ public function getForcedStatus(): string
{
return $this->forcedStatus;
}
diff --git a/src/Console/Command/CaptureAuthorizedPaymentCommand.php b/src/Console/Command/CaptureAuthorizedPaymentCommand.php
index 9ff16fef..92e70baf 100644
--- a/src/Console/Command/CaptureAuthorizedPaymentCommand.php
+++ b/src/Console/Command/CaptureAuthorizedPaymentCommand.php
@@ -52,7 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'paymentId' => $payment->getId(),
'orderNumber' => $payment->getOrder()?->getNumber() ?? 'N/A',
]);
- $output->writeln(sprintf('Capturing payment %d (order #%s)', $payment->getId(), $payment->getOrder()?->getNumber() ?? 'N/A'));
+ $output->writeln(sprintf('Capturing payment %d (order #%s)', $payment->getId(), $payment->getOrder()?->getNumber() ?? 'N/A')); // @phpstan-ignore-line
try {
$this->stateMachine->apply($payment, PaymentTransitions::GRAPH, PaymentTransitions::TRANSITION_COMPLETE);
diff --git a/src/Controller/CardController.php b/src/Controller/CardController.php
index 543175c8..d26770e0 100644
--- a/src/Controller/CardController.php
+++ b/src/Controller/CardController.php
@@ -8,6 +8,7 @@
use Payplug\Exception\NotFoundException;
use PayPlug\SyliusPayPlugPlugin\ApiClient\PayPlugApiClientInterface;
use PayPlug\SyliusPayPlugPlugin\Entity\Card;
+use PayPlug\SyliusPayPlugPlugin\Entity\CardsOwnerInterface;
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Customer\Context\CustomerContextInterface;
@@ -38,14 +39,13 @@ public function indexAction(): Response
{
$customer = $this->customerContext->getCustomer();
- if (!$customer instanceof CustomerInterface) {
- return $this->render('@PayPlugSyliusPayPlugPlugin/shop/saved_cards/index.html.twig', [
- 'savedCards' => [],
- ]);
+ $savedCards = [];
+ if ($customer instanceof CardsOwnerInterface) {
+ $savedCards = $customer->getCards();
}
return $this->render('@PayPlugSyliusPayPlugPlugin/shop/saved_cards/index.html.twig', [
- 'savedCards' => $customer->getCards(),
+ 'savedCards' => $savedCards,
]);
}
diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php
index 0fbc0410..8cb7afe1 100644
--- a/src/Controller/OrderController.php
+++ b/src/Controller/OrderController.php
@@ -35,16 +35,16 @@ final class OrderController extends BaseOrderController
private const APPLE_SUCCESS_RESPONSE_CODE = 1;
- #[Required]
+ #[Required] // @phpstan-ignore-next-line - Symfony write this attribute
private StateMachineInterface $stateMachineAbstraction;
- #[Required]
+ #[Required] // @phpstan-ignore-next-line - Symfony write this attribute
private ApplePayPaymentProvider $applePayPaymentProvider;
- #[Required]
+ #[Required] // @phpstan-ignore-next-line - Symfony write this attribute
private LockFactory $lockFactory;
- #[Required]
+ #[Required] // @phpstan-ignore-next-line - Symfony write this attribute
private LoggerInterface $logger;
#[Route(
diff --git a/src/Creator/PayPlugPaymentDataCreator.php b/src/Creator/PayPlugPaymentDataCreator.php
index ee7bc7dd..940fe558 100644
--- a/src/Creator/PayPlugPaymentDataCreator.php
+++ b/src/Creator/PayPlugPaymentDataCreator.php
@@ -80,7 +80,7 @@ public function create(
$this->addShippingInfo($shipping, $customer, $order, $deliveryType, $details);
$paymentMethod = $payment->getMethod();
- $gatewayFactoryName = $paymentMethod->getGatewayConfig()?->getFactoryName();
+ $gatewayFactoryName = $paymentMethod?->getGatewayConfig()?->getFactoryName();
if (
PayPlugGatewayFactory::FACTORY_NAME === $gatewayFactoryName &&
@@ -96,7 +96,7 @@ public function create(
$details->offsetSet('payment_context', $this->getCartContext($order));
}
- $this->addPaymentMethodFieldToDetails($details, $gatewayFactoryName);
+ $this->addPaymentMethodFieldToDetails($details, $gatewayFactoryName ?? '');
return $details;
}
diff --git a/src/Entity/CardsOwnerInterface.php b/src/Entity/CardsOwnerInterface.php
new file mode 100644
index 00000000..1a5ff0f1
--- /dev/null
+++ b/src/Entity/CardsOwnerInterface.php
@@ -0,0 +1,17 @@
+
+ */
+ public function getCards(): Collection;
+
+ public function addCard(Card $card): static;
+}
diff --git a/src/Entity/Traits/CustomerTrait.php b/src/Entity/Traits/CustomerTrait.php
index a445f6f5..9a7cc57c 100644
--- a/src/Entity/Traits/CustomerTrait.php
+++ b/src/Entity/Traits/CustomerTrait.php
@@ -21,7 +21,7 @@ trait CustomerTrait
protected $cards;
/**
- * @return Collection|Card[]
+ * @return Collection
*/
public function getCards(): Collection
{
diff --git a/src/Form/Extension/PaymentTypeExtension.php b/src/Form/Extension/PaymentTypeExtension.php
index 5f238ef0..5c0e96cf 100644
--- a/src/Form/Extension/PaymentTypeExtension.php
+++ b/src/Form/Extension/PaymentTypeExtension.php
@@ -105,7 +105,7 @@ public function buildForm(
\array_walk($errors, static function (FormError $error) use ($event): void {
$event->getForm()->get('method')->addError($error);
});
- $this->requestStack->getSession()->getFlashBag()->add('oney_has_error', true);
+ $this->requestStack->getSession()->getFlashBag()->add('oney_has_error', true); // @phpstan-ignore-line
return;
}
diff --git a/src/Gateway/Form/Type/AmericanExpressGatewayConfigurationType.php b/src/Gateway/Form/Type/AmericanExpressGatewayConfigurationType.php
index a78e7b24..a8b974ef 100644
--- a/src/Gateway/Form/Type/AmericanExpressGatewayConfigurationType.php
+++ b/src/Gateway/Form/Type/AmericanExpressGatewayConfigurationType.php
@@ -13,7 +13,7 @@
'type' => 'payplug_american_express',
'label' => 'payplug_sylius_payplug_plugin.ui.american_express_gateway_label',
'priority' => 70,
- ]
+ ],
)]
final class AmericanExpressGatewayConfigurationType extends AbstractGatewayConfigurationType
{
diff --git a/src/Gateway/Form/Type/ApplePayGatewayConfigurationType.php b/src/Gateway/Form/Type/ApplePayGatewayConfigurationType.php
index cd9613c9..6a29e2e3 100644
--- a/src/Gateway/Form/Type/ApplePayGatewayConfigurationType.php
+++ b/src/Gateway/Form/Type/ApplePayGatewayConfigurationType.php
@@ -13,7 +13,7 @@
'type' => 'payplug_apple_pay',
'label' => 'payplug_sylius_payplug_plugin.ui.apple_pay_gateway_label',
'priority' => 70,
- ]
+ ],
)]
final class ApplePayGatewayConfigurationType extends AbstractGatewayConfigurationType
{
diff --git a/src/Gateway/Form/Type/BancontactGatewayConfigurationType.php b/src/Gateway/Form/Type/BancontactGatewayConfigurationType.php
index 10b9d029..4831cf07 100644
--- a/src/Gateway/Form/Type/BancontactGatewayConfigurationType.php
+++ b/src/Gateway/Form/Type/BancontactGatewayConfigurationType.php
@@ -13,7 +13,7 @@
'type' => 'payplug_bancontact',
'label' => 'payplug_sylius_payplug_plugin.ui.bancontact_gateway_label',
'priority' => 80,
- ]
+ ],
)]
final class BancontactGatewayConfigurationType extends AbstractGatewayConfigurationType
{
diff --git a/src/Gateway/Form/Type/OneyGatewayConfigurationType.php b/src/Gateway/Form/Type/OneyGatewayConfigurationType.php
index 1d7b5624..fd548251 100644
--- a/src/Gateway/Form/Type/OneyGatewayConfigurationType.php
+++ b/src/Gateway/Form/Type/OneyGatewayConfigurationType.php
@@ -13,7 +13,7 @@
'type' => 'payplug_oney',
'label' => 'payplug_sylius_payplug_plugin.ui.oney_gateway_label',
'priority' => 90,
- ]
+ ],
)]
final class OneyGatewayConfigurationType extends AbstractGatewayConfigurationType
{
diff --git a/src/Gateway/Form/Type/PayPlugGatewayConfigurationType.php b/src/Gateway/Form/Type/PayPlugGatewayConfigurationType.php
index 858b5e72..f9056fdf 100644
--- a/src/Gateway/Form/Type/PayPlugGatewayConfigurationType.php
+++ b/src/Gateway/Form/Type/PayPlugGatewayConfigurationType.php
@@ -13,7 +13,7 @@
'type' => 'payplug',
'label' => 'payplug_sylius_payplug_plugin.ui.payplug_gateway_label',
'priority' => 100,
- ]
+ ],
)]
final class PayPlugGatewayConfigurationType extends AbstractGatewayConfigurationType
{
diff --git a/src/OrderPay/Provider/CaptureHttpResponseProvider.php b/src/OrderPay/Provider/CaptureHttpResponseProvider.php
index 50eba2f8..6fe83347 100644
--- a/src/OrderPay/Provider/CaptureHttpResponseProvider.php
+++ b/src/OrderPay/Provider/CaptureHttpResponseProvider.php
@@ -1,5 +1,7 @@
PaymentRequestInterface::ACTION_CAPTURE]
+ ['action' => PaymentRequestInterface::ACTION_CAPTURE],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.http_response_provider.payplug_oney',
- ['action' => PaymentRequestInterface::ACTION_CAPTURE]
+ ['action' => PaymentRequestInterface::ACTION_CAPTURE],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.http_response_provider.payplug_bancontact',
- ['action' => PaymentRequestInterface::ACTION_CAPTURE]
+ ['action' => PaymentRequestInterface::ACTION_CAPTURE],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.http_response_provider.payplug_apple_pay',
- ['action' => PaymentRequestInterface::ACTION_CAPTURE]
+ ['action' => PaymentRequestInterface::ACTION_CAPTURE],
)]
#[AutoconfigureTag(
'payplug_sylius_payplug_plugin.http_response_provider.payplug_american_express',
- ['action' => PaymentRequestInterface::ACTION_CAPTURE]
+ ['action' => PaymentRequestInterface::ACTION_CAPTURE],
)]
class CaptureHttpResponseProvider implements HttpResponseProviderInterface
{
- public function supports(RequestConfiguration $requestConfiguration, PaymentRequestInterface $paymentRequest,): bool
+ public function supports(RequestConfiguration $requestConfiguration, PaymentRequestInterface $paymentRequest): bool
{
return $paymentRequest->getAction() === PaymentRequestInterface::ACTION_CAPTURE &&
($paymentRequest->getResponseData()['redirect_url'] ?? null) !== null;
@@ -43,6 +45,10 @@ public function getResponse(
): Response {
// This is called after the capture payment request has been handled
$data = $paymentRequest->getResponseData();
+ if (!\is_string($data['redirect_url'] ?? null)) {
+ throw new \LogicException('Redirect URL is not set in the payment request response data.');
+ }
+
return new RedirectResponse($data['redirect_url']);
}
}
diff --git a/src/OrderPay/Provider/NotifyPaymentProvider.php b/src/OrderPay/Provider/NotifyPaymentProvider.php
index 46b0e491..5bae04a0 100644
--- a/src/OrderPay/Provider/NotifyPaymentProvider.php
+++ b/src/OrderPay/Provider/NotifyPaymentProvider.php
@@ -14,6 +14,7 @@
/**
* This provider is used to retrieve the payment from the order based on the request payload that Payplug sends.
+ *
* @see \Sylius\Bundle\PaymentBundle\Action\PaymentMethodNotifyAction
*/
#[AsNotifyPaymentProvider]
@@ -26,6 +27,7 @@ public function __construct(
public function getPayment(Request $request, PaymentMethodInterface $paymentMethod): PaymentInterface
{
+ /** @var string|null $orderNumber */
$orderNumber = $request->getPayload()->all('metadata')['order_number'] ?? null;
if (null === $orderNumber) {
throw new \InvalidArgumentException('Order number not found in request payload');
@@ -45,7 +47,7 @@ public function getPayment(Request $request, PaymentMethodInterface $paymentMeth
public function supports(Request $request, PaymentMethodInterface $paymentMethod): bool
{
- return \str_contains($paymentMethod->getGatewayConfig()?->getFactoryName(), 'payplug') &&
+ return \str_contains($paymentMethod->getGatewayConfig()?->getFactoryName() ?? '', 'payplug') &&
$request->getPayload()->has('id') &&
$request->getPayload()->has('metadata');
}
diff --git a/src/Provider/AbstractSupportedRefundPaymentMethodsProvider.php b/src/Provider/AbstractSupportedRefundPaymentMethodsProvider.php
index fb7b1452..9e31969c 100644
--- a/src/Provider/AbstractSupportedRefundPaymentMethodsProvider.php
+++ b/src/Provider/AbstractSupportedRefundPaymentMethodsProvider.php
@@ -5,7 +5,6 @@
namespace PayPlug\SyliusPayPlugPlugin\Provider;
use Payum\Core\Model\GatewayConfigInterface;
-use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Model\PaymentInterface;
use Sylius\Component\Core\Model\PaymentMethodInterface;
@@ -13,7 +12,6 @@
use Sylius\RefundPlugin\Provider\RefundPaymentMethodsProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
-use Webmozart\Assert\Assert;
abstract class AbstractSupportedRefundPaymentMethodsProvider
{
diff --git a/src/Provider/Payment/ApplePayPaymentProvider.php b/src/Provider/Payment/ApplePayPaymentProvider.php
index ab41e272..022d6084 100644
--- a/src/Provider/Payment/ApplePayPaymentProvider.php
+++ b/src/Provider/Payment/ApplePayPaymentProvider.php
@@ -76,7 +76,6 @@ public function provide(Request $request, OrderInterface $order): PaymentInterfa
$paymentDataObject = $this->paymentDataCreator->create(
$payment,
- ApplePayGatewayFactory::FACTORY_NAME,
[
'apple_pay' => [
'domain_name' => $order->getChannel()->getHostname(),