Fynd Order Processing Flow
Step1: Shipment Picked Event will be triggered:
Event:
{
"resource": "shipment",
"eventType": "PUT",
"eventSubType": "picked",
"accountSlug": "tab",
"accountId": null,
"actor": "SYSTEM",
"version": "v1",
"request_data": [],
"response_data": {
"customerOrderNumber": "16765240054291963350",
"orderSiteID": null,
"vendorOrderNumber": "FY63EDB9E40E2B48F15C",
"externalShipmentID": "16765240054291963350-5905-89",
"externalWarehouseID": "Delhi FC",
"externalChannelID": "CH5905",
"externalWmsChannelName": "FYND_EB1_TAB_280_1866",
"external_wms_channel_id": 1866,
"channelLabel": "FYND_EB1",
"integrationType": "15",
"vendorPartyID": null,
"partner_as2_id": null,
"defaultWarehouseCode": "Delhi FC",
"facilityLabel": "Delhi FC (DEL-TEST) Aup",
"facilityType": "auperator",
"orderDate": "2023-02-16 10:36:45",
"portal_id": 5,
"paymentType": "COD",
"expectedShipDate": "2023-02-18 10:45:51",
"dispatchAfterDate": null,
"externalManifestNumber": null,
"channelManifestNumber": null,
"order_id": 44175424,
"channel_id": 5905,
"warehouse_id": 280,
"channel_account_id": 0,
"account_id": 758,
"connectionId": 2589,
"locationId": "EB1",
"region": "",
"isMetro": "0",
"isSpecialplace": "0",
"shippingConnectionId": null,
"picklistCode": null,
"invoiceNumber": "",
"boxType": "UNKNOWN",
"isPriorityShipment": "0",
"isGift": "0",
"invoice_url": "",
"invoiceDate": null,
"label_url": "",
"labels": "",
"shippingInfo": [],
"boxAdditionalRecommendation": [],
"dimension_length": "0",
"dimension_width": "0",
"dimension_height": "0",
"weight": "0.01",
"trackingID": "",
"trackingDomain": "",
"packageID": "",
"barcode": "",
"taxAmount": 0,
"shipChargeAmount": 0,
"courierName": "",
"cp_id": 0,
"created_at": "2023-02-16 10:46:11",
"updated_at": "2023-02-16 10:46:11",
"status": "created",
"remarks": "",
"warehousePincode": "835210",
"thirdPartyShipping": true,
"customerName": "Sudip Das",
"customerContactNumber": "8638915874",
"email": "bulta0932@gmail.com",
"channelSlug": null,
"status_updated_at": "2023-02-16 10:46:11",
"status_log": {
"created": "2023-02-16 10:46:11"
},
"status_log_first_occurrence": {
"created": "2023-02-16 10:46:11"
},
"status_log_count": {
"created": 1
},
"status_log_id": "25460526",
"orderExternalCreatedAt": "2023-02-16 10:46:04",
"shippingAddress": {
"customerName": "Sudip Das",
"addressLine1": "234,Last Avanue,Near Jugashanka Office,Mumbai,Maharashtra,India,400051",
"addressLine2": null,
"city": "Mumbai",
"state": "Maharashtra",
"postalCode": "400051",
"countryCode": null,
"countryName": "India",
"contactPhone": "8638915874",
"email": "bulta0932@gmail.com"
},
"warehouseAddress": {
"addressLine1": "Khasra no 5 16 2 17",
"addressLine2": "Village Behrampur, Near Subhash Chowk, Sohna Road",
"city": "Gurgaon",
"state": "Haryana",
"postalCode": "835210",
"gstin": null
},
"id": 11170571,
"isCOD": "1",
"track_payload": [],
"items": [
{
"order_item_id": 23922668,
"lineItemSequenceNumber": 675361,
"orderItemID": "16765240054291963350-23922668",
"itemID": "NOTEBOOK",
"sku": "T1U973FNPT3",
"asin": "",
"productName": "this is test product",
"quantity": 1,
"orderItemCreatedAt": "2023-02-16 10:46:04",
"customerPrice": 3499,
"lineItemTotal": 1499,
"invoiceTotal": 1499,
"cashOnDeliveryCharges": 0,
"discount": 2000,
"taxRate": 0,
"taxAmount": 0,
"inventoryItemCode": "",
"giftMessage": "",
"isGift": "0",
"giftLabelContent": "",
"lineItemOrderStatus": "",
"orderItemIDs": [
"16765240054291963350-23922668"
],
"productImageUrl": "https:\/\/cdn.filestackcontent.com\/UWM2NeWeTV6MictRD64v",
"productAdditionalInfo": {
"specification": [
"is fragile",
"requires serial number (e.g. IMEI) scan"
],
"sku_code": "NOTEBOOK"
},
"expectedDeliveryDate": null,
"shippingCharges": 0,
"productUrl": null,
"originalOrderItemId": null,
"isVirtualKit": "0",
"component": [],
"onhold": "0",
"cancellationAdditionalReason": "",
"cancellationReason": "",
"customerOrderItemID": "675361",
"recallBlockedInventoryUsed": ""
}
],
"calledFrom": "call_from_log_3"
},
"previous_data": [],
"resource_type": "shipment.update",
"account_slug": "tab",
"custom": []
}
Step 2: Fetch the event in Endpoint and will push the event to Service File (FyndOrderProcessService) for Order Processing
Step 3: In the Service File, From the event, I will Extract externalShipmentID, CustomerOrderNumber, and lineItemsequenceNumbers Of Items. (Which will later be used to Create Request Body Of Pack Order Api)
Step 4: Extract Connection Id, using Connection Id I will fetch AccessToken for that connection Id:
Step 4.1: At first I will look for accessToken in cacheMemory for the Given Connection Id, If found we will save the accessToken
Step 4.2: If not Found In cache Memory, I will get the accessToken From DataBase using connectionId and save the accessToken
SELECT ie_appinstall_connection.accessToken AS accessToken,
ie_appinstall_connection.inputFields AS inputFields
FROM ie_appinstall_connection
WHERE ie_appinstall_connection.id =:connectionId"
Step 5: Then I will call Fynd Get courier Details API to check if CourierName and AWB number has been assigned or not by Fynd:
FYND GET COURIER DETAILS API:
curl --location --request GET 'https://api.fynd.com/hogwarts/aggregators/api/v2/eshopbox/shipment/courierDetails?orderId=16745424938391856720' \
--header 'ApiKey: :accessToken'
FYND GET COURIER DETAILS Response:
A. Success Response:
[
{
"idx": 1,
"awbNo": "5046512062023",
"status": "AVAILABLE",
"courierCode": "delhivery_surface_II",
"courierName": "delhivery_surface_II",
"orderId": "16734348221511076501"
}
]
For Success Response: i.e for ("status": "AVAILABLE")
I will Simply save “awbNo
" and “courierName
" In the RTS Return Response. and Continue from Step 6.
B.Failed Response Or Null Response :
[
{
"idx": 1,
"awbNo": null,
"status": "COURIER_NOT_ASSIGNED",
"courierCode": "NULL",
"courierName": "NULL",
"orderId": "16734348221511076501"
}
]
For FAILED Response: i.e for ("status": "COURIER_NOT_ASSIGNED_By_Fynd")
simply put “errorMsg”: “COURIER_NOT_ASSIGNED
" in RTS Return Response and simply return.(exit the flow)
Step6: Then I will call Fynd Shipment Pack API to confirm that the shipment has been packed:
FYND SHIPMENT PACK API:
curl --location --request POST 'https://api.fynd.com/hogwarts/aggregators/api/v2/eshopbox/shipment/pack' \
--header 'ApiKey: AccessToken' \
--header 'Content-Type: application/json' \
--data-raw '{
"orderId": "16742943651021887541", (customerOrderNumber)
"orderItems": [
{
"orderItemId": "647285" (LineItemSequenceNumber)
},
{
"orderItemId": "647286" (LineItemSequenceNumber)
}
]
}'
A. Success Response: Response
Situation 1: Request successful
{
"data": {
"payloadCount": 100,
"successCount": 100,
"failedCount": 0,
"status": "success",
"errors": []
}
}
In Success Response Simply Continue The Flow From Step 7:
B. Failed Response:
{
"data": {
"payloadCount": 1,
"successCount": 0,
"failedCount": 1,
"errors": [
{
"orderId": "16742943651021887541",
"orderItems": [
{
"orderItemId": 647285,
"quantity": 1,
"reasonCode": ""
},
{
"orderItemId": 647286,
"quantity": 1,
"reasonCode": ""
}
]
}
],
"status": "error"
}
}
For FAILED Response: i.e for ("status": "error")
put “errorMsg”: “ERROR_IN_PACK_ORDER_RESPONSE
" in RTS Return Response and simply return.(exit the flow)
Step 7: Call Fynd Invoice And Label Url To fetch the Invoice and Label pdfs, and invoice Number.
Fynd_Invoice_Label_API:
curl --location --request GET 'https://api.fynd.com/hogwarts/aggregators/api/v2/eshopbox/shipment?orderId=16751670371531123883' \
--header 'ApiKey: AccessToken' \
--data-raw ''
Response:
{
"orders": [
{
"id": "16751670371531123883",
"forward_id": "16751670371531123883",
"marketplaceOrderId": "FY63D9053C01EC407DD3",
"marketplaceReturnId": null,
"shippingAddress": {
"addressLine1": "A69 Okhla Phase 2,New Delhi,Delhi,Delhi,India,110020",
"state": "Delhi",
"email": "Deepak.kunwar@ril.com",
"name": "Deepak",
"pincode": "110020",
"country": "India",
"phone": "7503188960",
"city": "Delhi"
},
"thirdPartyShipping": true,
"additionalInfo": "you can add additional info here",
"orderPrice": {
"currency": "INR",
"totalPrepaidAmount": 1590.0
},
"orderItems": [
{
"variantId": "S",
"status": "CONFIRMED",
"shippingMethodCode": "STD",
"productId": "TPTP06ED7551-GR",
"onHold": false,
"shipNode": "7153",
"gst_details": {
"IGST": 170.36
},
"packetNumber": 0,
"sku": "8907760267396",
"quantity": 1,
"product_identifiers": {
"ean": "8907760267396"
},
"giftWrap": {
"giftWrapMessage": "",
"giftWrapCharges": 0
},
"orderItemPrice": {
"transferPrice": 0,
"discount": 0.0,
"totalPrice": 1590.0,
"sellingPrice": 1590.0,
"shippingCharges": 0,
"currency": "INR",
"cashOnDeliveryCharges": 0
},
"marketplaceOrderItemId": "21823683",
"orderItemId": "21823683",
"title": "Summer Beach Crochet Top"
}
],
"orderStatus": "CONFIRMED",
"orderDate": "2023-01-31T17:40:37",
"paymentType": "COD",
"cFormProvided": false,
"taxExempted": false,
"gstin": "",
"sla": "2023-02-04T14:18:22.731854+05:30",
"orderingChannel": "COVERSTORY-DEV",
"fyndInvoiceUrl": "https://fynd-assets-private.s3-accelerate.amazonaws.com/documents/invoice_a4/PDFs/16751670371531123883_invoice_a4.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJU7QAWL4LO5KSCYA%2F20230202%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Date=20230202T084822Z&X-Amz-Expires=604800&X-Amz-Signature=9d1c41ae8a8ba19e4de311e368a4c0937b802a679c1a8aa78e04644ba483ed46&X-Amz-SignedHeaders=host",
"fyndInvoiceUrlA6": "https://fynd-assets-private.s3-accelerate.amazonaws.com/documents/invoice_a6/PDFs/16751670371531123883_invoice_a6.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJU7QAWL4LO5KSCYA%2F20230202%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Date=20230202T084822Z&X-Amz-Expires=604800&X-Amz-Signature=5df013ddb5c552a6acd449f150683b676ac766b0e3d0db997445a89d9159a1b5&X-Amz-SignedHeaders=host",
"fyndLabelUrl": "https://fynd-assets-private.s3-accelerate.amazonaws.com/documents/label_a4/PDFs/16751670371531123883_label_a4.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJU7QAWL4LO5KSCYA%2F20230202%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Date=20230202T084822Z&X-Amz-Expires=604800&X-Amz-Signature=c4dd41fa1d5e6277f62b60245e302ddef7d6a3ecdf5d12dbea53d2862beae483&X-Amz-SignedHeaders=host",
"invoice_id": null,
"return_invoice_id": null,
"marketPlaceInvoiceUrl": "",
"marketPlaceLabelUrl": "",
"purchaseOrderNumberPDF": "",
"irn_number": "",
"invoice_qr_code": "",
"signed_invoice": "",
"B2BData": {
"name": "",
"phone": "",
"address": "",
"state": "",
"pincode": "",
"gstin": ""
},
"lockStatus": false,
"fulfilmentPriority": 10,
"journeyType": "Forward",
"awbNo": null,
"courierName": null,
"billingAddress": {
"addressLine1": "A69 Okhla Phase 2,New Delhi,Delhi,Delhi,India,110020",
"state": "Delhi",
"email": "Deepak.kunwar@ril.com",
"name": "Deepak",
"pincode": "110020",
"country": "India",
"phone": "7503188960",
"city": "Delhi"
}
}
]
}
Here I will fetch invoice PDF, Label PDF, and invoiceNumber from the response:
Step 8: At first I will merge the invoice and label Pdf.
Then, I will save awbNo (From step 5), courierName (From step 5), and invoiceNumber and merged pdfs To DataBase according to externalShipmentID.
Update shipments set trackingID=awbNo:a ,courierName=:courierName, "
+ "invoiceNumber=:invoiceNumber, label_url=:labelURL, invoiceDate=:invoiceDate "
+ "where externalShipmentID=:externalShipmentID
Step 9: Save awbNo, courierName, invoiceNumber, Merged Label Pdf to RTS return Response Then Return Response
RTS Success Response:
{
"awbNo": "5046512062023"
"courierName": "delhivery_surface_II"
"labelUrl": "https://fynd-assets-private.s3-accelerate.amazonaws.com/documents/label_a4/PDFs/16751670371531123883_label_a4.pdf"
"invoiceNo": "123542ABC"
}
Step 10: Post Order Dispatch (Handed over the order to delivery partner).
Limit 100 orders per transaction
Mark status as “packed”
API Method: Post:
{{oms_host}}/api/v2/{{aggregator}}/shipment/dispatch
Body:
[{
"orderId": "string",
"orderItems": [
{
"orderItemId": "string"
},
{
"orderItemId": "string"
}
]
}]
Error Table:
Reason | result | Description |
cancelled by customer/seller |
| If orderId is cancelled |
invalid orderId |
| If orderId doesn't belong to the requested location |
invalid request |
| If dispatch request raised where current status not equals "packed" |
Note: To check the case of Invalid Token usage in calling Fynd API, Create Some Reconcile API.