/
Flipkart Return Flow

Flipkart Return Flow

Step 1. Cron Endpoint /_ah/api/esb/v1/returnordercron

Use-case: It fetches the active connections and their respective channel data such as latestSyncTimeStamp, externalChannelID, externalWarehosueID etc. and pushes into the taskQueue.

 

Step 2. TaskQueue Listener: /_ah/api/esb/v1/order-return/cron/listener

Use-case: It listens and prepares 2 different Flipkart URL using the channel data received:

Courier Return URL:

Type of Return: “courier_return“

https://api.flipkart.net/sellers/v2/returns?source={{type of return}}&createdAfter={{latestSynctimeStamp}}&locationId=""

Sample Response:

{ "hasMore": true, "nextUrl": "/returns/search/ewogICJmaWx0ZXIiIDogewogICAgInNlcnZpY2VfcHJvZmlsZSIgOiBudWxsLAogICAgInR5cGUiIDogWyAiY291cmllcl9yZXR1cm4iIF0sCiAgICAic2hpcG1lbnRfdHlwZXMiIDogbnVsbCwKICAgICJzaGlwbWVudF9zdGF0dXMiIDogbnVsbCwKICAgICJyZXR1cm5fc3RhdHVzIiA6IFsgImluaXQiLCAiY3JlYXRlZCIsICJjb21wbGV0ZWQiLCAiY2FuY2VsbGVkIiwgInNlcnZpY2VfcmVxdWVzdGVkIiwgInJlamVjdGVkIiwgImNhbmNlbGxhdGlvbl9pbl9wcm9ncmVzcyIgXSwKICAgICJzaGlwbWVudF9leHBlY3RhdGlvbnMiIDogbnVsbCwKICAgICJza3UiIDogbnVsbCwKICAgICJwcm9taXNlX2JyZWFjaCIgOiBudWxsLAogICAgImFwcHJvdmVkIiA6IHsKICAgICAgImZyb21fZGF0ZSIgOiAiMjAyMi0wNS0xMSIsCiAgICAgICJ0b19kYXRlIiA6IG51bGwsCiAgICAgICJ2YWxpZF9mcm9tX2RhdGUiIDogdHJ1ZSwKICAgICAgInZhbGlkX3RvX2RhdGUiIDogdHJ1ZQogICAgfSwKICAgICJwcm9taXNlIiA6IG51bGwsCiAgICAib3V0X2Zvcl9kZWxpdmVyeSIgOiBudWxsLAogICAgInJldHVybl9jb21wbGV0ZWQiIDogbnVsbCwKICAgICJzaGlwbWVudF9jb21wbGV0ZWRfb24iIDogbnVsbCwKICAgICJjcmVhdGVkX2FmdGVyIiA6IG51bGwsCiAgICAibW9kaWZpZWRfYWZ0ZXIiIDogbnVsbAogIH0sCiAgInBhZ2luYXRpb24iIDogewogICAgInN0YXJ0aW5nX3BhZ2UiIDogMiwKICAgICJwYWdlX3NpemUiIDogMjUKICB9LAogICJzb3J0IiA6IG51bGwKfQ==", "returnItems": [ { "orderItemId": "22567472313060400", "locationId": "LOC01189f32db684bde949e36a36361d181", "orderId": "OD225674723130604000", "quantity": 1, "orderDate": "2022-08-07T17:06:02.363Z", "createdDate": "2022-08-09T15:59:21+05:30", "courierName": "flipkartlogistics", "sellerId": "28dba0d580f64708", "returnId": "10302568962761366770", "status": "created", "type": "courier_return", "reason": "order_cancelled", "subReason": "delivery_time_long", "trackingId": "FMPP1288153175", "shipmentStatus": "in_transit", "shipmentId": null, "comments": "Sorry don’t long delivery timeline", "updatedDate": "2022-08-09T16:01:12+05:30", "approvedOn": null, "expectedDate": "2022-09-08T15:59:39.000", "serviceProfile": "NON_FBF", "services": [] }, { "orderItemId": "22566680304412300", "locationId": "LOC62a30c1d159845e09dfeef303f52cfb9", "orderId": "OD225666803044123000", "quantity": 1, "orderDate": "2022-08-06T19:05:35.372Z", "createdDate": "2022-08-09T15:27:35+05:30", "courierName": "flipkartlogistics-cod", "sellerId": "28dba0d580f64708", "returnId": "10202568943708674424", "status": "created", "type": "courier_return", "reason": "order_cancelled", "subReason": "different_size_color", "trackingId": "FMPC2065775251", "shipmentStatus": "in_transit", "shipmentId": null, "comments": "Size different", "updatedDate": "2022-08-09T15:28:02+05:30", "approvedOn": null, "expectedDate": "2022-09-08T15:27:58.000", "serviceProfile": "NON_FBF", "services": [] } ] }

