Order creation in Fynd Platform

@SoumyaAcharya I am not able to create order by hitting API: /service/platform/order-manage/v1.0/company/{company_id}/create-order. Getting error ‘No application found’, 400. How to fix this?

Hi Punit, can you send us the company_id for debugging purpose.

Company Id is : 7040

Hi, can you send me the curl for it.

curl -X POST “https://api.fynd.com/service/platform/order-manage/v1.0/company/7040/create-order
-H ‘Authorization: {authorization_token}’
-H ‘Content-Type: application/json’

let platformConfig = new PlatformConfig({
companyId: “7040”,
apiKey: “6605b776841e29cf1b486fcb”,
apiSecret: “1ly_ciaf2qZRRAe”,
domain : “https://api.fynd.com
});

getToken();

async function getToken() {
try {
const token = await platformConfig.oauthClient.getAccesstokenObj({grant_type : ‘'‘client_credentials’'’});
platformConfig.oauthClient.setToken(token);
const platformClient = new PlatformClient(platformConfig);
const response1 = await platformClient.order.createOrder({
“body”: {
“shipments”:[{
“line_items”:[{
“charges”:[{
“name”:“ltrcar67_AR”,
“amount”:“500”,
“type”:“selling”
}],
“seller_identifier”:“Arodos”
}],
“location_id”:1
}],
“shipping_info”: {},
“billing_info”: {},
“currency_info”: {},
“payment_info”: {“primary_mode”:“COD”}
}
});

console.log(response1);

} catch (err) {
console.log(err);
}
}’

Kindly ensure the inclusion of extra headers in the platform client configuration, as exemplified below:

platformClient.setExtraHeaders({
  "x-application-id": "your-application-id",
});

Additionally, please note the requisite details for the ‘amount’ object in charges:

amount: {
  value: integer/number,
  currency: "INR"
}

Your attention to these details is appreciated. Thank you."

Thanks for the reply. However I have changed as per your comments, but still I am getting “No valid item found for given seller_identifier” error. I have checked item name and seller identifier. Please check once let me know if I am missing some thing. Here the code: const { PlatformConfig, PlatformClient } = require(“@gofynd/fdk-client-javascript”);

let platformConfig = new PlatformConfig({
companyId: “7040”,
apiKey: “6605b776841e29cf1b486fcb”,
apiSecret: “1ly_ciaf2qZRRAe”,
domain : “https://api.fynd.com
});

//Need to generate token using platformConfig.oauthClient.getAccesstokenObj() method
//grant_type can be ‘client_credentials’ or ‘authorization_code’
//platformConfig.oauthClient.setToken(token);
getToken();

async function getToken() {
try {
const token = await platformConfig.oauthClient.getAccesstokenObj({grant_type : ‘client_credentials’});
platformConfig.oauthClient.setToken(token);
const platformClient = new PlatformClient(platformConfig);
platformClient.setExtraHeaders({
“x-application-id”: “65f16e7dc6f2968d03eff02e”,
});
const response1 = await platformClient.order.createOrder({
“body”: {
“shipments”:[{
“line_items”:[{
“charges”:[{
“name”:“ltrcar67_ar”,
“amount”: {
“value”: 500,
“currency”: “INR”
},
“type”:“selling”
}],
“seller_identifier”:“Arodos”
}],
“location_id”:1
}],
“shipping_info”: {},
“billing_info”: {},
“currency_info”: {},
“payment_info”: {“primary_mode”:“COD”}
}
});

console.log(response1);

// console.log(response1);
} catch (err) {
console.log(err);
}
}

