Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d81eb2b

Browse files
DennisCodeBudsCoderMaggie
authored andcommitted
Add yaml configuration examples
In my projects I tend to use YAML for the configuration files so I thought it might be helpful to others to add configuration examples in the YMAL format
1 parent 3d912fd commit d81eb2b

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

docs/cookbook/payments/custom-payment-gateway.rst

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ In the following example, a new gateway will be configured, which will send paym
4141
}
4242
}
4343
44-
And at the end of ``src/Resources/config/services.xml`` add such a configuration for your gateway:
44+
And at the end of ``src/Resources/config/services.xml``, or, ``src/Resources/config/services.yaml`` add such a configuration for your gateway:
4545

4646
.. code-block:: xml
4747
@@ -52,6 +52,17 @@ In the following example, a new gateway will be configured, which will send paym
5252
<tag name="payum.gateway_factory_builder" factory="sylius_payment" />
5353
</service>
5454
55+
.. code-block:: yml
56+
57+
#src/Resources/config/services.yaml
58+
59+
app.sylius_payment:
60+
class: Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder
61+
arguments: [ Acme\SyliusExamplePlugin\Payum\SyliusPaymentGatewayFactory ]
62+
tags:
63+
- { name: payum.gateway_factory_builder, factory: sylius_payment }
64+
65+
5566
**3.** Next, one should create a configuration form, where authorization
5667
(or some additional information, like sandbox mode) can be specified.
5768

@@ -79,7 +90,7 @@ In the following example, a new gateway will be configured, which will send paym
7990
}
8091
}
8192
82-
And add its configuration to `src/Resources/config/services.xml`:
93+
And add its configuration to `src/Resources/config/services.xml` or ``src/Resources/config/services.yaml``:
8394

8495
.. code-block:: xml
8596
@@ -89,6 +100,15 @@ In the following example, a new gateway will be configured, which will send paym
89100
<tag name="sylius.gateway_configuration_type" type="sylius_payment" label="Sylius Payment" />
90101
<tag name="form.type" />
91102
</service>
103+
104+
.. code-block:: yml
105+
106+
#src/Resources/config/services.yaml
107+
108+
Acme\SyliusExamplePlugin\Form\Type\SyliusGatewayConfigurationType:
109+
tags:
110+
- { name: sylius.gateway_configuration_type, type: sylius_payment, label: 'Sylius Payment' }
111+
- { name: form.type }
92112
93113
**4.** To introduce support for new configuration fields, we need to create a value object which will be passed to action,
94114
so we can use an API Key provided in form.
@@ -347,7 +367,7 @@ so we can use an API Key provided in form.
347367
}
348368
}
349369
350-
And at the end of ``src/Resources/config/services.xml`` add such a configuration for your capture action:
370+
And at the end of ``src/Resources/config/services.xml`` or `src/Resources/config/services.yaml`` add such a configuration for your capture action:
351371

352372
.. code-block:: xml
353373
@@ -357,6 +377,16 @@ so we can use an API Key provided in form.
357377
<argument type="service" id="sylius.http_client" />
358378
<tag name="payum.action" factory="sylius_payment" alias="payum.action.capture" />
359379
</service>
380+
381+
.. code-block:: yaml
382+
383+
#src/Resources/config/services.yaml
384+
385+
Acme\SyliusExamplePlugin\Payum\Action\CaptureAction:
386+
arguments:
387+
- '@sylius.http_client'
388+
tags:
389+
- { name: payum.action, factory: sylius_payment, alias: payum.action.capture }
360390
361391
Your shop is ready to handle the first checkout with your newly created gateway!
362392

0 commit comments

Comments
 (0)