# Dashboard Mangopay - Subscription Feature

* [Why / Which context](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-why-whichcontext)
* [Steps to reproduce](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-stepstoreproduce)
  * [Make a booking on your platform](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-1.makeabookingonyourplatform)
  * [Accept the subscription request and enable payments](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-4.acceptthesubscriptionrequestandenablepaym)
  * [Test the active period](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-5.testtheactiveperiod)
  * [The asker needs to confirm the payin](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-6.theaskerneedtoconfirmthepayin)
  * [Test the next subscription period](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-7.testthenextsubscriptionperiod)
* [Commands](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-commands)
  * [Reminder](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-reminder)
* [Status](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-status)
  * [Subscription period](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-subscriptionperiod)
    * [Workflow](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-workflow)
    * [Status](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-status)
  * [Subscription status](#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-subscriptionstatus)

## Why / Which context <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-why-whichcontext" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-why-whichcontext"></a>

The inter-user subscription allows automatic recurring payment for one booking.

Payments are automatic in production, but in environment tests, it will take a few days to complete a workflow.

## Steps to reproduce <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-stepstoreproduce" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-stepstoreproduce"></a>

You do not need to have access to the Mangopay dashboard, all is handled through Second platform.

### Make a booking on your platform <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-1.makeabookingonyourplatform" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-1.makeabookingonyourplatform"></a>

Go on your platform and log in as an asker and create a booking request.

Learn more on the process of booking requests here: [Booking confirmation pages (Subscription Feature)](https://features.scnd.com/v2.0/core-concepts/payment-service-provider-features-psp/mangopay-bundle-psp-business-rules/broken-reference)

And fill in the credit card information.

The bank-wire payment is not available for subscription services.

### Accept the subscription request and enable payments <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-4.acceptthesubscriptionrequestandenablepaym" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-4.acceptthesubscriptionrequestandenablepaym"></a>

Once the payment has been made by the asker, the offeror can accept the subscription.

Learn more on the process of booking management here: [Bookings dashboard (Subscription Feature)](https://features.scnd.com/v2.0/dashboards/bookings-dashboard/bookings-dashboard-subscription)

By default, the Payin is done 2 days before the start date of the subscription period. This is set with the following configuration: subscription\_automatic.

The status of the subscription period will be Paid but the payin will not be done.

### Test the active period <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-5.testtheactiveperiod" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-5.testtheactiveperiod"></a>

Go in the SBO and fill the arguments in the command **subscription.status**

Arguments: --test --id=1868442188 --clock=P1Y1MT1H1M&#x20;

The same process to enable the payout: the command **cocorico:subscription:validate.**&#x20;

Arguments: --test --delay-weekly=-P1M

No space between the = and the Clock naming convention

Do not forget the - before the period

| **Period** | **Clock naming convention** |
| ---------- | --------------------------- |
| One minute | T1M                         |
| One hour   | T1H                         |
| One month  | P1M                         |
| One year   | P1Y                         |

### The asker need to confirm the payin <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-6.theaskerneedtoconfirmthepayin" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-6.theaskerneedtoconfirmthepayin"></a>

Once the offeror accept the booking, the asker will have to confirm the booking.

He have to fill a 2nd time his payment information. This is for security reasons but he will not be charge twice.

This security confirmation appears only for the first period. Once it is done you do not have to do it again.

### Test the next subscription period <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-7.testthenextsubscriptionperiod" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-7.testthenextsubscriptionperiod"></a>

To finish the complete workflow you should test the next period.

Once the period T is active it will create the next subscription period is pending.

You can reproduce the point **5. test the active period.**

The expected behavior is:

* The current subscription period is done
* The next subscription period is active
* The payout is available

You can reproduce steps 5 as many as you want in order to test several subscription period.

## Commands <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-commands" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-commands"></a>

* **second:subscription:expire**
  * Simulate a subscription request that has not been accepted or declined
  * No arguments
* **second:subscription:status**
  * Simulate the day of the platform to test payin and status
  * Args: --test --id=1868442188 --clock=P1M
* **second:subscription:validate**
  * Simulate the day of the platform to test payout and status and enable another subscription period
  * Args: --test --delay-weekly=-P1M

    <figure><img src="https://2306631548-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fn4EIoqjZx1xWQIo6LnjB%2Fuploads%2FZ53iONpDuH1Bq9NEixdG%2Fimage.png?alt=media&#x26;token=1298125f-1ac9-445e-840c-f00d62f08f21" alt=""><figcaption></figcaption></figure>

#### Reminder <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-reminder" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-reminder"></a>

No space between the = and the Clock naming convention

Do not forget the - before the period

| **Period** | **Clock naming convention** |
| ---------- | --------------------------- |
| One minute | T1M                         |
| One hour   | T1H                         |
| One month  | P1M                         |
| One year   | P1Y                         |

## Status <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-status" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-status"></a>

### Subscription period <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-subscriptionperiod" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-subscriptionperiod"></a>

#### Workflow <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-workflow" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-workflow"></a>

The subscription period workflow for a Accepted subscription request is:

Pending > Accepted > Paid > Active > Done

#### Status <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-status.1" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-status.1"></a>

* Pending: the next period, it is waiting for subscription acceptance or for payment
* Canceled: the next period was canceled by the asker
* Declined: the subscription request was canceled by the offerer
* PaymentError: the next period has a payment issue
* Paid: the next period was paid successfully but the period didn’t start yet (payment attempt delay)
* Active: the next period becomes active when the period starts (new cron command required)
* Done: the current period becomes done when the period ends (new cron command required)
* Canceled: the current period is paid or pending, and the active period (if any) becomes Done when the period ends.

### Subscription status <a href="#id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-subscriptionstatus" id="id-1.14.x-dashboardmangopay-inter-usersubscriptionbundle-subscriptionstatus"></a>

* Pending: the subscription request is waiting for the offerer acceptation
* Canceled: the subscription request was canceled by the asker
* Declined: the subscription request was canceled by the offerer
* Accepted: the subscription request was accepted by the offerer
* PaymentError: the next subscription period has a payment issue
* Paid: the first period was paid successfully but the period didn’t start yet (payment attempt delay)
* Active: the next period starts and it’s paid (new cron command required)
* Canceled: the next period was canceled and ( there is no current paid period or the current paid period ends ) (new cron command required)
