Editing orders
Add order row
Description
Call this endpoint to add an order row to an order. If the new order amount is higher than the current order amount, a credit check will be made.
Endpoint
/api/v1/orders/{CheckoutOrderId}/rows/
Sample Code
- C#
- Request
- Response
using Microsoft.Extensions.DependencyInjection;
using System.Text.Json;
using System.Text;
internal static class EditOrderAddRow
{
internal static async Task AddRowAsync(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}/rows/", checkoutOrderId);
//New Order Row
var addRowRequest = new AddRowRequest("A-1", "Article Name 1", 1000, 1000, 0, 0, 2500, "st");
var jsonString = JsonSerializer.Serialize(addRowRequest);
var addRowRequestJson = 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, addRowRequestJson);
// 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);
}
}
}
{
"ArticleNumber": "string",
"Name": "string",
"Quantity": 0,
"UnitPrice": 0,
"DiscountPercent": 0,
"DiscountAmount": 0,
"VatPercent": 0,
"Unit": "string"
}
{
"OrderRowId": [
2 //Row Id of the newly row added
]
}
Prerequisite
The order must have the action CanAddOrderRow.
Request parameters
| Parameter | Description | Type |
|---|---|---|
CheckoutOrderID required | Checkout order ID of the specified order. | Long |
OrderRow required | Order Row | OrderRow object |
Response
| Parameter | Description | Type |
|---|---|---|
| OrderRowID | The row ID of the newly created order row. | Long |
Response Code
| Code | HttpStatusCode | Description |
|---|---|---|
| 202 | Accepted | Add row request accepted for processing. |
| 400 | BadRequest | Reason:
|
| 403 | Forbidden | Merchant does not have permission to access this resource. |
| 401 | Unauthorized | Merchant is not authorized to retrieve information. |
Add order rows
Description
Call this endpoint to add several order rows to an order. If the new order amount is higher than the current order amount, a credit check will be made.
Endpoint
/api/v1/orders/{CheckoutOrderId}/rows/addOrderRows/
Sample Code
- C#
- Request
- Response
using Microsoft.Extensions.DependencyInjection;
using System.Text.Json;
using System.Text;
internal static class EditOrderAddRows
{
internal static async Task AddRowsAsync(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}/rows/addOrderRows", checkoutOrderId);
//New Order Rows
var addRowRequest = new List<AddRowRequest>
{
new AddRowRequest("A-1", "Article Name 1", 1000, 1000, 0, 0, 2500, "st"),
new AddRowRequest("A-2", "Article Name 2", 2000, 2000, 0, 0, 2500, "st"),
};
var addRowsRequest = new AddRowsRequest(addRowRequest);
var jsonString = JsonSerializer.Serialize(addRowsRequest);
var addRowRequestJson = 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, addRowRequestJson);
// 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 AddRowRequest(string ArticleNumber, string Name, long Quantity, long UnitPrice, long DiscountPercent, long DiscountAmount, long VatPercent, string Unit);
internal record AddRowsRequest(IList<AddRowRequest> OrderRows);
{
"OrderRows": [
{
"ArticleNumber": "test Item 1",
"Name": "testItem2",
"Quantity": 1000,
"UnitPrice": 2500,
"DiscountPercent": 0,
"DiscountAmount": 0,
"VatPercent": 1900,
"Unit": "st"
},
{
"ArticleNumber": "test Item 2",
"Name": "testItem2",
"Quantity": 1000,
"UnitPrice": 2500,
"DiscountPercent": 0,
"DiscountAmount": 0,
"VatPercent": 1900,
"Unit": "st"
}
]
}
{
"OrderRowId": [
10,
11
]
}
Prerequisite
The order must have the action CanAddOrderRow.
Request parameters
| Parameter | Description | Type |
|---|---|---|
CheckoutOrderID required | Checkout order ID of the specified order. | Long |
OrderRows required | List of OrderRow object | List of OrderRow |
Order Row
| Parameter | Description | Type |
|---|---|---|
| ArticleNumber | Article number as a string, can contain letters and numbers. | String |
Name required | Article name. | String |
Quantity required | Quantity of the product. | Long |
UnitPrice required | Price of the product including VAT. | Long |
| DiscountPercent | Discount percentage of the product. Cannot be used together with DiscountAmount. | Long |
| DiscountAmount | Discount amount of the product. Cannot be used together with DiscountPercent. | Long |
| VatPercent | The VAT percentage of the current product. | Long |
| Unit | The unit type, e.g., “st”, “pc”, “kg” etc. | String |
Response
| Parameter | Description | Type |
|---|---|---|
| OrderRowID | The row IDs of the newly created OrderRows. | List of Long |
Response Code
| Code | HttpStatusCode | Description |
|---|---|---|
| 202 | Accepted | Add row request accepted for processing. |
| 400 | BadRequest | Reason:
|
| 403 | Forbidden | Merchant does not have permission to access this resource. |
| 401 | Unauthorized | Merchant is not authorized to retrieve information. |
Update order row
Description
Call this endpoint to update an order row.
If the new order amount is higher than the current order amount, a credit check will be made.
Endpoint
/api/v1/orders/{CheckoutOrderId}/rows/{OrderRowId}/
Sample Code
- C#
- Request
- Response
using Microsoft.Extensions.DependencyInjection;
using System.Text.Json;
using System.Text;
internal static class EditOrderUpdateRow
{
internal static async Task EditOrderUpdateRowAsync(long checkoutOrderId, int rowId)
{
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}/rows/{1}", checkoutOrderId, rowId);
var updateRowRequest = new UpdateRowRequest("A-1", 5000);
var jsonString = JsonSerializer.Serialize(updateRowRequest);
var updateRowRequestJson = 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.PatchAsync(apiUrl, updateRowRequestJson);
// 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 UpdateRowRequest(string ArticleNumber, long Quantity, string? Name = "", long? UnitPrice = 0, long? DiscountPercent = 0, long? DiscountAmount = 0,
long? VatPercent = 0, string? Unit = "",
bool? IsCancelled = false);
{
"ArticleNumber": "string",
"Name": "string",
"Quantity": 0,
"UnitPrice": 0,
"DiscountPercent": 0,
"DiscountAmount": 0,
"VatPercent": 0,
"Unit": "string",
"IsCancelled": false //Set to true if the row needs to be cancelled
}
Prerequisite
The order must have the action CanUpdateOrderRow.
The order row must have the action CanUpdateRow.
Request parameters
| Parameter | Description | Type |
|---|---|---|
CheckoutOrderID required | Checkout order ID of the specified order. | Long |
OrderRowID required | ID of the specified row to be updated. | Long |
OrderRow required | OrderRow object | Order Row |
Response Code
| Code | HttpStatusCode | Description |
|---|---|---|
| 204 | No Content | Update Row request Accepted for processing. |
| 400 | BadRequest | Reason:
|
| 403 | Forbidden | Merchant does not have permission to access this resource. |
| 401 | Unauthorized | Merchant is not authorized to retrieve information. |
Update Order Row Request
| Parameter | Description | Type |
|---|---|---|
| ArticleNumber | Article number as a string, can contain letters and numbers. | String |
| Name | Article name. | String |
Quantity required | Quantity of the product. | Long |
| UnitPrice | Price of the product including VAT. | Long |
| DiscountPercent | Discount percentage of the product. Cannot be used together with DiscountAmount. | Long |
| DiscountAmount | Discount amount of the product. Cannot be used together with DiscountPercent. | Long |
| VatPercent | The VAT percentage of the current product. | Long |
| Unit | The unit type, e.g., “st”, “pc”, “kg” etc. | String |
| IsCancelled | Set to true if the row should be cancelled. | Boolean |
Update order rows
Description
Call this endpoint to update several order rows.
If the new order amount is higher than the current order amount, a credit check will be made.
Endpoint
/api/v1/orders/{CheckoutOrderId}/rows/updateOrderRows/
Note: Despite being an update operation, this endpoint uses the POST method.
Sample Code
- C#
- Request
- Response
using Microsoft.Extensions.DependencyInjection;
using System.Text.Json;
using System.Text;
internal static class EditOrderUpdateRows
{
internal static async Task EditOrderUpdateRowsAsync(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}/rows/updateOrderRows", checkoutOrderId);
var updateRowsRequest = new UpdateRowsRequest
{
OrderRows = new List<UpdateRowsObject>
{
new UpdateRowsObject(1, new UpdateRowRequest("A-1", 1000)),
new UpdateRowsObject(2, new UpdateRowRequest("A-2", 3000))
}
};
var jsonString = JsonSerializer.Serialize(updateRowsRequest);
var updateRowsRequestJson = 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, updateRowsRequestJson);
// 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 UpdateRowsObject(long RowId, UpdateRowRequest Row);
internal record UpdateRowRequest(string ArticleNumber, long Quantity, string? Name = "", long? UnitPrice = 0, long? DiscountPercent = 0, long? DiscountAmount = 0,
long? VatPercent = 0, string? Unit = "",
bool? IsCancelled = false);
internal class UpdateRowsRequest
{
public IList<UpdateRowsObject> OrderRows { get; set; }
}
{
"OrderRows": [
{
"RowId": 1,
"Row": {
"ArticleNumber": "1017643",
"DiscountPercent": 0,
"Name": "ABC",
"Quantity": 100,
"Unit": "St",
"UnitPrice": 1169000,
"VatPercent": 2500
}
}
]
}
Prerequisite
The order must have the action CanUpdateOrderRow.
The order row must have the action CanUpdateRow.
Request parameters
| Parameter | Description | Type |
|---|---|---|
CheckoutOrderID required | Checkout order ID of the specified order. | Long |
OrderRows required | To update several order rows with row ID specified. | List of Order Row |
Update Order Rows Request
| Parameter | Description | Type |
|---|---|---|
RowID required | Row ID of the order row. | Long |
| ArticleNumber | Article number as a string, can contain letters and numbers. | String |
| Name | Article name. | String |
Quantity required | Quantity of the product. | Long |
| UnitPrice | Price of the product including VAT. | Long |
| DiscountPercent | Discount percentage of the product. Cannot be used together with DiscountAmount. | Long |
| DiscountAmount | Discount amount of the product. Cannot be used together with DiscountPercent. | Long |
| VatPercent | The VAT percentage of the current product. | Long |
| Unit | The unit type, e.g., “st”, “pc”, “kg” etc. | String |
Response Code
| Code | HttpStatusCode | Description |
|---|---|---|
| 204 | No Content | Row update processed successfully. |
| 400 | BadRequest | Reason:
|
| 403 | Forbidden | Merchant does not have permission to access this resource. |
| 401 | Unauthorized | Merchant is not authorized to retrieve information. |
Replace order rows
Description
Call this endpoint to replace all existing order rows with new order rows.
The existing rows will be cancelled.
If the new order amount is higher than the current order amount, a credit check will be made.
Endpoint
/api/v1/orders/{CheckoutOrderId}/rows/replaceOrderRows
Sample Code
- C#
- Request
- Response
using Microsoft.Extensions.DependencyInjection;
using System.Text.Json;
using System.Text;
internal static class EditOrderReplaceRows
{
internal static async Task EditOrderReplaceRowsAsync(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}/rows/replaceOrderRows", checkoutOrderId);
//New Order Rows
var replaceRowRequest = new List<AddRowRequest>
{
new AddRowRequest("A-1", "Article Name 1", 1000, 1000, 0, 0, 2500, "st")
};
var addRowsRequest = new AddRowsRequest(replaceRowRequest);
var jsonString = JsonSerializer.Serialize(addRowsRequest);
var replaceRowRequestJson = 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.PutAsync(apiUrl, replaceRowRequestJson);
// 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 AddRowRequest(string ArticleNumber, string Name, long Quantity, long UnitPrice, long DiscountPercent, long DiscountAmount, long VatPercent, string Unit);
{
"OrderRows": [
{
"Name": "A-3",
"Quantity": 100,
"UnitPrice": 1000
}
]
}
Prerequisite
The order must have the action CanUpdateOrderRow.
⚠️ This endpoint is only applicable for orders with payment type:
Request parameters
| Parameter | Description | Type |
|---|---|---|
CheckoutOrderID required | Checkout order ID of the specified order. | Long |
OrderRows required | The new order rows that will replace all existing rows. | List of Order Row |
Response Code
| Code | HttpStatusCode | Description |
|---|---|---|
| 204 | No Content | Update Row request Accepted for processing. |
| 400 | BadRequest | Reason:
|
| 403 | Forbidden | Merchant does not have permission to access this resource. |
| 401 | Unauthorized | Merchant is not authorized to retrieve information. |
Extend order expiry date
Description
Call this endpoint to update expiry date of an order. The requested new expiry date of an order should not be in the past and greater than current date.
Endpoint
/api/v1/orders/{CheckoutOrderId}/extendOrder/{expiryDate}/
Sample Code
- C#
- Request
- Response
using Microsoft.Extensions.DependencyInjection;
internal static class EditOrderExtendExpiryDate
{
internal static async Task EditOrderExtendExpiryDateAsync(long checkoutOrderId, string expiryDate)
{
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}/extendOrder/{1}/", checkoutOrderId, expiryDate);
// Add authorization header
Authentication.CreateAuthenticationToken(out string token, out string timestamp);
httpClient.DefaultRequestHeaders.Add("Authorization", token);
httpClient.DefaultRequestHeaders.Add("Timestamp", timestamp);
try
{
HttpResponseMessage response = await httpClient.PatchAsync(apiUrl, new StringContent(""));
// 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);
}
}
}
Request parameters
| Parameter | Description | Type |
|---|---|---|
CheckoutOrderID required | Checkout order ID of the specified order. | Long |
ExpiryDate required | New expiry date of an order in ISO 8601 format. e.g. 2024-01-01 | Date |
Response Code
| Code | HttpStatusCode | Description |
|---|---|---|
| 200 | Success | Extend date has been updated successfully. |
| 400 | BadRequest | Reason:
|
| 403 | Forbidden | Merchant does not have permission to access this resource. |
| 401 | Unauthorized | Merchant is not authorized to retrieve information. |
Update Metadata
Description
Call this endpoint to update metadata of an order which is an optional set of custom key–value pairs that can be attached to the request to help with internal tracking, filtering, or correlation (for example: sales channel, external reference IDs, or source system identifiers).
Endpoint
/api/v1/orders/{CheckoutOrderId}/metadata
Sample Code
- C#
- Request
- Response
using Microsoft.Extensions.DependencyInjection;
internal static class UpdateOrderMetadata
{
internal static async Task UpdateOrderMetadataAsync(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}/metadata", checkoutOrderId);
//Metadata
var metadataItems = new MetadataItem[]
{
new MetadataItem { Key = "key1", Value = "value1" },
new MetadataItem { Key = "key2", Value = "value2" }
};
var metadataRequest=new MetadataRequest(metadataItems);
var jsonString = JsonSerializer.Serialize(metadataRequest);
var metadataRequestJson = new StringContent(
jsonString,
Encoding.UTF8,
"application/json");
// Add authorization header
Authentication.CreateAuthenticationToken(out string token, out string timestamp);
httpClient.DefaultRequestHeaders.Add("Authorization", token);
httpClient.DefaultRequestHeaders.Add("Timestamp", timestamp);
try
{
HttpResponseMessage response = await httpClient.PutAsync(apiUrl, metadataRequestJson());
// 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 MetadataRequest(MetadataItem[] Metadata);
internal record MetadataItem(string Key,string Value);
{
"Metadata": [
{
"Key": "string",
"Value": "string"
}
]
}
Prerequisite
Maximum 50 key–value pairs per request.
Maximum 50 characters per key.
Maximum 500 characters per value.
Each key can only be used once per order.
Request parameters
| Parameter | Description | Type |
|---|---|---|
CheckoutOrderID required | Checkout order ID of the specified order. | Long |
Metadata required | List of metadata | List of key value pair |
Response Code
| Code | HttpStatusCode | Description |
|---|---|---|
| 200 | Success | Order metadata has been added successfully. |
| 400 | BadRequest | Reason:
|
| 403 | Forbidden | Merchant does not have permission to access this resource. |
| 401 | Unauthorized | Merchant is not authorized to retrieve information. |
Do not store or transmit sensitive information in metadata (e.g., passwords, access tokens, personal data, payment details, or other confidential identifiers).