Create an order for a customer of an indirect reseller
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.
Call the Create or CreateAsync method to create the order.
C# example
// 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
REST request
Request syntax
Method | Request URI |
---|---|
POST | {baseURL}/v1/customers/{customer-id}/orders HTTP/1.1 |
URI parameters
Use the following path parameter to identify the customer.
Name | Type | Required | Description |
---|---|---|---|
customer-id | string | Yes | A GUID formatted string that identifies the customer. |
Request headers
For more information, see Partner Center REST headers.
Request body
Order
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. |
lineItems | array of objects | Yes | An array of OrderLineItem resources. |
creationDate | string | No | 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. |
attributes | object | No | Contains "ObjectType":"OrderLineItem". |
Request example
POST https://api.partnercenter.microsoft.com/v1/customers/c501c3c4-d776-40ef-9ecf-9cefb59442c1/orders HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 02109f46-3ff2-4be4-9f37-b2eb6d58d542
MS-CorrelationId: 85195ae6-3de5-4978-abd4-7be2fbfe4c84
X-Locale: en-US
Content-Type: application/json
Host: api.partnercenter.microsoft.com
Content-Length: 410
Expect: 100-continue
{
"Id": null,
"ReferenceCustomerId": "c501c3c4-d776-40ef-9ecf-9cefb59442c1",
"BillingCycle": "unknown",
"LineItems": [{
"LineItemNumber": 0,
"OfferId": "DB2E705F-B82A-4024-A3D5-D88E12F2DB35",
"SubscriptionId": null,
"ParentSubscriptionId": null,
"FriendlyName": "New offer purchase.",
"Quantity": 5,
"PartnerIdOnRecord": "4847383",
"Attributes": {
"ObjectType": "OrderLineItem"
}
}
],
"CreationDate": null,
"Attributes": {
"ObjectType": "Order"
}
}
REST response
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.
Response example
HTTP/1.1 201 Created
Content-Length: 831
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 85195ae6-3de5-4978-abd4-7be2fbfe4c84
MS-RequestId: 02109f46-3ff2-4be4-9f37-b2eb6d58d542
MS-CV: Nd3Oum/L5EywtKQK.0
MS-ServerId: 020021921
Date: Mon, 10 Apr 2017 23:02:24 GMT
{
"id": "3eddcac6-63b2-4c40-b0b6-f47e18301492",
"referenceCustomerId": "c501c3c4-d776-40ef-9ecf-9cefb59442c1",
"billingCycle": "monthly",
"lineItems": [{
"lineItemNumber": 0,
"offerId": "DB2E705F-B82A-4024-A3D5-D88E12F2DB35",
"subscriptionId": "42226ED6-070A-4E0F-B80C-4CDFB3E97AA7",
"friendlyName": "New offer purchase.",
"quantity": 5,
"partnerIdOnRecord": "4847383",
"links": {
"subscription": {
"uri": "/customers/c501c3c4-d776-40ef-9ecf-9cefb59442c1/subscriptions/42226ED6-070A-4E0F-B80C-4CDFB3E97AA7",
"method": "GET",
"headers": []
}
}
}
],
"creationDate": "2017-04-10T16:02:25.983-07:00",
"links": {
"self": {
"uri": "/customers/c501c3c4-d776-40ef-9ecf-9cefb59442c1/orders/3eddcac6-63b2-4c40-b0b6-f47e18301492",
"method": "GET",
"headers": []
}
},
"attributes": {
"etag": "eyJpZCI6IjNlZGRjYWM2LTYzYjItNGM0MC1iMGI2LWY0N2UxODMwMTQ5MiIsInZlcnNpb24iOjF9",
"objectType": "Order"
}
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for