Interactive edition · Version 1 · Commerce SDK 9.60 for application version 10.0.50
Dynamics 365 Commerce Development: From Zero to Professional
This book takes a C# developer with no Commerce background to the point of shipping production extensions for Dynamics 365 Commerce. It covers every layer you will touch: the Commerce Runtime, the headless Commerce APIs, the Store Commerce point of sale, the hardware station, the channel database, and the headquarters side in X++.
Chapters 1 and 2 are free to read here. The other 23 chapters, the appendix, five more animations and their quizzes open after purchase.
- chapters
- 23
- code listings
- 79
- diagrams
- 16
- animations
- 6
- quiz questions
- 69
Contents
Foundations
Chapters 1 to 4
Commerce Runtime and APIs
Chapters 5 to 10
Store Commerce
Chapters 11 to 15
Headquarters and shipping
Chapters 18 to 22
Going further
Chapters 24 to 25
Animations
Front matter
About this book
This book takes a C# developer with no Commerce background to the point of shipping production extensions for Dynamics 365 Commerce. It covers every layer you will touch: the Commerce Runtime, the headless Commerce APIs, the Store Commerce point of sale, the hardware station, the channel database, and the headquarters side in X++.
Every chapter follows the same pattern: the concept, a diagram of the flow, the steps, working code, the mistakes that cost real projects time, and a short checklist.
Who this book is for
You write C# comfortably. You know what a REST API is and you can read TypeScript. You have never built a Commerce extension, or you have copied one and want to understand it. No X++ experience is assumed; chapter 18 teaches the small part you need.
What this book does not cover
The e-commerce storefront and its online SDK. The APIs you build here can be called from a storefront, but building pages and modules is a separate skill.
Functional setup of headquarters beyond the steps an extension needs.
Fiscal device and tax authority integrations in depth. Chapter 9 points to the framework Commerce provides for them.
The legacy Retail SDK folder model used before version 10.0.19.
What you need
| Item | Why |
|---|---|
| A finance and operations developer machine: a cloud-hosted environment or the downloadable VHD | Headquarters, SQL Server, IIS, and Visual Studio are already on it; chapter 3 adds the rest |
| Visual Studio 2026 | The only editor this book uses, for C#, TypeScript, and X++ |
| .NET 10 SDK and .NET Framework 4.7.2 developer pack | Required by the 9.60 samples; installers target .NET Framework. Older branches pin their SDK in global.json |
| SQL Server | Already on the developer machine; hosts the channel database of your scale unit |
| Access to Lifecycle Services | The sealed scale unit and Store Commerce installers |
| Access to the Commerce NuGet feed | SDK packages are published on the dynamics365-commerce feed |
| The two sample repositories | Dynamics365Commerce.ScaleUnit and Dynamics365Commerce.InStore |
Book version
This is version 1 of the book, released on 1 December 2026. The version is printed on the cover. Quote it when you report a mistake, so that the fix can be matched to the text you read.
Which SDK this book uses
The book uses the current Commerce SDK: independent packaging, NuGet-based references, and sealed installers. It does not teach the legacy Retail SDK folder model. Code was checked against the official samples on branch release/9.60, which maps to application version 10.0.50. At the time of writing, 10.0.50 is in preview and 9.59 (10.0.49) is the newest generally available SDK; the code applies unchanged to it. The branch for application version 10.0.XX is release/9.(XX + 10). Package versions move every release, so always match the SDK version to the scale unit you deploy to (chapter 19 explains the rule).
How the code was checked
Every pattern in this book was compared with Microsoft's sample repositories or with a Microsoft documentation page, listed under Sources in the appendix. Nothing was compiled against a live Commerce environment while writing.
A few member names come from Microsoft's documentation or long-standing API usage and do not appear in the current samples: Where and Parameters on SqlPagedQuery, InventLocationDataAreaId, ActiveSalesLines, and the Id, StoreId, and TerminalId properties of a sales transaction, and the name and value properties of a configuration parameter. All of them were later confirmed against the documentation shipped inside the 9.59 SDK packages.
How the book is organised
| Part | Chapters | After it you can |
|---|---|---|
| Foundations | 1 to 4 | Explain the architecture, set up a machine, and ship a first extension |
| Commerce Runtime and APIs | 5 to 10 | Add business logic, data, headquarters calls, external calls, and new APIs |
| Store Commerce | 11 to 15 | Build views, operations, triggers, and receipt changes in the point of sale |
| Hardware and payments | 16 to 17 | Drive a new device and integrate a payment terminal |
| Headquarters and shipping | 18 to 22 | Sync custom data, package, automate releases, debug, and tune |
| Capstone | 23 | Build one complete feature across every layer |
| Going further | 24 to 25 | Build a custom app for Android, iOS, and Mac; Install a scale unit in a store or a datacentre |
The running example: Contoso Warranty
One feature runs through the whole book, so each chapter adds a real piece instead of an isolated sample. A cashier sells an extended warranty for an item in the cart.
| Layer | What we build | Chapter |
|---|---|---|
| Headquarters | A warranty policy table and its sync job | 18 |
| Channel database | Extension tables for policies and sold warranties | 7 |
| Commerce Runtime | A service that reads policies and validates a sale | 5, 6 |
| Real-time service | A cross-store warranty lookup | 8 |
| External API | A serial number check with the manufacturer | 9 |
| Commerce API | A controller the point of sale can call | 10 |
| Store Commerce | A button, a dialog, a cart column, and a blocking rule | 12 to 14 |
| Receipt | A warranty line on the printed receipt | 15 |
| Packaging | One scale unit package and one store installer | 19 |
| Mobile | The same feature in a custom app for Android, iOS, and Mac, offline included | 24 |
Conventions
All custom objects carry the prefix
Contoso. Use your own company prefix in real projects.Code is trimmed to what teaches the point. The capstone chapter lists the full file layout.
Each chapter ends with a Watch link where an official video exists, and a Read list of official pages.
Chapter 1 · Foundations
The Commerce architecture a developer must know
A Commerce feature is never one piece of code. It is a request that travels from the point of sale, through an API, into the business logic, down to a database, and sometimes up to headquarters. Before you write an extension, you must know which box your code runs in.

