@@ -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\S yliusPayPlugPlugin\A ction\C aptureAction:
73+ arguments:
74+ $payplugCardRepository: '@payplug.repository.payplug_card'
75+
76+ PayPlug\S yliusPayPlugPlugin\R epository\R efundHistoryRepositoryInterface:
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\E ntity\C ustomer;
108+ namespace App\E ntity\C ustomer;
77109
78- use Doctrine\O RM\M apping as ORM;
79- use PayPlug\S yliusPayPlugPlugin\E ntity\C ardsOwnerInterface;
80- use PayPlug\S yliusPayPlugPlugin\E ntity\T raits\C ustomerTrait;
81- use Sylius\C omponent\C ore\M odel\C ustomer as BaseCustomer;
110+ use Doctrine\O RM\M apping as ORM;
111+ use PayPlug\S yliusPayPlugPlugin\E ntity\C ardsOwnerInterface;
112+ use PayPlug\S yliusPayPlugPlugin\E ntity\T raits\C ustomerTrait;
113+ use Sylius\C omponent\C ore\M odel\C ustomer as BaseCustomer;
82114
83- /**
84- * @ORM\E ntity
85- * @ORM\T able(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\E ntity
117+ * @ORM\T able(name="sylius_customer")
118+ */
119+ #[ORM\E ntity]
120+ #[ORM\T able(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\E ntity\P ayment;
103-
104- use Doctrine\O RM\M apping as ORM;
105- use PayPlug\S yliusPayPlugPlugin\E ntity\T raits\P aymentMethodTrait;
106- use Sylius\C omponent\C ore\M odel\P aymentMethod as BasePaymentMethod;
107- use Sylius\C omponent\P ayment\M odel\P aymentMethodTranslationInterface;
108-
109- /**
110- * @ORM\E ntity
111- * @ORM\T able(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\E ntity\P ayment;
135+
136+ use Doctrine\O RM\M apping as ORM;
137+ use PayPlug\S yliusPayPlugPlugin\E ntity\T raits\P aymentMethodTrait;
138+ use Sylius\C omponent\C ore\M odel\P aymentMethod as BasePaymentMethod;
139+ use Sylius\C omponent\P ayment\M odel\P aymentMethodTranslationInterface;
140+
141+ /**
142+ * @ORM\E ntity
143+ * @ORM\T able(name="sylius_payment_method")
144+ */
145+ #[ORM\E ntity]
146+ #[ORM\T able(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\E ntity\P ayment;
165+ namespace App\E ntity\P ayment;
134166
135- use Doctrine\C ommon\C ollections\A rrayCollection;
136- use Doctrine\O RM\M apping as ORM;
137- use PayPlug\S yliusPayPlugPlugin\E ntity\T raits\P aymentTrait;
138- use Sylius\C omponent\C ore\M odel\P ayment as BasePayment;
167+ use Doctrine\C ommon\C ollections\A rrayCollection;
168+ use Doctrine\O RM\M apping as ORM;
169+ use PayPlug\S yliusPayPlugPlugin\E ntity\T raits\P aymentTrait;
170+ use Sylius\C omponent\C ore\M odel\P ayment as BasePayment;
139171
140- /**
141- * @ORM\E ntity
142- * @ORM\T able(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\E ntity
174+ * @ORM\T able(name="sylius_payment")
175+ */
176+ #[ORM\E ntity]
177+ #[ORM\T able(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.
166198In your back-office, go to `Configuration > Payment methods`, then click on `Create` and choose "**Payplug**".
0 commit comments