Checkout Service

CheckoutService is found in Poq.Shopify.Services namespace. It requires several dependencies to be used in your backend. All required dependencies should be registered using IoC:

services.AddScoped<ShopifyClientConfiguration, ShopifyClientConfiguration>();
services.AddScoped<IShopifyCheckoutClient, ShopifyCheckoutClient>();
services.AddScoped<IAccountService, AccountService>();
services.AddScoped<ICheckoutResponseModifier, CheckoutResponseModifier>();
services.AddScoped<IShopifyMultipassTokenGenerator, ShopifyMultipassTokenGenerator>();
services.AddScoped<ICheckoutService, CheckoutService>();

Explanation of services:

  • ShopifyClientConfiguration is part of Shopify SDK. It should be registered in IoC with correct settings.

  • IShopifyCheckoutClient is part of Shopify SDK. It should be registered in IoC with all required dependencies.

  • IAccountService is available as part of Shopify SDK.

  • ICheckoutResponseModifier with implementation CheckoutResponseModifier is responsible of creation response object returned from checkout/start.

  • IShopifyMultipassTokenGenerator with implementation ShopifyMultipassTokenGenerator This service is used only when MultipassToken is provided in configuration. It generates new access token to transfer shopify checkout.

  • ICheckoutService with implementation CheckoutService Checkout Service transfers Cart information from Poq Cart Api to Shopify. Service functionality and order items mapping can be modified by providing custom implementation of ICheckoutResponseModifier.

Here in an example of overriding default handling in ICheckoutResponseModifier.

services.AddScoped<ICheckoutResponseModifier, MyCheckoutResponseModifier>();
public class MyCheckoutResponseModifier : ICheckoutResponseModifier
Task<StartCartTransferResponse> CreateCheckoutResponseAsync(ShopifyCheckout shopifyCheckout, OrderInStartCartTransferResponse order)
var response = new StartCartTransferResponse
Url = shopifyCheckout.Url,
Method = "GET",
Order = order,
return Task.FromResult(response);
public OrderInStartCartTransferResponse CreateOrderResponse(CartWithProductsResponse cart, string channel, string currency)
var orderResponse = new OrderInStartCartTransferResponse
Channel = channel,
Currency = currency,
Reference = Guid.NewGuid().ToString(),
Subtotal = cart.Total.Now
foreach (var cartItem in cart.CartItems)
var oderResponseItem = new OrderItemInStartCartTransferResponse
CartItemId = cartItem.Id,
ExternalID = cartItem.ListingId,
Quantity = cartItem.Quantity,
Price = cartItem.Price.Was ?? cartItem.Price.Now,
Sku = cartItem.VariantId,
SpecialPrice = cartItem.Price.Now,
ProductTitle = cartItem.Title
return orderResponse;
public Task<List<ShopifyCheckoutLineItem>> CreateShopifyCheckoutItemsAsync(CartWithProductsResponse cart)
var shopifyItems = new List<ShopifyCheckoutLineItem>();
foreach (var item in cart.CartItems)
shopifyItems.Add(new ShopifyCheckoutLineItem
Quantity = item.Quantity,
VariantId = Convert.ToBase64String(
return Task.FromResult(shopifyItems);