# Salary slips and e-payslips

There are two ways a worker gets a salary slip. You can **fetch the PDF** of a paid calculation and show or send it yourself. Or Salaxy can **deliver an electronic payslip** to the worker's online bank, with no code from you.
Examples use the **test** environment; see [Environments](https://code.salaxy.com/get-started/environments.md) for demo and production.

*Diagram: A salary calculation is paid and reaches the status paymentSucceeded. From there, Salaxy delivers an electronic payslip to the worker's online bank automatically, if the delivery setting is on. Separately, your system can ask the Salaxy REST API for the salary slip PDF of the paid calculation. (Both start from a paid calculation. The e-payslip is automatic; the PDF is a call you make.)*

## Which fits you?

### Fetch the PDF
Fits when you show the salary slip in your own UI, store it, or send it to the worker yourself.

**Fetch the PDF: how it works:**
Salaxy generates and saves a salary slip PDF for each paid calculation: one slip per worker and payment, available as soon as the calculation is paid. There is no monthly slip run to wait for; the [monthly cycle](https://code.salaxy.com/integration/monthly-cycle.md) produces reports and invoices, not slips. The printout can be adjusted to the visual style of the company; contact Salaxy for that.

| Method | Path | Purpose |
|---|---|---|
| `GET` | `/v03/api/reports/assure-pdf/salarySlip?ids={calculationId}` | Make sure the salary slip PDF exists and return it |
| `GET` | `/v03/api/calculations` | Find calculation ids ([queries](https://code.salaxy.com/reference/queries.md)) |

Add `disposition` to choose how the PDF is returned:

| `disposition` | Response |
|---|---|
| not given | The PDF as a Base64 string in a JSON response (`application/json`) |
| `attachment` | A PDF file response with `Content-Disposition: attachment` |
| `inline` | A PDF file response with `Content-Disposition: inline` |

The `language` query parameter sets the language of the report. Other slip types exist in the same report type list: `salarySlipPaid`, `salarySlipCopy` and `eSalarySpecification`.

```
GET https://test-secure.salaxy.com/v03/api/reports/assure-pdf/salarySlip?ids=<calculationId>&disposition=attachment
Authorization: Bearer <token>
```

You need a token for the company that owns the calculation: see [REST authentication](https://code.salaxy.com/security/rest-authentication.md) and [impersonation](https://code.salaxy.com/security/impersonation.md). Find the calculation id with the calculations query, or from data you already read: an invoice header lists the calculations it covers ([invoices and payments](https://code.salaxy.com/integration/invoices-and-payments.md)), and [accounting data](https://code.salaxy.com/integration/accounting-data.md) entries carry the originating calculation id in their dimensions.

### Electronic payslip
Fits when you want the worker to get the slip in their online bank without building anything.

**Electronic payslip: how it works:**
The electronic payslip is known as *verkkopalkka* in Finnish and shown as "Online salary" in the UI. Salaxy delivers it through an e-payslip operator. **There is no endpoint to call.** Delivery is automatic and driven by the calculation status:

1. A salary calculation reaches `paymentSucceeded`.
2. Salaxy checks that the salary slip delivery methods of the calculation include the electronic payslip.
3. If so, the payslip is posted to the operator in the background, within moments.

On a customer funds account channel, `paymentSucceeded` means Salaxy has received the employer's funds, so the payslip is sent later, when Salaxy has paid the worker. See [Payroll lifecycle](https://code.salaxy.com/integration/payroll-lifecycle.md#customer-funds-account-channels).

The delivery methods are listed in the `responsibilities.salarySlipDeliveryMethods` array of the calculation result. It is read-only, and its values are `default`, `payslip` and `omapalkka`; `payslip` is the electronic payslip. The value comes from the Salaxy settings, not from your code.

If you use a [payment channel](https://code.salaxy.com/integration/payment-channels.md), the calculation reaches `paymentSucceeded` because you report the invoice `paid`. Delivery is a consequence of that, and it is not reported back through the payment channel API. See [Payroll lifecycle](https://code.salaxy.com/integration/payroll-lifecycle.md) for the statuses.

## Rules to know

- **Reporting `paid` sends the payslip.** In a payment channel integration, reporting `paid` is what puts a document in the worker's bank. Keep that in mind when you choose which event stands for `paid` ([Invoices and payments](https://code.salaxy.com/integration/invoices-and-payments.md#rules-that-save-you-a-day)).
- **There is no duplicate protection.** If a calculation leaves `paymentSucceeded` and enters it again, the worker gets a second payslip. Do not undo a `paid` report yourself; after payment, a correction is a Salaxy support action.
- **Cancelling a payment removes the payslip.** Salaxy's cancel and refund flow asks the operator to delete it.
- **A repaired calculation does not send a second payslip.** The original payslip stays as the record of the corrected payment.

## Test it

- **PDF:** pay a test calculation (see [Create a payroll](https://code.salaxy.com/get-started/rest/create-payroll.md) and [Set for payment](https://code.salaxy.com/get-started/rest/set-for-payment.md)), then call `assure-pdf/salarySlip` as above and check the response for each `disposition` you use.
- **E-payslip:** there is no test gate on this delivery: driving a calculation to `paymentSucceeded` in the test environment runs it. It goes to the operator's test service, so no real online bank receives it. Use fake data only.

## Checklist

- You know how each customer gets the slip: PDF through your system, e-payslip from Salaxy, or both.
- PDF fetch uses a token for the company that owns the calculation.
- Your code handles each `disposition` response it uses.
- You chose the event that stands for `paid` knowing that it also sends the e-payslip.
- You never undo a `paid` report yourself, so a calculation never passes through `paymentSucceeded` twice.

**Next:** [Messages and notifications](https://code.salaxy.com/integration/messages-and-notifications.md)
