Skip to main content

Delivering orders

Deliver order​

Description

Call this endpoint to deliver an order.
The request body must contain a list of all order row IDs to be delivered.
To make a complete delivery, include all order rows IDs or set the row IDs array empty.
If the delivery doesn't contain any order rows, it will still count as complete.
To make a partial delivery, only include the order rows that are to be delivered.

Endpoint​

Method: POST
/api/v1/orders/{CheckoutOrderId}/deliveries

Sample Code​

Deliver Order Example
using Microsoft.Extensions.DependencyInjection;
using System.Text.Json;
using System.Text;

internal static class DeliverOrder
{
internal static async Task DeliverOrderAsync(long checkoutOrderId)
{
var services = new ServiceCollection();
services.AddHttpClient("MyApiClient", client =>
{
client.BaseAddress = new Uri("https://paymentadminapistage.svea.com/api/");
});

var serviceProvider = services.BuildServiceProvider();
var httpClientFactory = serviceProvider.GetRequiredService<IHttpClientFactory>();
var httpClient = httpClientFactory.CreateClient("MyApiClient");

var apiUrl = string.Format("v1/orders/{0}/deliveries", checkoutOrderId);
var orderRowIds = new int[] { 4 }; //Deliver Order with RowId - 4
var rowDeliveryOptions = new List<RowDeliveryOptions>
{
new RowDeliveryOptions{OrderRowId = 4, Quantity = 100} `//Deliver Order with RowId - 4, Quantity - 1 (100 in minor units)`
};

var deliveryRequest = new DeliveryRequest(orderRowIds, rowDeliveryOptions, 1, false);
var jsonString = JsonSerializer.Serialize(deliveryRequest);
var deliveryRequestJson = new StringContent(
jsonString,
Encoding.UTF8,
"application/json");

// Add authorization header
Authentication.CreateAuthenticationToken(out string token, out string timestamp, jsonString);
httpClient.DefaultRequestHeaders.Add("Authorization", token);
httpClient.DefaultRequestHeaders.Add("Timestamp", timestamp);

try
{
HttpResponseMessage response = await httpClient.PostAsync(apiUrl, deliveryRequestJson);

// Check if the request was successful
if (response.IsSuccessStatusCode)
{
string responseData = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response: " + responseData);
}
else
{
Console.WriteLine("Failed to retrieve data. Status code: " + response.StatusCode);
}
}
catch (HttpRequestException ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
}

internal record DeliveryRequest(int[] OrderRowIds, IList<RowDeliveryOptions> RowDeliveryOptions, int InvoiceDistributionType, bool CancelRemaining);
internal class RowDeliveryOptions
{
public int OrderRowId { get; set; }
public int Quantity { get; set; }
}

InvoiceDistributionType​

ValueNameDescription
0UnknownNot specified
2PostInvoice sent by post
3EmailInvoice sent by email
4EInvoiceB2BElectronic invoice for B2B
6OmniOmni channel distribution

Prerequisite​

The order must have action CanDeliverOrder or CanDeliverPartially to deliver the order.
To make a partial delivery, the order must have the action CanDeliverPartially and each order row must have the action CanDeliverRow.

info

Payment Plan Orders are delivered fully.

Payload parameters​

ParameterDescriptionType

OrderRowIDs

required
ID of the order rows to be deliveredList of Long
InvoiceDistributionType

Valid only for invoice payment method.
Invoice distribution types:

  • Default = 0
  • Post = 2
  • Email = 3
  • EInvoiceB2B = 4
Long
RowDeliveryOptionsAn object containing details of partial delivery of order rows.RowDeliveryOptions
CancelRemaining

Default value is FALSE.
If this parameter is set TRUE, then rest of the order will be cancelled after delivery.


Is applicable for orders with payment type:

InvoiceAccount CreditCard VippsMobilepayApplepay

Googlepay.

Boolean

Row Delivery Options​

ParameterDescriptionType
OrderRowID

Order row ID for order rows.
ID should be present in the [OrderRowIDs] collection in request.

Long
Quantity

Number of items to be delivered for specified row. Quantity cannot be less than 0, or more than the quantity of the row.

Long

Response Code​

CodeHttpStatusCodeDescription
202AcceptedDeliver request Accepted for processing.
400BadRequest
Reason:
  • Missing request details.
  • Missing CanDeliverOrder or CanDeliverPartially action.

  • Order row already delivered.
  • Order row ID is not valid.
  • Order row ID is missing CanDeliverRow action.
  • Order not found.
  • No order rows to deliver.
  • Invalid distribution type.
  • Order expired/closed.
  • Any other internal error.
403ForbiddenMerchant does not have permission to access this resource.
401UnauthorizedMerchant is not authorized to retrieve information.

Deliver order with lower amount​

info

Available for orders with payment type: Card Vipps Mobilepay Applepay Googlepay

Description

Call this endpoint to deliver part of the order amount and cancel the remaining amount.
Order status will be changed to Delivered , and no further action can be done on the order rows.
Delivered amount can be cancelled/credited depending on the action available.

Endpoint​

Method: POST
/api/v1/orders/{CheckoutOrderId}/deliveries/DeliverAndLowerAmount

Sample Code​

Deliver Order Example
using Microsoft.Extensions.DependencyInjection;
using System.Text.Json;
using System.Text;

internal static class DeliverOrderAmount
{
internal static async Task DeliverOrderAmountAsync(long checkoutOrderId)
{
var services = new ServiceCollection();
services.AddHttpClient("MyApiClient", client =>
{
client.BaseAddress = new Uri("https://paymentadminapistage.svea.com/api/");
});

var serviceProvider = services.BuildServiceProvider();
var httpClientFactory = serviceProvider.GetRequiredService<IHttpClientFactory>();
var httpClient = httpClientFactory.CreateClient("MyApiClient");

var apiUrl = string.Format("v1/orders/{0}/deliveries/DeliverAndLowerAmount", checkoutOrderId);


var deliveryRequest = new DeliveryAmountRequest(100);
var jsonString = JsonSerializer.Serialize(deliveryRequest);
var deliveryRequestJson = new StringContent(
jsonString,
Encoding.UTF8,
"application/json");

// Add authorization header
Authentication.CreateAuthenticationToken(out string token, out string timestamp, jsonString);
httpClient.DefaultRequestHeaders.Add("Authorization", token);
httpClient.DefaultRequestHeaders.Add("Timestamp", timestamp);

try
{
HttpResponseMessage response = await httpClient.PostAsync(apiUrl, deliveryRequestJson);

// Check if the request was successful
if (response.IsSuccessStatusCode)
{
string responseData = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response: " + responseData);
}
else
{
Console.WriteLine("Failed to retrieve data. Status code: " + response.StatusCode);
}
}
catch (HttpRequestException ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
}

internal record DeliveryAmountRequest(long DeliveredAmount);

Prerequisite​

The order must have the actions CanDeliverOrder and CanCancelAmount.

Payload parameters​

ParameterDescriptionType

DeliveredAmount required

Amount to be Delivered.Long

Response Code​

CodeHttpStatusCodeDescription
202AcceptedDeliver request Accepted for processing.
400BadRequest
Reason:
  • Missing request details.
  • Missing CanDeliverOrder or CanCancelAmount action.
  • Order not found.
  • Any other internal error.
403ForbiddenMerchant does not have permission to access this resource.
401UnauthorizedMerchant is not authorized to retrieve information.

Deliver and Lower Amount​

Description

Call this endpoint to lower the order amount and deliver in a single operation. Useful when you want to deliver an order for less than its full amount (e.g. the customer returned part of an order before delivery).

Endpoint​

Method: POST
/api/v1/orders/{CheckoutOrderId}/deliveries/DeliverAndLowerAmount

Prerequisite​

The order must have BOTH actions:

  • CanCancelAmount (to lower the amount)
  • CanDeliverOrder (to deliver)

Request parameters​

ParameterDescriptionType
CheckoutOrderId (required)Checkout order ID of the specified order.Long
DeliveredAmount (required)The amount to deliver (in minor units).Decimal
CancelRemainingWhen set to true, undelivered order rows will be automatically cancelled after delivery. Only applicable for Invoice, PaymentPlan, and AccountCredit orders. Default: false.Boolean

Response​

ParameterDescriptionType
DeliveryIdID of the created delivery.Long

Response Code​

CodeHttpStatusCodeDescription
202AcceptedDeliver and lower amount request accepted for processing.
400BadRequestInvalid request details, missing actions, or order not found.
403ForbiddenMerchant not permitted.
401UnauthorizedMerchant not authorized.