# Subscription

There are two different ways to use subscriptions.

* Payrexx managed recurring payments
* Self managed using a tokenization

{% hint style="warning" %}
Not all payment provider support subscriptions & tokenizations.\
Visit our [PSP Feature](https://help.payrexx.com/payment/payment-provider/psp-features) article to find a suitable payment provider.
{% endhint %}

## Payrexx Managed

We will debit your customer's payment mean based on your details.

### Gateway Creation

Payrexx managed subscriptions can easily be implemented using the Gateway.\
Use the following parameters to perform a subscription via the gateway

* subscriptionState: Set to true for subscriptions
* subscriptionInterval: Payment interval
* subscriptionPeriod: Duration of the subscription
* subscriptionCancellationInterval: Cancellation possibility for your customer

{% content-ref url="../build" %}
[build](https://docs.payrexx.com/developer/guides/gateway/build)
{% endcontent-ref %}

{% hint style="info" %}
If youn choose Payrexx managed subscriptions, you will receive a [subscription Webhook](https://docs.payrexx.com/developer/guides/gateway/payment-types/broken-reference) instead of a [transaction Webhook](https://docs.payrexx.com/developer/guides/gateway/payment-types/broken-reference).
{% endhint %}

## Self Managed

With this type of subscription, you are responsible for the individual charges of the subscription. Tokenization is the toolbox that helps you to do this.

### Setup Tokenization

Use the instructions from the Tokenization documentation for the setup.

{% content-ref url="tokenization" %}
[tokenization](https://docs.payrexx.com/developer/guides/gateway/payment-types/tokenization)
{% endcontent-ref %}

### Example

Once you have an authorized Transaction you can make charges using this tokenization.

**Example**\
Subscription Interval: 1 month\
Subscription preiod: 1 year

Make a charge every month for one year.\
You can find out how charges work in the [tokenization documentation](https://docs.payrexx.com/developer/guides/gateway/payment-types/tokenization).

{% hint style="warning" %}
You must implement the logic for **cancellations**, **renewals** etc.\
This allows you unlimited customisability!

Tokenization charges may fail due to different reasons.\
Make sure to handle this case in your code!
{% endhint %}
