/
Amazon Return Default Layer
Amazon Return Default Layer
Return Event Structure
{
"version": "0",
"id": "7aa1902a-a34f-ae08-22e1-45b4721d0ed0",
"detail-type": "Returns.Created",
"source": "com.amazon.yojaka.orders",
"account": "227455371037",
"time": "2021-09-10T08:35:55Z",
"resources": [],
"detail": {
"returnId": "bcc59e2f-aa4f-4188-8cdb-c97898a7fe41",
"returnLocationId": "e5ede046-5f51-4e59-ade4-96e0e6bf613d",
"merchantId": "AAFR4ZPY4GS0"
}
}
Now we need to extract the following keys from the Return Event:
MerchantId: To extract all the Active Connections using the below Query:
SELECT id FROM ie_appinstall_connection WHERE inputFields LIKE '%"merchantId":"AAFR4ZPY4GS0"%'
AND refreshToken IS NOT NULL AND accessToken IS NOT NULL
Now pull ChannelData by Using ConnectionId with the following Query:
SELECT channels.integrationType AS integrationType, accounts.account_slug AS accountSlug,
channels.connectionId AS connectionId, channels.externalChannelId AS externalChannelId,
external_wms_channels.locationId AS locationId,
warehouses.externalWarehouseId AS externalWareHouseId FROM
channels LEFT JOIN external_wms_channels ON
channels.id= external_wms_channels.channel_id
LEFT JOIN warehouses ON warehouses.id = external_wms_channels.warehouse_id
LEFT JOIN accounts ON channels.account_id = accounts.id
WHERE channels.connectionId =:connectionId GROUP BY external_wms_channels.locationId ORDER BY external_wms_channels.id ASC
Along with the ChannelData, we will also need accessToken, refresh token, and isActive flag. So we will use the following Query:
SELECT accessToken, inputFields, refreshToken,
isActive FROM ie_appinstall_connection WHERE id = :connectionId
So, now our connection_ChannelData will look like below:
Cache key: “connection_channeldata_{{connectionId}}"
{
"channelData": {
"integrationType": "8",
"storeSlug": "",
"externalChannelId": "CH1200",
"accountSlug": "eshop",
"connectionId": "361",
"location": {
"804cde7b-bd2f-4a3e-923c-386715089fa1": "MJPAT_109",
"8fc83148-5b97-49cf-b724-7c46d50946aa": "ESBBLR_111",
"d1391379-8283-4335-a43c-0a2eb2fe2d21": "ESBMUM_112"
},
"accessToken": "Atza|IwEBIBmnRqef-YkpJOZ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RlciIsImd0eSI6InBahc3N3b3JkIn0.CqjOddltmRN_aZqNZAdKMCk7X5xJsG4j71pBAvFtbKg5uW8p-uuWLJyQ87dZgjM_9xq0mi3BxTHO2IYbNDX6xiD9F8H4Y9uCVUW7gmSOdfLcFzeNgLggiUo8hHi_pJK1HgZRspxA76ld0w97xNQAYbZpyl3cc-wdgIyrUO-kpoYetcZ2PW5fHYqQMLwh75OpnsGtsAekKcaOVcqVvSF1WfDNYDtV4H9lfKe0IzNFDQ8WQ18DSjvwvWWDSxQxSG9BTVa8d3NPKnEyTAhH9yeZTe6FCBk9T_8fwzbTaehZ_wvUFfYooQLMUCTUalQxjjOLiCiIZ4GDwF8ogOCMbLF0bA"
}
}
Now we will check whether the Return created belongs to the Location we have mapped or not. To do this, we need to compare the LocationId from the Return Event to the LocationId given in the connection_ChannelData. If matches then proceed further.
Now fetch Return Event Details using Return Order ID
Method: GET
https://api.sandbox.dub.yojaka.xp.sellers.a2z.com/v1/returns/d9d57ba9-597a-4266-b359-f199ceca946f
Response: FBA ORDER
{
"id": "4e164917-e034-423e-80a8-f4237d2c76bc",
"returnLocationId": "e5ede046-5f51-4e59-ade4-96e0e6bf613d",
"merchantSku": "MyReturnSku",
"numberOfUnits": "1",
"fulfillmentLocationId": "e5ede046-5f51-4e59-ade4-96e0e6bf613d",
"returnType": "CUSTOMER",
"status": "CREATED",
"creationTimestamp": 1631262501958,
"lastUpdatedTimestamp": 1631262503290,
"returnMetadata": {
"returnReason": "qmpOK7NgaR",
"fulfillmentOrderId": "9948f571-8b85-4133-b2e5-a489734be718",
"rmaId": "Test123rmaID",
"invoiceInfo": {
"invoiceId": "j18UDqRu61"
}
},
"returnShippingInfo": {
"forwardTrackingInfo": {
"trackingId": 1578351542,
"carrierName": "ATS"
},
"reverseTrackingInfo": {
"trackingId": TestReverse,
"carrierName": "TestCarrier"
}
},
"marketplaceChannelDetails": {
"marketplaceChannel": {
"marketplaceName": "AMAZON_IN",
"channelName": "FBA"
},
"merchantId": "AAFR4ZPY4GS0",
"shipmentId": "3YqT8mD2FT",
"customerOrderId": "LE70KrxT0z",
"returnLocationId": "Test-location-Eshop",
"channelSku": "MyReturnSku"
}
}
Response: MFN ORDER
{
"id": "c15d227d-b4e7-4eb5-9dcb-262ef33c3995",
"returnLocationId": "d8c359ad-58f3-4faa-968b-2564679ab63e",
"merchantSku": "MyReturnSku",
"numberOfUnits": "1",
"fulfillmentLocationId": "d8c359ad-58f3-4faa-968b-2564679ab63e",
"returnType": "CUSTOMER",
"returnStatus": "CREATED",
"creationTimestamp": 1633516373636,
"lastUpdatedTimestamp": 1633516374773,
"returnMetadata": {
"returnReason": "kGagAYL8pe",
"fulfillmentOrderId": "b5c5f4c6-6f15-4161-b7a2-d259db5ba0b7",
"rmaId": "Test123rmaID",
"invoiceInfo": {
"invoiceId": "9OF6oFeV4S"
}
},
"returnShippingInfo": {
"forwardTrackingInfo": {
"trackingId": "0873529358",
"carrierName": "ATS"
},
"reverseTrackingInfo": {
"trackingId": "true",
"carrierName": "TestCarrier"
}
},
"returnMarketplaceChannelDetails": {
"marketplaceChannel": {
"marketplaceName": "AMAZON_IN",
"channelName": "MFN"
},
"merchantId": "AAFR4ZPY4GS0",
"shipmentId": "pxp4cP2DNy",
"customerOrderId": "s68b4PIyxi",
"returnLocationId": "DEFAULT",
"channelSku": "MyReturnSku"
}
}
Once the Detailed Return Response is retrieved, Prepare QueueData which will be sent to Amzprime-Order Service for Transformation. It will look like as given below:
{
"queueData": {
"channelData": {
"integrationType": "8",
"amzprime_workspaceToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlJVVXdSREZCUVRSRFFqQkdORFUxTVVZeE16ZEdPRFJHTnpORk5EaEJSVEU0TVVORk5qVTJOdyJ9.eyJodHRwczovL2FwcERhdGEiOnsiYXBwQ2xpZW50SWQiOiJjM2I3ZGUzMzk0MzRkNWYxZDY0ZjFkNTllMmM0ZGM3YiJ9LCJodHRwczovL2FjY291bnRTbHVnIjoibW9udGVjYXJsbyIsImh0dHBzOi8vdXNlckRldGFpbHMiOnsiaWQiOjExMDQsInVzZXJUeXBlIjoiZGVmYXVsdCIsImVtYWlsIjoiYXBwdXNlcjExMkBlc2hvcGJveC5jb20ifSwiaHR0cHM6Ly9hY2NvdW50cyI6WyJtb250ZWNhcmxvIl0sImh0dHBzOi8vd2FyZWhvdXNlV29ya3NwYWNlcyI6W10sImh0dHBzOi8vd2FyZWhvdXNlcyI6W10sImh0dHBzOi8vcGFydG5lcnMiOltdLCJpc3MiOiJodHRwczovL2VzaG9wYm94LXBheW1lbnQtcmVjby5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8NjA1MDk3MzkyNGEwYTIwMDY4OTc1ZjI3IiwiYXVkIjoiaHR0cHM6Ly9lc2hvcGJveC1wb3J0YWwtZGV2LmFwcHNwb3QuY29tIiwiaWF0IjoxNjMyMjgyNDQ2LCJleHAiOjE2MzI1NDE2NDYsImF6cCI6Inc4dllYa2ZMSWZmOFl2Mmo0TzNUOUplYWoxUzNxOHJlIiwic2NvcGUiOiJyZWFkOnByb2R1Y3RzIHJlYWQ6aW52ZW50b3J5IHJlYWQ6cHJvZHVjdF9saXN0aW5ncyIsImd0eSI6InBhc3N3b3JkIn0.UPCXr1fqPqYZgTkaKvXAD038XilsiaXjT4ia1OW0KeGawpphJQkNLZnzUdrySqJB5ZhgZ38tj2Stjxyd2Nh6Tg6k-VRuNCag2RCJBAVwBlyik7cJBDHDR4yEM_qZR9bEYnX5xNijH8aHBEngM6KrIaiKQFcTSSXFx54hzALQtzIvTBo8vQJeqhbbvmW3VqTHikJLwNjVvk2Tx5wxsJzD77HCFWaXWWKk1YOEuCY_6to26elsrNopGKT9gebdr8n1nnWwtHbJNg_oLULF3CKqa9MsL6i0NRU0PffmIQy1Qg8rN0yRF81tGKoT4zwRaKWjpkWFO4nzJPKKlnR6uGpj3g",
"storeSlug": "",
"externalChannelId": "CH4698",
"accountSlug": "montecarlo",
"connectionId": "294",
"location": {
"0d88483e-a595-4388-8450-366a4cdf892c": "XSAA",
"05593b4c-eb61-471a-8642-e11f40fb028d": "QNEV",
"e5ede046-5f51-4e59-ade4-96e0e6bf613d": "Warehouse"
},
"accessToken": "Atza|IwEBIHdxXBTYg__CTpLxdfzpr0MqE63R2P8HkLatEg9zIVuIAcMz3jy970mFddvEJ9RORMM6OhUPq0wQU0p6nc0KS5KeVuQtXjchInHJiy8kc7mLRcBwfymSkkyFqTGXA-9pijXshkM9lEH5_BoFApJpq7gdS7VvB6tb8IQ3TyImodpc-_WXcarpDSiDEdhoEwY3VUroXup40JjjjRH1EGYg9QmrnglfaffmqRxiLiDn6n-5G0yhSXkkuhtiwXewoPJcdAq8mD6NyuE-Xp8dogAK2q9_oN545Ta1aif9CXE6VbDMg-oKPeTE4gKM14JeKuxIQrruqiG94UVIwb3SiO_1dRWUw1sJeOttyJPyZfdIGIDtBXXMfrx2lJMcxDlismlGH5cp_-ma03TPl8cK1LJpJl9-Tu_j4Wgv-XVZYydPQlmJ-V5KgwTKwRQzOnr4_TjGE2o",
"isActive": "active",
"refreshToken": "Atzr|IwEBIKGUcydGuZ9AGyNlmsKVeGx0AbY4SuW6JfOKM9Qd-cbU74jQdSnRty28M0TbYceByx0o44aQiCMjattsw2LL-yy4hZDGhEh6gPosUA9oD_c5PYQAy1coh-FGt9XMi2Sg0B5VjkKM0cwqaKj9VVAVZu3q-N9u0NIgrSr0yAe6mT0a7pZ8GmCGwiVnMYytqgGPmwD9aljAcC2AyYdJSIO6RLJuttyqWKkXEvdh86K2Q-PwY-3Ou1Rw8Kezj4CIU3FYwDFa3bmxpo-S08o_vp3bOYQI9pZE1lMOCkdhsbowKUdcsjyG61T25GgRkGuwcIyvKgh41R4VfIZptTsm0Lxx05tSSr2YA_2aoq20PRvjyBuwRKWxCt8DsCXmMSjPWN0aT0-VL8MFgYuZzTizG01qX8nGul1DJuwZvcAHiGzg0u1CZk3x0hVa_YxMw1OEzK_SDYGCpQCh77GWWJxcVVobIdnV"
},
"orderDetail": {
"creationTimestamp": 1632244612521,
"fulfillmentLocationId": "e5ede046-5f51-4e59-ade4-96e0e6bf613d",
"id": "ae1f8e01-9bf7-4af3-8c7a-a37c3e4b8393",
"lastUpdatedTimestamp": 1632244613868,
"merchantSku": "MyReturnSku",
"numberOfUnits": 1,
"returnLocationId": "e5ede046-5f51-4e59-ade4-96e0e6bf613d",
"returnMarketplaceChannelDetails": {
"channelSku": "MyReturnSku",
"customerOrderId": "M6bMEWxr3Z",
"marketplaceChannel": {
"channelName": "FBA",
"marketplaceName": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlJVVXdSREZCUVRSRFFqQkdORFUxTVVZeE16ZEdPRFJHTnpORk5EaEJSVEU0TVVORk5qVTJOdyJ9.eyJodHRwczovL2FwcERhdGEiOnsiYXBwQ2xpZW50SWQiOiJjM2I3ZGUzMzk0MzRkNWYxZDY0ZjFkNTllMmM0ZGM3YiJ9LCJodHRwczovL2FjY291bnRTbHVnIjoibW9udGVjYXJsbyIsImh0dHBzOi8vdXNlckRldGFpbHMiOnsiaWQiOjExMDQsInVzZXJUeXBlIjoiZGVmYXVsdCIsImVtYWlsIjoiYXBwdXNlcjExMkBlc2hvcGJveC5jb20ifSwiaHR0cHM6Ly9hY2NvdW50cyI6WyJtb250ZWNhcmxvIl0sImh0dHBzOi8vd2FyZWhvdXNlV29ya3NwYWNlcyI6W10sImh0dHBzOi8vd2FyZWhvdXNlcyI6W10sImh0dHBzOi8vcGFydG5lcnMiOltdLCJpc3MiOiJodHRwczovL2VzaG9wYm94LXBheW1lbnQtcmVjby5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8NjA1MDk3MzkyNGEwYTIwMDY4OTc1ZjI3IiwiYXVkIjoiaHR0cHM6Ly9lc2hvcGJveC1wb3J0YWwtZGV2LmFwcHNwb3QuY29tIiwiaWF0IjoxNjMyMjgyMjgwLCJleHAiOjE2MzI1NDE0ODAsImF6cCI6Inc4dllYa2ZMSWZmOFl2Mmo0TzNUOUplYWoxUzNxOHJlIiwic2NvcGUiOiJyZWFkOnByb2R1Y3RzIHJlYWQ6aW52ZW50b3J5IHJlYWQ6cHJvZHVjdF9saXN0aW5ncyIsImd0eSI6InBhc3N3b3JkIn0.SGgOc0lpGkoHFLUcj9nwclp3j6SvvBviEHccPYPlgEArtZbrOaT73xfwFGvbmhcWrIkZ4g04YbifbhSIUYHQJVRhI2VJkvi_yx6WZ1cpABHlipn1vTrnYXO5K0x45GtnEnXFFHnD6fCuB2ERGl9HK-g4AzfaGxgLfYZD_MoCr0V347qhbfcit3HsNAL-Oi3blikZSQbPQCNaMjmcucyW9OLyomtdddKmohBSvtbEIx54yjHRpJNDfmWNRRZtUPlsXnPBfaAlrKFa5a-Ij5NlaOIS3QzUEltKM8i48QkDdnbHiOm3c88RfsF7pV5UEJD7dk_WXZ9sse7SmUZI3c7n-Q"
},
"merchantId": "AAFR4ZPY4GS0",
"returnLocationId": "Test-location-Eshop",
"shipmentId": "EeIlTeLVhM"
},
"returnMetadata": {
"fulfillmentOrderId": "824f235d-0cf7-4fbf-95f6-fbc73d2bcade",
"invoiceInfo": {},
"returnReason": "SS27vFE5ZM",
"rmaId": "Test123rmaID"
},
"returnShippingInfo": {
"forwardTrackingInfo": {
"carrierName": "ATS",
"trackingId": "9650980635"
},
"reverseTrackingInfo": {
"carrierName": "TestCarrier",
"trackingId": "true"
}
},
"returnStatus": "CREATED",
"returnType": "CUSTOMER"
}
}
}
, multiple selections available,
Related content
Amazon Create Return V2
Amazon Create Return V2
Read with this
Amazon Return Complete Flow
Amazon Return Complete Flow
More like this
Amazon Return Update Flow - new
Amazon Return Update Flow - new
More like this
Amazon return cancellation flow
Amazon return cancellation flow
Read with this
Amazon Cron Job return Flow
Amazon Cron Job return Flow
More like this
Amazon Create Order Flow
Amazon Create Order Flow
More like this