Create Session For Subscription Payment
Use this API endpoint to create a new subscription using the checkout modality. Upon a successful request, you'll receive a paymentUrl
that your application must redirect the customer to in order to complete the subscription setup.
Endpoint
- URL:
https://demo-api.frontpayment.no/api/v1/connect/subscription/create
([docs.frontpayment.no][2]) - Method:
POST
Authentication
Requires Bearer Token authentication. Include the token in the Authorization
header:
Authorization: Bearer YOUR_ACCESS_TOKEN
If the token is missing or invalid, the API returns a 401 Unauthorized
response. ([docs.frontpayment.no][1])
Request Payload
The body must be JSON and include fields such as products, billing schedule, customer details, callback URLs, etc. Here's a condensed example:
{
"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",
"payablePerCycle": "2000.00"
},
"billingFrequency": "month",
"numberOfRepeats": 12,
"subscriptionStartDate": "21 Feb, 2023",
"subscriptionEndsDate": "21 Feb, 2024",
"dueDateForPaymentLink": "1677047770.652",
"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": {
"via": "visa",
"currency": "NOK"
},
"callback": {
"success": "https://demo.frontpayment.no/?order_identifier=...&order_status=success",
"failure": "https://demo.frontpayment.no/?order_identifier=...&order_status=failed"
}
}
([docs.frontpayment.no][1])
Validation Rules
Below are the validation constraints for each field:
Field | Type | Description |
---|---|---|
products.*.name | string | Required |
products.*.productId | string | Optional, max length 25 |
products.*.quantity | numeric | Required |
products.*.rate | numeric | Required |
products.*.discount | numeric | Optional |
products.*.tax | numeric | Required |
products.*.amount | numeric | Required |
billingFrequency | string | Required (e.g., monthly, weekly, daily) |
numberOfRepeats | numeric | Required |
orderSummary.subTotal | numeric | Required |
orderSummary.totalTax | numeric | Required |
orderSummary.totalDiscount | numeric | Required |
orderSummary.grandTotal | numeric | Required |
orderSummary.payablePerCycle | numeric | Required |
subscriptionStartDate | string | Required |
subscriptionEndsDate | string | Required |
dueDateForPaymentLink | string | Required |
customerDetails.type | string | Required (nullable) |
customerDetails.countryCode | string | Required (nullable) |
customerDetails.msisdn | string | Required (nullable) |
customerDetails.email | email | Required (nullable) |
customerDetails.name | string | Required |
customerDetails.personalNumber | string | Optional, Customer's personal identification number, must be 11 characters. |
customerDetails.organizationId | string | Required if type=corporate, Optional, regex /^[a-zA-Z0-9]+$/ |
customerDetails.preferredLanguage | string | Required |
customerDetails.address | array | Required |
customerDetails.address.street | string | Required |
customerDetails.address.zip | string | Required |
customerDetails.address.city | string | Required |
customerDetails.address.country | string | Required, ISO Alpha-2 country code |
customerNotes | string | Optional |
termsAndConditions | string | Optional |
submitPayment.currency | string | Required |
submitPayment.via | string | Optional |
settings | array | Optional |
settings.secureDetails | boolean | Optional |
callback.success | url | Required |
callback.failure | url | Required |
Response
Success
Returns HTTP status 201
with a payload like:
{
"status_code": 201,
"status_message": "OK",
"message": "subscriptionRequestSuccessfullyHandled",
"is_data": true,
"data": {
"subscriptionUuid": "SUB1812030514",
"orderUuid": "ODR3798113293",
"customerUuid": "CSRT3820359602",
"paymentUrl": "https://..."
}
}
([docs.frontpayment.no][1])
Error Responses
-
510 Execution Exception – Internal processing error:
{ "status_code": 510, "status_message": "Execution Exception Occurred", "message": "Internal Error Occurred Please Try Again Later", "is_error": true, "errors": [...] }
-
500 Internal Dependency Error – Critical failure in dependency:
{ "status_code": 500, "status_message": "Internal Dependency Error", "message": "Internal Error Occurred Please Try Again Later", "is_error": true, "errors": [ { "happenedAt": "String", "internalErrorDetails": "String" } ] }