Customer Return URL:

Type of Return: “customer_return“

https://api.flipkart.net/sellers/v2/returns?source={{type of return}}&createdAfter={{latestSynctimeStamp}}&locationId=""

Sample Response:

{ "hasMore": true, "nextUrl": "/returns/search/ewogICJmaWx0ZXIiIDogewogICAgInNlcnZpY2VfcHJvZmlsZSIgOiBudWxsLAogICAgInR5cGUiIDogWyAiY3VzdG9tZXJfcmV0dXJuIiBdLAogICAgInNoaXBtZW50X3R5cGVzIiA6IG51bGwsCiAgICAic2hpcG1lbnRfc3RhdHVzIiA6IG51bGwsCiAgICAicmV0dXJuX3N0YXR1cyIgOiBbICJpbml0IiwgImNyZWF0ZWQiLCAiY29tcGxldGVkIiwgImNhbmNlbGxlZCIsICJzZXJ2aWNlX3JlcXVlc3RlZCIsICJyZWplY3RlZCIsICJjYW5jZWxsYXRpb25faW5fcHJvZ3Jlc3MiIF0sCiAgICAic2hpcG1lbnRfZXhwZWN0YXRpb25zIiA6IG51bGwsCiAgICAic2t1IiA6IG51bGwsCiAgICAicHJvbWlzZV9icmVhY2giIDogbnVsbCwKICAgICJhcHByb3ZlZCIgOiB7CiAgICAgICJmcm9tX2RhdGUiIDogIjIwMjItMDUtMTEiLAogICAgICAidG9fZGF0ZSIgOiBudWxsLAogICAgICAidmFsaWRfZnJvbV9kYXRlIiA6IHRydWUsCiAgICAgICJ2YWxpZF90b19kYXRlIiA6IHRydWUKICAgIH0sCiAgICAicHJvbWlzZSIgOiBudWxsLAogICAgIm91dF9mb3JfZGVsaXZlcnkiIDogbnVsbCwKICAgICJyZXR1cm5fY29tcGxldGVkIiA6IG51bGwsCiAgICAic2hpcG1lbnRfY29tcGxldGVkX29uIiA6IG51bGwsCiAgICAiY3JlYXRlZF9hZnRlciIgOiBudWxsLAogICAgIm1vZGlmaWVkX2FmdGVyIiA6IG51bGwKICB9LAogICJwYWdpbmF0aW9uIiA6IHsKICAgICJzdGFydGluZ19wYWdlIiA6IDIsCiAgICAicGFnZV9zaXplIiA6IDI1CiAgfSwKICAic29ydCIgOiBudWxsCn0=", "returnItems": [ { "orderItemId": "12564433122421701", "locationId": "LOCd3b2ee7836024b329ec7510e1c19702c", "orderId": "OD125644331224217000", "quantity": 1, "orderDate": "2022-08-04T04:40:52.734Z", "createdDate": "2022-08-09T15:50:35+05:30", "courierName": "Ekart Logistics", "sellerId": "28dba0d580f64708", "returnId": "12202568957502145417", "status": "created", "type": "customer_return", "reason": "SIZE_FIT_ISSUES", "subReason": "SIZE_SMALLER", "trackingId": "FMPR0316520937", "shipmentStatus": "start", "shipmentId": null, "comments": "Size is small", "updatedDate": "2022-08-09T15:51:53+05:30", "approvedOn": null, "expectedDate": null, "serviceProfile": "NON_FBF", "services": [] }, { "orderItemId": "12560154790591201", "locationId": "LOC62a30c1d159845e09dfeef303f52cfb9", "orderId": "OD125601547905912000", "quantity": 1, "orderDate": "2022-07-30T05:51:37.169Z", "createdDate": "2022-08-09T15:39:26+05:30", "courierName": "Ekart Logistics", "sellerId": "28dba0d580f64708", "returnId": "12302568950817296342", "status": "created", "type": "customer_return", "reason": "SIZE_FIT_ISSUES", "subReason": "SIZE_LARGER", "trackingId": "FMPR0316517116", "shipmentStatus": "start", "shipmentId": null, "comments": "A size bigger than my normal size 7", "updatedDate": "2022-08-09T15:41:17+05:30", "approvedOn": null, "expectedDate": null, "serviceProfile": "NON_FBF", "services": [] } ] }

