Update a Subscription Plan

Localpayment allows you to modify existing subscription plans to accommodate changes in your pricing strategy, billing cycles, or service offerings. This guide details how to update a subscription plan through Localpayment's API, ensuring existing subscriptions can continue under the new terms or according to your configured policies.

Before You Begin

Ensure you have:


Step 1: Update a Subscription Plan

To modify an existing subscription plan, send aPATCH request to the Update Subscription Plan endpoint.

Key Request Parameters

The request requires several key parameters:

ParameterDescriptionRequired
amountUpdated billing amount
autoRecurringUpdated configuration for automatic recurring billing
autoRecurring.repetitionsUpdated number of billing cycles (use 0 for recurrence on demand)
autoRecurring.typeUpdated billing frequency unit (use customfor recurrence on demand)

Supported Billing Frequencies

Daily

Update to daily billing. Ideal for services transitioning to daily usage patterns.

Send theautoRecurring.type property with value: day

Monthly

Update to monthly billing. Common for standardizing billing cycles across product lines.

Send theautoRecurring.type property with value: month

Custom (On-demand)

Update to on-demand billing. Suitable for moving to usage-based pricing models.

Send theautoRecurring.type property with value: custom

Example Request

Below is an example using curl:

curl --request PATCH \
  --url 'https://api.stage.localpayment.com/api/subscriptions/plan/{internalId}' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <your_access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "amount": 150,
    "autoRecurring": {
      "repetitions": 1,
      "type": "month"
    }
  }'

See all available parameters in the request.


Step 2: Handle the Response

Successful Response

A successfully updated subscription plan returns confirmation with the current status:

{
    "internalId": "106e9aff-96da-42e9-a9e1-4dee207e6073",
    "status": {
        "code": "100",
        "description": "ACTIVE",
        "detail": "Subscription plan was update"
    }
}

Key Response Fields

ParameterDescriptionUse Case
internalIdLocalpayment's unique plan identifier.Verify you've updated the correct plan.
status.codeCurrent plan status code.Confirm the plan remains active after updates.
status.descriptionHuman-readable status description.Display status in administrative interfaces.
status.detailDetailed status information.Confirm the update operation was successful.

Error Response

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

{
  "status": {
    "code": "400",
    "description": "REJECTED",
    "detail": "amount must be greater than or equal to 1"
  }
}

Step 3: Track Transaction Status

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

Common Status Codes

CodeStatusDescription
100ACTIVEPlan is active and available for subscription associations.
400REJECTEDPlan update 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 Amount Update: Modify plan pricing with valid amount values.
  2. Billing Frequency Change: Update from monthly to daily or custom billing.
  3. Partial Updates: Modify only specific fields without sending complete payload.
  4. Validation Errors: Test with invalid amounts, missing required fields, or unsupported frequencies.
  5. Nonexistent Plan: Attempt to update a plan that doesn't exist.
  6. Authentication Failures: Test with invalid or expired access tokens.

Next Steps

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