---
title: "Subscriptions"
description: "Płatności cykliczne. Każda aplikacja jest modułem na jednym modelu danych."
canonical: "https://obop.dev/pl/apps/subscriptions/"
lang: "pl"
---

# Subscriptions

## Do czego służy

Define recurring plans and track customer subscriptions with trial, active, past due and cancelled states, including the next invoice date. It does not create invoices by itself.

## Co pakiet robi, a czego nie robi

Recurring plans and customer subscriptions with a trial, active, past due and cancelled flow. It records the next invoice date; it does not create invoices on its own.

## Modele

### `subscriptions_plan`

A recurring offer customers can subscribe to

Grupa odczytu: `subscriptions.user`. Grupa zapisu: `subscriptions.manager`.

| Pole | Rodzaj | Klasa danych | Dane osobowe | Grupa | Agenci widzą | Opis |
|---|---|---|---|---|---|---|
| `name` | text | `none` | nie | `subscriptions.user` | jawnie | Plan name, for example Team yearly |
| `code` | text | `none` | nie | `subscriptions.user` | jawnie | Short code of the plan |
| `interval` | select (monthly, quarterly, yearly) | `none` | nie | `subscriptions.user` | jawnie | How often the customer is billed: monthly, quarterly, yearly |
| `price` | money | `none` | nie | `subscriptions.user` | jawnie | Standard price per billing interval (minor currency units, e.g. cents) |
| `trial_days` | number | `none` | nie | `subscriptions.user` | jawnie | Length of the free trial in days |
| `active` | bool | `none` | nie | `subscriptions.user` | jawnie | Whether new customers can pick the plan |

### `subscriptions_subscription`

A customer's recurring subscription to a plan

Grupa odczytu: `subscriptions.user`. Grupa zapisu: `subscriptions.manager`.

| Pole | Rodzaj | Klasa danych | Dane osobowe | Grupa | Agenci widzą | Opis |
|---|---|---|---|---|---|---|
| `customer_id` | ref → party | `none` | nie | `subscriptions.user` | jawnie | The customer who subscribed |
| `plan_id` | ref → subscriptions_plan | `none` | nie | `subscriptions.user` | jawnie | The plan subscribed to |
| `started_on` | date | `none` | nie | `subscriptions.user` | jawnie | Date the subscription began (YYYY-MM-DD) |
| `trial_ends_on` | date | `none` | nie | `subscriptions.user` | jawnie | Date the free trial ends (YYYY-MM-DD) |
| `next_invoice_on` | date | `none` | nie | `subscriptions.user` | jawnie | Date the next invoice is due (YYYY-MM-DD) |
| `recurring_amount` | money | `none` | nie | `subscriptions.user` | jawnie | Amount billed each interval after discounts (minor currency units, e.g. cents) |
| `currency` | text | `none` | nie | `subscriptions.user` | jawnie | ISO 4217 currency code, for example EUR |
| `seats` | number | `none` | nie | `subscriptions.user` | jawnie | Number of licences or users covered |
| `cancel_reason` | longtext | `none` | nie | `subscriptions.user` | jawnie | Why the customer cancelled |
| `state` | select (trial, active, past_due, cancelled) | `none` | nie | `subscriptions.user` | jawnie | Subscription status: trial, active, past_due, cancelled |

## Przepływy pracy

### `subscriptions_subscription`

| Akcja | Przenosi | Kto może uruchomić | Zatwierdzenie |
|---|---|---|---|
| `subscriptions_subscription.activate` | state: trial → active | `subscriptions.manager` | nie |
| `subscriptions_subscription.mark_past_due` | state: active → past_due | `subscriptions.manager` | nie |
| `subscriptions_subscription.recover` | state: past_due → active | `subscriptions.manager` | nie |
| `subscriptions_subscription.cancel_trial` | state: trial → cancelled | `subscriptions.manager` | tak |
| `subscriptions_subscription.cancel` | state: active → cancelled | `subscriptions.manager` | tak |
| `subscriptions_subscription.cancel_overdue` | state: past_due → cancelled | `subscriptions.manager` | tak |

## Grupy uprawnień

Grupy używane przez tę aplikację:

- `subscriptions.manager`
- `subscriptions.user`

## Kroki zatwierdzania

Kroki, które agent może tylko zaproponować:

- `subscriptions_subscription.cancel_trial`
- `subscriptions_subscription.cancel`
- `subscriptions_subscription.cancel_overdue`

## Co agenci mogą, a czego nie mogą

Agent może odczytywać, wyszukiwać, tworzyć i aktualizować rekordy tej aplikacji oraz uruchamiać akcje niewymagające zatwierdzenia, w ramach grup uprawnień swojego tokenu.

Te kroki może tylko zaproponować, a człowiek musi je zatwierdzić: `subscriptions_subscription.cancel_trial`, `subscriptions_subscription.cancel`, `subscriptions_subscription.cancel_overdue`, `subscriptions_plan.delete`, `subscriptions_subscription.delete`.

## Zależności

- `base`

## Instalacja

Zainstaluj ją w aplikacji Customize (Marketplace) lub z wiersza poleceń:

```bash
obop modules install-from subscriptions
```

Wymaga bazy danych i uprawnień administratora.

## Zbuduj własną

[Przewodnik po modułach pokazuje, jak pisze się takie aplikacje](/pl/docs/reference/module-manifest/)
