Update Order
Use this request to update an existing Checkout order.
Only cart and merchantData can be updated on an existing order. If you need to update other fields, simply create a new Checkout order.
caution
Quantity, UnitPrice, DiscountPercent, DiscountAmount and VatPercent for each order row expected to be given in minor units.
info
HTTP status code 200 indicates a successful update
info
Method POST is also supported. Works exactly the same way as PUT
Endpoint
Method: POST
/api/orders/{orderId}
Request
URI Parameters
Name | Description | Type | Additional Information |
---|---|---|---|
orderId | OrderId returned by CreateOrder request | Int64 |
Body Parameters
- Request Model
- Request Samples
- Code Snippets
Name | Description | Type | Additional Information |
---|---|---|---|
cart | Important: The entire cart is overwritten on every update. Always send all of the order rows. It is possible to update the order with a cart that has a total cost of the order rows less than 0 (e.g. an empty cart). However the end customer will not be able to finish the purchase in the Checkout until the total cost of the order rows is equal or higher than 0. | Cart | |
merchantData | Metadata visible to the store | String | Max length: 6000 Cleaned up from Checkout database after 45 days |
shippingInformation | Shipping information to be updated. Only applicable if merchant has shipping enabled. | ShippingInformation (order) | |
validation | Order validations such as minimum age requirement should be fulfilled here. (It's nullable it means you do not need to provide anything in case the age limit is not required) | OrderValidation | Apply it in order to have order validation such as minimum age / Nullable |
- Request Sample
- UpdateOrderRequestModel.cs
application/json
{
"cart": {
"Items": [
{
"ArticleNumber": "ABC80",
"Name": "Computer",
"Quantity": 400, // 4.00 units
"UnitPrice": 550000, // 5500.00 SEK
"DiscountPercent": 1000, // 10.00% discount
"VatPercent": 2500, // 25.00% VAT
"Unit": null, // e.g. pcs, kg...
"TemporaryReference": null,
"RowNumber": 1,
"MerchantData": null,
"RowType": "Row" | "ShippingFee",
},
{
"ArticleNumber": "ABC81",
"Name": "Another Computer",
"Quantity": 100, // 1.00 units
"UnitPrice": 250000, // 2500.00 SEK
"DiscountAmount": 10000, // 100.00 SEK discount
"VatPercent": 2500, // 25.00% VAT
"Unit": null, // e.g. pcs, kg...
"TemporaryReference": null,
"RowNumber": 2,
"MerchantData": null,
"RowType": "Row" | "ShippingFee",
}
]
},
"ShippingInformation": {
"EnableShipping": true,
"EnforceFallback": false,
"Weight": 1000.0, // grams
"Tags": {
"bulky": "true",
"key": "value"
//etc
},
"FallbackOptions": [
{
"Id": "145af7a2-e432-48b8-a6ce-2acf0519882a",
"Carrier": "Bring",
"Name": "Home Delivery",
"Price": 29, // 29.00 SEK
"ShippingFee": 2900, // 29.00 SEK
"addons": [{...}],
"fields": [{...}]
}
]
},
"merchantData": "Some data",
"validation": {
"minAge": 18
}
}
UpdateOrderRequestModel.cs
public class UpdateOrderRequestModel
{
public Cart Cart { get; set; } = new Cart();
public string MerchantData { get; set; } = string.Empty;
public ShippingInformation? ShippingInformation { get; set; }
public Validation? Validation { get; set; }
}
public class Cart
{
public List<OrderRow> Items { get; set; } = new List<OrderRow>();
}
public class OrderRow
{
public string? ArticleNumber { get; set; }
public string Name { get; set; } = string.Empty;
public long Quantity { get; set; }
public long UnitPrice { get; set; }
public long DiscountPercent { get; set; }
public long DiscountAmount { get; set; }
public long VatPercent { get; set; }
public string Unit { get; set; } = string.Empty;
public string? TemporaryReference { get; set; }
public int RowNumber { get; set; }
public string? MerchantData { get; set; }
public string? RowType { get; set; }
}
public class Validation
{
}
public class ShippingInformation
{
public bool EnableShipping { get; set; }
public bool EnforceFallback { get; set; }
public double Weight { get; set; }
public Dictionary<string, string>? Tags { get; set; }
public List<FallbackOption>? FallbackOptions { get; set; }
public bool ShouldRejectShippingSession { get; set; }
}
- UpdateOrderSample.cs
- UpdateOrderMockRequest.cs
UpdateOrderSample.cs
public class UpdateOrderSample
{
public static async Task UpdateOrder(long orderId)
{
var services = new ServiceCollection();
services.AddHttpClient("MyApiClient", client =>
{
client.BaseAddress = new Uri("https://checkoutapistage.svea.com");
});
var serviceProvider = services.BuildServiceProvider();
var httpClientFactory = serviceProvider.GetRequiredService<IHttpClientFactory>();
var httpClient = httpClientFactory.CreateClient("MyApiClient");
var updateOrderRequest = UpdateOrderMockRequest.CreateBaseMockRequestSE();
var jsonString = JsonSerializer.Serialize(updateOrderRequest);
var updateOrderRequestJson = 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);
var apiUrl = $"/api/orders/{orderId}";
try
{
HttpResponseMessage response = await httpClient.PostAsync(apiUrl, updateOrderRequestJson);
// 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);
}
}
}
UpdateOrderMockRequest.cs
public class UpdateOrderMockRequest
{
public static UpdateOrderRequestModel CreateBaseMockRequestSE() => new()
{
Cart = new Cart()
{
Items = new List<OrderRow>(){
new() {
Name="Article1",
Quantity=500,
UnitPrice=100,
ArticleNumber="123-456-789",
Unit="st"
},
new() {
Name="Article2",
Quantity=500,
UnitPrice=100,
ArticleNumber="123-asd-fgh",
Unit="st"
},
}
}
};
}
Response
- Response Model
- Response Sample
Name | Description | Type | Additional Information |
---|---|---|---|
OrderId | The id of the Order, needed to get and update order in the Checkout API | Int64 | |
ClientOrderNumber | String | ||
Gui | Contains the Snippet that is used to embed the Checkout UI on your site | Gui | |
Status | The current status of the order | CheckoutOrderStatus | |
Cart | Order rows. | Cart | |
Currency | Currency as defined by ISO 4217 | String | |
Locale | The locale of the Checkout, e.g. sv-SE. | String | |
Customer | Customer information | Customer | |
CountryCode | Defined by two-letter ISO 3166-1 alpha-2, e.g. SE, NO, FI, DK | String | |
EmailAddress | Customer's email address | String | |
PhoneNumber | Customer's phone number | String | |
ShippingAddress | Customer's shipping address. | Address | |
BillingAddress | Customer's billing address. | Address | |
PaymentType | The payment method that the customer used to finish the purchase. Only set when order status is Final
| String | |
Payment | The payment method that the customer used to finish the purchase. Only set when order status is Final | PaymentInfo | |
SveaWillBuyOrder | True = Svea will buy this invoice. False = Svea will not buy this invoice. null = Selected payment method is not Invoice. | Boolean | |
MerchantSettings | MerchantSettings | ||
IdentityFlags | IdentityFlags | ||
CustomerReference | B2B Customer reference | String | |
PeppolId | A company’s ID in the PEPPOL network, which allows the company to receive PEPPOL invoices. A PEPPOL ID can be entered when placing a B2B order using the payment method invoice. | String | |
MerchantData | Metadata visible to the store | String | Cleaned up from Checkout database after 45 days. |
ShippingInformation | The returned Shipping information from a previously created/updated order. After the order is finalized and the shipping is created we will include a couple more properties in the ShippingInformation on Order level associated with the Shipping Provider. | GetOrderShippingInformation | |
Recurring new | Indicates if the order is recurring order and will create a recurring token when order is finalized. Only applicable if merchant has recurring orders enabled. | Boolean / Null | |
RecurringToken new | Recurring token to be used for subsequent recurring orders. Only available when order is finalized. Only applicable if merchant has recurring orders enabled. | String / Null | |
BillingReferences | A collection of B2B billing references. | BillingReference | Applicable for B2B orders |
application/json
{
"MerchantSettings": {
"CheckoutValidationCallBackUri": "https://your.domain/validation-callback/{checkout.order.uri}",
"PushUri": "https://your.domain/push-callback/{checkout.order.uri}",
"TermsUri": "https://your.domain/terms/",
"CheckoutUri": "https://your.domain/checkout-callback/",
"ConfirmationUri": "https://your.domain/confirmation-callback/",
"ActivePartPaymentCampaigns": [
1111,
2222,
3333,
4444
],
"PromotedPartPaymentCampaign": 1111
},
"Cart": {
"Items": [
{
"ArticleNumber": "ABC80",
"Name": "Computer",
"Quantity": 300, // 3.00 units
"UnitPrice": 500000, // 5000.00 SEK
"DiscountPercent": 1000, // 10.00% discount
"VatPercent": 2500, // 25.00% VAT
"Unit": null, // e.g. pcs, kg...
"TemporaryReference": null,
"RowNumber": 1,
"MerchantData": null,
"RowType": "Row" | "ShippingFee",
},
{
"ArticleNumber": "ABC81",
"Name": "Another Computer",
"Quantity": 200, // 2.00 units
"UnitPrice": 400000, // 4000.00 SEK
"DiscountAmount": 10000, // 100.00 SEK discount
"VatPercent": 2500, // 25.00% VAT
"Unit": null, // e.g. pcs, kg...
"TemporaryReference": null,
"RowNumber": 2,
"MerchantData": null,
"RowType": "Row" | "ShippingFee",
}
]
},
"ShippingInformation": {
"EnableShipping": true,
"EnforceFallback": false,
"Weight": 1000.0, // grams
"Tags": {
"bulky": "true",
"key": "value"
//etc
},
"FallbackOptions": [
{
"Id": "145af7a2-e432-48b8-a6ce-2acf0519882a",
"Carrier": "Bring",
"Name": "Home Delivery",
"Price": 29, // 29.00 SEK
"ShippingFee": 2900, // 29.00 SEK
"addons": [{...}],
"fields": [{...}]
}
],
"ShippingProvider": { //only set when shipping order has been created
"Name": "nShift",
"ShipmentId": "622162",
"ShippingOption": {
"Id": "345af7a2-e432-48b8-a6ce-2acf0519882a",
"Name": "Bring PickUp Parcel",
"Carrier": "Bring",
"Price": 29, // 29.00 SEK
"ShippingFee": 2900, // 29.00 SEK
"Location": {
"Id": "74383",
"Name": "Agent name"
},
"Fields": [{"Id": "FCRECEIVERSMS", "Value": "070123456"}],
"Addons": [{"id":"FCNOTIFYPHONE","price":29,"fields":[{"id":"phone","value":"01234567"}]}],
"PostalCode": "99999"
}
}
},
"Customer": {
"Id": 1,
"NationalId": "121314-1234",
"CountryCode": "SE",
"IsCompany": false,
"IsVerified": false
},
"ShippingAddress": {
"FullName": "John Doe",
"FirstName": "John",
"LastName": "Doe",
"StreetAddress": "My Street 1",
"CoAddress": "",
"PostalCode": "99999",
"City": "My Town",
"CountryCode": "SE",
"IsGeneric": false,
"AddressLines": null
},
"BillingAddress": {
"FullName": "John Doe",
"FirstName": "John",
"LastName": "Doe",
"StreetAddress": "My Street 1",
"CoAddress": "",
"PostalCode": "99999",
"City": "My Town",
"CountryCode": "SE",
"IsGeneric": false,
"AddressLines": null
},
"Gui": {
"Layout": "desktop",
"Snippet": "<iframe src=\"\"></iframe>"
},
"Locale": "sv-SE",
"Currency": "SEK",
"CountryCode": "SE",
"ClientOrderNumber": "ABCDEFGHIJKLMNOP0123456789",
"OrderId": 1234567890,
"EmailAddress": "john.doe@svea.com",
"PhoneNumber": "070-1234567",
"PaymentType": "INVOICE",
"Payment": null,
"Status": "Final",
"CustomerReference": null,
"SveaWillBuyOrder": false,
"IdentityFlags": {
"HideNotYou": false,
"HideChangeAddress": true,
"HideAnonymous": true
},
"MerchantData": null,
"PeppolId": null,
"Recurring": true,
"RecurringToken": "d651c11e-984a-4a80-a2d5-c69fe38e10e0" //Token to be used for subsequent order, only avaliable when order has been finalized
}