Create Order

Create Order

An order is always created against the terminal$id obtained after terminal registration. This includes line items with their respective prices and serves as the initial step for initiating a payment, forming the basis of the payment flow. Each payment attempt must be linked to an order using its orderId, which is essential for efficient transaction processing.

Prerequisites

API Credentials

API-KEY, API-SECRET, and MERCHANT-ID required for API access

Terminal ID

terminal$id of the registered terminal obtained via Register Terminal API

Create an Order

1

Make POST Request

Make a POST request to the Create New Order API with the essential details:

  • terminal$id: ID of the registered terminal for creating the order
  • type: Specify the order type as "purchase"
  • orderLines: List the products in the order, including product ID, product name, and quantity
2

Receive Order ID

The request will return an Order ID, a unique identifier for the created order. This Order ID is required for:

  • Initiating payment
  • Checking order status
  • Processing returns and refunds
3

Initiate Payment

You can initiate a payment using any supported/active method, and once successful, the status will be updated to PAYMENT_COMPLETED.

Example Request

$curl -X POST \
> -d '{
> "terminal$id": "a1b2c3d4e5f6g7h8i9",
> "type": "purchase",
> "referenceId": "POS-RECEIPT-001",
> "orderLines": [
> {
> "id": "ITEM-001",
> "name": "Product Name",
> "quantity": 2,
> "amount": {
> "regular": 15000,
> "total": 30000,
> "currency": "578",
> "tax": [
> {
> "amount": 6000,
> "percentage": 25,
> "type": "vat"
> }
> ]
> }
> }
> ],
> "totalOrderAmount": {
> "regular": 30000,
> "total": 30000,
> "currency": "578",
> "tax": [
> {
> "amount": 6000,
> "percentage": 25,
> "type": "vat"
> }
> ]
> }
> }' \
> -H 'Content-Type: application/json' \
> -H 'API-KEY: your-api-key' \
> -H 'API-SECRET: your-api-secret' \
> -H 'MERCHANT-ID: your-merchant-id' \
> 'https://api.sagapay.no/orders'

Example Response

1{
2 "status": "SUCCESS",
3 "data": {
4 "orderId": "834bf5f923fa88090b",
5 "orderStatus": "PENDING",
6 "createdAt": "2026-01-24T10:30:00.000Z"
7 },
8 "message": "Order created successfully"
9}

Order Parameters Reference

Terminal & Order Identification

ParameterTypeRequiredDescription
terminal$idstringRequiredUnique identifier of the terminal used for processing payments
typestringRequiredOrder type: "purchase" for buying goods/services, "return" for returning previously purchased products
datestringOptionalDate of the order created
referenceIdstringRequiredExternal identification for reference of the created order
purchaseOrderIdstringConditionalMandatory for return orders - links to original purchase

Company Purchase Details

ParameterTypeRequiredDescription
companyPurchasebooleanOptionalSet to true when purchases are made on behalf of an organization
companyobjectOptionalCompany information for the order
company.idstringRequiredID of the company purchased for
company.vatIdstringOptionalVAT ID of the company
company.poDetailsstringRequiredAdditional purchase order details

Customer Information

ParameterTypeRequiredDescription
customerobjectOptionalAll relevant customer details
customer.personobjectOptionalPersonal details of the customer
customer.person.idstringRequiredCustomer’s ID
customer.person.name.firstNamestringOptionalFirst name
customer.person.name.middleNamestringOptionalMiddle name
customer.person.name.lastNamestringOptionalLast name
customer.person.emailstringOptionalCustomer’s email
customer.person.phoneNumber.codenumberRequiredInternational dialing code
customer.person.phoneNumber.numberstringRequiredPhone number (5-15 digits)
customer.person.birthDatestringOptionalDate of birth (YYYY-MM-DD)
customer.person.nationalIdstringOptionalGovernment-issued unique identifier
customer.person.nationalIdTypestringOptionalType of national ID
customer.person.countryResidencestringOptionalCountry of residence (ISO 2-letter code)

Billing Details

ParameterTypeRequiredDescription
customer.billingobjectOptionalCustomer’s billing address
customer.billing.careOfstringOptionalC/O name for correspondence
customer.billing.address1stringRequiredAddress line 1
customer.billing.address2stringOptionalAddress line 2
customer.billing.address3stringOptionalAddress line 3
customer.billing.citystringRequiredCity
customer.billing.postalCodestringRequiredPostal code
customer.billing.countrystringRequiredCountry (ISO 2-letter code)

Shipping Details

