Cart service provider

Version: 10.3

Service providers are wrapper objects designed to make it easier to interact with Connect pipelines. The providers implement no logic other than calling Connect pipelines. All of the business logic is implemented in the pipeline processors.

For each method in the provider, there is a corresponding Request and Result object used, for example, GetCarts takes a GetCartsRequest object and returns a GetCartsResult object. In some cases, the response objects are re-used when returning the same data.

Customized versions of the default request and result arguments can be used by calling the overloaded generics based versions of the methods.

The Cart service provider contains the following methods for interacting with cart data.

GetCarts method

TheGetCarts method is used to query cart data against the external commerce system and does not return a collection of Carts, but a collection of CartBase objects that only contains the summary of the main cart data.

Name:

GetCarts

Description:

Gets the carts that match the specified criteria. Calls the GetCartspipeline.

Usage:

Called when a list of carts is needed.

Examples include:

  • Getting the carts for a specific visitor across all visitors.

  • Getting one of the carts for the current visitor in a multicart solution.

  • Getting the carts that have not been used within a period of time, for example, abandoned.

Signature:

GetCartsResult GetCarts(GetCartsRequest request)

Input:

UserId – Optional - The ids of the users whose carts should be retrieved. If no value is specified, the user IDs are not considered when retrieving carts.

CustomerId – Optional – The ids of the customers whose carts should be retrieved. If no value is specified the customer IDs are not considered when retrieving carts.

CartName – Optional - The names of the carts that should be retrieved. If no value is specified, the cart names are not considered when retrieving carts.

CartStatus – Optional – The status of carts that should be retrieved. Examples include Active and Abandoned. If no value is specified, the cart statuses are not considered when retrieving carts.

This could be used in a B2B scenario when you want to display a list of available carts to a user but only carts that are not locked.

IsLocked – Optional – If provided it means the search also filters on whether the cart is locked or not.

ShopName – Optional. Name of shop to search for carts in.

Output:

IEnumerable<CartBase> – A collection of CartBase objects.

The lists represent the carts that match the criteria specified in the request.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
// Create request to get the carts.
var request = new GetCartsRequest("MyStore")
{
    UserIds = new Collection<string> { "John" },
    CustomerIds = new Collection<string> { "JohnCustomerId" },
    Names = new Collection<string> { "JohnsName" },
    Statuses = new Collection<string> { "InProcess" },
    IsLocked = false
};
// Call service provider and receive the result.
var result = cartServiceProvider.GetCarts(request);

CreateOrResumeCart method

Name:

CreateOrResumeCart

Description:

Initiate the creation of a shopping cart and in the process:

  • Tries to load persisted, potentially abandoned cart, if present.

  • Triggers event in Experience Analytics.

  • Enters user in Marketing Automation plan with ID of shopping cart.

Usage:

Called when a shopping cart is needed upon visitor arrival to shop.

Signature:

CreateOrResumeCartResult CreateCart(CreateOrResumeCartRequest request)

Input:

All four input parameters are used to search and match against existing carts for the current visitor, but only two of them are mandatory.

UserId – Mandatory

CustomerId – Optional

CartId or CartName – Mandatory to load or resume cart. Optional when creating cart.

ShopName – Mandatory

Output:

Cart – A Cart object instance which represents the shopping cart. In case multiple carts already exist for the current visitor and it is undecided which one to return, then no cart is returned.

IEnumerable<CartBase> - In case multiple carts already exist for the current visitor and it is undecided which one to return, then a list of CartBase objects are returned.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
// Create the request.
var createCartRequest = new CreateOrResumeCartRequest("Autohaus", "Bred");
// Call the service provider to get the cart
var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart;
// Read the id of the returned cart
var id = cart.ExternalId;
// Create request to remove the cart.
var deleteCartRequest = new DeleteCartRequest(cart);
// Call the service provider and receive the result.
cartServiceProvider.DeleteCart(deleteCartRequest);

LoadCart method

Name:

LoadCart

Description:

Gets the cart with given Cart ID on the specified shop. Calls the LoadCart pipeline. This method returns the full cart object with all cart lines associated.

Usage:

Called when a specific cart is needed

Signature:

LoadCartResult LoadCart(LoadCartRequest request)

Note

The LoadCartRequest class provides the Recalculate property (boolean) that allows to specify whether or not to recalculate the cart. At the Commerce Engine (CE) Connect layer, if LoadCartRequest.Recalculate is set to false, then when CE Connect prepares the request to the engine to get the cart, it adds the DoNotCalculateCart string to the policykeys header. By default, the LoadCartRequest.Recalculate property is set to true.

Input:

CartId – Mandatory

ShopName - Mandatory

Output:

Cart – A cart object instance which represents the shopping cart that matches the criteria specified in the request.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
// Create the request
var request = new LoadCartRequest("Autohaus", "Bred");
// call the service provider to get the cart
var cart = cartServiceProvider.LoadCart(request).Cart;

SaveCart method

Name:

SaveCart

Description:

Saves the specified cart in the external system if supported as well as in Sitecore EA state. Calls the SaveCart pipeline.

Called from other service layer methods implicitly, but not called explicitly

Usage:

Called when a specific cart needs to be persisted. The method should be executed after any operation that modified the cart resulting in a change of cart.

It is executed implicitly when updating the cart, adding, deleting or updating cart lines, as well as locking and un-locking the cart.

Signature:

SaveCartResult SaveCart(SaveCartRequest request)

Input:

Cart – Mandatory

Output:

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
// Create cart and lock it.
var createCartRequest = new CreateOrResumeCartRequest("Autohaus", "Mark");
var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart;
// add a cartline to the cart
var cartLine1 = new CartLine
{
    Quantity = 1,
    Product = new CartProduct
    {
        ProductId = "Audi Q10",
        Price = new Price(55, "USD")
    }
};
var cartLines = new Collection<CartLine> { cartLine1 };
var addCartLinesRequest = new AddCartLinesRequest(cart, cartLines);
cart = cartServiceProvider.AddCartLines(addCartLinesRequest).Cart;
var saveCartRequest = new SaveCartRequest(cart);
var result = cartServiceProvider.SaveCart(saveCartRequest);

AddCartLines method

Name:

AddCartLines

Description:

Responsibility is to add lines to cart.

Usage:

Called when a list of cart lines is about to be added to the shopping cart, when the user clicks Add To Cart.

Signature:

AddCartLinesResult AddCartLines(AddCartLinesRequest request)

Input:

Cart – Required - The cart must be unmodified. Any changes made to the cart instance will be disregarded. Only the cart Id and ShopName are considered for retrieving and modifying the cart.

IEnumerable<CartLine> CartLines – Mandatory- A collection of cart lines to add.

ForceNewLines – Optional – If true, the cart lines items will be added as new cart lines in the customer cart. Otherwise, the lines will be merged into existing cart lines if possible.

Note

This parameter is only supported if the external commerce system supports this functionality.

Output:

Cart - Cart object that represent the updated cart in the external system.

AddedCartLineExternalIds – A list of the External IDs of the lines that were added to the cart.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
// Prepare parameters for getting cart for visitor ID Ivan in shop Autohaus
var createCartRequest = new CreateOrResumeCartRequest("Autohaus", "Ivan");
// Get a cart, new or existing
var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart;
// Create cart line with subline to add to the cart
var cartLines = new List<CartLine>(new Collection<CartLine> 
{ 
    new CartLine 
    { 
        Product = new CartProduct 
        { 
            ProductId = "Audi",
            Price = new Price(10000, "USD") },
Quantity = 1,
SubLines = new Collection<CartLine> 
            { 
new CartLine 
            {
                Product = new CartProduct 
                {
                    ProductId = "Winter Tyres",
                    Price = new Price(100, "USD") 
                },
                Quantity = 4 
            }, 
new CartLine 
            {
                Product = new CartProduct 
                { 
                    ProductId = "Summer Tyres",
                    Price = new Price(80, "USD") 
                }, 
                Quantity = 4 
            } 
            } 
    } 
}
);
// Create request with prefix and prefix lines
var request = new AddCartLinesRequest(cart, cartLines);
// Add prefix lines into prefix
var result = cartServiceProvider.AddCartLines(request);
var resultCart = result.Cart;

RemoveCartLines method

Name:

RemoveCartLines

Description:

Responsibility is to remove lines from cart.

Usage:

Called when one or more cart lines are about to be removed from the shopping cart, when the user updates the cart by removing one or more lines.

Signature:

RemoveCartLinesResult RemoveCartLines(RemoveCartLinesRequest request)

Input:

Cart - Mandatory. The cart must be unmodified. Any changes made to the cart instance will be disregarded. Only the cart Id and ShopName are considered for retrieving and modifying the cart.

IEnumerable<CartLine> CartLines – Mandatory - A collection of cart linesto remove.

ExternalCartLineId, LineNumber or the object reference can be used to identify the line(s) to be removed.

The default Connect based implementation removes lines by object reference.

Output:

Cart - Cart object that represents the updated cart in the external system.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
// Create cart with "Audi Q10", "BMW X7" and "Citroen C3"
var createCartRequest = new CreateOrResumeCartRequest("Autohaus", "John");
var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart;
var cartLine1 = new CartLine 
{ 
    Quantity = 1, 
    Product = new CartProduct 
    { 
        ProductId = "Audi Q10", 
        Price = new Price(55, "USD") 
    } 
};
            
var cartLine2 = new CartLine 
{ 
    Quantity = 2, 
    Product = new CartProduct 
    { 
        ProductId = "BMW X7", 
        Price = new Price(10, "USD") 
    } 
};
            
var cartLine3 = new CartLine 
{ 
    Quantity = 1, 
    Product = new CartProduct 
    { 
        ProductId = "Citroen C3", 
        Price = new Price(25, "USD") 
    } 
};
var cartLines = new Collection<CartLine>
{
    cartLine1, cartLine2, cartLine3
};
            
var addCartLinesRequest = new AddCartLinesRequest(cart, cartLines);
cart = cartServiceProvider.AddCartLines(addCartLinesRequest).Cart;
// Create request to remove cart line "BMW X7".      
var request = new RemoveCartLinesRequest(cart, cart.Lines.Where(l => l.Product.ProductId == "BMW X7").ToArray());
// Call service provider and receive the result.
var result = cartServiceProvider.RemoveCartLines(request);

UpdateCartLines method

Name:

UpdateCartLines

Description:

Responsibility is to update lines on cart.

Usage:

Occurs when a shopping cart is about to be updated referring to lines already in the cart. In terms of UI, it is when the user updates the cart regarding a specific product. Most typically it is when:

  • The quantity is changed.

  • A service is added such as insurance or shipping.

  • A promotion code is added for a given product.

  • A product is replaced with another variant.

Signature:

UpdateCartLinesResult UpdateCartLines(UpdateCartLinesRequest request)

Input:

Cart - Mandatory  - The cart must be unmodified. Any changes made to the cart instance will be disregarded. Only the cart Id and ShopName are considered for retrieving and modifying the cart.

IEnumerable<CartLine> CartLines – Mandatory- A collection of cart linesto update on cart.

Output:

Cart – Cart object that represents the updated cart in the external system.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
// Create cart with "Audi Q10", "BMW X7" and "Citroen C3"
var createCartRequest = new CreateOrResumeCartRequest("Autohaus", "John");
var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart;
var cartLine1 = new CartLine
{
    Quantity = 1,
    Product = new CartProduct
    {
        ProductId = "Audi Q10",
        Price = new Price(55, "USD")
    }
};
var cartLine2 = new CartLine
{
    Quantity = 2,
    Product = new CartProduct
    {
        ProductId = "BMW X7",
        Price = new Price(10, "USD")
    }
};
var cartLines = new Collection<CartLine> { cartLine1, cartLine2 };
var addCartLinesRequest = new AddCartLinesRequest(cart, cartLines);
cart = cartServiceProvider.AddCartLines(addCartLinesRequest).Cart;
var bmw = cart.Lines.First(i => i.Product.ProductId == "BMW X7");
bmw.Product.Price = new Price(110000, "USD");
bmw.Quantity = 3;
// Create request to update cart lines.
var updateCartLinesRequest = new UpdateCartLinesRequest(cart, new Collection<CartLine> { bmw });
// Call service provider and receive the result.
var result = cartServiceProvider.UpdateCartLines(updateCartLinesRequest);

