Editing orders
Add order row
Description
Call this endpoint to add 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("http://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 | Order Row 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 is not authorized to retrieve information. |
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("http://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 Order Row Object | List of Order Row |
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 | The discount percent of the product. | Long |
DiscountAmount | The discount amount of the product. | 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 is not authorized to retrieve information. |
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("http://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 | Order Row Object | Order Row |
Response Code
Code | HttpStatusCode | Description |
---|---|---|
204 | No Content | Update Row request Accepted for processing. |
400 | BadRequest | Reason:
|
403 | Forbidden | Merchant is not authorized to retrieve information. |
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 | The discount percent of the product. | Long |
DiscountAmount | The discount amount of the product. | 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 needs to 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/
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("http://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 RowId 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 | The discount percent of the product. | Long |
DiscountAmount | The discount amount of the product. | 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 | Update Row request Accepted for processing. |
400 | BadRequest | Reason:
|
403 | Forbidden | Merchant is not authorized to retrieve information. |
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("http://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.
Request parameters
Parameter | Description | Type |
---|---|---|
CheckoutOrderId required | Checkout order ID of the specified order. | Long |
OrderRows required | To update several order rows with RowId specified. | List of Order Row |
Response Code
Code | HttpStatusCode | Description |
---|---|---|
204 | No Content | Update Row request Accepted for processing. |
400 | BadRequest | Reason:
|
403 | Forbidden | Merchant is not authorized to retrieve information. |
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 then 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("http://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 changed successfully. |
400 | BadRequest | Reason:
|
403 | Forbidden | Merchant is not authorized to retrieve information. |
401 | Unauthorized | Merchant is not authorized to retrieve information. |