ParameterTypeRequiredDescription
shippingobjectOptionalShipping address details
shipping.name.firstNamestringRequiredRecipient’s first name
shipping.name.middleNamestringOptionalRecipient’s middle name
shipping.name.lastNamestringRequiredRecipient’s last name
shipping.emailstringRequiredRecipient’s email
shipping.phoneNumber.codenumberRequiredInternational dialing code
shipping.phoneNumber.numberstringRequiredPhone number (5-15 digits)
shipping.careOfstringOptionalC/O name
shipping.address1stringRequiredShipping address line 1
shipping.address2stringOptionalShipping address line 2
shipping.address3stringOptionalShipping address line 3
shipping.citystringRequiredDelivery city
shipping.postalCodestringRequiredPostal code
shipping.countrystringRequiredCountry (ISO 2-letter code)

Order Line Items

ParameterTypeRequiredDescription
orderLinesarrayRequiredCollection of items in the order
orderLines[].idstringRequiredItem ID
orderLines[].categoryIdstringOptionalCategory ID for item organization
orderLines[].namestringRequiredName of the item
orderLines[].descriptionstringOptionalDescription of the item
orderLines[].quantitynumberRequiredQuantity of the item
orderLines[].gtinstringOptionalGlobal Trade Item Number (14 digits)
orderLines[].imageUrlstringOptionalImage URL of the item
orderLines[].brandstringOptionalBrand of the item
orderLines[].unitstringOptionalMetric unit (see supported units below)

Supported Units: m, mm, cm, km, in, ft, mi, kg, g, mg, lb, oz, l, ml, cu. m, gal, pt, fl oz, W, kW, kWh, sq m, sq km, sq ft, h, min, s, days, wk, mn, yr, nos

Item Amount

ParameterTypeRequiredDescription
orderLines[].amountobjectRequiredPrice details of the item
orderLines[].amount.regularnumberRequiredRegular price (minor units)
orderLines[].amount.campaignnumberOptionalCampaign/discount price
orderLines[].amount.shippingnumberOptionalShipping price
orderLines[].amount.totalnumberRequiredTotal payable amount
orderLines[].amount.currencystringRequiredCurrency (ISO 4217 numeric code, e.g., "578" for NOK)
orderLines[].amount.taxarrayRequiredTax details array
orderLines[].amount.tax[].amountnumberRequiredTax amount
orderLines[].amount.tax[].percentagenumberRequiredTax percentage
orderLines[].amount.tax[].typestringRequiredTax type (currently "vat")
Amount Calculation
  • If orderLineLevelCalculation is TRUE: total = (regular × quantity) - campaign + shipping
  • If orderLineLevelCalculation is FALSE: total = regular - campaign + shipping

Campaign Details

ParameterTypeRequiredDescription
orderLines[].campaignobjectOptionalCampaign details
orderLines[].campaign.externalCampaignbooleanRequiredWhether it’s an external campaign
orderLines[].campaign.idstringOptionalCampaign ID
orderLines[].campaign.namestringRequiredCampaign name

Total Order Amount

ParameterTypeRequiredDescription
totalOrderAmountobjectOptionalTotal breakdown of the order
totalOrderAmount.regularnumberRequiredSum of all item regular prices
totalOrderAmount.campaignnumberOptionalTotal campaign discount
totalOrderAmount.shippingnumberOptionalTotal shipping cost
totalOrderAmount.totalnumberRequiredTotal payable for the order
totalOrderAmount.currencystringRequiredCurrency (ISO 4217 numeric code)
totalOrderAmount.taxarrayRequiredOrder-level tax details

Adjustments & Metadata

ParameterTypeRequiredDescription
adjustmentsarrayOptionalAdd or deduct from total (e.g., Tips, Charity, Gift cards)
adjustments[].typestringRequiredAdjustment type
adjustments[].valuestringRequiredAdjustment value
metaDataobjectOptionalAdditional data in key-value pairs

Total order amount = regular + shipping - campaign + adjustments


Control Functions

Control functions allow you to customize the order processing behavior.

Order Management Controls

ParameterTypeRequiredDescription
controlFunctions.cancelPreviousPendingOrderbooleanOptionalSet true to cancel all previous pending orders
controlFunctions.orderLineLevelCalculationbooleanOptionalSet true to apply campaign/shipping at row level
controlFunctions.includeAdjustmentsbooleanOptionalFor returns: include adjustments in refund (default: true)

Payment Processing Options

ParameterTypeRequiredDescription
controlFunctions.payButtonTypestringOptionalCustomize payment button text. Values: ADD_MONEY, BOOK, BUY, CHECKOUT, CONTINUE, DONATE, ORDER, PAY, RENT, SUBSCRIBE, SUPPORT, TIP, TOP_UP
controlFunctions.lockToPaymentMethodsarrayOptionalLock to specific methods: CARD, SSWISH
controlFunctions.delayCapturebooleanOptionalAllows capture at a later date
controlFunctions.delayPayoutstringOptionalDelay payout (format: "7m" for 7 minutes)
controlFunctions.authModestringOptionalPRE-AUTH or AUTH (default). PRE-AUTH sets delayCapture to true

Notification and Error Handling