DeleteCart method

Name:

DeleteCart

Description:

Responsibility is to delete a cart permanently:

  • The cart is deleted.

  • Trigger event in DMS telling that the cart is deleted.

Usage:

Must be called when a cart needs to be deleted.

In terms of the UI, this could be:

  • When the user has gone through the B2C scenario of paying and an order has been created and registered.

  • After a cart has been in an abandoned state for a given time and the visitor is not expected to return.

Signature:

DeleteCartResult DeleteCart(DeleteCartRequest request)

Input:

Cart - Mandatory. The cart must be unmodified. Any changes made to the cart instance will be disregarded. Only the cart Id and ShopName are considered for retrieving and modifying the cart.

Output:

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
// Create the request.
var createCartRequest = new CreateOrResumeCartRequest("Autohaus", "Bred");
// Call the service provider to get the cart
var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart;
// Read the id of the returned cart
var id = cart.ExternalId;
// Create request to remove the cart.
var deleteCartRequest = new DeleteCartRequest(cart);
// Call the service provider and receive the result.
cartServiceProvider.DeleteCart(deleteCartRequest);

UpdateCart method

Name:

UpdateCart

Description:

Responsibility is to pass an updated cart to the external commerce system.

Triggers an event in DMS telling that the cart is being updated.

Usage:

The method should be executed after any operation that modifies the cart, typically when Adjustments have been added, removed or modified.

Signature:

UpdateCartResult UpdateCart(UpdateCartRequest request)

Input:

Cart - Mandatory - The cart to be updated. The cart must be unmodified. Any changes made to the cart instance will be disregarded. Only the cart Id and ShopName are considered for retrieving and modifying the cart.

Cart Base – An instance of the Cart Base containing the changes to be made to the cart

Typically the only properties allowed to be modified are: UserId, CustomerId, CartName and, potentially, ShopName.

Whether the IsLocked and CartStatus values are considered, depends on business logic in the external commerce system.

Null values will not be considered, but blank values will be.

Output:

Cart – Cart object that represents the updated cart in the external system.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
// Create prefix.
var createCartRequest = new CreateOrResumeCartRequest("Autohaus", "Peter");
var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart;
// Create the instance of the CartBase with properties that should be changed in existing prefix.
var changes = new CartBase
{
    CustomerId = "Customer Peter",
    Name = "Peter's Cart",
    ShopName = "Autohaus"
};
// Create request to update the prefix.
var updateCartRequest = new UpdateCartRequest(cart, changes);
// Call service provider with prepared request and receive the result.
var result = cartServiceProvider.UpdateCart(updateCartRequest);

LockCart method

Name:

LockCart

Description:

Responsibility is to set the cart in a locked state where it is ready to be committed to an order but before any optional payment transaction is performed:

  • Set cart to locked and save it.

  • Triggers the event in DMS telling that the cart is in a locked state.

When the cart is in a locked state, it indicates two things:

  • It is not possible to modify the shopping cart content using the other service layer methods.

  • It is easy to identify the carts in a locked state in order to compare and confirm with payment transactions whether there are carts that have not been finalized due to some unforeseen incident in the checkout process.

There is a corresponding UnlockCart method. If the cart is locked when the LockCart method is called, the pipeline is aborted and nothing happens.

Usage:

Typically executed during the checkout process, just before any payment transaction is about to be executed and before turning the cart into an order. In terms of UI, it is triggered when a user in the checkout flow has clicked Confirm and in a B2C scenario is going to pay and the order is created.

