Skip to main content

Create Subscription

Use the following endpoint and payload to create a new subscription. After getting a successful response you need to redirect to the given payment link which is given in response payload.

Authentication

This endpoint requires authentication using a Bearer Token. The client must send the token in the Authorization header for every request.

Example Authentication Header:

Authorization: Bearer YOUR_ACCESS_TOKEN

If the token is missing or invalid, the API will return a 401 Unauthorized response.

Endpoint : https://demo-api.frontpayment.no/api/v1/connect/subscription/submit
Method : POST
Authorization : Bearer
Payload Validations :
'products.*.name' => 'required|string',
'products.*.productId' => 'nullable|string',
'products.*.quantity' => 'required|numeric',
'products.*.rate' => 'required|numeric',
'products.*.discount' => 'nullable|numeric',
'products.*.tax' => 'required|numeric',
'products.*.amount' => 'required|numeric',
'billingFrequency' => 'required|string', //(eg: monthly, weekly, daily)
'numberOfRepeats' => 'required|numeric',
'orderSummary.subTotal' => 'required|numeric',
'orderSummary.totalTax' => 'required|numeric',
'orderSummary.totalDiscount' => 'required|numeric',
'orderSummary.grandTotal' => 'required|numeric',
'orderSummary.initialCycleAmount' => 'nullable|numeric',
'orderSummary.payablePerCycle' => 'required|numeric',
'subscriptionStartDate' => 'required|string',
'subscriptionEndsDate' => 'required|string',
'dueDateForPaymentLink' => 'required|string',
'sendOrderBy.sms' => 'required|boolean',
'sendOrderBy.email' => 'required|boolean',
'customerDetails.type' => 'required|nullable|string',
'customerDetails.countryCode' => 'required|nullable|string',
'customerDetails.msisdn' => 'required|nullable|string',
'customerDetails.email' => 'required|nullable|email',
'customerDetails.name' => 'required|string',
'customerDetails.personalNumber' => 'nullable|string|max:11',
'customerDetails.organizationId' => 'required_if:customerDetails.type,corporate|nullable|string|regex:/^[a-zA-Z0-9]+$/',
'customerDetails.preferredLanguage' => 'required|string',
'customerDetails.address' => 'required|array',
'customerDetails.address.street' => 'required|string',
'customerDetails.address.zip' => 'required|string',
'customerDetails.address.city' => 'required|string',
'customerDetails.address.country' => 'required|string',
'customerNotes' => 'nullable|string',
'termsAndConditions' => 'nullable|string'

Example Payload :
{
    "products": {
        "0": {
            "name": "product 3",
            "productId": null,
            "quantity": "1",
            "rate": "2000",
            "discount": 0,
            "tax": "0",
            "amount": 2000
        }
    },
    "orderSummary": {
        "subTotal": "2000.00",
        "totalTax": "0.00",
        "totalDiscount": "0.00",
        "grandTotal": "2000.00",
        "initialCycleAmount": "500.00",
        "payablePerCycle":"2000.00"
    },
    "billingFrequency":"month",
    "numberOfRepeats":12,
    "subscriptionStartDate": "21 Feb, 2023",
    "subscriptionEndsDate": "21 Feb, 2024",
    "dueDateForPaymentLink": "1677047770.652",
    "sendOrderBy": {
        "sms": false,
        "email": true
    },
    "customerDetails": {
        "customerUuid": "CSRT3798554634",
        "type": "private",
        "countryCode": "+47",
        "msisdn": "46567468",
        "email": "[email protected]",
        "name": "Kari Nordmann",
        "personalNumber": null,
        "organizationId": "925710482",
        "preferredLanguage": "no",
        "address": {
            "street": "Luramyrveien 65",
            "zip": "4313",
            "city": "Sandnes",
            "country": "Norway"
        }
    },
    "customerNotes":"test",
    "termsAndConditions":"terms and conditions",
    "submitPayment": {
        "currency": "NOK"
    }
}

Response Structure :  
{
    "status_code": 201,
    "status_message": "OK",
    "message": "subscriptionRequestSuccessfullyHandled",
    "is_data": Boolean,
    "data": {
        "subscriptionUuid": "String",
         "orderUuid": "String",
         "customerUuid":"String",
        "checkoutUrl": "String"
    }
}
Example Response :
{
    "status_code": 201,
    "status_message": "OK",
    "message": "subscriptionRequestSuccessfullyHandled",
    "is_data": true,
    "data": {
         "subscriptionUuid": "SUB1812030514",
         "orderUuid": "ODR3798113293",
         "customerUuid": "CSRT3820359602",
         "checkoutUrl": "https://demo-api.frontpayment.no/subscription/payment/details/SUB1812030514"
    }
}