Create a Subscription

Localpayment enables merchants to set up recurring payment subscriptions using credit and debit cards, supporting both fixed plans and custom billing scenarios across multiple countries. This guide outlines the process for creating a subscription through Localpayment's API, detailing required parameters, handling responses, and interpreting status codes.

Before You Begin

Ensure you have:


Step 1: Create a Subscription

To create a new subscription, you'll need to send a POST request to the Create a Subscription endpoint.

Key Request Parameters

The request requires several key parameters depending on whether you're creating a fixed plan subscription or a custom subscription:

ParameterDescriptionRequired
externalIdYour unique reference for the subscription
merchantMerchant/business details
countryCountry code where the subscription will be processed
currencyCurrency code for the subscription
paymentMethodPayment method configuration
planIdID of a predefined subscription plan (for fixed plans)
autoRecurringBilling frequency (required for scheduled subscriptions)Conditional
amountSubscription amount (required if no planId)Conditional

Subscription Types

  • Fixed Plan Subscription: Use when you have predefined subscription plans created via the Create Subscription Plan endpoint.
  • Custom Subscription: Use for variable billing scenarios where each payment may differ in amount or timing.

Example Request

Below is an example using curl:

curl --request POST \
     --url https://api.stage.localpayment.com/api/payin/subscriptions \
     --header 'Authorization: Bearer <your_access_token>' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
    "paymentMethod": {
        "type": "CreditCard",
        "code": "1900",
        "flow": "DIRECT"
    },
    "externalId": "1fe38b94-7e11-44c1-9a88-b4aa9fbe5b4a",
    "country": "COL",
    "amount": 10000.00,
    "currency": "COP",
    "accountNumber": "170.170.00000004",
    "conceptCode": "0001",
    "comment": "Test subscription",
    "merchant": {
        "type": "COMPANY",
        "name": "My Company SA DE CV",
        "document": {
            "type": "CC",
            "id": "717321230"
        }
    },
    "payer": {
        "type": "INDIVIDUAL",
        "name": "John",
        "lastname": "Doe",
        "document": {
            "id": "1073695321",
            "type": "CC"
        },
        "email": "[email protected]"
    },
    "card": {
        "name": "John Doe",
        "number": "4242424242424242",
        "cvv": "123",
        "expirationMonth": "11",
        "expirationYear": "2029",
        "installments": 1
    },
    "type": "SOFTWARE",
    "autoRecurring": {
        "repetitions": 1,
        "type": "day"
    }
}'
'

See all available parameters in the request.


Step 2: Handle the Response

Successful Response

A successful response includes detailed subscription information and identifiers:

{
    "type": "SOFTWARE",
    "externalId": "1fe38b94-7e11-44c1-9a88-b4aa9fbe5b4a",
    "internalId": "990017f0-7928-4c20-a149-0c1673035f2c",
    "country": "COL",
    "currency": "COP",
    "accountNumber": "170.170.00000004",
    "status": {
        "code": "105",
        "description": "WAITINGAUTH",
        "detail": "The subscription is active"
    },
    "date": {
        "creationDate": "2025-11-13T05:05:58.8502173",
        "nextPaymentDate": "2025-11-14T05:05:58.8502036"
    },
    "payments": [
        {
            "externalId": "36e1ce13-8a20-4565-b5f5-e275e1df0010",
            "internalId": "adccc452-4a8c-414c-b777-152f4b0ed2da",
            "status": {
                "code": "100",
                "description": "INPROGRESS",
                "detail": "The payin is pending the confirmation"
            },
            "redirectUrl": "https://web-checkout.stage.localpayment.com/redirect/aHR0cHM6Ly93ZWItY2hlY2tvdXQuc3RhZ2UubG9jYWxwYXltZW50LmNvbS92ZXJpZmljYXRpb24vMDA5Nz9pbnRlcm5hbElkPTQzYzVjZDE1LTg0N2UtNDRhNC05MTU1LTcyYmVmNjZiZDAzMw"
        }
    ],
    "errors": []
}

Key Response Fields

ParameterDescriptionUse Case
internalIdLocalpayment's unique subscription identifier.Subscription tracking and management.
status.codeCurrent subscription status code.Status monitoring and automation.
date.creationDateWhen the subscription was createdAudit trail and reporting.
date.nextPaymentDateWhen the next payment will be processed.Billing cycle management.
paymentsArray of payment objects for the subscription.Payment history and tracking.

Error Response

When a request fails, you'll receive detailed error information:

{
    "externalId": "b27ebf99-e92d-4aca-ba16-f9f8412372cd",
    "internalId": "f95883ce-f08a-485f-9734-0182ec3af70d",
    "country": "COL",
    "currency": "COP",
    "accountNumber": "170.170.00000004",
    "type": "SOFTWARE",
    "autoRecurring": {
        "repetitions": 1,
        "type": "day"
    },
    "status": {
        "code": "300",
        "description": "REJECTED"
    },
    "date": {
        "creationDate": "2025-11-13T05:07:42.7612531"
    },
    "payments": [
        {
            "externalId": "672022a9-b595-4d78-88d0-6ac8d6738082",
            "internalId": "8279db2d-2502-4c1f-8d3b-b668c8b5ff53",
            "status": {
                "code": "300",
                "description": "REJECTED"
            }
        }
    ],
    "errors": [
        {
            "code": "300",
            "detail": "Invalid param + [payer.email] + must not be null"
        }
    ]
}

Step 3: Track Transaction Status

After creating a subscription, monitor its lifecycle through these methods:

Common Status Codes

The Localpayment API provides various status codes to indicate the state of the subscription.

CodeStatusDescription
105ACTIVESubscription is active and in progress.
300REJECTEDSubscription creation or payment was rejected.
📝

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


Testing Your Integration

Test Scenarios

Verify your integration handles these scenarios:

  1. Successful Subscription Creation: Standard subscription flow with valid card.
  2. Fixed Plan Subscription: Subscription with predefined plan.
  3. Custom Subscription: Subscription with custom billing parameters.
  4. Validation Errors: Invalid card, missing required fields
  5. Status Updates: Webhook handling and status polling

Next Steps

After a subscription is created, you may need to perform additional actions, such as: