Onboarding
Authentication towards nShift
The checkout shipping will require the merchant to send nShift Credentials to establish proper integration with nShift.These are:
- nShift Checkout delivery ID
- nShift CombinedId
Create/Update Onboarding Credentials
This endpoint is used to enable nShift shipping for Svea Checkout
info
You are able to provide all required credentials using this particular endpoint, and moreover, you can update and get the credentials that are already stored as well. Primarily, you are supposed to use the onboarding endpoint once and change it only if your nshift account has changed.
info
HTTP status code 200 indicates success
Endpoint
Method: POST
/api/shipping/onboarding
Body Parameters
- C#
- Request
- Response
Shipping Onboarding Create/Update
using Microsoft.Extensions.DependencyInjection;
using System.Text;
using System.Text.Json;
namespace APIPortal_CodeSamples.Checkout
{
public class ShippingOnboardingCreateSample
{
public static async Task ShippingOnboardingCreateUpdate()
{
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");
Authentication.CreateAuthenticationToken(out string token, out string timestamp);
httpClient.DefaultRequestHeaders.Add("Authorization", token);
httpClient.DefaultRequestHeaders.Add("Timestamp", timestamp);
var createOnboardingRequest = new CreateOnboardingRequest("**", "**");
var jsonString = JsonSerializer.Serialize(createOnboardingRequest);
var createOnboardingRequestJson = new StringContent(
jsonString,
Encoding.UTF8,
"application/json");
var apiUrl = $"/api/shipping/onboarding";
try
{
HttpResponseMessage response = await httpClient.PostAsync(apiUrl, createOnboardingRequestJson);
// 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 CreateOnboardingRequest(string NshiftCombinedId, string NshiftDeliveryCheckoutId);
}
application/json
{
"NshiftCombinedId": "**",
"NshiftDeliveryCheckoutId": "**"
}
application/json
{
"id": 100003,
"accessToken": "aWQ=",
"deliveryCheckoutId": "id1",
"isAddonDisabled": false
}
Request
Name | Description | Type | Additional Information |
---|---|---|---|
NshiftCombinedId | Combined ID from nShift | String | |
NshiftDeliveryCheckoutId | Delivery checkout ID from nShift | String |
Response
Name | Description | Type | Additional Information |
---|---|---|---|
id | Checkout Merchant Id | Int64 | |
accessToken | Masked NshiftCombinedId | String | |
deliveryCheckoutId | Delivery checkout ID from nShift | String | |
isAddonDisabled | Boolean |
Get Onboarding Credentials
This endpoint is used to retrieve nShift Credentials
info
HTTP status code 200 indicates success
Endpoint
Method: GET
/api/shipping/onboarding
Body Parameters
- C#
- Response
Shipping Onboarding Get Credentials
using Microsoft.Extensions.DependencyInjection;
namespace APIPortal_CodeSamples.Checkout
{
public class ShippingOnboardingGetSample
{
public static async Task ShippingOnboardingGet()
{
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");
Authentication.CreateAuthenticationToken(out string token, out string timestamp);
httpClient.DefaultRequestHeaders.Add("Authorization", token);
httpClient.DefaultRequestHeaders.Add("Timestamp", timestamp);
var apiUrl = $"/api/shipping/onboarding";
try
{
HttpResponseMessage response = await httpClient.GetAsync(apiUrl);
// 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);
}
}
}
}
application/json
{
"id": 100001,
"accessToken": "VE0********************1k=",
"deliveryCheckoutId": "00000000-0000-0000-0000-000000000000",
"isAddonDisabled": false
}
Response
Name | Description | Type | Additional Information |
---|---|---|---|
id | Checkout Merchant Id | Int64 | |
accessToken | Access Token created by Svea from NshiftCombinedId | String | |
deliveryCheckoutId | Delivery checkout ID from nShift | String | |
isAddonDisabled | Boolean |