and console error: {“level”:“ERROR”,“detail”:{“message”:“Something went wrong”,“status”:500,“code”:null,“exception”:null,“info”:{“success”:false,“errors”:“‘No valid item found for given seller_identifier’”,“status_code”:500,“fynd_order_id”:“FYMP666A77D901F2DC73”},“request_id”:null,“stack_trace”:null,“meta”:“‘No valid item found for given seller_identifier’”},“request”:{“method”:“post”,“url”:“/service/platform/order-manage/v1.0/company/7040/create-order”,“headers”:{“Accept”:“application/json, text/plain, /”,“Content-Type”:“application/json”,“Authorization”:“Bearer oa-10df1fdde4e74552e2442285fd185e83fce56aba”,“x-application-id”:“65f16e7dc6f2968d03eff02e”,“x-fp-sdk-version”:“1.4.2-beta.7”,“x-fp-date”:“20240613T043846Z”,“x-fp-signature”:“v1.1:66a79dde957b38f8659a0de447ce1c96f127e240c77f1293978b6aef4583e002”,“User-Agent”:“axios/0.27.2”,“Content-Length”:265}},“time”:“Thu Jun 13 2024 10:08:49
GMT+0530 (India Standard Time)”,“version”:“1.4.2-beta.7”}

How do we get seller_identifier of a particular product? Is it similar to SKU?

Yes, the SKU is the same as the seller identifier. It appears that the seller identifier in your payload is incorrect; it should be “LTRCAR67_AR”.

Hi currently i am facing error:
{
“level”: “ERROR”,
“detail”: {
“message”: “Something went wrong”,
“status”: 500,
“code”: null,
“exception”: null,
“info”: {
“success”: false,
“errors”: “"‘2 validation errors for OrderValidator\\nbusiness → ordering_channel\\n none is not an allowed value (type=type_error.none.not_allowed)\\narticles → 0 → ordering_channel\\n none is not an allowed value (type=type_error.none.not_allowed)’"”,
“status_code”: 500,
“fynd_order_id”: “FYMP66712ACD018A30B1”
},
“request_id”: null,
“stack_trace”: null,
“meta”: “"‘2 validation errors for OrderValidator\\nbusiness → ordering_channel\\n none is not an allowed value (type=type_error.none.not_allowed)\\narticles → 0 → ordering_channel\\n none is not an allowed value (type=type_error.none.not_allowed)’"”
},
“request”: {
“method”: “post”,
“url”: “/service/platform/order-manage/v1.0/company/7040/create-order”,
“headers”: {
“Accept”: “application/json, text/plain, /”,
“Content-Type”: “application/json”,
“Authorization”: “Bearer oa-8f409d40b315498401f160fcc1c449c58d20bad1”,
“x-application-id”: “65f16e7dc6f2968d03eff02e”,
“x-fp-sdk-version”: “1.4.2-beta.7”,
“x-fp-date”: “20240618T063554Z”,
“x-fp-signature”: “v1.1:f09e7b3dda692f0f334c285f629f0c276c1b92dfbd400b5e31ee853de52b9d39”,
“User-Agent”: “axios/0.27.2”,
“Content-Length”: 738
}
},
“time”: “Tue Jun 18 2024 12:05:55 GMT+0530 (India Standard Time)”,
“version”: “1.4.2-beta.7”
}

and My code is :
const { PlatformConfig, PlatformClient } = require(“@gofynd/fdk-client-javascript”);
const { Prices } = require(“@gofynd/fdk-client-javascript/sdk/application/Order/OrderApplicationModel”);

let platformConfig = new PlatformConfig({
companyId: “7040”,
apiKey: “6605b776841e29cf1b486fcb”,
apiSecret: “1ly_ciaf2qZRRAe”,
domain : “https://api.fynd.com
});

//Need to generate token using platformConfig.oauthClient.getAccesstokenObj() method
//grant_type can be ‘client_credentials’ or ‘authorization_code’
//platformConfig.oauthClient.setToken(token);
getToken();

