Loading
Salesforce から送信されるメールは、承認済ドメインからのみとなります続きを読む

Create Orders on behalf of customer via OCAPI in B2C Commerce

公開日: Feb 27, 2026
説明

The information provided in this article outline how an OCAPI implementation can create an order using OCAPI. The steps describe an order creation which places an order in CREATED state but please note that the payment authorization step after this is not included.  This should be used as a reference where OCAPI implementations need to create an order on behalf of the customer. The postman collection is attached.

 

Example scenarios
- Automatic recurring orders
- Customer service center

 

Pre-requisites:

  • Add customerNo to assign the order to a registered customer 
  • Since SSO is enabled, BM User password will be Access Key (Use Type: Agent User Login and OCAPI for Access key)

Endpoints/Request Calls flow:

  1. /dw/oauth2/access_token - get agent access token // Authentication: Business Manager user grant
  2. /dw/shop/v23_1/baskets - Create a basket and all the necessary info
  3. /dw/shop/v23_1/orders - Create order

Business Manager User functional permission: Create_Order_On_Behalf_Of

Example Variables:
SandboxURL: xxxx-xxx.dx.commercecloud.salesforce.com
siteID: RefArch
bmUsername: bmUsername@bmUsername.com
bmUserAccessKey: xxxx
ocapiClientID: Account_Manager_ClientID
ocapiClientPassword: Account_Manager_ClientPwd
customerEmail: x@gmail.com
customerNo: 000000001
product_id: productID to be added to cart and submitted for order.
 
解決策

Example cURLS for 3 endpoints:

curl --location --request POST 'https://{{SandboxURL}}/dw/oauth2/access_token?client_id={{ocapiClientID}}&grant_type=urn%3Ademandware%3Aparams%3Aoauth%3Agrant-type%3Aclient-id%3Adwsid%3Adwsecuretoken' \
--header 'Authorization: Basic {{BASE64(bmUsername:bmUserAccessKey:ocapiClientPassword)}}' \
--header 'Content-Type: application/x-www-form-urlencoded'

 

curl --location 'https://{{SandboxURL}}/s/{{siteID}}/dw/shop/v23_1/baskets' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
  "customer_info": {
    "email": "{{customerEmail}}",
    "customer_no": "{{customerNo}}"}//other basket data
}'

curl --location 'https://{{SandboxURL}}/s/{{siteID}}/dw/shop/v23_1/orders' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
    "basket_id": "{{basket_id}}"
}'

ナレッジ記事番号

000395402

添付ファイル

OCAPI- Agent Create Order.postman_collection.json

4 KB

OCAPI- Agent Create Order - Empty.postman_environment.json

1 KB

 
読み込み中
Salesforce Help | Article