Update a Subscription
Localpayment enables you to modify existing subscriptions to accommodate changes in customer needs, such as upgrading or downgrading plans, updating billing information, or changing subscription frequencies. This guide details the process for updating a subscription through Localpayment's API.
Before You Begin
Ensure you have:
Step 1: Update a Subscription
To modify an existing subscription, send a PATCH request to the Update a Subscription endpoint.
Key Request Parameters
The request requires several key parameters:
| Parameter | Description |
|---|---|
amount | New subscription amount |
card | Card object with updated payment details |
autoRecurring | Billing frequency and repetition settings |
discount | Discount configuration to apply to subscription |
retry | Payment retry configuration for failed charges |
dateToUpdate | Specific date when changes should take effect |
suspension | Subscription suspension settings |
status | Subscription status change (e.g., pause/resume) |
Example Request
Below is an example using curl:
curl --request PATCH \
--url https://api.stage.localpayment.com/api/payin/subscriptions/{externalId} \
--header 'Authorization: Bearer <your_access_token>' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"dateToUpdate": "2025-10-28",
"amount": 1600.00,
"autoRecurring": {
"repetitions": "2",
"type": "hour",
},
"retry": {
"repetitions": 2,
"intervalUnit": "day",
"intervalValue": 1
}
}
'
See all available parameters in the request.
Step 2: Handle the Response
Successful Response
A successful update returns the modified subscription details:
{
"externalId": "564b161a-76ba-4a84-b5cf-583f2df8c377",
"internalId": "52425bbd-b68b-4abc-9480-5ae88d53adb3",
"status": {
"code": "107",
"description": "APPROVED",
"detail": "Update subscription success"
},
"errors": []
}Key Response Fields
| Parameter | Description | Use Case |
|---|---|---|
status.code | Current subscription status code. | Status monitoring. |
Error Response
When a request fails, you'll receive detailed error information:
{
"status": {
"code": "400",
"description": "ERROR",
"detail": "Invalid operation"
}
}Step 3: Track Transaction Status
After updating a subscription, monitor its status through these methods:
Webhooks (Recommended)
Receive real-time notifications when transaction status changes. Most efficient for production environments.
Status API Endpoint
Query transaction status programmatically. Useful for polling or recovering lost webhook notifications.
Dashboard View
Visual interface for monitoring transactions. Great for manual oversight and detailed transaction analysis.
Common Status Codes
The Localpayment API provides various status codes to indicate the progress and outcome of the payment in the response.
| Code | Status | Description |
|---|---|---|
107 | APPROVED | Update was approved and applied. |
400 | ERROR | Subscription update was rejected. |
Note: For complete status code reference, see the Transaction Status documentation.
Testing Your Integration
Test Scenarios
Verify your integration handles these scenarios:
- Successful Plan Upgrade: Increasing subscription tier or amount.
- Successful Plan Downgrade: Decreasing subscription tier or amount.
- Payment Method Update: Changing card details.
- Customer Information Update: Modifying customer details.
- Validation Errors: Invalid amounts, missing required fields.
- Status Updates: Webhook handling and status polling
Next Steps
After updating a subscription, you may need to perform additional actions:
Updated about 11 hours ago