async function getToken() {
try {
const token = await platformConfig.oauthClient.getAccesstokenObj({grant_type : ‘client_credentials’});
platformConfig.oauthClient.setToken(token);
const platformClient = new PlatformClient(platformConfig);
platformClient.setExtraHeaders({
“x-application-id”: “65f16e7dc6f2968d03eff02e”,
});
const response1 = await platformClient.order.createOrder({
“body”: {
“shipments”: [
{
“line_items”: [
{
“charges”: [
{
“name”: “ltrcar67_AR”,
“amount”: {
“value”: 600,
“currency”: “INR”
},
“type”: “selling”
}
],
“quantity”: 1,
“seller_identifier”: “LTRCAR67_AR”
}
],
“location_id”: 25179,
“price”: {
“amount_paid”: 500,
“refund_amount”: 500,
“price_marked”: 600,
“cod_charges”: 0,
“discount”: 100,
“cashback_applied”: 0,
“delivery_charge”: 0,
“fynd_credits”: 0,
“cashback”: 0,
“price_effective”: 500,
“refund_credit”: 0,
“value_of_good”: 476.19,
“coupon_value”: 0,
“tax_collected_at_source”: 0,
“promotion_effective_discount”: 0,
“fynd_promotion_effective_discount”: 0,
“seller_promotion_effective_discount”: 0,
“cn_refund_amount”: 0,
“gift_price”: 0,
“amount_paid_roundoff”: 500
},

    }
],
"shipping_info": {},
"billing_info": {},
"currency_info": {},
"payment_info": {
    "primary_mode": "COD"
}

}
});

console.log(response1);

// console.log(response1);
} catch (err) {
console.log(err);
}
}

To resolve the issue with creating orders through the Fynd Platform SDK, please use the following corrected payload structure. Note that the price object has been removed as it is not accepted by the API. (refer API docs maybe you have done some mistake)

{
    "shipments": [
        {
            "line_items": [
                {
                    "charges": [
                        {
                            "name": "Amount Paid",
                            "amount": {
                                "currency": "INR",
                                "value": 5000.0
                            },
                            "type": "amount_paid"
                        },
                        {
                            "name": "Unit Price",
                            "amount": {
                                "currency": "INR",
                                "value": 5000.0
                            },
                            "type": "unit_price"
                        },
                        {
                            "name": "Value Of Good",
                            "amount": {
                                "currency": "INR",
                                "value": 5000.0
                            },
                            "type": "value_of_good"
                        }
                    ],
                    "quantity": 1,
                    "seller_identifier": "491200396"
                }
            ],
            "meta": {
                "invoice_id": "INV877357544"
            },
            "location_id": 2352,
            "order_type": "PickAtStore"
        }
    ],
    "shipping_info": {
        "state": "Maharashtra",
        "primary_mobile_number": "90338343969",
        "first_name": "DD",
        "country": "India",
        "city": "Mumbai",
        "address1": "Fynd",
        "pincode": "400101",
        "primary_email": "[email protected]"
    },
    "billing_info": {
        "state": "Maharashtra",
        "primary_mobile_number": "9033843969",
        "first_name": "DD",
        "country": "India",
        "city": "Mumbai",
        "address1": "Fynd",
        "pincode": "400101",
        "primary_email": "[email protected]"
    },
    "external_order_id": "R030290000406032024",
    "charges": [
        {
            "name": "Order Value",
            "amount": {
                "value": "4500.00",
                "currency": "INR"
            },
            "type": "order_value"
        }
    ],
    "external_creation_date": "Wed Jan 20 2024 06:45:00 GMT 0000 (Coordinated Universal Time)",
    "meta": {
        "store_code": "HS-76090",
        "order_platform": "rpos",
        "channel": "swadesh"
    },
    "config": {
        "application": {
            "company_id": 813,
            "id": "657fec55dd27c9d11767d896",
            "token": "A8U6de8mV"
        },
        "dp_configuration": {
            "shipping_by": "fynd"
        },
        "payment": {
            "source": "ECOMM",
            "token": "A8U6de8mV"
        }
    },
    "payment_info": {
        "primary_mode": "DEBIT",
        "payment_methods": [
            {
                "collect_by": "seller",
                "mode": "CASH",
                "refund_by": "seller",
                "name": "LC REF",
                "amount": 4500.0
            }
        ]
    },
    "user_info": {
        "primary_email": "[email protected]",
        "first_name": "Guest",
        "last_name": "Customer",
        "primary_mobile_number": " 919999999999"
    }
}

If you have any further questions or need additional assistance, please let me know!

Thanks for the reply. I am still not able to create order for multiple SKUs. For single SKU i am able to hit order. Please let me know what should be payload for an order that contains multiple products or SKUs. Here the code i have used:

“shipments”: [
{
“line_items”: [
{
“charges”: [
{
“name”: “Amount Paid”,
“amount”: {
“currency”: “INR”,
“value”: 500.0
},
“type”: “amount_paid”
},
{
“name”: “Unit Price”,
“amount”: {
“currency”: “INR”,
“value”: 500.0
},
“type”: “unit_price”
},

                    ],
                    "quantity": 2,
                    "seller_identifier": "LTRCAR67_AR",
                  

                },
                {
                    "charges": [
                                                
                        {
                            "name": "Amount Paid",
                            "amount": {
                                "currency": "INR",
                                "value": 650.0
                            },
                            "type": "amount_paid"
                        },
                        {
                            "name": "Unit Price",
                            "amount": {
                                "currency": "INR",
                                "value": 650.0
                            },
                            "type": "unit_price"
                        }
                    ],
                  
                     "quantity": 1,
                    "seller_identifier": "LTRCAQXC_AR"

                },
              
              
                
            ],
          /*  "meta": {
                "invoice_id": "INV877357544"
            },*/
            "location_id": 25179,
           /* "order_type": "PickAtStore"*/
        }
    ],
    "shipping_info": {
        "state": "Guwahati",
        "primary_mobile_number": "8402085350",
        "first_name": "DJ Deka",
        "country": "India",
        "city": "Guwahati",
        "address1": "Dispur",
        "pincode": "781011",
        "primary_email": ""
    },
    "billing_info": {
        "state": "Maharashtra",
        "primary_mobile_number": "8402085350",
        "first_name": "DD",
        "country": "India",
        "city": "Mumbai",
        "address1": "Fynd",
        "pincode": "400101",
        "primary_email": ""
    },
 /*   "external_order_id": "R030290000406032024",*/
    "charges": [
        {
            "name": "Order Value",
            "amount": {
                "value": "1650.00",
                "currency": "INR"
            },
            "type": "order_value"
        }
    ],
  /*  "external_creation_date": "Wed Jan 20 2024 06:45:00 GMT 0000 (Coordinated Universal Time)",*/
  /*  "meta": {
        "store_code": "hs-02",
        "order_platform": "rpos",
        "channel": "Arodos"
    },*/
  /*  "config": {
        "application": {
            "company_id": 813,
            "id": "657fec55dd27c9d11767d896",
            "token": "A8U6de8mV"
        },
        "dp_configuration": {
            "shipping_by": "fynd"
        },
        "payment": {
            "source": "ECOMM",
            "token": "A8U6de8mV"
        }
    },*/
    "payment_info": {
        "primary_mode": "DEBIT",
        "payment_methods": [
            {
                "collect_by": "seller",
                "mode": "CASH",
                "refund_by": "seller",
                "name": "Arodos",
                "amount": 1650.0
            }
        ]
    },
    "user_info": {
        "primary_email": "",
        "first_name": "Guest",
        "last_name": "Customer",
        "primary_mobile_number": " 8402085350"
    }
}

Please share the complete code and the specific error you are encountering. The provided JSON looks correct to me, but seeing the actual error message will help me better understand the issue and assist you more effectively.

Actually I am not getting error but in my order dashboard order is created only for one SKU not for the other one LTRCAQXC_AR. Also please let me know how do i create a return order?

here the code:

const { PlatformConfig, PlatformClient } = require(“@gofynd/fdk-client-javascript”);
const { Prices } = require(“@gofynd/fdk-client-javascript/sdk/application/Order/OrderApplicationModel”);

let platformConfig = new PlatformConfig({
companyId: “7040”,
apiKey: “6605b776841e29cf1b486fcb”,
apiSecret: “1ly_ciaf2qZRRAe”,
domain : “https://api.fynd.com
});

//Need to generate token using platformConfig.oauthClient.getAccesstokenObj() method
//grant_type can be ‘client_credentials’ or ‘authorization_code’
//platformConfig.oauthClient.setToken(token);
getToken();

async function getToken() {
try {
const token = await platformConfig.oauthClient.getAccesstokenObj({grant_type : ‘client_credentials’});
platformConfig.oauthClient.setToken(token);
const platformClient = new PlatformClient(platformConfig);
platformClient.setExtraHeaders({
“x-application-id”: “65f16e7dc6f2968d03eff02e”,
});
const response1 = await platformClient.order.createOrder({
“body”: {
“shipments”: [
{
“line_items”: [
{
“charges”: [
{
“name”: “Amount Paid”,
“amount”: {
“currency”: “INR”,
“value”: 500.0
},
“type”: “amount_paid”
},
{
“name”: “Unit Price”,
“amount”: {
“currency”: “INR”,
“value”: 500.0
},
“type”: “unit_price”
},

                ],
                "quantity": 2,
                "seller_identifier": "LTRCAR67_AR",
              

            },
            {
                "charges": [
                                            
                    {
                        "name": "Amount Paid",
                        "amount": {
                            "currency": "INR",
                            "value": 650.0
                        },
                        "type": "amount_paid"
                    },
                    {
                        "name": "Unit Price",
                        "amount": {
                            "currency": "INR",
                            "value": 650.0
                        },
                        "type": "unit_price"
                    }
                ],
              
                 "quantity": 1,
                "seller_identifier": "LTRCAQXC_AR"

            },
          
          
            
        ],
      /*  "meta": {
            "invoice_id": "INV877357544"
        },*/
        "location_id": 25179,
       /* "order_type": "PickAtStore"*/
    }
],
"shipping_info": {
    "state": "Guwahati",
    "primary_mobile_number": "8402085350",
    "first_name": "DJ Deka",
    "country": "India",
    "city": "Guwahati",
    "address1": "Dispur",
    "pincode": "781011",
    "primary_email": ""
},
"billing_info": {
    "state": "Maharashtra",
    "primary_mobile_number": "8402085350",
    "first_name": "DD",
    "country": "India",
    "city": "Mumbai",
    "address1": "Fynd",
    "pincode": "400101",
    "primary_email": ""
},

/* “external_order_id”: “R030290000406032024”,/
“charges”: [
{
“name”: “Order Value”,
“amount”: {
“value”: “1650.00”,
“currency”: “INR”
},
“type”: “order_value”
}
],
/
“external_creation_date”: “Wed Jan 20 2024 06:45:00 GMT 0000 (Coordinated Universal Time)”,/
/
“meta”: {
“store_code”: “hs-02”,
“order_platform”: “rpos”,
“channel”: “Arodos”
},/
/
“config”: {
“application”: {
“company_id”: 813,
“id”: “657fec55dd27c9d11767d896”,
“token”: “A8U6de8mV”
},
“dp_configuration”: {
“shipping_by”: “fynd”
},
“payment”: {
“source”: “ECOMM”,
“token”: “A8U6de8mV”
}
},*/
“payment_info”: {
“primary_mode”: “DEBIT”,
“payment_methods”: [
{
“collect_by”: “seller”,
“mode”: “CASH”,
“refund_by”: “seller”,
“name”: “Arodos”,
“amount”: 1650.0
}
]
},
“user_info”: {
“primary_email”: “”,
“first_name”: “Guest”,
“last_name”: “Customer”,
“primary_mobile_number”: " 8402085350"
}
}
});

console.log(response1);

// console.log(response1);
} catch (err) {
console.log(err);
}
}

@Suditya_Gupta1 Can you please update on this.

@Suditya_Gupta1 Waiting for an update.

@Suditya_Gupta1 Would be great if you can update on this.

The reason your second order isn’t being created is that the SKU “LTRCAQXC_AR” does not exist in location ID: 25179 and location code: hs-02.

Also Please ensure that all details in the payload, including prices, are accurate.