> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monieswitch.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Accepting Recurring Payments with Monieswitch

> A guide to setting up and managing subscription or recurring billing using Monieswitch APIs.

### Who is this for?

<Note>
  Businesses and developers who want to automate subscription billing or
  recurring payments using Monieswitch.
</Note>

## Overview

This guide covers:

* Setting up recurring payment plans
* Subscribing customers to plans
* Managing and cancelling subscriptions
* Handling webhooks for payment events

***

## Prerequisites

<Steps>
  <Step title="Create Monieswitch Account">
    **A Monieswitch account**. Register at [Monieswitch
    Dashboard](https://dashboard.monieswitch.com/register).
  </Step>

  <Step title="Obtain API Key">
    **API Key** from your Monieswitch dashboard.
  </Step>

  <Step title="Set Up Backend Server">
    **A backend server** to securely manage subscriptions and webhooks.
  </Step>
</Steps>

***

## 1. Create a Recurring Payment Plan

Send a request to create a subscription plan:

```json theme={"system"}
POST https://nini.monieswitch.com/api/subscription/plans
Headers:
  Authorization: Bearer YOUR_API_KEY
  Content-Type: application/json

Body:
{
  "name": "Pro Plan",
  "amount": 10000,
  "interval": "monthly", // or "weekly", "yearly"
  "currency": "NGN",
  "description": "Access to premium features"
}
```

***

## 2. Subscribe a Customer to a Plan

Once you have a plan, subscribe a customer:

```json theme={"system"}
POST https://nini.monieswitch.com/api/subscription/subscribe
Headers:
  Authorization: Bearer YOUR_API_KEY
  Content-Type: application/json

Body:
{
  "planId": "YOUR_PLAN_ID",
  "customer": {
    "email": "customer@example.com"
  },
  "startDate": "2024-09-01"
}
```

***

## 3. Managing Subscriptions

* **List Subscriptions:**
  `GET /api/subscription/list`
* **Cancel Subscription:**
  `POST /api/subscription/cancel`
  Body: `{ "subscriptionId": "SUBSCRIPTION_ID" }`

***

## 4. Handling Webhooks

<Callout type="info" title="Tip">
  Set up webhooks to receive real-time notifications for successful payments,
  failed renewals, and cancellations.
</Callout>

* Configure your webhook endpoint in the Monieswitch dashboard.
* Handle events like `subscription.payment_success`, `subscription.payment_failed`, and `subscription.cancelled`.

***

## 5. Best Practices

* Always verify webhook signatures for security.
* Notify customers on successful or failed payments.
* Allow customers to manage their subscriptions from your dashboard.

***

<Callout type="success" title="Need Help?">
  Visit our [Support](/help/support) page or join the [Monieswitch
  Community](https://slack.com)
</Callout>
