Create a Subscription Plan

Localpayment enables you to create fixed subscription plans for standardized recurring billing scenarios. This guide details how to set up subscription plans through Localpayment's API, which can then be associated with customer subscriptions for consistent, automated billing.

Before You Begin

Ensure you have:


Step 1: Create a Subscription Plan

To create a new subscription plan, send a POST request to the Create Subscription Plan endpoint.

Key Request Parameters

The request requires several key objects:

ParameterDescriptionRequired
nameDescriptive name for the subscription plan
descriptionDetailed explanation of plan features and benefits
countryCountry code where the plan will be available
amountFixed billing amount
currencyCurrency code for billing
accountNumberYour merchant account number
autoRecurring.repetitionsNumber of billing cycles (use 0 for recurrence on demand)
autoRecurring.typeBilling frequency unit (use customfor recurrence on demand)

Supported Billing Frequencies

Daily

Bill customers every day. Ideal for services with daily usage or short-term subscriptions.

Send theautoRecurring.type property with value: day

Monthly

Monthly recurring billing for most SaaS products, membership services, and subscription boxes.

Send theautoRecurring.type property with value: month

Custom (On-demand)

On-demand billing for variable usage scenarios. Perfect for pay-as-you-go or usage-based services.

Send theautoRecurring.type property with value: custom

Example Request

Below is an example using curl:

curl --request POST \
  --url https://api.stage.localpayment.com/api/subscriptions/plan \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <your_access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Plan Básico Mensual",
    "description": "Acceso básico a contenido exclusivo",
    "country": "MEX",
    "amount": 50,
    "currency": "MXN",
    "accountNumber": "{{accountNumber}}",
    "autoRecurring": {
      "repetitions": 1,
      "type": "hour"
    }
  }'

See all available parameters in the request.


Step 2: Handle the Response

Successful Response

A successfully created subscription plan returns complete plan details:

{
    "internalId": "70af52e2-ea99-46a8-a931-65f15f6a3c20",
    "name": "Plan Básico Mensual",
    "description": "Acceso básico a contenido exclusivo",
    "amount": 50,
    "country": "MEX",
    "currency": "MXN",
    "accountNumber": "{{accountNumber}}",
    "autoRecurring": {
        "repetitions": 1,
        "type": "hour"
    },
    "status": {
        "code": "100",
        "description": "ACTIVE",
        "detail": "Subscription plan is active"
    }
}

Key Response Fields

ParameterDescriptionUse Case
internalIdLocalpayment's unique plan identifier.Use as planId when creating subscriptions
status.codeCurrent plan status code.Status monitoring.
autoRecurring.typeConfirmed billing frequency.Billing cycle verification.
autoRecurring.repetitionsConfirmed number of billing cycles.Plan duration tracking.

Error Response

When subscription plan creation fails, you'll receive detailed error information:

{
    "status": {
        "code": "400",
        "description": "REJECTED",
        "detail": "autoRecurring.type is required"
    }
}

Step 3: Track Transaction Status

After creating a subscription plan, monitor its status through these methods:

Common Status Codes

CodeStatusDescription
100ACTIVEPlan is active and available for subscription associations.
400REJECTEDPlan creation failed due to validation errors or invalid parameters.
📝

Note: For complete status code reference, see the Transaction Status documentation.


Testing Your Integration

Test Scenarios

Verify your integration handles these scenarios:


  1. Successful Plan Creation: Standard plan creation with valid parameters.
  2. Tiered Pricing Structure: Creating multiple plans at different price points.
  3. Various Billing Frequencies: Testing daily, monthly, and custom on-demand plans.
  4. Validation Errors: Missing required fields, invalid amounts, unsupported countries.
  5. Subscription Association: Testing that plans can be successfully linked to subscriptions

Next Steps

After creating a subscription plan, you may need to perform additional actions::