ParameterTypeRequiredDescription
controlFunctions.callBackUrlstringOptionalDynamic webhook URL for order-related callbacks
controlFunctions.throwErrorIfTerminalInactiveFornumberOptionalError if terminal inactive for X seconds

Terminal Interaction (NFC)

ParameterTypeRequiredDescription
readTagsstringOptionalNFC reading mode: NONE, SINGLE, MULTIPLE_EDITABLE, MULTIPLE_NONEDITABLE

Online Payment Settings

ParameterTypeRequiredDescription
online.enforceTokenizationbooleanOptionalTokenize card for future transactions
online.paymentPageValidForstringOptionalPayment page validity (format: "30m")
online.redirectUrlstringOptionalRedirect URL after transaction (orderId added as query param)
online.failureRedirectUrlstringOptionalRedirect URL for failed transactions
online.generateShortLinkbooleanOptionalGenerate short URL for payment page

Recurring Payments

ParameterTypeRequiredDescription
recurring.subscriptionAmountTypestringRequired"fixed" or "variable"
recurring.maxAmountnumberOptionalMax amount for variable subscriptions (minor units)
recurring.frequencystringConditionalRequired for subscriptions: daily, twiceWeekly, weekly, tenDays, fortNightly, monthly, everyTwoMonths, trimester, quarterly, twiceYearly, annually, unscheduled
recurring.numberOfPaymentsnumberOptionalExpected total payment count
recurring.uniqueReferencestringOptionalUnique reference for recurring order

If merchants need to make changes to an existing order before initiating payments, they can update the order using the Update Order API. However, merchants cannot update the order after initiating a payment.


Initiate a Payment

Once you create an order, you can initiate payments through a checkout system or registered payment terminal. Each payment attempt is linked to the created order using the orderId.

Prerequisites

API Credentials

API-KEY, API-SECRET, and MERCHANT-ID

Order ID

orderId received from the Create Order response

Initiate Payment

1

Make Payment Request

Make a request with the orderId to the Initiate Payment API endpoint. Specify the paymentMethod:

Payment MethodDescription
CARDCard present payment (default)
CARD_NPCard not present (for refunds)
KLARNAKlarna payment
SWISHSwish payment
2

Receive Payment ID

After successful initiation, a unique paymentId will be generated. Store this securely for:

  • Tracking payment status
  • Processing refunds
  • Other payment-related actions

Example Request

$curl -X POST \
> -d '{
> "orderId": "834bf5f923fa88090b",
> "paymentMethod": "CARD"
> }' \
> -H 'Content-Type: application/json' \
> -H 'API-KEY: your-api-key' \
> -H 'API-SECRET: your-api-secret' \
> -H 'MERCHANT-ID: your-merchant-id' \
> 'https://api.sagapay.no/payments'

Example Response

1{
2 "status": "SUCCESS",
3 "data": {
4 "paymentId": "pay_x1y2z3a4b5c6",
5 "orderId": "834bf5f923fa88090b",
6 "paymentStatus": "INITIATED",
7 "paymentMethod": "CARD"
8 },
9 "message": "Payment initiated successfully"
10}

To enable partial payments, specify the desired payment amount in the smallest currency unit within the amount parameter.


Fetch Order Status

Tracking the order status is crucial for ensuring smooth payment processing and addressing any errors or issues that could impact the payment completion.

Prerequisites

API Credentials

API-KEY, API-SECRET, and MERCHANT-ID

Order ID

orderId received from the Create Order response

Fetch Status

1

Make Status Request

Include the orderId in the Fetch Order Status API request.

2

Check Order Status

The response will include one of the following statuses:

StatusDescription
PENDINGOrder created, awaiting payment processing
PAYMENT_COMPLETEDPayments fully completed
PAYMENT_CANCELLEDPayment attempt cancelled
PARTIAL_PAYMENT_COMPLETEDPayment partially completed
3

Get Payment IDs

If status is PAYMENT_COMPLETED, the response includes an array of payment IDs.

Example Request

$curl -X GET \
> -H 'Content-Type: application/json' \
> -H 'API-KEY: your-api-key' \
> -H 'API-SECRET: your-api-secret' \
> -H 'MERCHANT-ID: your-merchant-id' \
> 'https://api.sagapay.no/orders/834bf5f923fa88090b/status'

Example Response

1{
2 "status": "SUCCESS",
3 "data": {
4 "orderId": "834bf5f923fa88090b",
5 "orderStatus": "PAYMENT_COMPLETED",
6 "payments": [
7 {
8 "paymentId": "pay_x1y2z3a4b5c6",
9 "paymentStatus": "SUCCESS",
10 "paymentMethod": "CARD",
11 "amount": 30000
12 }
13 ],
14 "completedAt": "2026-01-24T10:35:00.000Z"
15 },
16 "message": "Order status retrieved successfully"
17}

You can also get order status updates by integrating webhooks, which provide real-time updates on payment events directly, eliminating the need for frequent polling.

Next Steps

After the order is completed, merchants can: