web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Unanswered

D365 Commerce External integration - Create Sales

(0) ShareShare
ReportReport
Posted on by 110

Hi Everyone;

I'm trying to create retail transaction using external app integration; I achieved to query some data like sales orders, customers and create new customer, but I haven't create sales. Does anyone know what is the minimum fields that are required?

namespace MyCustom.Integracion
{


class Program
{

static void Main(string[] args)
{

GetConfiguration();

Cart newCart = new Cart()
{

//fields minimun requiered

}

var createdCart = Task.Run(async () => await CreateCart(newCart)).Result;
Console.WriteLine(string.Format("New cart created: {0}", createdCart?.Name));

}

private static void GetConfiguration()
{
clientId = ConfigurationManager.AppSettings["aadClientId"];
clientSecret = ConfigurationManager.AppSettings["aadClientSecret"];
authority = new Uri(ConfigurationManager.AppSettings["aadAuthority"]);
retailServerUrl = new Uri(ConfigurationManager.AppSettings["retailServerUrl"]);
operatingUnitNumber = ConfigurationManager.AppSettings["operatingUnitNumber"];
resource = ConfigurationManager.AppSettings["resource"];
}

private static async Task<ManagerFactory> CreateManagerFactory()
{
//System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext authenticationContext = new Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext(authority.ToString(), false);

Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult authResult = null;
authResult = await authenticationContext.AcquireTokenAsync(resource, new Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential(clientId, clientSecret));

Microsoft.Dynamics.Commerce.RetailProxy.Authentication.ClientCredentialsToken clientCredentialsToken = new Microsoft.Dynamics.Commerce.RetailProxy.Authentication.ClientCredentialsToken(authResult.AccessToken);
RetailServerContext retailServerContext = RetailServerContext.Create(retailServerUrl, operatingUnitNumber, clientCredentialsToken);
ManagerFactory factory = ManagerFactory.Create(retailServerContext);
return factory;
}

private static async Task<Cart> CreateCart(Cart cart)
{
ManagerFactory managerFactory = await CreateManagerFactory();
ICartManager cartManage = managerFactory.GetManager<ICartManager>();
return await cartManage.Create(cart);
}

}

}

Thanks in advance.

I have the same question (0)
  • ToddB Profile Picture
    Microsoft Employee on at

    Hi Adolfo,

    Please take a look at the code for ShoppingApp (that we ship as part of sample extension) which would be calling all these APIs.:

     

    SampleExtensions

    This folder contains the sample projects and templates for extensions:

    ·         CommerceRuntime â€“ Sample extension projects for business logic extensions (Commerce runtime [CRT] triggers, handlers, and new service extension).

    ·         HardwareStation â€“ Sample Hardware station extension projects.

    ·         HybridApp â€“ Android and iOS shell apps for the POS. Extension can build these apps and deploy them to the Android and iOS platforms.

    ·         OnlineStore â€“ The sample online storefront app.

    ·         RetailProxy â€“ The sample C# proxy project for POS offline mode. As of version 10.0.11, the C# proxy is obsolete (deprecated). The Retail server extension libraries can be used directly in offline mode. You don't have to have separate proxy libraries.

    ·         RetailServer â€“ Sample Retail server extension projects.

    ·         SampleExtensionsTest â€“ The sample project for creating an extension test project.

    ·         ShoppingApp â€“ The sample mobile app (Retailer shopping app) for users in Android and iOS.

    ·         TypeScriptProxy â€“ Sample proxy projects that show how to generate TypeScript for the POS.

  • Adolfome9 Profile Picture
    110 on at

    Hi Todd;

    Thank you, I will check it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 155 Super User 2026 Season 1

#2
Laurens vd Tang Profile Picture

Laurens vd Tang 101 Super User 2026 Season 1

#3
Zain Mehmood Profile Picture

Zain Mehmood 89 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans