Skip to content

Commit e339a2a

Browse files
Add 1.13 compatibility (#9)
* add compatibility with 1.13 Sylius * add compatibility with 1.13 Sylius * update friendsofsymfony/jsrouting-bundle version * add composer.lock file * update sylius/admin-order-creation-plugin reference in composer.json file * update installation docs * update VersionChecker class. Update installation manual * fix issue with payment link * update installation manual to support migrations are running on Sylius 1.13.x * update installation manual to support migrations are running on Sylius 1.13.x * refactor VersionChecker class * update MollieGatewayConfig orm file. Update ProductTrait * update installation docs to support Sylius 1.13 * fix issue with completing Alma payments * refactor version.xml file --------- Co-authored-by: SergejSavic <sergej.savic@logeecom.com>
1 parent 65b5a3c commit e339a2a

File tree

9 files changed

+333
-52
lines changed

9 files changed

+333
-52
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
"license": "MIT",
66
"require": {
77
"php": "^7.4 || ^8.0",
8-
"sylius/sylius": "~1.9.0 || ~1.10.0 || ~1.11.0 || ~1.12.0",
8+
"sylius/sylius": "~1.9.0 || ~1.10.0 || ~1.11.0 || ~1.12.0 || ~1.13.0",
99
"symfony/messenger": "^4.4 || ^5.2 || ^6.0",
1010
"mollie/mollie-api-php": "^v2.71.0",
1111
"sylius/refund-plugin": "^1.0",
12-
"sylius/admin-order-creation-plugin": "^0.12 || ^0.13 || v0.14",
12+
"sylius/admin-order-creation-plugin": "^0.12 || ^0.13 || v0.14 || v0.15.0",
1313
"ext-json": "*",
1414
"willdurand/js-translation-bundle": "^4.0 || ^5.0"
1515
},

doc/installation.md

Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,57 @@ class GatewayConfig extends BaseGatewayConfig implements GatewayConfigInterface
5555
$this->mollieGatewayConfig = new ArrayCollection();
5656
}
5757
}
58+
```
59+
In case if you have installed Sylius version 1.13.x, use the following code instead
60+
```php
61+
<?php
62+
63+
declare(strict_types=1);
64+
65+
namespace App\Entity\Payment;
66+
67+
use Doctrine\ORM\Mapping as ORM;
68+
use SyliusMolliePlugin\Entity\GatewayConfigInterface;
69+
use SyliusMolliePlugin\Entity\GatewayConfigTrait;
70+
use Doctrine\Common\Collections\ArrayCollection;
71+
use Sylius\Bundle\PayumBundle\Model\GatewayConfig as BaseGatewayConfig;
72+
use SyliusMolliePlugin\Entity\MollieGatewayConfig;
73+
74+
/**
75+
* @ORM\Entity
76+
* @ORM\Table(name="sylius_gateway_config")
77+
*/
78+
#[ORM\Entity]
79+
#[ORM\Table(name: 'sylius_gateway_config')]
80+
class GatewayConfig extends BaseGatewayConfig implements GatewayConfigInterface
81+
{
82+
use GatewayConfigTrait;
83+
84+
/**
85+
* @var ArrayCollection
86+
* @ORM\OneToMany(
87+
* targetEntity="SyliusMolliePlugin\Entity\MollieGatewayConfig",
88+
* mappedBy="gateway",
89+
* orphanRemoval=true,
90+
* cascade={"all"}
91+
* )
92+
*/
93+
#[ORM\OneToMany(
94+
mappedBy: "gateway",
95+
targetEntity: MollieGatewayConfig::class,
96+
cascade: ["all"],
97+
orphanRemoval: true
98+
)]
99+
protected $mollieGatewayConfig;
100+
101+
public function __construct()
102+
{
103+
parent::__construct();
104+
105+
$this->mollieGatewayConfig = new ArrayCollection();
106+
}
107+
}
108+
58109
```
59110

60111
You can find more annotation examples under the [tests/Application/src/Entity/*](/tests/Application/src/Entity/) path.
@@ -109,6 +160,7 @@ use SyliusMolliePlugin\Entity\RecurringOrderTrait;
109160
use Doctrine\Common\Collections\Collection;
110161
use Sylius\Component\Core\Model\Order as BaseOrder;
111162
use Sylius\Component\Core\Model\OrderItemInterface;
163+
use Doctrine\ORM\Mapping as ORM;
112164

113165
/**
114166
* @ORM\Entity
@@ -189,6 +241,114 @@ class Order extends BaseOrder implements OrderInterface
189241
}
190242
}
191243

244+
```
245+
In case if you have installed Sylius version 1.13.x, use the following code instead
246+
```php
247+
<?php
248+
249+
declare(strict_types=1);
250+
251+
namespace App\Entity\Order;
252+
253+
use SyliusMolliePlugin\Entity\MolliePaymentIdOrderTrait;
254+
use SyliusMolliePlugin\Entity\OrderInterface;
255+
use SyliusMolliePlugin\Entity\MollieSubscriptionInterface;
256+
use SyliusMolliePlugin\Entity\AbandonedEmailOrderTrait;
257+
use SyliusMolliePlugin\Entity\QRCodeOrderTrait;
258+
use SyliusMolliePlugin\Entity\RecurringOrderTrait;
259+
use Doctrine\Common\Collections\Collection;
260+
use Sylius\Component\Core\Model\Order as BaseOrder;
261+
use Sylius\Component\Core\Model\OrderItemInterface;
262+
use Doctrine\ORM\Mapping as ORM;
263+
264+
/**
265+
* @ORM\Entity
266+
* @ORM\Table(name="sylius_order")
267+
*/
268+
#[ORM\Entity]
269+
#[ORM\Table(name: 'sylius_order')]
270+
class Order extends BaseOrder implements OrderInterface
271+
{
272+
use AbandonedEmailOrderTrait;
273+
use RecurringOrderTrait;
274+
use QRCodeOrderTrait;
275+
use MolliePaymentIdOrderTrait;
276+
277+
/**
278+
* @var bool
279+
* @ORM\Column(type="boolean", name="abandoned_email")
280+
*/
281+
#[ORM\Column(name: "abandoned_email", type: "boolean")]
282+
protected bool $abandonedEmail = false;
283+
284+
/**
285+
* @var ?int
286+
* @ORM\Column(type="integer", name="recurring_sequence_index", nullable=true)
287+
*/
288+
#[ORM\Column(name: "recurring_sequence_index", type: "integer", nullable: true)]
289+
protected ?int $recurringSequenceIndex = null;
290+
291+
/**
292+
* @var string|null
293+
* @ORM\Column(type="text", name="qr_code", nullable=true)
294+
*/
295+
#[ORM\Column(name: "qr_code", type: "text", nullable: true)]
296+
protected ?string $qrCode = null;
297+
298+
/**
299+
* @var string|null
300+
* @ORM\Column(type="text", name="mollie_payment_id", nullable=true)
301+
*/
302+
#[ORM\Column(name: "mollie_payment_id", type: "text", nullable: true)]
303+
protected ?string $molliePaymentId = null;
304+
305+
/**
306+
* @var MollieSubscriptionInterface|null
307+
* @ORM\ManyToOne(targetEntity="SyliusMolliePlugin\Entity\MollieSubscription")
308+
* @ORM\JoinColumn(name="subscription_id", fieldName="subscription", onDelete="RESTRICT")
309+
*/
310+
#[ORM\ManyToOne(targetEntity: MollieSubscription::class)]
311+
#[ORM\JoinColumn(name: "subscription_id", onDelete: "RESTRICT")]
312+
protected ?MollieSubscriptionInterface $subscription = null;
313+
314+
public function getRecurringItems(): Collection
315+
{
316+
return $this
317+
->items
318+
->filter(function (OrderItemInterface $orderItem) {
319+
$variant = $orderItem->getVariant();
320+
321+
return $variant !== null
322+
&& true === $variant->isRecurring();
323+
})
324+
;
325+
}
326+
327+
public function getNonRecurringItems(): Collection
328+
{
329+
return $this
330+
->items
331+
->filter(function (OrderItemInterface $orderItem) {
332+
$variant = $orderItem->getVariant();
333+
334+
return $variant !== null
335+
&& false === $variant->isRecurring();
336+
})
337+
;
338+
}
339+
340+
public function hasRecurringContents(): bool
341+
{
342+
return 0 < $this->getRecurringItems()->count();
343+
}
344+
345+
public function hasNonRecurringContents(): bool
346+
{
347+
return 0 < $this->getNonRecurringItems()->count();
348+
}
349+
}
350+
351+
192352
```
193353