Step 3. Once the data has been fetched from the above URL, then the data is pushed to a PubSub topic in the following format:

Courier Return PubSub Topic Name: return_create_courier

Customer Return PubSub Topic Name: "return_create_customer

Sample Payload Published:

{ "channelData": { "integrationType": "6", "externalChannelId": "CH1919", "accountSlug": "nilkamal", "connectionId": "925", "location": { "LOC2538cf886e2a42edb79cc1596ff2d040": "Bangalore_FC", "LOC05a659129d8f4b9daa4ca300eaf954cb": "Mumbai_Velocity_FC", "LOCe39cdd4dedc74feaa409c6b6d37eb7e7": "Kolkata_FC", "LOC69872addafba4041aab8833cb8173020": "Gurgaon_FC" }, "accessToken": "ff23b0a2-c394-470d-a838-516c43b983db", "isActive": "active", "refreshToken": "49b8b22c-2058-42c3-9e84-2dd029152ca9", "Flipkart_workspaceToken_nilkamal": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik1UaERRamxD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Tpwb3J0YWwgcmVhZDp3b3Jrc3BhY2UgcmVhZDpzYWxlc19jaGFubmVsIHJlYWQ6ZnVsZmlsbG1lbnRfY2VudGVyIiwiZ3R5IjoicGFzc3dvcmQifQ.bL9XErm8IQrWZb5kZ8PVG6YAEw4E8OnQKAXRo9l6bYvChZA7ljN3Yg-j3-25-eyimVGGPSSpCQACy53sawdCi2YqSTZjDzdakIlZrpBqoSfkWoDn_5ZdHu3gXQmq1-trDT48tbOzopKmY8iS7soqFyOwTKmheMJPiVwq7ACNUXb3Bvsc3_VAWS8VzbJ-p33o3zmmDjcQ50CpanwQ6AXPLSCHs8mGOYZws8LLwEnugl6nBrp3e5LZWWYUAXOXGT5lDNc1ysIR31WpN9kdEpjSy8cc5N3JfiiZOvpGVvFGpjMSF_TSmuIoqxd7PDkkF-7yHjjaCweultStPxCmzPWNTw", "latestSyncTimeStamp": "2022-07-12 09:17:39.0" }, "courierReturnItem": { "reason": "Rejected_by_Customer", "quantity": 1.0, "comments": "", "orderId": "OD225356528665737000", "orderItemId": "22535652866573700", "updatedDate": "2022-07-12T02:05:46+05:30", "expectedDate": "2022-08-11T02:05:43.000", "services": [], "type": "courier_return", "subReason": "Rejected_by_Customer", "courierName": "flipkartlogistics-cod", "createdDate": "2022-07-12T02:05:42+05:30", "sellerId": "k5qx5xkrfbp80kk8", "locationId": "LOCe39cdd4dedc74feaa409c6b6d37eb7e7", "returnId": "10202544270573278808", "serviceProfile": "NON_FBF", "orderDate": "2022-07-01T21:13:51.273Z", "status": "created", "trackingId": "FMPC1993864455", "shipmentStatus": "in_transit" } }

 

 

Step 4. Endpoint FileName: ReturnOrderEndPoint.java

Use-case: It listens to the specific return event such as Courier return endpoint will receive only courier returns and vice-versa for Customer returns

 

Step 5.1. Now the transformation happens in the Service file ReturnOrderService.java.

Method Name: customerReturnListener

SELECT orders.customerOrderNumber, orders.shipping_customerName, orders.shipping_addressLine1, orders.shipping_addressLine2, orders.shipping_city, orders.shipping_state, orders.shipping_contactPhone, orders.isCOD, orders.shipping_postalCode, orders.shipping_email, order_items.itemId, order_items.orderItemID AS orderItemID, order_items.`shipment_id` FROM orders LEFT JOIN order_items ON order_items.order_id = orders.id WHERE orders.channel_id IN (: channels) AND order_items.lineItemSequenceNumber =: lineItemSequenceNumber AND orders.vendorOrderNumber =: vendorOrderNumber

 

Eshopbox Keys

Flipkart Keys

Eshopbox Keys

Flipkart Keys

customerOrderNumber

{{fetched from db}}

customerReturnNumber

{{courierReturnItem.returnId}}

refundAmount

null

courierName

{{courierReturnItem.courierName}}

trackingID

{{courierReturnItem.trackingId}}

externalChannelID

{{channelData.externalChannelID}}

pickup_type

"reverse"

isCOD

{{fetched from db}}

return_request_date

{{courierReturnItem.createdDate}}

repaymentType

originalPaymentMode

optional

null

pickupAddress.customerName

{{fetched from db}}

pickupAddress.addressLine1

{{fetched from db}}

pickupAddress.addressLine2

{{fetched from db}}

pickupAddress.city

{{fetched from db}}

pickupAddress.postalCode

{{fetched from db}}

pickupAddress.state

{{fetched from db}}

pickupAddress.countryName

"INDIA"

pickupAddress.contactPhone

"IN"

pickupAddress.email

{{fetched from db}}

items[].lineItemSequenceNumber

courierReturnItem.orderItemId

items[].itemID

{{fetched from db}}

items[].quantity

1 (constant)

items[].returnReason

courierReturnItem.reason

items[].additionalInfo

"" (constant)

items[].itemImage

""(constant)

Step 5.2. After transformation, the following request body has been prepared to create a return:

{ "customerOrderNumber": "03d4da5b-1c3c-4e0e-9d47-4b1844956960", "externalChannelID": "CH1943", "pickup_type": "reverse", "isCOD": 0, "return_request_date": "2022-07-10", "repaymentType": "originalPaymentMode", "optional": null, "pickupAddress": { "customerName": "Richa", "addressLine1": "90/1 patel marg, mansarovar jaipur", "addressLine2": "Mansarovar", "city": "Jaipur", "postalCode": "302020", "countryCode": "IN", "state": "Rajasthan", "countryName": "INDIA", "contactPhone": "9999999999", "email": "xyz@gmail.com" }, "customerReturnNumber": "12202542781141533518", "refundAmount": null, "courierName": "Ekart Logistics", "trackingID": "FMPR0306666949", "items": [ { "lineItemSequenceNumber": "22537911896058800", "itemID": "SHTGBN5C5EHJZPZH", "quantity": 1, "returnReason": "SIZE_FIT_ISSUES", "additionalInfo": { "image": "", "comments": "" }, "itemImage": "" } ] }

 

Step 6.1. Now the transformation happens in the Service file ReturnOrderService.java.

Method Name: courierReturnRequest

SELECT orders.customerOrderNumber, orders.shipping_customerName, orders.shipping_addressLine1, orders.shipping_addressLine2, orders.shipping_city, orders.shipping_state, orders.shipping_contactPhone, orders.isCOD, orders.shipping_postalCode, orders.shipping_email, order_items.itemId, order_items.orderItemID AS orderItemID, order_items.`shipment_id` FROM orders LEFT JOIN order_items ON order_items.order_id = orders.id WHERE orders.channel_id IN (: channels) AND order_items.lineItemSequenceNumber =: lineItemSequenceNumber AND orders.vendorOrderNumber =: vendorOrderNumber

Eshopbox Keys

Flipkart Keys

Eshopbox Keys

Flipkart Keys

customerReturnNumber

{{fetched from db}}

customerOrderNumber

""

type

"courier_return"

status

"RTO"

remarks

courierReturnItem.reason

courierName

courierReturnItem.courierName

trackingID

courierReturnItem.trackingID

items[].itemID

{{fetched from db}}

items[].orderItemID

{{fetched from db}}

Step 6.2. After transformation, the following request body has been prepared to create a return:

{ "customerReturnNumber": "", "customerOrderNumber": "", "type": "courier_return", "status": "RTO", "remarks": "order_cancelled", "courierName": "flipkartlogistics-cod", "trackingID": "FMPC2003301890", "items": [ { "itemId": "", "orderItemID": "" } ] }

 

 

New and suggested return flow | Flipkart

 

 

 

 

 

 

Related content