mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
GITBOOK: Export Sylius documentation
This commit is contained in:
parent
cee940f50f
commit
da85bce5c1
6 changed files with 146 additions and 2 deletions
BIN
docs/.gitbook/assets/invoice.png
Normal file
BIN
docs/.gitbook/assets/invoice.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
BIN
docs/.gitbook/assets/order_invoices.png
Normal file
BIN
docs/.gitbook/assets/order_invoices.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
BIN
docs/.gitbook/assets/shop_billing_data.webp
Normal file
BIN
docs/.gitbook/assets/shop_billing_data.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
BIN
docs/.gitbook/assets/sylius_payment.webp
Normal file
BIN
docs/.gitbook/assets/sylius_payment.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
|
|
@ -1,6 +1,51 @@
|
||||||
---
|
---
|
||||||
hidden: true
|
layout:
|
||||||
|
title:
|
||||||
|
visible: true
|
||||||
|
description:
|
||||||
|
visible: false
|
||||||
|
tableOfContents:
|
||||||
|
visible: true
|
||||||
|
outline:
|
||||||
|
visible: true
|
||||||
|
pagination:
|
||||||
|
visible: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# Invoices
|
# Invoices
|
||||||
|
|
||||||
|
An invoice is a commercial document issued by a shop as a confirmation of a sales transaction. It lists the products, quantities, and prices agreed upon, and typically includes payment terms (e.g., due date, payment status). For the shop, it's a sales invoice; for the customer, it's a purchase invoice.
|
||||||
|
|
||||||
|
## Invoicing in Sylius
|
||||||
|
|
||||||
|
Sylius provides invoicing functionality through [a free open-source plugin](https://github.com/Sylius/InvoicingPlugin). For installation, refer to the plugin’s README.
|
||||||
|
|
||||||
|
Once the plugin is installed, a new “Invoices” item appears under the “Sales” section in the admin panel. This lets you view all issued invoices with sorting and filtering options. An “Invoices” section is also added to the admin Order page and the customer's Order page in the shop.
|
||||||
|
|
||||||
|
<figure><img src="../../.gitbook/assets/order_invoices.png" alt=""><figcaption></figcaption></figure>
|
||||||
|
|
||||||
|
### When is an Invoice Issued?
|
||||||
|
|
||||||
|
By default, invoices are generated when the customer places an order (after clicking the Confirm button at checkout). The invoice becomes downloadable for both the admin and the customer at this point.
|
||||||
|
|
||||||
|
{% hint style="info" %}
|
||||||
|
To change when invoices are generated, customize the logic in the event listener and `OrderPlacedProducer`. Check [here](https://github.com/Sylius/InvoicingPlugin/blob/main/src/Resources/config/services/listeners.xml#L18-L23).
|
||||||
|
{% endhint %}
|
||||||
|
|
||||||
|
### Sending and Downloading Invoices
|
||||||
|
|
||||||
|
Sending an invoice is separate from its generation. By default, invoices are sent when the order's payment is marked as paid.
|
||||||
|
|
||||||
|
To change this, you can modify the configuration in the `config.yml` file by adding or editing state machine event listeners.
|
||||||
|
|
||||||
|
### Shop Billing Data
|
||||||
|
|
||||||
|
The plugin uses the billing data provided in Sylius Channels for invoice details. Each channel has a section where you can input shop billing data, which will be shown on the invoice.
|
||||||
|
|
||||||
|
<figure><img src="../../.gitbook/assets/shop_billing_data.webp" alt=""><figcaption></figcaption></figure>
|
||||||
|
|
||||||
|
<figure><img src="../../.gitbook/assets/invoice.png" alt=""><figcaption></figcaption></figure>
|
||||||
|
|
||||||
|
## Learn more
|
||||||
|
|
||||||
|
* [Sylius Invoicing Plugin](https://github.com/Sylius/InvoicingPlugin)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,105 @@
|
||||||
---
|
---
|
||||||
hidden: true
|
layout:
|
||||||
|
title:
|
||||||
|
visible: true
|
||||||
|
description:
|
||||||
|
visible: false
|
||||||
|
tableOfContents:
|
||||||
|
visible: true
|
||||||
|
outline:
|
||||||
|
visible: true
|
||||||
|
pagination:
|
||||||
|
visible: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# Payments
|
# Payments
|
||||||
|
|
||||||
|
Sylius has a flexible payment management system that integrates with various gateways through the Payum library. Payum handles operations like capturing, refunds, and recurring payments, while Sylius manages payments within the checkout and tracks related payment data.
|
||||||
|
|
||||||
|
## Payment
|
||||||
|
|
||||||
|
Every payment, whether successful or failed, is represented by the `Payment` model in Sylius. This model includes essential details and links to the related order.
|
||||||
|
|
||||||
|
### Creating a Payment Programmatically
|
||||||
|
|
||||||
|
Payments must be linked to an order. To create a new payment:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$payment = $this->container->get('sylius.factory.payment')->createNew();
|
||||||
|
$payment->setOrder($order);
|
||||||
|
$payment->setCurrencyCode('USD');
|
||||||
|
$this->container->get('sylius.repository.payment')->add($payment);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Payment State Machine
|
||||||
|
|
||||||
|
Payments in Sylius have a state machine with states such as: **cart, new, processing, completed, failed, cancelled,** and **refunded.**
|
||||||
|
|
||||||
|
The available transitions between these states are:
|
||||||
|
|
||||||
|
```
|
||||||
|
transitions:
|
||||||
|
create:
|
||||||
|
from: [cart]
|
||||||
|
to: new
|
||||||
|
process:
|
||||||
|
from: [new]
|
||||||
|
to: processing
|
||||||
|
authorize:
|
||||||
|
from: [new, processing]
|
||||||
|
to: authorized
|
||||||
|
complete:
|
||||||
|
from: [new, processing, authorized]
|
||||||
|
to: completed
|
||||||
|
fail:
|
||||||
|
from: [new, processing]
|
||||||
|
to: failed
|
||||||
|
cancel:
|
||||||
|
from: [new, processing, authorized]
|
||||||
|
to: cancelled
|
||||||
|
refund:
|
||||||
|
from: [completed]
|
||||||
|
to: refunded
|
||||||
|
```
|
||||||
|
|
||||||
|
<figure><img src="../../.gitbook/assets/sylius_payment.webp" alt=""><figcaption></figcaption></figure>
|
||||||
|
|
||||||
|
You can add custom states and transitions to fit your workflow. Transitions trigger changes to the payment state.
|
||||||
|
|
||||||
|
## Payment Methods
|
||||||
|
|
||||||
|
`PaymentMethod` defines how customers pay during checkout and is linked to a payment gateway with custom configurations.
|
||||||
|
|
||||||
|
### **Creating a Payment Method Programmatically:**
|
||||||
|
|
||||||
|
```php
|
||||||
|
$paymentMethod = $this->container->get('sylius.factory.payment_method')->createWithGateway('offline');
|
||||||
|
$paymentMethod->setCode('ALFA1');
|
||||||
|
$this->container->get('sylius.repository.payment_method')->add($paymentMethod);
|
||||||
|
```
|
||||||
|
|
||||||
|
Ensure you add the payment method to a channel to make it available:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$paymentMethod->addChannel($channel);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Payment Gateway Configuration
|
||||||
|
|
||||||
|
To add a custom gateway, create a configuration form type and tag it with `sylius.gateway_configuration_type`. Check out examples like PayPal and Stripe for guidance. If you're unsure, refer to the Payum documentation.
|
||||||
|
|
||||||
|
#### Troubleshooting
|
||||||
|
|
||||||
|
Sylius saves payment data in the `details` column of `sylius_payment`, which can be helpful for debugging.
|
||||||
|
|
||||||
|
#### **PayPal Error Code 10409**
|
||||||
|
|
||||||
|
If you receive the error "Checkout token was issued for a merchant account other than yours," You have most likely changed the PayPal credentials during the checkout process, clear the cache:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bin/console cache:clear
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Payment Complete Events
|
||||||
|
|
||||||
|
Events such as `sylius.payment.pre_complete` and `sylius.payment.post_complete` are dispatched during certain admin actions. Note that these events don’t cover payments completed by gateways. For that, consider adding a callback to the `sylius_order_payment` state machine for the `pay` transition.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue