Create Subscription
Use thethis following endpoint and payloadAPI to create a new subscription. After getting a successful response you need to redirect torequest, the givenresponse will include a payment link whichthat isyou givenmust redirect your customer to in responseorder payload.to complete the subscription setup.
Endpoint
- URL:
https://demo-api.frontpayment.no/api/v1/connect/subscription/submit
- Method:
POST
([docs.frontpayment.no][1])
Authentication
-
This endpoint requires authentication using aUses Bearer Token.Theauthentication.client -
sendInclude the token in the
Authorization
headerforwitheverytherequest.format:Example Authentication Header: -
If the token is missing or invalid, the API
will returnreturns a401 Unauthorized
response. ([docs.frontpayment.no][1])
the customer toEndpoint:https://demo-api.frontpayment.no/api/v1/connect/subscription/submitMethod:POSTAuthorization:BearerPayload 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'ExampleRequest Payload
:The
request body should be a JSON object including the following elements: { "products":
{ "0":[ { "name": "product 3"string", "productId":null,"string or null", "quantity":"1",number, "rate":"2000",number, "discount":0,number (optional), "tax":"0",number, "amount":2000number }}], "billingFrequency": "string", "numberOfRepeats": number, "orderSummary": { "subTotal":"2000.00",number, "totalTax":"0.00",number, "totalDiscount":"0.00",number, "grandTotal":"2000.00", "initialCycleAmount": "500.00",number, "payablePerCycle":"2000.00"number },"billingFrequency":"month", "numberOfRepeats":12,"subscriptionStartDate": "21 Feb, 2023"string", "subscriptionEndsDate": "21 Feb, 2024"string", "dueDateForPaymentLink": "1677047770.652"string", "sendOrderBy": { "sms":false,boolean, "email":trueboolean }, "customerDetails": { "customerUuid": "CSRT3798554634", "type": "private"string or null", "countryCode": "+47"string or null", "msisdn": "46567468"string or null", "email": "[email protected]"string or null (must be email format)", "name": "Kari Nordmann"string", "personalNumber":null,"string or null", "organizationId": "925710482"string or null (when type=corporate)","preferredLanguage"://"no",(other"address":fields{like"street":preferredLanguage"Luramyrveienor65",address"zip":may"4313",apply"city":in"Sandnes",checkout"country":session—refer"Norway"to specific endpoints) } },"customerNotes":"test", "termsAndConditions":"terms and conditions", "submitPayment": { "currency": "NOK" } }Validation Rules
The following table outlines validation constraints for each field in the request payload:
Field Type Description products.*.name
string
Required. Name of the product. Response Structureproducts.*.productId
:string
Optional. Unique identifier for the product. products.*.quantity
numeric
Required. Quantity of the product. products.*.rate
numeric
Required. Rate per unit of the product. products.*.discount
numeric
Optional. Discount applied to the product. products.*.tax
numeric
Required. Tax rate (e.g., 0, 12, 15, 25). Unless you have other configuration. products.*.amount
numeric
Required. Total amount for the product line item. billingFrequency
string
Required Defines how often the billing occurs (e.g., daily, weekly, monthly) numberOfRepeats
numeric
RequiredSpecifies how many times the billing cycle should be repeated. orderSummary.subTotal
numeric
Required. Subtotal of all products before tax and discount. orderSummary.totalTax
numeric
Required. Total tax for the order. orderSummary.totalDiscount
numeric
Required. Total discount for the order. orderSummary.grandTotal
numeric
Required. Grand total of the order. orderSummary.payablePerCycle
numeric
RequiredAmount to be paid by the customer for each billing cycle. subscriptionStartDate
string
Required The date when the subscription becomes active. subscriptionEndsDate
string
Required The end date of subscription dueDateForPaymentLink
string
Required. Unix timestamp for the due date of the payment link. sendOrderBy.sms
boolean
Required If the payment link should send via sms sendOrderBy.email
boolean
Required If the payment link should send via email customerDetails.type
string
Required. Customer type must be either private
orcorporate
.customerDetails.countryCode
string
Required. Country code for the customer's phone number (e.g., "+47") customerDetails.msisdn
string
Required. Mobile Subscriber ISDN Number (phone number). customerDetails.email
email
Required. Customer's email address. customerDetails.name
string
Required. Customer's full name. customerDetails.personalNumber
string
Optional Customer's personal identification number, must be 11 characters customerDetails.organizationId
string
Required if customerDetails.type
iscorporate
. Must be numberResponses
Successful Response
On success, you’ll receive a JSON response containing the status and a payment link to redirect the user:
{ "status_code":
201,200, "status_message": "OK", "message": "subscriptionRequestSuccessfullyHandled", "is_data": Boolean, "data": { "subscriptionUuid": "String", "orderUuid": "String", "customerUuid":"String", "checkoutUrl": "String" } } must redirectExample Response:{ "status_code": 201, "status_message": "OK", "message": "subscriptionRequestSuccessfullyHandled"subscriptionCreatedSuccessfully", "is_data": true, "data": { "paymentLink": "https://…", "subscriptionUuid": "SUB1812030514"…", "orderUuid": "ODR3798113293"…","customerUuid": "CSRT3820359602", "checkoutUrl": "https://demo-api.frontpayment.no/subscription/payment/details/SUB1812030514"Possibly other metadata } }You
paymentLink
to finalize the subscription. ([docs.frontpayment.no][1])Error Responses