Skip to main content

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
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);
}

Request

NameDescriptionTypeAdditional Information
NshiftCombinedIdCombined ID from nShiftString
NshiftDeliveryCheckoutIdDelivery checkout ID from nShiftString

Response

NameDescriptionTypeAdditional Information
idCheckout Merchant IdInt64
accessTokenMasked NshiftCombinedIdString
deliveryCheckoutIdDelivery checkout ID from nShiftString
isAddonDisabledBoolean

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
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);
}
}
}
}

Response

NameDescriptionTypeAdditional Information
idCheckout Merchant IdInt64
accessTokenAccess Token created by Svea from NshiftCombinedIdString
deliveryCheckoutIdDelivery checkout ID from nShiftString
isAddonDisabledBoolean