Signature:

LockCartResult LockCart(LockCartRequest request)

Input:

Cart - Mandatory

Output:

Cart – Cart object that represent the updated cart in the external system.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
// Create a sample cart.
var createCartRequest = new CreateOrResumeCartRequest("Autohaus", "Jho");
var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart;
// Create request to lock this cart.
var lockCartRequest = new LockCartRequest(cart);
// Call service provider and receive the result.
var result = cartServiceProvider.LockCart(lockCartRequest);

UnlockCart method

Name:

UpdateCartLines

Description:

Responsibility is to set the cart in an unlocked state:

  • Sets the cart to unlocked and saves it.

  • Triggers an event in DMS telling that the cart is in a locked state.

By default a cart is in an unlocked state and can be edited.

There is a corresponding LockCart method, which sets the state to locked. If the cart is not locked when the UnlockCart method is called, the pipeline is aborted and nothing happens.

Usage:

Typically called if a user returns to a cart and decides to modify the content after starting the checkout process and payment transaction, but its implementation specifies how it should be handled.

Signature:

UnlockCartResult UnlockCart(UnlockCartRequest request)

Input:

Cart – Mandatory

Output:

Cart – Cart object that represents the updated cart in the external system.

SystemMessages - Collection of messages from the external system. This is how error conditions can be reported.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
// Create cart and lock it.
var createCartRequest = new CreateOrResumeCartRequest("Autohaus", "Mark");
var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart;
var lockCartRequest = new LockCartRequest(cart);
cart = cartServiceProvider.LockCart(lockCartRequest).Cart;
// Create request to unlock this cart.
var unlockCartRequest = new UnlockCartRequest(cart);
// Call service provider and receive the result.
var result = cartServiceProvider.UnlockCart(unlockCartRequest);

MergeCart method

Name:

MergeCart

Description:

Responsibility is to merge two specified carts:

  • Both carts must have identical shop names.

  • Both carts must have different ExternalIDs.

  • Cart1 and Cart2 cart line items are merged and returned.

Usage:

Typically called when a user logs in and the system notices an anonymous cart exists.

Signature:

CartResult MergeCart([NotNull] MergeCartRequest request)

Input:

UserCart – Mandatory

AnonymousCart - Mandatory

Output:

Cart – Cart object representing the merged user cart.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
var userCart = new Cart 
{ 
    ExternalId = "0", 
    ShopName = "first shop", 
    Lines  = new List<CartLine>
    {
        new CartLine
        {
            Quantity = 1,
            Product = new CartProduct
            {
                ProductId = "Audi Q10",
                Price = new Price(55, "USD")
            }
        }
    }
};
var anonymousCart = new Cart
{ 
    ExternalId = "1", 
    ShopName = "first shop", 
    Lines  = new List<CartLine>
    {
        new CartLine
        {
            Quantity = 1,
            Product = new CartProduct
            {
                ProductId = "BMW M5",
                Price = new Price(75, "USD")
            }
        }
    }
};
var request = new MergeCartRequest(userCart, anonymousCart);
var mergeredCart = cartServiceProvider.MergeCart(request).Cart;
cartServiceProvider.DeleteCart(new DeleteCartRequest(anonymousCart));

AddParties method

Name:

AddParties

Description:

Responsibility is to add parties to a cart.

Usage:

Typically called when adding party information to a cart.

Signature:

RequestResponse
AddPartiesResult AddParties([NotNull] AddPartiesRequest request)

Input:

Cart – Mandatory

Parties - Mandatory

Output:

Parties – The read-only list of all parties associated with this cart after the add.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
var createCartRequest = new CreateOrResumeCartRequest("Autohaus", "John");
var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart;
var partyList = new List<Party>
{
    new Party
    {
        PartyId = "123", FirstName = "Joe", LastName = "Smith", 
        Address1 = "123 Street", City = "Ottawa", 
        State = "Ontario", Country = "Canada"
    },
    new Party
    {
        PartyId = "456", FirstName = "Jane", LastName = "Smith", 
        Address1 = "234 Street", City = "Toronto", 
        State = "Ontario", Country = "Canada"
    } 
};
var addPartiesRequest = new AddPartiesRequest(cart, partyList);
var addPartiesResult = cartServiceProvider.AddParties(addPartiesRequest);

