Skip to content

Commit e5537ec

Browse files
upgrade-v2: update README with complete instructions
1 parent d82b031 commit e5537ec

2 files changed

Lines changed: 136 additions & 97 deletions

File tree

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@
1717
/tests/TestApplication/.env.local
1818
/tests/TestApplication/.env.*.local
1919
/var/
20+
21+
22+
Audit.md
23+
CLAUDE.md
24+
.DS_Store
25+
.claude
26+
.review

README.md

Lines changed: 129 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -31,136 +31,168 @@ In local environment, the plugin will not work properly because you will not be
3131
3232
## Compatibility
3333

34-
| | Version |
35-
| :--- |:--------|
36-
| PHP | ^8.2 |
34+
| | Version |
35+
|:-------|:--------|
36+
| PHP | ^8.2 |
3737
| Sylius | ^2.0 |
3838

3939
## Installation
4040

41-
1. Require the **payplug/sylius-payplug-plugin** :
41+
### 1. Require the **payplug/sylius-payplug-plugin** :
4242

43-
```bash
44-
composer config extra.symfony.allow-contrib true
45-
composer require payplug/sylius-payplug-plugin
46-
```
43+
```bash
44+
composer config extra.symfony.allow-contrib true
45+
composer require payplug/sylius-payplug-plugin
46+
```
47+
48+
### 3. Register Sylius resources
49+
50+
The plugin's extension does not prepend its `resources.yaml`, so the Sylius resource services for the Card and RefundHistory entities are never created. Add them manually in `config/packages/sylius_resource.yaml`:
51+
52+
```yaml
53+
sylius_resource:
54+
resources:
55+
payplug.payplug_card:
56+
driver: doctrine/orm
57+
classes:
58+
model: PayPlug\SyliusPayPlugPlugin\Entity\Card
59+
payplug.payplug_refund_history:
60+
driver: doctrine/orm
61+
classes:
62+
model: PayPlug\SyliusPayPlugPlugin\Entity\RefundHistory
63+
repository: PayPlug\SyliusPayPlugPlugin\Repository\RefundHistoryRepository
64+
```
4765
48-
2. Apply migrations to your database:
66+
### 4. Fix service autowiring
4967
50-
```shell
51-
bin/console doctrine:migrations:migrate
52-
```
68+
The plugin uses `#[Autoconfigure]` on some actions and relies on named constructor arguments that Symfony cannot resolve automatically. Add the following to `config/services.yaml`:
69+
70+
```yaml
71+
services:
72+
PayPlug\SyliusPayPlugPlugin\Action\CaptureAction:
73+
arguments:
74+
$payplugCardRepository: '@payplug.repository.payplug_card'
75+
76+
PayPlug\SyliusPayPlugPlugin\Repository\RefundHistoryRepositoryInterface:
77+
alias: payplug.repository.payplug_refund_history
78+
```
5379

54-
3. Add Payplug to refundable payment method for Sylius Refund Plugin in `config/services.yaml`
80+
### 5. Apply migrations to your database:
5581

56-
```yaml
57-
parameters:
58-
locale: fr_FR
59-
sylius_refund.supported_gateways:
60-
- payplug
61-
- payplug_oney
62-
- payplug_bancontact
63-
- payplug_apple_pay
64-
- payplug_american_express
65-
```
82+
```shell
83+
bin/console doctrine:migrations:migrate
84+
```
6685

67-
4. Add Traits for Customer and PaymentMethod entities
86+
### 6. Add Payplug to refundable payment method for Sylius Refund Plugin in `config/services.yaml`
87+
88+
```yaml
89+
parameters:
90+
locale: fr_FR
91+
sylius_refund.supported_gateways:
92+
- payplug
93+
- payplug_oney
94+
- payplug_bancontact
95+
- payplug_apple_pay
96+
- payplug_american_express
97+
```
98+
99+
### 7. Add Traits for Customer and PaymentMethod entities
68100

69101
* App\Entity\Customer\Customer
70102

71-
```php
72-
<?php
103+
```php
104+
<?php
73105
74-
declare(strict_types=1);
106+
declare(strict_types=1);
75107
76-
namespace App\Entity\Customer;
108+
namespace App\Entity\Customer;
77109
78-
use Doctrine\ORM\Mapping as ORM;
79-
use PayPlug\SyliusPayPlugPlugin\Entity\CardsOwnerInterface;
80-
use PayPlug\SyliusPayPlugPlugin\Entity\Traits\CustomerTrait;
81-
use Sylius\Component\Core\Model\Customer as BaseCustomer;
110+
use Doctrine\ORM\Mapping as ORM;
111+
use PayPlug\SyliusPayPlugPlugin\Entity\CardsOwnerInterface;
112+
use PayPlug\SyliusPayPlugPlugin\Entity\Traits\CustomerTrait;
113+
use Sylius\Component\Core\Model\Customer as BaseCustomer;
82114
83-
/**
84-
* @ORM\Entity
85-
* @ORM\Table(name="sylius_customer")
86-
*/
87-
#[ORM\Entity]
88-
#[ORM\Table(name: 'sylius_customer')]
89-
class Customer extends BaseCustomer implements CardsOwnerInterface
90-
{
91-
use CustomerTrait;
92-
}
93-
```
115+
/**
116+
* @ORM\Entity
117+
* @ORM\Table(name="sylius_customer")
118+
*/
119+
#[ORM\Entity]
120+
#[ORM\Table(name: 'sylius_customer')]
121+
class Customer extends BaseCustomer implements CardsOwnerInterface
122+
{
123+
use CustomerTrait;
124+
}
125+
```
94126

