### Example User Address Request Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8c425bb4866910149bf3c19b8f239309.html An example GET request to retrieve addresses for a specific user. Ensure you have the necessary rights to access user resources. ```http GET https://localhost:9002/occ/v2/wsTest/users/2036bc69-d1ee-4cf4-9205-210c2f936970/addresses ``` -------------------------------- ### Install AddOn with Specific Storefront Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b96a80f8669101482d4f3c1e27b4eb6.html Use this command to install an AddOn, such as occaddon, and specify the target storefront, like ycommercewebservices. Ensure the addonnames and addonStorefront parameters are correctly set. ```bash ant addoninstall -Daddonnames="occaddon" -DaddonStorefront.ycommercewebservices="ycommercewebservices" ``` ```bash ant addoninstall -Daddonnames="occaddon" -DaddonStorefront.ycommercewebservices="mycommercewebservices" ``` -------------------------------- ### Example Global Order Request Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8c425bb4866910149bf3c19b8f239309.html An example GET request to retrieve a specific order using its global identifier. Proper authorization is required to access global order resources. ```http GET https://localhost:9002/occ/v2/wsTest/orders/1beb1e9f5043ef28aa5f821ada8aeee5a7a40ac4 ``` -------------------------------- ### Example Cart Entry Creation Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8c425bb4866910149bf3c19b8f239309.html An example POST request to add or update entries in a specific user's cart. The 'code' and 'qty' query parameters are used for this operation. ```http POST https://localhost:9002/occ/v2/wsTest/users/2036bc69-d1ee-4cf4-9205-210c2f936970/carts/0000012/entries?code=12345&qty=2 ``` -------------------------------- ### Example User Order Request Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8c425bb4866910149bf3c19b8f239309.html An example POST request related to a specific user's order. Ensure you have the necessary rights to access user-specific orders. ```http POST https://localhost:9002/occ/v2/wsTest/users/2036bc69-d1ee-4cf4-9205-210c2f936970/orders/testOrder1 ``` -------------------------------- ### Get Product Details Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieves detailed information for a specific product using its code. ```APIDOC ## Get Product Details ### Description Searches for a specific camera and returns the code, description, price, and product summary. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/products/{productCode} ### Path Parameters - **productCode** (string) - Required - The unique code of the product. ### Query Parameters - **fields** (string) - Optional - Comma-separated list of fields to return (e.g., code,description,price,summary). ### Request Example None ### Response #### Success Response (200) - **code** (string) - The product code. - **description** (string) - The product description. - **price** (object) - The product price information. - **summary** (string) - A brief summary of the product. ### Response Example { "example": "response body" } ``` -------------------------------- ### Get Product Details Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieves detailed information for a specific product identified by its code. ```APIDOC ## GET /occ/v2/electronics/products/{productCode} ### Description Get details for product with the specified code. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/products/{productCode} ### Parameters #### Path Parameters - **productCode** (string) - Required - The unique code of the product to retrieve. ``` -------------------------------- ### Retrieve Specific Order for User Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Gets information about a specific order for the user. ```APIDOC ## GET https://localhost:9002/occ/v2/electronics/users/current/order00002037 ### Description Gets information about the order with code 00002037. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/order{orderCode} ### Parameters #### Path Parameters - **orderCode** (string) - Required - The code of the order to retrieve (e.g., "00002037"). #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **(No specific fields documented)** #### Response Example (No example provided in source) ``` -------------------------------- ### Get Product Details Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieves detailed information for a specific product identified by its code. ```APIDOC ## GET /occ/v2/electronics/products/{productCode} ### Description Gets details for the product with the specified code. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/products/{productCode} ### Parameters #### Path Parameters - **productCode** (string) - Required - The unique code of the product. #### Query Parameters None #### Body Parameters None ### Request Example ``` GET /occ/v2/electronics/products/3429337 HTTP/1.1 Host: localhost:9002 ``` ### Response #### Success Response (200) - Detailed information about the product. ### Response Example ```json { "code": "3429337", "name": "Detailed Product Name", "description": "Detailed product description." } ``` ``` -------------------------------- ### Sample Response Body for GET /products/123 Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/6792c1e270184fffaa110fb48678a164.html Illustrates the structure of the response body for a product query, specifically showing the updated image URL with the /occ/v2 prefix. ```json { "code" : "123", "images" : [ { "url" : "/occ/v2/medias/?context=..." } ] } ``` -------------------------------- ### Get Order by Code Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieves detailed information for a given order code. ```APIDOC ## GET /occ/v2/electronics/users/current/order/{orderCode} ### Description Gets information about the order with the specified code. ### Method GET ### Endpoint /occ/v2/electronics/users/current/order/00012002 ### Query Parameters None ### Request Body None ### Authorization OAUTH token for customer. ### Response #### Success Response (200) - **order** (object) - Contains the order details. ### Response Example { "example": "{\"code\": \"00012002\", \"totalPrice\": {\"currency\": \"USD\", \"value\": 150.0}}" } ``` -------------------------------- ### Get Specific Product Details using OCC API Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieve detailed information for a specific product by its code. ```HTTP GET https://localhost:9002/occ/v2/electronics/products/4899702 ``` -------------------------------- ### Create an account for the anonymous user Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Creates a new user account using the provided GUID and password. ```APIDOC ## POST /occ/v2/electronics/users ### Description Creates an account for the anonymous user. ### Method POST ### Endpoint https://localhost:9002/occ/v2/electronics/users ### Parameters #### Request Body - **guid** (string) - Required - The unique identifier for the user. - **password** (string) - Required - The password for the new account. ``` -------------------------------- ### Ehcache Configuration Example Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b711228866910149500b73575cb386e.html This XML configuration defines cache settings for Ehcache, including memory and disk storage, expiration, and eviction policies. It's located in commercewebservices/web/webroot/WEB-INF/cache/ehcache.xml. ```xml ... ... ... ``` -------------------------------- ### Login and Get Access Token Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieves an access token by logging into the storefront as a specific user. This token is used for subsequent authenticated requests. ```APIDOC ## POST /authorizationserver/oauth/token (Login) ### Description Retrieves an access token by logging into the storefront as a specific user. The access token is used in the requests that follow. ### Method POST ### Endpoint https://localhost:9002/authorizationserver/oauth/token ### Parameters #### Query Parameters None #### Body Parameters - **client_id** (string) - Required - The client ID for authentication. - **client_secret** (string) - Required - The client secret for authentication. - **grant_type** (string) - Required - Must be 'password'. - **username** (string) - Required - The username to log in with (often 'current' when using this flow). - **password** (string) - Required - The password for the user. ### Request Example ``` POST /authorizationserver/oauth/token HTTP/1.1 Host: localhost:9002 Content-Type: application/x-www-form-urlencoded client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=password&username=john.doe@mail.com&password=your_password ``` ### Response #### Success Response (200) - **access_token** (string) - The generated access token for the logged-in user. - **token_type** (string) - The type of the token (e.g., 'bearer'). - **expires_in** (integer) - The token's expiration time in seconds. ### Response Example ```json { "access_token": "user_specific_access_token", "token_type": "bearer", "expires_in": 3600 } ``` ``` -------------------------------- ### Create an anonymous cart Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Initiates a shopping cart for an anonymous user. The response includes a GUID that is essential for subsequent cart-related operations. ```http https://localhost:9002/occ/v2/electronics/users/anonymous/carts ``` -------------------------------- ### Response for Getting All Regions Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/6f814eb5e1e646eb99594b169bad1365.html This is an example of the JSON response generated when calling the REST API to get all regions for a specified country. It includes the isocode and name for each region. ```JSON { "regions": [ { "isocode": "US-AL", "name": "Alabama" }, { "isocode": "US-AK", "name": "Alaska" }, { "isocode": "US-AS", "name": "American Samoa" }, ... } ``` -------------------------------- ### Getting All Regions Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/6f814eb5e1e646eb99594b169bad1365.html Retrieves all regions for a specified country. The example uses 'us' for the United States. ```APIDOC ## GET /countries/{countryIsoCode}/regions ### Description Retrieves all regions (e.g., states, provinces) associated with a specific country. ### Method GET ### Endpoint https://{HOST}:9002/occ/v2/{baseSiteId}/countries/us/regions ### Response #### Success Response (200) - **regions** (array) - A list of region objects. - **isocode** (string) - The ISO code for the region. - **name** (string) - The name of the region. ### Response Example ```json { "regions": [ { "isocode": "US-AL", "name": "Alabama" }, { "isocode": "US-AK", "name": "Alaska" }, { "isocode": "US-AS", "name": "American Samoa" } ] } ``` ``` -------------------------------- ### Create User Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Registers a new user in the system. ```APIDOC ## POST /occ/v2/electronics/users ### Description Registers a new user. ### Method POST ### Endpoint https://localhost:9002/occ/v2/electronics/users ### Parameters #### Query Parameters None #### Request Body - **uid** (string) - Required - The unique identifier for the user (email address). - **password** (string) - Required - The user's password. - **firstName** (string) - Required - The user's first name. - **lastName** (string) - Required - The user's last name. - **titleCode** (string) - Optional - The user's title code (e.g., 'mr', 'ms'). ### Request Example ```json { "uid":"john.doe@mail.com", "password":"your_password", "firstName":"John", "lastName":"Doe", "titleCode":"mr" } ``` ### Response #### Success Response (200) - **uid** (string) - The unique identifier of the created user. ### Response Example ```json { "uid": "john.doe@mail.com" } ``` ``` -------------------------------- ### Retrieve Orders for User Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Gets all the orders for the specified user. ```APIDOC ## GET https://localhost:9002/occ/v2/electronics/users/current/orders ### Description Gets all the orders for the specified user. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/orders ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **(No specific fields documented)** #### Response Example (No example provided in source) ``` -------------------------------- ### Create User Account Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Registers a new user account with the provided personal and login details. ```APIDOC ## POST /occ/v2/electronics/users ### Description Registers a new user. ### Method POST ### Endpoint https://localhost:9002/occ/v2/electronics/users ### Parameters #### Query Parameters None #### Request Body - **uid** (string) - Required - The user's unique identifier (email). - **password** (string) - Required - The user's password. - **firstName** (string) - Required - The user's first name. - **lastName** (string) - Required - The user's last name. - **titleCode** (string) - Optional - The user's title code (e.g., 'mr'). ### Request Example ```json { "uid":"john.doe@mail.com", "password":"your_password", "firstName":"John", "lastName":"Doe", "titleCode":"mr" } ``` ### Response #### Success Response (200) - **uid** (string) - The UID of the newly created user. ### Response Example ```json { "uid": "john.doe@mail.com" } ``` ``` -------------------------------- ### Retrieve All Orders Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Gets all orders placed by the registered user. ```APIDOC ## GET /occ/v2/electronics/users/current/orders ### Description Gets all orders for the user. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/orders ### Parameters #### Query Parameters None #### Body Parameters None #### Authorization OAUTH token for customer. ### Request Example ``` GET https://localhost:9002/occ/v2/electronics/users/current/orders Authorization: Bearer YOUR_ACCESS_TOKEN ``` ### Response #### Success Response (200) - **orders** (array) - A list of orders. - **code** (string) - The code of the order. #### Response Example ```json { "orders": [ { "code": "0000000123", "placed": "2023-10-27T10:00:00+0000" } ] } ``` ``` -------------------------------- ### Media Serving Configuration Properties Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/6792c1e270184fffaa110fb48678a164.html These properties should be added to the local.properties or project.properties file in the commercewebservices extension to enable custom media web serving. ```properties allow.custom.mediaweb.webroot=true mediaweb.webroot=/v2/medias ``` -------------------------------- ### Retrieve User Addresses Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Gets a list of addresses for the current user. ```APIDOC ## GET /occ/v2/electronics/users/current/addresses ### Description Gets a list of addresses for the users. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/addresses ### Query Parameters None ### Request Body None ### Authorization OAUTH token for customer. ### Response #### Success Response (200) - [Fields not specified in source] ``` -------------------------------- ### Initiate Payment Provider Subscription Request Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Initiates the process to create a subscription by contacting the payment provider directly, retrieving necessary information. ```APIDOC ## GET /occ/v2/electronics/users/current/carts/{cartId}/payment/sop/request ### Description Gets the information needed to create a subscription by contacting the payment provider directly. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/carts/00012001/payment/sop/request ### Query Parameters - **responseUrl** (string) - Required - The URL to redirect to after the payment provider interaction. Example: `https://{storefront}:9002/storefront/sop/response`. ### Request Body None ### Authorization OAUTH token for customer. ### Response #### Success Response (200) - **sopRequestData** (object) - Data required to initiate the subscription with the payment provider. ### Response Example ```json { "sopRequestData": { "transactionId": "12345", "requestUrl": "https://paymentprovider.com/pay" } } ``` ``` -------------------------------- ### Retrieve User Addresses Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Gets the current address for the registered user. ```APIDOC ## GET /occ/v2/electronics/users/current/addresses ### Description Gets the current address for the registered user. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/addresses ### Parameters #### Query Parameters None #### Body Parameters None #### Authorization OAUTH token for customer. ### Request Example ``` GET https://localhost:9002/occ/v2/electronics/users/current/addresses Authorization: Bearer YOUR_ACCESS_TOKEN ``` ### Response #### Success Response (200) - **DEFAULT** (object) - Contains address details. - **id** (string) - The ID of the address. #### Response Example ```json [ { "DEFAULT": { "id": "8796192014359", "streetName": "123 Main St", "town": "Anytown" } } ] ``` ``` -------------------------------- ### Log in as New User using OAuth Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Authenticates a user to obtain an OAuth token for subsequent operations. This is typically done after account creation. ```HTTP POST https://localhost:9002/authorizationserver/oauth/token ``` -------------------------------- ### Get Delivery Modes Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieves the available delivery modes for a given cart. ```APIDOC ## GET /occ/v2/electronics/users/anonymous/carts/{cartId}/deliverymodes ### Description Gets the delivery modes; response should contain a value. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/anonymous/carts/{cartId}/deliverymodes ### Parameters #### Path Parameters - **cartId** (string) - Required - The ID of the cart. #### Query Parameters - **fields** (string) - Optional - Specifies the fields to include in the response (e.g., 'BASIC'). ``` -------------------------------- ### Enable Legacy Content Negotiation Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8be744f1866910149050c4049bd96db3.html To enable fallback mode and use a format query parameter for response formats, add this property to your configuration. This is useful when content negotiation using path extensions is disabled. ```properties commercewebservices.content.negotiation.legacy=true ``` -------------------------------- ### Retrieve Delivery Modes Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Gets the available delivery modes for a specific cart. ```APIDOC ## GET /occ/v2/electronics/users/current/cart/{cartId}/deliverymodes ### Description Gets the delivery modes. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/cart/00012001/deliverymodes ### Query Parameters - **fields** (string) - Optional - Specifies the fields to retrieve. Example: BASIC. ### Request Body None ### Authorization OAUTH token for customer. ### Response #### Success Response (200) - [Fields not specified in source] ``` -------------------------------- ### Create Order Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Authorizes the cart and places an order. ```APIDOC ## POST /occ/v2/electronics/users/current/orders ### Description Authorizes the cart and places an order. ### Method POST ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/orders ### Query Parameters - **cartId** (string) - Required - The ID of the cart to create an order from. - **securityCode** (string) - Required - A security code for the order. ### Request Body None ### Authorization OAUTH token for customer. ### Response #### Success Response (200) - [Fields not specified in source] ``` -------------------------------- ### Create Cart Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Creates an empty cart for a registered user. ```APIDOC ## POST /occ/v2/electronics/users/current/carts ### Description Creates an empty cart and returns it. The code attribute of the cart is used in the calls that follow. ### Method POST ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/carts ### Parameters #### Query Parameters None #### Body Parameters None #### Authorization OAUTH token for customer ### Response #### Success Response (200) - **code** (string) - The unique code of the created cart. #### Response Example ```json { "code": "00012001", "creationTime": "2023-10-27T10:00:00+0000", "modifiedTime": "2023-10-27T10:00:00+0000", "totalPrice": { "currencyIso": "USD", "value": 0.0, "formattedValue": "$0.00" }, "totalPriceWithTax": { "currencyIso": "USD", "value": 0.0, "formattedValue": "$0.00" }, "net": true, "totalUnitCount": 0, "entries": [], "guid": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "user": { "uid": "current" } } ``` ``` -------------------------------- ### Create Cart Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Creates an empty cart for a registered user. ```APIDOC ## POST /occ/v2/electronics/users/current/carts ### Description Creates an empty cart and returns it. The code attribute of the cart is used in the calls that follow. ### Method POST ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/carts ### Parameters #### Query Parameters None #### Body Parameters None #### Authorization OAUTH token for customer ### Request Example ``` POST https://localhost:9002/occ/v2/electronics/users/current/carts Authorization: Bearer YOUR_ACCESS_TOKEN ``` ### Response #### Success Response (200) - **code** (string) - The unique code of the created cart. #### Response Example ```json { "code": "00012001", "totalPrice": { "currencyIso": "USD", "formattedValue": "$0.00", "value": 0.0 }, "totalItems": 0 } ``` ``` -------------------------------- ### Global Orders Resource Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8c425bb4866910149bf3c19b8f239309.html Access global orders. The orderID can be a '${code}' or '${guid}'. ```APIDOC ## GET /orders/{orderID} ### Description Retrieves global order resources. ### Method GET ### Endpoint https://localhost:9002/occ/v2/{baseSiteID}/orders/{orderID} ### Parameters #### Path Parameters - **baseSiteID** (string) - Required - The base site identifier. - **orderID** (string) - Required - The identifier for the order. Valid values: '${code}' or '${guid}'. ### Request Example ``` GET https://localhost:9002/occ/v2/wsTest/orders/1beb1e9f5043ef28aa5f821ada8aeee5a7a40ac4 ``` ``` -------------------------------- ### Log in as a Customer and Retrieve Token Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Obtain an access token for a specific customer using their credentials. This token is essential for performing actions on behalf of the logged-in user. ```HTTP POST https://localhost:9002/authorizationserver/oauth/token Query Parameters | None Body Parameters | client_id=$CLIENT_ID$&client_secret=$CLIENT_SECRET$&grant_type=password&username=current&password=your_password Authorization | None ``` -------------------------------- ### Register a New Customer User Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html This endpoint registers a new customer. Ensure you have a valid system authorization token before making this request. ```JSON { "uid":"john.doe@mail.com", "password":"your_password", "firstName":"John", "lastName":"Doe", "titleCode":"mr" } ``` -------------------------------- ### Get Customer Token Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Obtains an access token for a logged-in customer using their credentials. ```APIDOC ## POST /authorizationserver/oauth/token ### Description Gets an access token for the customer that is used in the calls that follow. ### Method POST ### Endpoint https://localhost:9002/authorizationserver/oauth/token ### Parameters #### Query Parameters None #### Request Body - **client_id** (string) - Required - The client ID for authentication. - **client_secret** (string) - Required - The client secret for authentication. - **grant_type** (string) - Required - Must be 'password'. - **username** (string) - Required - Set to 'current' for the logged-in user. - **password** (string) - Required - The user's password. ### Response #### Success Response (200) - **access_token** (string) - The obtained access token. - **token_type** (string) - The type of token (e.g., 'bearer'). - **expires_in** (integer) - The token's expiration time in seconds. ### Response Example ```json { "access_token": "your_customer_access_token", "token_type": "bearer", "expires_in": 3600 } ``` ``` -------------------------------- ### Retrieve Product Details Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Fetches detailed information for a specific product using its unique code. ```HTTP GET https://localhost:9002/occ/v2/electronics/products/3429337 Query Parameters | None Body Parameters | None Authorization | None ``` -------------------------------- ### Add AddOn Extensions to localextensions.xml Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b96a80f8669101482d4f3c1e27b4eb6.html Before generating an AddOn, ensure that the 'addonsupport' and 'yoccaddon' extensions are added to your localextensions.xml file. This is required for the AddOn build process and to use the AddOn installation script. ```xml ... ``` -------------------------------- ### Retrieve Delivery Modes for Cart Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Gets the available delivery modes for the specified cart. ```APIDOC ## GET /occ/v2/electronics/users/current/carts/{cartId}/deliverymodes ### Description Gets the delivery modes for the cart. The response should contain a value. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/carts/{cartId}/deliverymodes ### Parameters #### Path Parameters - **cartId** (string) - Required - The ID of the cart. #### Query Parameters None #### Body Parameters None #### Authorization OAUTH token for customer. ### Response #### Success Response (200) - **deliveryModes** (array) - A list of available delivery modes. - **code** (string) - The code of the delivery mode (e.g., 'premium-gross'). - **name** (string) - The name of the delivery mode. - **description** (string) - A description of the delivery mode. #### Response Example ```json { "deliveryModes": [ { "code": "standard-gross", "name": "Standard Delivery", "description": "Standard delivery within 3-5 business days." }, { "code": "premium-gross", "name": "Premium Delivery", "description": "Express delivery within 1-2 business days." } ] } ``` ``` -------------------------------- ### Retrieve User Payment Details Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Gets the credit payment information saved for the user. ```APIDOC ## GET /occ/v2/electronics/users/current/paymentdetails ### Description Gets credit payment information that was previously saved during checkout. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/paymentdetails ### Parameters #### Query Parameters - **saved** (boolean) - Optional - If true, retrieves saved payment details. Defaults to true. #### Body Parameters None #### Authorization OAUTH token for customer. ### Request Example ``` GET https://localhost:9002/occ/v2/electronics/users/current/paymentdetails?saved=true Authorization: Bearer YOUR_ACCESS_TOKEN ``` ### Response #### Success Response (200) - **id** (string) - The ID of the payment details. #### Response Example ```json [ { "id": "8796158591018", "type": { "code": "creditCard" }, "cardNumber": "**** **** **** 1111" } ] ``` ``` -------------------------------- ### Create Authorization Token Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieves an access token for the system user, which will be used to register a new customer. ```APIDOC ## POST /authorizationserver/oauth/token ### Description Retrieves an access token that will be used to register a new customer. ### Method POST ### Endpoint https://localhost:9002/authorizationserver/oauth/token ### Parameters #### Query Parameters None #### Body Parameters - **client_id** (string) - Required - The client ID for authentication. - **client_secret** (string) - Required - The client secret for authentication. - **grant_type** (string) - Required - Must be 'client_credentials'. ### Request Example ``` POST /authorizationserver/oauth/token HTTP/1.1 Host: localhost:9002 Content-Type: application/x-www-form-urlencoded client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=client_credentials ``` ### Response #### Success Response (200) - **access_token** (string) - The generated access token. - **token_type** (string) - The type of the token (e.g., 'bearer'). - **expires_in** (integer) - The token's expiration time in seconds. ### Response Example ```json { "access_token": "your_access_token", "token_type": "bearer", "expires_in": 3600 } ``` ``` -------------------------------- ### Log in as the new user Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Obtains an OAuth 2.0 token by logging in as a user with their credentials. ```APIDOC ## POST /authorizationserver/oauth/token ### Description Logs in as the new user and obtains an authorization token. ### Method POST ### Endpoint https://localhost:9002/authorizationserver/oauth/token ### Parameters #### Query Parameters - **username** (string) - Required - The username of the user. - **password** (string) - Required - The password of the user. - **grant_type** (string) - Required - Must be 'password'. ``` -------------------------------- ### Retrieve Delivery Modes for Cart Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Gets the available delivery modes for the specified cart. ```APIDOC ## GET /occ/v2/electronics/users/current/carts/{cartId}/deliverymodes ### Description Gets the delivery modes for the cart. The response should contain a value. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/carts/{cartId}/deliverymodes ### Parameters #### Path Parameters - **cartId** (string) - Required - The ID of the cart. #### Query Parameters None #### Body Parameters None #### Authorization OAUTH token for customer. ### Request Example ``` GET https://localhost:9002/occ/v2/electronics/users/current/carts/00012001/deliverymodes Authorization: Bearer YOUR_ACCESS_TOKEN ``` ### Response #### Success Response (200) - **code** (string) - The code of the delivery mode. #### Response Example ```json [ { "code": "pickup", "name": "Pickup" } ] ``` ``` -------------------------------- ### Get Delivery Modes for Cart Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieves the available delivery modes for the specified cart. ```APIDOC ## GET /occ/v2/electronics/users/current/carts/{cartId}/deliverymodes ### Description Gets the delivery modes available for the specified cart. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/carts/{cartId}/deliverymodes ### Parameters #### Path Parameters - **cartId** (string) - Required - The ID of the cart. #### Query Parameters None #### Body Parameters None ### Request Example ``` GET /occ/v2/electronics/users/current/carts/00012001/deliverymodes HTTP/1.1 Host: localhost:9002 Authorization: Bearer your_access_token ``` ### Response #### Success Response (200) - A list of available delivery modes for the cart. ### Response Example ```json { "deliveryModes": [ { "code": "standard-gross", "name": "Standard Delivery" }, { "code": "premium-gross", "name": "Premium Delivery" } ] } ``` ``` -------------------------------- ### Configure Site-Specific Commerce Web Services HTTP Root Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8c261cad866910149bcad3d2c5be5f37.html For sites with multiple storefronts, specify the HTTP root by appending the site name after 'webroot.commercewebservices'. ```properties webroot.commercewebservices.wsIntegrationTest.http=http://localhost:9001/rest ``` -------------------------------- ### Get Merged Cart Details Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieves the details of a specific merged cart using its code. ```APIDOC ## Get Merged Cart Details ### Description Gets the merged cart that contains two products: product with code 1382080 and product with code 489702. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/carts/{cartCode} ### Path Parameters - **cartCode** (string) - Required - The code of the merged cart to retrieve. ### Query Parameters - **fields** (string) - Optional - Comma-separated list of fields to return (e.g., code,guid,entries(DEFAULT)). ### Request Body None ### Request Example None ### Response #### Success Response (200) - **code** (string) - The code of the merged cart. - **guid** (string) - The GUID of the merged cart. - **entries** (array) - A list of entries in the merged cart. ### Response Example { "example": "response body" } ``` -------------------------------- ### Retrieve Payment Details for Subscription Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Gets the information needed to create a subscription from the payment provider. ```APIDOC ## GET /occ/v2/electronics/users/current/carts/{cartId}/payment/sop/request ### Description Gets the information needed to create a subscription from the payment provider. In this flow, you must set extendedMerchantCallback=true flag to get the correct URL for the merchant callback, which will create payment details for customer cart. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/carts/00012001/payment/sop/request ### Query Parameters - **extendedMerchantCallback** (boolean) - Required - Set to true to get the correct URL for the merchant callback. - **responseUrl** (string) - Required - The URL for the merchant callback. Example: https://{storefront}:9002/storefront/sop/response ### Request Body None ### Authorization OAUTH token for customer. ### Response #### Success Response (200) - [Fields not specified in source] ``` -------------------------------- ### Add Product Entry to Cart Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Adds a specified product to an existing cart. Ensure the cart ID and product code are correct. ```JSON { "product":{ "code":"1382080" }, } ``` -------------------------------- ### Create Order Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Authorizes the cart and places an order for the registered user. ```APIDOC ## POST /occ/v2/electronics/users/current/orders ### Description Authorizes the cart and places an order. ### Method POST ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/orders ### Parameters #### Query Parameters - **cartId** (string) - Required - The ID of the cart to be ordered. - **securityCode** (string) - Required - A security code for the order authorization. #### Body Parameters None #### Authorization OAUTH token for customer. ### Request Example ``` POST https://localhost:9002/occ/v2/electronics/users/current/orders?cartId=00012001&securityCode=123 Authorization: Bearer YOUR_ACCESS_TOKEN ``` ### Response #### Success Response (200) - **code** (string) - The code of the created order. #### Response Example ```json { "code": "0000000123", "placed": true } ``` ``` -------------------------------- ### Get Order by Code Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieves detailed information for a specific order using its unique code. ```APIDOC ## GET /occ/v2/electronics/users/current/orders/{orderCode} ### Description Gets information about the order with the specified code. ### Method GET ### Endpoint /occ/v2/electronics/users/current/orders/{orderCode} ### Parameters #### Path Parameters - **orderCode** (string) - Required - The unique identifier for the order. #### Query Parameters None #### Request Body None ### Request Example ```http GET https://localhost:9002/occ/v2/electronics/users/current/orders/00012001 Authorization: OAUTH token for customer. ``` ### Response #### Success Response (200) - **order** (object) - Contains the order details. #### Response Example (Response body structure not provided in source) ``` -------------------------------- ### Retrieve User Payment Details Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Gets the credit payment information that was previously saved for a user during checkout. ```APIDOC ## GET /occ/v2/electronics/users/current/paymentdetails ### Description Gets credit payment information that was previously saved during checkout. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/paymentdetails ### Parameters #### Query Parameters - **saved** (boolean) - Optional - Filters for saved payment details. Set to 'true' to retrieve saved details. #### Body Parameters None #### Authorization OAUTH token for customer. ### Request Example GET https://localhost:9002/occ/v2/electronics/users/current/paymentdetails?saved=true ### Response #### Success Response (200) - **paymentDetails** (array) - A list of saved payment details. - **id** (string) - The ID of the payment details. - **cardNumber** (string) - The masked card number. #### Response Example { "paymentDetails": [ { "id": "8796158591018", "cardNumber": "**** **** **** 1234" } ] } ``` -------------------------------- ### Create Order Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Authorizes the cart and places an order for the registered user. ```APIDOC ## POST /occ/v2/electronics/users/current/orders ### Description Authorizes the cart and places an order. ### Method POST ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/orders ### Parameters #### Query Parameters - **cartId** (string) - Required - The ID of the cart to be ordered. - **securityCode** (string) - Required - A security code, typically the CVV for the payment. #### Body Parameters None #### Authorization OAUTH token for customer. ### Response #### Success Response (200) - **code** (string) - The order code. - **placedDate** (string) - The date the order was placed. - **total** (object) - The total amount of the order. - **value** (number) - The order total value. - **currencyIso** (string) - The ISO currency code. #### Response Example ```json { "code": "00001234", "guid": "f1e2d3c4-b5a6-7890-1234-567890abcdef", "creationTime": "2023-10-27T10:35:00+0000", "placedDate": "2023-10-27T10:35:00+0000", "total": { "currencyIso": "USD", "value": 650.0, "formattedValue": "$650.00" }, "user": { "uid": "current" } } ``` ``` -------------------------------- ### Retrieve Anonymous Cart Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieves information about a specific anonymous user's cart using its GUID. ```APIDOC ## Retrieve Anonymous Cart ### Description Gets information about a specific anonymous user's cart. ### Method GET ### Endpoint https://localhost:9002/occ/v2/electronics/users/anonymous/carts/{cartGuid} ### Path Parameters - **cartGuid** (string) - Required - The GUID of the anonymous cart to retrieve. ### Query Parameters None ### Request Body None ### Request Example None ### Response #### Success Response (200) - **guid** (string) - The GUID of the cart. - **code** (string) - The code of the cart. - **entries** (array) - A list of entries in the cart. ### Response Example { "example": "response body" } ``` -------------------------------- ### Create Cart Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Creates an empty shopping cart for a registered user and returns the cart details, including its unique code. ```APIDOC ## POST /occ/v2/electronics/users/current/carts ### Description Creates an empty cart and returns it. The code attribute of the cart is used in the calls that follow. ### Method POST ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/carts ### Parameters #### Query Parameters None #### Body Parameters None #### Authorization OAUTH token for customer ### Request Example None ### Response #### Success Response (200) - **code** (string) - The unique identifier for the created cart. - **guid** (string) - The global unique identifier for the cart. #### Response Example { "code": "00012001", "guid": "some-guid" } ``` -------------------------------- ### Assign Delivery Mode to Cart Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Sets the delivery mode for the cart. This example assigns 'pickup' as the delivery mode. ```HTTP PUT https://localhost:9002/occ/v2/electronics/occ/v2/electronics/users/current/carts/00012001/deliverymode Query Parameters | deliveryModeId=pickup --- Body Parameters | None Authorization | OAUTH token for customer. Description | Sets pickup as the current delivery mode. ``` -------------------------------- ### Create Order Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Authorizes the cart and creates an order. ```APIDOC ## POST /occ/v2/electronics/users/current/orders ### Description Authorizes the cart and creates an order. ### Method POST ### Endpoint https://localhost:9002/occ/v2/electronics/users/current/orders ### Query Parameters - **cartId** (string) - Required - The ID of the cart to create an order from. - **securityCode** (string) - Required - Security code for the order. ### Request Body None ### Authorization OAUTH token for customer. ### Response #### Success Response (200) - **order** (object) - Details of the created order. ### Response Example ```json { "order": { "code": "123456789", "status": "PLACED" } } ``` ``` -------------------------------- ### Retrieve All Orders for User Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Use this endpoint to get a list of all orders for the current user. An OAuth token is required. ```HTTP GET https://localhost:9002/occ/v2/electronics/users/current/orders ``` -------------------------------- ### Add Product to Cart Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Adds a specified product and quantity to an existing cart. Requires the cart code and product code. ```JSON { "product":{ "code":"349337" }, "quantity": 1 } ``` -------------------------------- ### Get System User Token Source: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/3476714bba0b4cb9b3eb58c270e44439/8b9e95cf866910148348c3bcab4be0b6.html Retrieves an access token for the system user, necessary for certain administrative operations. ```APIDOC ## GET /authoriationserver/token ### Description Gets an access token for the system user. The token is used in the calls that follow. ### Method GET ### Endpoint https://localhost:9002/authoriationserver/token ### Parameters #### Query Parameters None #### Request Body - **client_id** (string) - Required - The client ID for authentication. - **client_secret** (string) - Required - The client secret for authentication. - **grant_type** (string) - Required - Must be 'client_credentials'. ### Response #### Success Response (200) - **access_token** (string) - The obtained access token. - **token_type** (string) - The type of token (e.g., 'bearer'). - **expires_in** (integer) - The token's expiration time in seconds. ### Response Example ```json { "access_token": "your_system_access_token", "token_type": "bearer", "expires_in": 3600 } ``` ```