Sales Order Creation

Overview

Service Unique Name SalesOrder
Request Method POST
Content Type application/x-www-form-urlencoded; charset=utf-8

Description

Sales Order API is used to create sales order.

Request Body

These are form parameters:

  • salesOrderNumber: SO0008
  • Warehouse: Delhi
  • products: Product in json format
  • customerCode: HERO
  • receiverName: John
  • shippingAddress: Kolkata
  • shippingCity: Kolkata
  • shippingState: WB
  • shippingPincode: 110168
  • shippingPhone: 8017135434
  • paymentType: COD
  • codAmount: 5000
  • codAmountCurrency: 5000
  • dutyPaidBy: SENDER
  • shippingCountry: IN

Request Details

Parameter Data Type Required/Optional Description
SecureKey int Required It is a Unique key for accessing the API. For secure key email to support team.
Sales Order Number String Required Sales Order Number
Warehouse String Required Warehouse code.
Products String Required Products list in json format. For eg:
[{
"measurmentUnit":"unit of measurement",
"quantity":"10",
"price":"12",
"product_sku":"BELT"
},
{
"measurmentUnit":"unit of measurement",
"quantity":"10",
"price":"12",
"product_sku":"BOX"
}]
Customer Code String Required Existing customer code if the sales order is of that existing customer.
Receiver Name String Required Receiver’s name.
Shipping Address String Required Receiver’s address
Shipping City String Required Receiver’s city
Shipping State String Required Receiver’s state
Shipping Country String Required Receiver’s country code
Shipping Pincode String Required Receiver’s pincode
Shipping Phone String Required Receiver’s phone
Customer Name String Required if customerCode is not there If customer code is valid then customer’s name property is optional otherwise required.
Customer Address String Required if customerCode is not there If customer code is valid then customer’s address property is optional otherwise required.
Customer City String Required if customerCode is not there If customer code is valid then customer’s city property is optional otherwise required.
Customer State String Required if customerCode is not there If customer code is valid then customer’s state property is optional otherwise required.
Customer Country String Required if customerCode is not there If customer code is valid then customer’s country code property is optional otherwise required.
Customer Pincode String Required if customerCode is not there If customer code is valid then customer’s pincode property is optional otherwise required.
Customer Phone String Required if customerCode is not there If customer code is valid then customer’s phone property is optional otherwise required.
Customer Email String Optional Customer’s email
Create Invoice String Optional Takes value true or false.If user wants to create sales invoice with sales order simultaneously then give true. If user don’t want to create sales invoice then give ‘false’ or dont give this parameter in API.
Username String Optional This parameter is mandatory only when create invoice is true.
eCommerce Site String Optional This is optional parameter.
Carrier Code String Optional Carrier code
Carrier Product Code String Optional Carrier product code
Payment Type String Required It takes values as Prepaid / COD.
COD Amount String Optional Mandatory if payment type is COD.
COD Amount Currency String Optional Mandatory if payment type is COD.
Duty Paid By String Optional It takes values Sender / Receiver.
withoutstock String Optional Set the the parameter in case you want to create sales order without available stock.
salesOrderType Optional Return or Regular By default it’s regular
receiverCode Optional By default 00000
withoutstock String Optional Set the the parameter in case you want to create sales order without available stock.
Products Required [{ "measurmentUnit":"Pieces", "quantity":"3", "price":"10", "product_sku":"TEST1","salesInvoiceAmount":"25" }, { "measurmentUnit":"Pieces", "quantity":"1", "price":"100", "product_sku":"ADIDASSHOE1001","salesInvoiceAmount":"95" }]
deliveryDate Optional Yyyy-mm-dd format
deliveryFromTime Optional Hh:mm:ss am/pm
deliveryToTime Optional Hh:mm:ss am/pm
Note: All the following parameters must be in form data.
Note: customer state,city must be according to its country.

Response Format

ON SUCCESS
{
"message": "Sales order successfully created.",
"messageType": "Success",
"salesOrderNumber": "SO0008"
}

ON ERROR
{
"message": "Record already exists by this sales order number",
"messageType" : "Error"
}

Error Message String

