Create an order for a customer of an indirect reseller
Article
How to create an order for a customer of an indirect reseller.
Prerequisites
Credentials as described in Partner Center authentication. This scenario supports authentication with App+User credentials only.
A customer ID (customer-tenant-id). If you don't know the customer's ID, you can look it up in Partner Center by selecting the Customers workspace, then the customer from the customer list, then Account. On the customer's Account page, look for the Microsoft ID in the Customer Account Info section. The Microsoft ID is the same as the customer ID (customer-tenant-id).
The offer identifier of the item to purchase.
The tenant identifier of the indirect reseller.
C#
To create an order for a customer of an indirect reseller:
Get a collection of the indirect resellers that have a relationship with the signed-in partner.
Get a local variable to the item in the collection that matches the indirect reseller ID. This step helps you access the reseller's MpnId property when you create the order.
Instantiate an Order object and set the ReferenceCustomerID property to the customer identifier in order to record the customer.
Create a list of OrderLineItem objects, and assign the list to the order's LineItems property. Each order line item contains the purchase information for one offer. Be sure to populate the PartnerIdOnRecord property in each line item with the PartnerID of the indirect reseller. You must have at least one order line item.
Obtain an interface to order operations by calling the IAggregatePartner.Customers.ById method with the customer ID to identify the customer, and then retrieve the interface from the Orders property.
// IAggregatePartner partnerOperations;// string customerId;// string offerId;// string indirectResellerId;// Get the indirect resellers with a relationship to the signed-in partner.var indirectResellers = partnerOperations.Relationships.Get(PartnerRelationshipType.IsIndirectCloudSolutionProviderOf);
// Find the matching reseller in the collection.var selectedIndirectReseller = (indirectResellers != null && indirectResellers.Items.Any()) ?
indirectResellers.Items.FirstOrDefault(reseller => reseller.Id.Equals(indirectResellerId, StringComparison.OrdinalIgnoreCase)) :
null;
// Prepare the order and populate the PartnerIdOnRecord with the reseller's Partner Id.var order = new Order()
{
ReferenceCustomerId = customerId,
LineItems = new List<OrderLineItem>()
{
new OrderLineItem()
{
OfferId = offerId,
FriendlyName = "New offer purchase.",
Quantity = 5,
PartnerIdOnRecord = selectedIndirectReseller != null ? selectedIndirectReseller.MpnId : null
}
}
};
// Place the order.var createdOrder = partnerOperations.Customers.ById(customerId).Orders.Create(order);
Sample: Console test appProject: Partner Center SDK Samples Class: PlaceOrderForCustomer.cs
This table describes the Order properties in the request body.
Name
Type
Required
Description
id
string
No
An order identifier that is supplied upon successful creation of the order.
referenceCustomerId
string
Yes
The customer identifier.
billingCycle
string
No
The frequency with which the partner is billed for this order. The default is "Monthly" and is applied upon successful creation of the order. Supported values are the member names found in BillingCycleType. Note: the annual billing feature isn't yet generally available. Support for annual billing is coming soon.
The date the order was created, in date-time format. Applied upon successful creation of the order.
attributes
object
No
Contains "ObjectType": "Order"
OrderLineItem
This table describes the OrderLineItem properties in the request body.
Name
Type
Required
Description
lineItemNumber
int
Yes
Each line item in the collection gets a unique line number, counting up from 0 to count-1.
offerId
string
Yes
The offer identifier.
subscriptionId
string
No
The subscription identifier.
parentSubscriptionId
string
No
Optional. The ID of the parent subscription in an add-on offer. Applies to PATCH only.
friendlyName
string
No
Optional. The friendly name for the subscription defined by the partner to help disambiguate.
quantity
int
Yes
The number of licenses for a license-based subscription.
partnerIdOnRecord
string
No
When an indirect provider places an order on behalf of an indirect reseller, populate this field with the PartnerID of the indirect reseller only (never the ID of the indirect provider). This ensures proper accounting for incentives. Failure to provide the reseller PartnerID does not cause the order to fail. However, the reseller isn't recorded and as a consequence incentive calculations might not include the sale.
If successful, the response body contains the populated Order resource.
Response success and error codes
Each response comes with an HTTP status code that indicates success or failure and additional debugging information. Use a network trace tool to read this code, error type, and additional parameters. For the full list, see Partner Center error codes.
This module is a guided lab experience for Microsoft Dynamics 365 Intelligent Order Management. Optimize order management, coordinating and standardizing orders across channels and systems.