RemoveParties method

Name:

RemoveParties

Description:

Responsibility is to remove parties from a cart.

Usage:

Typically called when removing party information.

Signature:

RequestResponse
RemovePartiesResult RemoveParties([NotNull] RemovePartiesRequest request)

Input:

Cart – Mandatory

Parties – Mandatory – The list of parties to remove from the cart.

Output:

Parties – The read-only list of all parties associated with this cart after the remove.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
var createCartRequest = new CreateOrResumeCartRequest("Autohaus", "John");
var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart;
var partyList = new List<Party>
{
    new Party
    {
        PartyId = "123", FirstName = "Joe", LastName = "Smith", 
        Address1 = "123 Street", City = "Ottawa", 
        State = "Ontario", Country = "Canada"
    },
    new Party
    {
        PartyId = "456", FirstName = "Jane", LastName = "Smith", 
        Address1 = "234 Street", City = "Toronto", 
        State = "Ontario", Country = "Canada"
    } 
};
var addPartiesRequest = new AddPartiesRequest(cart, partyList);
var addPartiesResult = cartServiceProvider.AddParties(addPartiesRequest);
var removePartiesRequest = new RemovePartiesRequest(cart, new List<Party> 
{ 
    partyList[0] 
});
var removePartiesResult = cartServiceProvider.RemoveParties(removePartiesRequest);

UpdateParties method

Name:

UpdateParties

Description:

Responsibility is to update a list of parties within a cart.

Usage:

Typically called when parties need to be updated.

Signature:

RequestResponse
UpdatePartiesResult UpdateParties([NotNull] UpdatePartiesRequest request)

Input:

Cart – Required

Parties – Required – The list of parties to update in the cart.

Output:

Parties – The read-only list of all parties associated with this cart after the update.

Usage example:

RequestResponse
var cartServiceProvider = new CartServiceProvider();
var createCartRequest = new CreateOrResumeCartRequest("Autohaus", "John");
var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart;
var party1 = new Party
{
    PartyId = "123",
    FirstName = "Joe",
    LastName = "Smith",
    Address1 = "123 Street",
    City = "Ottawa",
    State = "Ontario",
    Country = "Canada"
};
var party2 = new Party
{
    PartyId = "456",
    FirstName = "Jane",
    LastName = "Smith",
    Address1 = "234 Street",
    City = "Toronto",
    State = "Ontario",
    Country = "Canada"
};
var partyList = new List<Party> { party1, party2 };
            
var addPartiesRequest = new AddPartiesRequest(cart, partyList);
var addPartiesResult = cartServiceProvider.AddParties(addPartiesRequest);
party1.Address1 = "678 Road";
party1.City = "London";
var updatePartiesRequest = new UpdatePartiesRequest(cart, new List<Party> { party1 });
var removePartiesResult = cartServiceProvider.UpdateParties(updatePartiesRequest);

AddPaymentInfo method

Name:

AddPaymentInfo

Description:

Responsibility is to add payment information to a cart.

Usage:

Typically called during a checkout flow to add the payment info for processing of an order.

Signature:

RequestResponse
AddPaymentInfoResult AddPaymentInfo([NotNull] AddPaymentInfoRequest request)

Input:

Cart – Mandatory

Payments – Mandatory – a list of payment info to be added to the cart.

Output:

Payments – The read-only list of payments associated with the cart after the add.

Usage example:

RequestResponse
var cartService = new CartServiceProvider();
var cart = cartService.CreateOrResumeCart(new 
    CreateOrResumeCartRequest("MyShop", "Me")).Cart;
var paymentList = new List<PaymentInfo>
{
    new PaymentInfo() { ExternalId = "1", PaymentMethodID = "1"},
    new PaymentInfo() { ExternalId = "2", PaymentMethodID = "2"}
};
var addPaymentRequest = new AddPaymentInfoRequest(cart, paymentList);
var addPaymentResult = cartService.AddPaymentInfo(addPaymentRequest);

RemovePaymentInfo method

Name:

RemovePaymentInfo

Description:

Responsibility is to remove payment information from a cart.

Usage:

Typically called when a user wants to change their payment information.

Signature:

RequestResponse
RemovePaymentInfoResult RemovePaymentInfo([NotNull] RemovePaymentInfoRequest request)

Input:

Cart – Mandatory

Payments – Mandatory– A list of payment info to be removed from the cart.

Output:

Payments – The read-only list of payments associated with the cart after the remove.

Usage example:

RequestResponse
var cartService = new CartServiceProvider();
var cart = cartService.CreateOrResumeCart(new 
    CreateOrResumeCartRequest("MyShop", "Me")).Cart;
var paymentList = new List<PaymentInfo>
{
    new PaymentInfo() { ExternalId = "1", PaymentMethodID = "1"},
    new PaymentInfo() { ExternalId = "2", PaymentMethodID = "2"}
};
var addPaymentRequest = new AddPaymentInfoRequest(cart, paymentList);
var addPaymentResult = cartService.AddPaymentInfo(addPaymentRequest);
var removePaymentRequest = new RemovePaymentInfoRequest(cart, new 
List<PaymentInfo> {paymentList[0]});
var removeResult = cartService.RemovePaymentInfo(removePaymentRequest);

AddShippingInfo method

Name:

AddShippingInfo

Description:

Responsibility is to add shipping information to a cart.

Usage:

Typically called during a checkout flow to add the shipping info for processing of an order.

Signature:

RequestResponse
AddShippingInfoResult AddShippingInfo([NotNull] AddShippingInfoRequest request)

Input:

Cart – Mandatory

ShippingInfo – Mandatory – A list of shipping info to add to the cart.

Output:

ShippingInfo – A read-only list of shipping info associated with the cart after the add.

Usage example:

RequestResponse
var cartService = new CartServiceProvider();
var cart = cartService.CreateOrResumeCart(new 
    CreateOrResumeCartRequest("MyShop", "Me")).Cart;
var shippingList = new List<ShippingInfo>
{
    new ShippingInfo() { ExternalId = "1", ShippingMethodID = "1"},
    new ShippingInfo() { ExternalId = "2", ShippingMethodID = "2"}
};
var addRequest = new AddShippingInfoRequest(cart, shippingList);
var addResult = cartService.AddShippingInfo(addRequest);

RemoveShippingInfo method

Name:

RemoveShippingInfo

Description:

Responsibility is to remove shipping information from a cart

Usage:

Typically called during a checkout flow to remove the shipping info for processing of an order.

Signature:

RequestResponse
RemoveShippingInfoResult RemoveShippingInfo([NotNull] RemoveShippingInfoRequest request)

Input:

Cart – Mandatory

ShippingInfo – Mandatory – A list of shipping info to remove from the cart.

Output:

ShippingInfo – A read-only list of shipping info associated with the cart after the remove.

Usage example:

RequestResponse
var cartService = new CartServiceProvider();
var cart = cartService.CreateOrResumeCart(new 
    CreateOrResumeCartRequest("MyShop", "Me")).Cart;
var shippingList = new List<ShippingInfo>
{
    new ShippingInfo() { ExternalId = "1", ShippingMethodID = "1"},
    new ShippingInfo() { ExternalId = "2", ShippingMethodID = "2"}
};
var addRequest = new AddShippingInfoRequest(cart, shippingList);
var addPaymentResult = cartService.AddShippingInfo(addRequest);
var removeRequest = new RemoveShippingInfoRequest(cart, new 
List<ShippingInfo> {shippingList[0]});
var removeResult = cartService.RemoveShippingInfo(removeRequest);

Do you have some feedback for us?

If you have suggestions for improving this article,