Skip to main content

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
  • must
  • send

    Include the token in the Authorization header forwith everythe request.format:

    Example Authentication Header:

    Authorization: Bearer YOUR_ACCESS_TOKEN
    
  • If the token is missing or invalid, the API will returnreturns a 401 Unauthorized response. ([docs.frontpayment.no][1])

    The

    You

    mustredirect
    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

    Request Payload

    :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 "Luramyrveienor 65",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:

    FieldTypeDescription
    products.*.namestringRequired. Name of the product.
    Response Structureproducts.*.productId :string Optional. Unique identifier for the product.
    products.*.quantitynumericRequired. Quantity of the product.
    products.*.ratenumericRequired. Rate per unit of the product.
    products.*.discountnumericOptional. Discount applied to the product.
    products.*.taxnumericRequired. Tax rate (e.g., 0, 12, 15, 25). Unless you have other configuration.
    products.*.amountnumericRequired. Total amount for the product line item.
    billingFrequencystringRequired Defines how often the billing occurs (e.g., daily, weekly, monthly)
    numberOfRepeatsnumericRequiredSpecifies how many times the billing cycle should be repeated.
    orderSummary.subTotalnumericRequired. Subtotal of all products before tax and discount.
    orderSummary.totalTaxnumericRequired. Total tax for the order.
    orderSummary.totalDiscountnumericRequired. Total discount for the order.
    orderSummary.grandTotalnumericRequired. Grand total of the order.
    orderSummary.payablePerCyclenumericRequiredAmount to be paid by the customer for each billing cycle.
    subscriptionStartDatestringRequired The date when the subscription becomes active.
    subscriptionEndsDatestringRequired The end date of subscription
    dueDateForPaymentLinkstringRequired. Unix timestamp for the due date of the payment link.
    sendOrderBy.smsbooleanRequired If the payment link should send via sms
    sendOrderBy.emailbooleanRequired If the payment link should send via email
    customerDetails.typestringRequired. Customer type must be either private or corporate.
    customerDetails.countryCodestringRequired. Country code for the customer's phone number (e.g., "+47")
    customerDetails.msisdnstringRequired. Mobile Subscriber ISDN Number (phone number).
    customerDetails.emailemailRequired. Customer's email address.
    customerDetails.namestringRequired. Customer's full name.
    customerDetails.personalNumberstringOptional Customer's personal identification number, must be 11 characters
    customerDetails.organizationIdstringRequired if customerDetails.type is corporate. Must be number

    Responses

    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"
        }
    }
    Example 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
      }
    }
    

    the customer to paymentLink to finalize the subscription. ([docs.frontpayment.no][1])

    Error Responses

    • 401 Unauthorized: Missing or invalid Bearer token.
    • Other validation errors will return appropriate HTTP error codes (e.g., 400 Bad Request) along with error messages specifying the invalid or missing fields.