Store Commerce never talks to the runtime or the database directly. It calls an API, and the API hands a request to the Commerce Runtime, which is the only place that reads the channel database or calls headquarters.
The six places your code can run
| Place | Technology | What it owns | What you add there |
|---|---|---|---|
| Commerce headquarters | X++ in finance and operations | Master data, configuration, posting | Tables, forms, sync jobs, real-time service methods |
| Headless Commerce APIs (Retail Server) | C#, OData on ASP.NET Core | The API surface every client calls | Controllers that expose new APIs |
| Commerce Runtime (CRT) | C# | All channel business logic | Request handlers and triggers |
| Channel database | SQL Server | Channel data and transactions | Tables, views, and procedures in the ext schema |
| Store Commerce | TypeScript, HTML, CSS | The cashier experience | Views, dialogs, operations, triggers |
| Hardware station | C# | Printers, drawers, scanners, payment terminals | Device handlers and payment connectors |
The APIs, the CRT, and the channel database ship together as the Commerce Scale Unit. Microsoft calls that trio the headless commerce engine. The API layer runs on ASP.NET Core: it became the default in 10.0.22 and the only option from 10.0.38, so a page that describes the older ASP.NET host is out of date.
One request, end to end
Follow one tap on the screen. The cashier selects Add warranty on a cart line.
A Store Commerce operation starts in TypeScript.
The operation calls a Commerce API through a generated TypeScript proxy.
Retail Server checks the device token and the worker, then hands a request object to the CRT.
The CRT runs any pre-triggers, then the handler, then any post-triggers.
The handler reads the channel database. If the answer lives in headquarters, it makes a real-time service call. If it lives outside Commerce, it calls an external API.
The response returns along the same path, and Store Commerce refreshes the cart.
Every chapter in this book adds code to one of those six steps.
Online and offline: one CRT, two hosts
When the register is online, the CRT runs inside the scale unit. A Store Commerce register with offline enabled also carries its own copy of the CRT and a local database, and uses them when the scale unit cannot be reached. Offline mode exists in Store Commerce for Windows and in custom mobile apps built with the Store Commerce SDK (Android and iOS from 10.0.45, Mac from 10.0.49). The mobile apps published in the app stores and Store Commerce for web have no offline mode.
This has two consequences for you:
A CRT extension that must work offline ships twice: once in the scale unit package and once in the store installer.
Code that runs offline cannot reach headquarters. Any feature that depends on a real-time call needs a defined offline behaviour.
How data moves
| Path | Direction | Timing | Use it for |
|---|---|---|---|
| Commerce Data Exchange download | Headquarters to channel database | Scheduled | Master data and configuration |
| Commerce Data Exchange upload | Channel database to headquarters | Scheduled | Transactions and custom transaction data |
| Real-time service | CRT to headquarters | Immediate | Data that must be current across all stores |
Read from the channel database whenever you can. A real-time call adds latency to the cashier and fails when headquarters is unreachable.
Choosing the layer
| You need to | Put the code in |
|---|---|
| Change what the cashier sees or taps | Store Commerce |
| Enforce a business rule for every client | CRT trigger |
| Compute or store something new | CRT handler plus an ext table |
| Let a client call your logic | Commerce API controller |
| Use data maintained by back-office users | Headquarters table plus a download job |
| Check something that changes minute by minute across stores | Real-time service method |
| Talk to a device | Hardware station |
A rule enforced only in Store Commerce is not enforced. E-commerce and third-party clients call the same APIs and skip your TypeScript.
Checklist
Watch: Dynamics 365 Commerce: Store Commerce app (FastTrack Architecture Insights; the Commerce SDK part starts at 08:32).
Read: Commerce architecture overview and Headless commerce architecture.
Check yourself
Three questions on this chapter.
1. Store Commerce needs the warranty policies for an item. How does it reach the channel database?
Store Commerce never talks to the runtime or the database directly. Every call enters through an API, and only the Commerce Runtime reads the channel database.
2. Which language do you use for extensions in headquarters?
Headquarters extensions are written in X++: tables, forms, sync jobs, and real-time service methods.
3. What is true of the real-time service?
The real-time service is an immediate call from the runtime to headquarters. It has no offline mode, so every use needs a designed fallback.
Chapter 2 · Foundations
The extension model
Commerce is extended, never modified. You add assemblies, scripts, and TypeScript beside the product, and Microsoft updates the product without touching your code. That contract holds only while you stay inside the supported extension points.
The extension package
Everything you build for the channel side belongs to one extension package. The package has a name, a publisher, and a version, and those values are shared by every project through one file.
<!-- CustomizationPackage.props -->
<Project>
<Import Project="..\..\repo.props" />
<PropertyGroup>
<PackagePublisher Condition="'$(PackagePublisher)' == ''">$(Publisher)</PackagePublisher>
<PackagePublisherDisplayName Condition="'$(PackagePublisherDisplayName)' == ''">$(PublisherDisplayName)</PackagePublisherDisplayName>
<PackageVersion Condition="'$(PackageVersion)' == ''">$(Version)</PackageVersion>
<PackageName Condition="'$(PackageName)' == ''">Contoso.Warranty</PackageName>
<PackageDisplayName Condition="'$(PackageDisplayName)' == ''">Contoso Warranty</PackageDisplayName>
<PackageDescription Condition="'$(PackageDescription)' == ''">Extended warranty sales in Store Commerce</PackageDescription>
</PropertyGroup>
</Project>Every project imports this file. One package then deploys to two targets: the scale unit, and the store machines.
What you may do in each layer
| Layer | Supported | Not supported |
|---|---|---|
| Commerce Runtime | New requests and handlers, pre and post triggers, handler overrides, extension properties | Calling classes from Runtime.Workflow, Runtime.Services, or Runtime.DataServices |
| Commerce APIs | New controllers that implement IController | Inheriting from the standard controllers |
| Channel database | New tables, views, procedures, and types in the ext schema | Changing objects or data in the ax, crt, or dbo schemas |
| Store Commerce | New views, dialogs, operations, and request handlers; triggers; view extensions; overrides of the listed request handlers | Editing standard views or relying on their internal markup |
| Hardware station | New device handlers, new controllers, payment connectors | Replacing the hardware station host |
| Headquarters | X++ class extensions, event handlers, new objects | Overlayering standard code |
In the CRT, reference only the request, response, and entity types from the Messages, Framework, Data, and Entities namespaces. Microsoft does not keep the internal service classes backward compatible, so a reference to them breaks on upgrade.
Create or extend
Store Commerce splits every extension into two groups, and the manifest uses the same two words.
| Group | Meaning | Examples |
|---|---|---|
| Create | Something that did not exist | A warranty view, a dialog, a new operation |
| Extend | A change to something standard | A column in the cart, a trigger before payment, an override of a serial number prompt |
Prefer the lightest tool
Use this order. Move down only when the option above cannot do the job.
Configuration in headquarters, such as attributes, screen layouts, and receipt formats.
A trigger before or after the standard logic.
A new request and handler beside the standard logic.
An override of a standard handler that still calls the original.
A full replacement of a standard handler.
Every step down is more code to retest on each update. A full replacement also hides any improvement Microsoft later makes to that handler.
Enabling the package
Store Commerce loads your package only when the scale unit says the package is enabled. The scale unit asks the CRT for the list, and your CRT extension adds itself with a post-trigger. Without this class, the build succeeds, the installer succeeds, and nothing appears in the point of sale.
namespace Contoso.Warranty.CommerceRuntime.Triggers
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Dynamics.Commerce.Runtime;
using Microsoft.Dynamics.Commerce.Runtime.DataModel;
using Microsoft.Dynamics.Commerce.Runtime.Messages;
public class DefinePosExtensionPackageTrigger : IRequestTriggerAsync
{
public IEnumerable<Type> SupportedRequestTypes =>
new[] { typeof(GetExtensionPackageDefinitionsRequest) };
public Task OnExecuting(Request request) => Task.CompletedTask;
public Task OnExecuted(Request request, Response response)
{
ThrowIf.Null(request, nameof(request));
ThrowIf.Null(response, nameof(response));
var definitions = (GetExtensionPackageDefinitionsResponse)response;
definitions.ExtensionPackageDefinitions.Add(new ExtensionPackageDefinition
{
Name = "Contoso.Warranty",
Publisher = "Contoso",
IsEnabled = true,
});
return Task.CompletedTask;
}
}
}Keep three values identical: PackageName in the props file, name in the Store Commerce manifest.json, and Name in this trigger. Publisher here matches publisher in the manifest. From 9.60 a custom mobile app can carry more than one extension package. Each PackageName is then a separate package, and each one must be listed by this trigger and enabled on the scale unit.
Mistakes that cost projects time
A rule placed only in TypeScript, then bypassed by another channel.
A handler replaced when a post-trigger would have done the job.
A table added to the
axschema because the standard table was nearby.The enabling trigger left out, followed by a day spent reinstalling the app.
One package name in the props file and another in the manifest.
Checklist
Read: Commerce runtime extensibility and POS extension basics.
Check yourself
Three questions on this chapter.
1. A requirement could be met by configuration, a trigger, or a full replacement of a standard handler. Which do you try first?
Prefer the lightest tool. Every step down the list is more code to retest on each update, and a full replacement hides later improvements from Microsoft.
2. Which Microsoft packages may an extension project reference?
The SDK packages are the supported surface. Anything else can change or disappear in an update.
3. What should every custom table, key, operation and class carry?
A prefix keeps your objects from colliding with Microsoft's and with other extensions on the same environment.
Chapter 3 · Foundations
Setting up the development environment
This chapter is part of the full book.
In this chapter
- What the developer machine already has
- Step 1: Check Visual Studio and add the runtimes
- Step 2: Get the samples from GitHub
- Step 3: Know what you cloned
- Step 4: Understand the four files that control versions
- Step 5: Download the sealed installers
- Step 6: Install the scale unit on the machine
- Step 7: Build, deploy, and debug in Visual Studio
- Step 8: Prepare Store Commerce
- When the first build or install fails
Chapter 4 · Foundations
Your first extension, end to end
This chapter is part of the full book.
In this chapter
- The solution layout
- Choose the target framework for the CRT project
- Step 1: Rename the package
- Step 2: Remove what you do not need
- Step 3: Add one API
- Step 4: Build, deploy, and call
- What just happened
- Why the anonymous role is here, and why it must go
- Where the outputs land
Chapter 5 · Commerce Runtime and APIs
Commerce Runtime requests, responses, and handlers
This chapter is part of the full book.
In this chapter
- The three types
- Step 1: Define an entity
- Step 2: Define the request and the response
- Step 3: Write the handler
- Step 4: Call it
- Overriding a standard handler
- Rules that keep handlers safe
Chapter 6 · Commerce Runtime and APIs
Commerce Runtime triggers
This chapter is part of the full book.
In this chapter
- The interface
- A pre-trigger that blocks a bad cart
- A post-trigger that enriches a response
- Where an ext setting is defined
- Requests worth knowing
- Three ways triggers go wrong
Chapter 7 · Commerce Runtime and APIs
Extending data
This chapter is part of the full book.
In this chapter
- Extension properties
- The channel database project
- A table that receives data from headquarters
- A table that sends data to headquarters
- Saving extension properties with the sale
- Offline and mobile databases
Chapter 8 · Commerce Runtime and APIs
Calling headquarters with the real-time service
This chapter is part of the full book.
In this chapter
- When it is the right tool
- Step 1: Write the X++ method
- Step 2: Call it from the CRT
- Step 3: Wrap the call in a service with a failure path
- What happens offline
- Design rules
Chapter 9 · Commerce Runtime and APIs
Calling external APIs from the Commerce Runtime
This chapter is part of the full book.
In this chapter
- Decide the contract first
- Where configuration and secrets live
- A serial number check
- Calls that can wait: store and forward
- Before you build a tax authority integration
- Where the call leaves from
Chapter 10 · Commerce Runtime and APIs
Headless Commerce APIs
This chapter is part of the full book.
In this chapter
- Anatomy of a controller
- The roles
- The warranty controller
- What belongs in a controller, and what does not
- Calling the API from Store Commerce
- Calling the API from other clients
- API design rules
Chapter 11 · Store Commerce
Store Commerce extension anatomy
This chapter is part of the full book.
In this chapter
- The project
- A folder layout that scales
- The manifest
- The API has three families
- The context object
- The result pattern
- Strings
- How the package reaches a register
Chapter 12 · Store Commerce
Store Commerce views, dialogs, and controls
This chapter is part of the full book.
In this chapter
- Standard dialogs
- A view extension: a warranty column in the cart
- Which standard views you can extend
- A templated dialog
- A custom view
- What the sample teaches about views
Chapter 13 · Store Commerce
Store Commerce operations, buttons, and commands
This chapter is part of the full book.
In this chapter
- How a button reaches your code
- The four files
- Knowing which line is selected
- The handler
- Register the operation in the manifest
- Register the operation in headquarters
- Other ways to start code
Chapter 14 · Store Commerce
Store Commerce triggers and request handlers
This chapter is part of the full book.
In this chapter
- Three kinds of trigger
- A cancelable trigger
- A data modification trigger
- A post-trigger
- Trigger types seen in Microsoft's samples
- Overriding a standard request handler
- Your own client request
- Client trigger or CRT trigger
Chapter 15 · Store Commerce
Receipts and printing
This chapter is part of the full book.
In this chapter
- How a receipt is produced
- Step 1: Define the field in headquarters
- Step 2: Know where the data comes from
- Step 3: Write the receipt handler
- Images and codes
- Controlling when receipts print
- Testing a receipt without a printer
- Mistakes seen in real projects
Chapter 16 · Hardware and payments
Hardware station extensions
This chapter is part of the full book.
In this chapter
- Where the hardware station runs
- The project
- Pattern 1: A new endpoint
- Calling the endpoint from Store Commerce
- Pattern 2: Wrap a standard device
- Choosing a pattern
- Field rules
Chapter 17 · Hardware and payments
Payment connectors
This chapter is part of the full book.
In this chapter
- The vocabulary
- Where the code runs
- The shape of a card-present connector
- The life of one card payment
- The hard part: lost answers
- Rules that are not negotiable
- Configuration in headquarters
- Testing matrix
Chapter 18 · Headquarters and shipping
The headquarters side
This chapter is part of the full book.
In this chapter
- X++ for C# developers, in one table
- What we build
- Step 1: Create the model
- Step 2: Create the tables
- Step 3: Describe the sync in a resource file
- Step 4: Register the resource
- Step 5: Initialize the scheduler
- Step 6: Verify, in this order
- Reading the data in X++
- Where sync goes wrong
Chapter 19 · Headquarters and shipping
Packaging
This chapter is part of the full book.
In this chapter
- What goes where
- The scale unit package
- The Store Commerce installer
- The version rules
- One property that changed between versions
- Versioning your own package
- Signing
- Deployment order for a release
Chapter 20 · Headquarters and shipping
Build and release pipelines
This chapter is part of the full book.
In this chapter
- The principle: build once, promote the same files
- Branching
- The build pipeline
- The pull request build
- The release pipeline
- The headquarters pipeline
- Environment-specific values
- Rollback
Chapter 21 · Headquarters and shipping
Debugging, logging, and troubleshooting
This chapter is part of the full book.
In this chapter
- Find the box
- Debugging the scale unit
- Debugging Store Commerce
- Logging that helps at two in the morning
- Where the logs are
- Symptoms and causes
- A habit worth more than any tool
Chapter 22 · Headquarters and shipping
Performance, upgrades, and professional practice
This chapter is part of the full book.
In this chapter
- Where time goes at the register
- Performance rules for the CRT
- Performance rules for Store Commerce
- Measure before and after
- Designing for upgrades
- The store test script
- Security review, before someone else does it
- What professionals do that beginners skip
Chapter 23 · Capstone
Capstone, the complete Contoso Warranty feature
This chapter is part of the full book.
In this chapter
- What the feature does
- The repository
- The project registry
- Build order
- The complete manifest
- Headquarters setup for the release
- Acceptance script
- Exercises
Chapter 24 · Going further
A custom Store Commerce app for mobile
This chapter is part of the full book.
In this chapter
- The store app or your own app
- What you need
- Step 1: Add the mobile dependencies
- Step 2: Start from Microsoft's sample
- Step 3: Embed your extensions
- Step 4: Make the database work offline
- Step 5: The hardware station inside the app
- Step 6: One or more extension packages
- Step 7: Build, run, and debug
- Step 8: Activate and test offline
- Signing and distribution
- When the build fails
Chapter 25 · Going further
Installing a self-hosted Commerce Scale Unit
This chapter is part of the full book.
In this chapter
- Cloud or self-hosted
- The order of work
- Step 1: Prepare the machine
- Step 2: Certificates
- Step 3: Register the apps in Microsoft Entra ID
- Step 4: Configure headquarters
- Step 5: Run the installer
- Step 6: Run the first sync and check
- Step 7: Install your extensions
- Step 8: Activate the registers
- Keeping it running
- When it does not work
Appendix
Cheat sheets, glossary, and further reading
This chapter is part of the full book.
In this chapter
- Projects, frameworks, and packages
- Version mapping
- Commerce Runtime quick reference
- Store Commerce quick reference
- Channel database quick reference
- Sync jobs mentioned in this book
- Headquarters pages used in this book
- Glossary
- Samples worth opening
- Watch
- Sources