194354
If you don't use annotations, you can also define new Entity mapping inside your `src/Resources/config/doctrine` directory.
@@ -247,6 +407,40 @@ class Product extends BaseProduct implements ProductInterface
247407
*/
248408
protected ?ProductType $productType = null;
249409
}
410+
```
411+
In case if you have installed Sylius version 1.13.x, use the following code instead
412+
```php
413+
<?php
414+
415+
declare(strict_types=1);
416+
417+
namespace App\Entity\Product;
418+
419+
use Doctrine\ORM\Mapping as ORM;
420+
use SyliusMolliePlugin\Entity\ProductInterface;
421+
use SyliusMolliePlugin\Entity\ProductTrait;
422+
use Sylius\Component\Core\Model\Product as BaseProduct;
423+
use SyliusMolliePlugin\Entity\ProductType;
424+
425+
/**
426+
* @ORM\Entity
427+
* @ORM\Table(name="sylius_product")
428+
*/
429+
#[ORM\Entity]
430+
#[ORM\Table(name: 'sylius_product')]
431+
class Product extends BaseProduct implements ProductInterface
432+
{
433+
use ProductTrait;
434+
435+
/**
436+
* @ORM\ManyToOne(targetEntity="SyliusMolliePlugin\Entity\ProductType")
437+
* @ORM\JoinColumn(name="product_type_id", referencedColumnName="id", onDelete="SET NULL")
438+
*/
439+
#[ORM\ManyToOne(targetEntity: ProductType::class)]
440+
#[ORM\JoinColumn(name: "product_type_id", referencedColumnName: "id", onDelete: "SET NULL")]
441+
protected ?ProductType $productType = null;
442+
}
443+
250444
```
251445

252446
If you don't use annotations, you can also define new Entity mapping inside your `src/Resources/config/doctrine` directory.
@@ -379,6 +573,104 @@ trait RecurringProductVariantTrait
379573
}
380574
}
381575
```
576+
In case if you have installed Sylius version 1.13.x, use the following code instead
577+
```php
578+
<?php
579+
580+
declare(strict_types=1);
581+
582+
namespace App\Entity\Product;
583+
584+
use Doctrine\ORM\Mapping as ORM;
585+
use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant;
586+
use Sylius\Component\Product\Model\ProductVariantTranslationInterface;
587+
588+
/**
589+
* @ORM\Entity
590+
* @ORM\Table(name="sylius_product_variant")
591+
*/
592+
#[ORM\Entity]
593+
#[ORM\Table(name: 'sylius_product_variant')]
594+
class ProductVariant extends BaseProductVariant
595+
{
596+
use RecurringProductVariantTrait;
597+
598+
protected function createTranslation(): ProductVariantTranslationInterface
599+
{
600+
return new ProductVariantTranslation();
601+
}
602+
603+
public function getName(): ?string
604+
{
605+
return parent::getName() ?: $this->getProduct()->getName();
606+
}
607+
}
608+
609+
```
610+
Add RecurringProductVariantTrait implementation:
611+
```php
612+
<?php
613+
614+
declare(strict_types=1);
615+
616+
namespace App\Entity\Product;
617+
618+
use Doctrine\ORM\Mapping as ORM;
619+
620+
trait RecurringProductVariantTrait
621+
{
622+
/**
623+
* @var bool
624+
* @ORM\Column(type="boolean", name="recurring", nullable="false", options={"default":0})
625+
*/
626+
#[ORM\Column(name: "recurring", type: "boolean", nullable: false, options: ['default' => 0])]
627+
private bool $recurring = false;
628+
629+
/**
630+
* @var ?int
631+
* @ORM\Column(type="integer", name="recurring_times", nullable="true")
632+
*/
633+
#[ORM\Column(name: "recurring_times", type: "integer", nullable: true)]
634+
private ?int $times = null;
635+
636+
/**
637+
* @var ?string
638+
* @ORM\Column(type="string", name="recurring_interval", nullable="true")
639+
*/
640+
#[ORM\Column(name: "recurring_interval", type: "string", nullable: true)]
641+
private ?string $interval = null;
642+
643+
public function isRecurring(): bool
644+
{
645+
return $this->recurring;
646+
}
647+
648+
public function setRecurring(bool $recurring): void
649+
{
650+
$this->recurring = $recurring;
651+
}
652+
653+
public function getTimes(): ?int
654+
{
655+
return $this->times;
656+
}
657+
658+
public function setTimes(?int $times): void
659+
{
660+
$this->times = $times;
661+
}
662+
663+
public function getInterval(): ?string
664+
{
665+
return $this->interval;
666+
}
667+
668+
public function setInterval(?string $interval): void
669+
{
670+
$this->interval = $interval;
671+
}
672+
}
673+
```
382674