95127
* App\Entity\Payment\PaymentMethod
96128

97-
```php
98-
<?php
99-
100-
declare(strict_types=1);
101-
102-
namespace App\Entity\Payment;
103-
104-
use Doctrine\ORM\Mapping as ORM;
105-
use PayPlug\SyliusPayPlugPlugin\Entity\Traits\PaymentMethodTrait;
106-
use Sylius\Component\Core\Model\PaymentMethod as BasePaymentMethod;
107-
use Sylius\Component\Payment\Model\PaymentMethodTranslationInterface;
108-
109-
/**
110-
* @ORM\Entity
111-
* @ORM\Table(name="sylius_payment_method")
112-
*/
113-
#[ORM\Entity]
114-
#[ORM\Table(name: 'sylius_payment_method')]
115-
class PaymentMethod extends BasePaymentMethod
129+
```php
130+
<?php
131+
132+
declare(strict_types=1);
133+
134+
namespace App\Entity\Payment;
135+
136+
use Doctrine\ORM\Mapping as ORM;
137+
use PayPlug\SyliusPayPlugPlugin\Entity\Traits\PaymentMethodTrait;
138+
use Sylius\Component\Core\Model\PaymentMethod as BasePaymentMethod;
139+
use Sylius\Component\Payment\Model\PaymentMethodTranslationInterface;
140+
141+
/**
142+
* @ORM\Entity
143+
* @ORM\Table(name="sylius_payment_method")
144+
*/
145+
#[ORM\Entity]
146+
#[ORM\Table(name: 'sylius_payment_method')]
147+
class PaymentMethod extends BasePaymentMethod
148+
{
149+
use PaymentMethodTrait;
150+
151+
protected function createTranslation(): PaymentMethodTranslationInterface
116152
{
117-
use PaymentMethodTrait;
118-
119-
protected function createTranslation(): PaymentMethodTranslationInterface
120-
{
121-
return new PaymentMethodTranslation();
122-
}
153+
return new PaymentMethodTranslation();
123154
}
124-
```
155+
}
156+
```
125157

126158
* App\Entity\Payment\Payment
127159

128-
```php
129-
<?php
160+
```php
161+
<?php
130162
131-
declare(strict_types=1);
163+
declare(strict_types=1);
132164
133-
namespace App\Entity\Payment;
165+
namespace App\Entity\Payment;
134166
135-
use Doctrine\Common\Collections\ArrayCollection;
136-
use Doctrine\ORM\Mapping as ORM;
137-
use PayPlug\SyliusPayPlugPlugin\Entity\Traits\PaymentTrait;
138-
use Sylius\Component\Core\Model\Payment as BasePayment;
167+
use Doctrine\Common\Collections\ArrayCollection;
168+
use Doctrine\ORM\Mapping as ORM;
169+
use PayPlug\SyliusPayPlugPlugin\Entity\Traits\PaymentTrait;
170+
use Sylius\Component\Core\Model\Payment as BasePayment;
139171
140-
/**
141-
* @ORM\Entity
142-
* @ORM\Table(name="sylius_payment")
143-
*/
144-
#[ORM\Entity]
145-
#[ORM\Table(name: 'sylius_payment')]
146-
class Payment extends BasePayment
147-
{
148-
use PaymentTrait;
149-
}
150-
```
172+
/**
173+
* @ORM\Entity
174+
* @ORM\Table(name="sylius_payment")
175+
*/
176+
#[ORM\Entity]
177+
#[ORM\Table(name: 'sylius_payment')]
178+
class Payment extends BasePayment
179+
{
180+
use PaymentTrait;
181+
}
182+
```
151183

152-
5. Process translations
184+
### 8. Process translations
153185

154-
```bash
155-
php bin/console translation:extract en PayPlugSyliusPayPlugPlugin --dump-messages
156-
php bin/console translation:extract fr PayPlugSyliusPayPlugPlugin --dump-messages
157-
```
186+
```bash
187+
php bin/console translation:extract en PayPlugSyliusPayPlugPlugin --dump-messages
188+
php bin/console translation:extract fr PayPlugSyliusPayPlugPlugin --dump-messages
189+
```
158190

159-
6. Clear cache:
191+
### 9. Clear cache:
160192

161-
```shell
162-
php bin/console cache:clear
163-
```
193+
```bash
194+
bin/console cache:clear
195+
```
164196

165197
🎉 You are now ready to add Payplug Payment method.
166198
In your back-office, go to `Configuration > Payment methods`, then click on `Create` and choose "**Payplug**".

0 commit comments

Comments
 (0)