Error Messages Description
Add Warehouse When warehouse details is missing from the request.
Product Details Missing When product json is missing from the request.
Customer Name Missing When there is no customer code and customer’s name is also missing.
Receiver Name Missing Receiver Name is not given.
Shipping City Missing Shipping City is not given.
Shipping State Missing Shipping State is not given.
Shipping Country Missing Shipping Country is not given.
Shipping Pincode Missing Shipping Pincode is not given.
Shipping Phone Missing Shipping Phone is not given.
Customer Address Missing When there is no customer code and customer address is also not given.
Customer City Missing When there is no customer code and customer city is also not given.
Customer State Missing When there is no customer code and customer state is also missing.
Customer Country Missing WWhen there is no customer code and customer country is also not given.
Customer Pincode Missing When there is no customer code and customer pincode is also not given.
Customer Phone Missing When there is no customer code and customer phone is also not given.
Invalid Warehouse Detail When given warehouse code does not exist.
Customer Details Missing When provided customer code is invalid.
Product Code is not Available If the product sku code is invalid or blank.

Sample Code

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.LinkedHashMap;

import java.util.Map;

public class SalesOrderCreation {

private static final String API_URL = "https://api.logixplatform.com/Rachna/webservice/v2/SalesOrder?secureKey=";
private static final int SECURE_KEY = SECURE KEY;
private static final String ACCESS_URL = API_URL+SECURE_KEY;

public static void main(String[] args) throws IOException {

URL url = new URL(ACCESS_URL);
Map params = new LinkedHashMap<>();
params.put("salesOrderNumber", "SO06652652");
params.put("Warehouse", "Delhi");
params.put("products", "[{\r\n" +
"\"measurmentUnit\":\"Pieces\",\r\n" +
"\"quantity\":\"10\",\r\n" +
"\"price\":\"12\",\r\n" +
"\"product_sku\":\"BELT\"\r\n" +
"},\r\n" +
"{\r\n" +
"\"measurmentUnit\":\"Pieces\",\r\n" +
"\"quantity\":\"10\",\r\n" +
"\"price\":\"12\",\r\n" +
"\"product_sku\":\"BOX\"\r\n" +
"}]");
params.put("customerCode", "HERO");
params.put("shippingAddress", "Kolkata");
params.put("shippingCity", "Kolkata");
params.put("shippingState", "WB");
params.put("shippingPincode", "110168");
params.put("shippingPhone", "8017135434");
params.put("customerName", "dddd");
params.put("customerAddress", "Kolkata");
params.put("customerCity", "Kolkata");
params.put("customerState", "WB");
params.put("customerCountry", "IN");
params.put("customerPhone", "123654789");
params.put("paymentType", "COD");
params.put("codAmount", "5000");
params.put("eCommerceSite", "");
params.put("carrierCode", "");
params.put("carrierProductCode", "");
params.put("codAmountCurrency", "INR");
params.put("dutyPaidBy", "SENDER");
params.put("shippingCountry", "IN");

params.put("receiverName", "John");

StringBuilder postData = new StringBuilder();
for (Map.Entry param : params.entrySet()) {
if (postData.length() != 0) postData.append('&');
postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
postData.append('=');
postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));

}

byte[] postDataBytes = postData.toString().getBytes("UTF-8");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
conn.setDoOutput(true);
conn.getOutputStream().write(postDataBytes);
Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
StringBuilder data = new StringBuilder();
for (int c; (c = in.read()) >= 0;) {
data.append((char)c);
}
String intentData = data.toString();
System.out.println(intentData);
}

}
import requests

import json

access_url = "https://api.logixplatform.com/Rachna/webservice/v2/SalesOrder"

params = {'SecureKey' : 'secure_key'}

products=json.dumps([{
"measurmentUnit":"Pieces",
"quantity":"10",
"price":"12",
"product_sku":"BELT"
},
{
"measurmentUnit":"Pieces",
"quantity":"10",
"price":"12",
"product_sku":"BOX"

}])

payload = {
"salesOrderNumber": "SO066526555",
"Warehouse": "Delhi",
"customerCode":"HERO",
"shippingAddress":"Kolkata",
"shippingCity":"Kolkata",
"shippingState":"WB",
"shippingPincode":"110168",
"shippingPhone":"8017135434",
"customerName":"dddd",
"customerAddress":"Kolkata",
"customerCity":"Kolkata",
"customerState":"WB",
"customerCountry":"IN",
"customerPhone":"123654789",
"paymentType":"COD",
"codAmount":"5000",
"eCommerceSite":"",
"carrierCode":"",
"carrierProductCode":"",
"codAmountCurrency":"INR",
"dutyPaidBy":"SENDER",
"shippingCountry":"IN",
"receiverName":"John",

"products":products

}

headers = {'Content-Type': 'application/x-www-form-urlencoded', 'AccessKey' : 'logixerp'}

try:
r = requests.post(access_url, params=params,headers=headers, data=payload)
print (r.text)
except requests.exceptions.RequestException as err:
print (err)
please wait...