383675
If you don't use annotations, you can also define new Entity mapping inside your `src/Resources/config/doctrine` directory.
384676

@@ -467,6 +759,9 @@ sylius_mollie_plugin:
467759

468760
#### 12. Update your database
469761

762+
In case if you have installed Sylius 1.13.x version, you will need to first remove { resource: "@SyliusRefundPlugin/Resources/config/app/config.yml" }
763+
from acme/config/packages/sylius_refund.yaml
764+
470765
Apply migration to your database: (this is for the plugin fresh installation only)
471766
```
472767
bin/console doctrine:migrations:migrate

src/Action/Api/CreatePaymentAction.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace SyliusMolliePlugin\Action\Api;
77

8+
use Mollie\Api\Types\PaymentMethod;
89
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
910
use SyliusMolliePlugin\Logger\MollieLoggerActionInterface;
1011
use SyliusMolliePlugin\Parser\Response\GuzzleNegativeResponseParserInterface;
@@ -67,6 +68,10 @@ public function execute($request): void
6768
'metadata' => $details['metadata'],
6869
];
6970

71+
if ($details['metadata']['molliePaymentMethods'] === PaymentMethod::ALMA) {
72+
$paymentDetails['billingAddress'] = $details['billingAddress'];
73+
}
74+
7075
if (true === isset($details['locale'])) {
7176
$paymentDetails['locale'] = $details['locale'];
7277
}

0 commit comments

Comments
 (0)