Create Returns

Create a return

When you create a return:

Diagram

The message sent is the next one.

magento.postsales.return_management.authorize

{
    "return": {
        "sales_channel_id": "ST1",
        "order_id": "000000255",
        "source_id": "SOU1",
        "user": "userA",
        "custom_attributes": [],
        "lines": [
            {
                "id": "98",
                "line_number": 1,
                "custom_attributes": [],
                "reason": "Wrong",
                "reason_description": "I dont like"
            }
        ]
    }
}

Once you send this message, depending on the configuration Auto Approve Return the return will be approver or not.

Auto Approve Return disabled:

Reported event will be thrown.

magento.postsales.return_management.reported

{
    "return": {
        "sales_channel_id": "ST1",
        "order_id": "000000255",
        "source_id": "SOU1",
        "user": "userA",
        "rma": "RMA-CS-000000255-1",
        "custom_attributes": [],
        "status": {
            "code": "REQUESTED",
            "name": "REQUESTED",
            "reason_code": "CSRREQUEST",
            "date": "2018-03-15T14:43:54+00:00"
        },
        "lines": [
            {
                "id": "98",
                "line_number": 1,
                "sku": "24-MB04",
                "status": "REQUESTED",
                "custom_attributes": [],
                "reason": "Wrong",
                "reason_description": "I dont like"
            }
        ]
    }
}

And the event return updated is thrown

magento.postsales.return_management.updated

{
    "return": {
        "sales_channel_id": "ST1",
        "order_id": "000000255",
        "source_id": "SOU1",
        "user": "userB",
        "rma": "RMA-CS-000000255-1",
        "custom_attributes": [],
        "status": {
            "code": "REQUESTED",
            "name": "REQUESTED",
            "reason_code": "CSRREQUEST",
            "date": "2018-03-15T15:03:04+00:00"
        },
        "lines": [
            {
                "id": "98",
                "line_number": 1,
                "sku": "24-MB04",
                "status": "APPROVED",
                "custom_attributes": [],
                "reason": "Wrong",
                "reason_description": "I dont like"
            }
        ]
    }
}

If you want to approve the return,

Diagram

Diagram

You send the event:

magento.postsales.return_management.received

{
    "return": {
        "sales_channel_id": "ST1",
        "order_id": "000000255",
        "user": "userA",
        "rma": "RMA-CS-000000255-1",
        "lines": [
            {
                "id": "98",
                "line_number": 1,
                "sku": "24-MB04"
            }
        ]
    }
}

After that, the event return updated will be thrown

magento.postsales.return_management.updated

{
    "return": {
        "sales_channel_id": "ST1",
        "order_id": "000000255",
        "source_id": "SOU1",
        "user": "userA",
        "rma": "RMA-CS-000000255-1",
        "custom_attributes": [],
        "status": {
            "code": "APPROVED",
            "name": "APPROVED",
            "reason_code": "CSRREQUEST",
            "date": "2018-03-15T15:03:04+00:00"
        },
        "lines": [
            {
                "id": "98",
                "line_number": 1,
                "sku": "24-MB04",
                "status": "APPROVED",
                "custom_attributes": [],
                "reason": "Wrong",
                "reason_description": "I dont like"
            }
        ]
    }
}

The event refund reported is thrown:

magento.postsales.refund_management.reported

{
    "refund": {
        "order_id": "000000255",
        "store_id": "200001",
        "sales_channel_id": "ST1",
        "credit_note_number": "CES222",
        "credit_note_date": "2018-03-15T14:43:53+00:00",
        "status": {
            "code": "RELEASED",
            "name": "RELEASED",
            "reason_code": "REQUESTED",
            "reason_name": "REQUESTED",
            "date": "2018-03-15T14:43:53+00:00"
        },
        "refund_type": "Return",
        "rma": "RMA-CS-000000255-1",
        "user": "LOGISTICS",
        "refund_reason": "REQUESTED",
        "lines": [
            {
                "order_line": "1",
                "order_item_id": "98",
                "reason": "Wrong",
                "reason_description": "I dont like",
                "payments": [
                    {
                        "details": {
                            "cost_gross": "34.64",
                            "cost_net": "32",
                            "cost_vat": "2.64",
                            "vat_rate": "8.25",
                            "vat_detail": [
                                {
                                    "type": "VAT",
                                    "amount": "2.64",
                                    "rate": "8.25"
                                }
                            ]
                        },
                        "status": {
                            "code": "REFUNDED",
                            "name": "REFUNDED"
                        }
                    }
                ]
            }
        ],
        "custom_attributes": []
    }
}

And finally the event refund updated:

magento.postsales.refund_management.updated

{
    "refund": {
        "order_id": "000000255",
        "store_id": "200001",
        "sales_channel_id": "ST1",
        "credit_note_number": "CES222",
        "credit_note_date": "2018-03-15T14:43:53+00:00",
        "status": {
            "code": "RELEASED",
            "name": "RELEASED",
            "reason_code": "REQUESTED",
            "reason_name": "REQUESTED",
            "date": "2018-03-15T14:43:53+00:00"
        },
        "refund_type": "Return",
        "rma": "RMA-CS-000000255-1",
        "user": "LOGISTICS",
        "refund_reason": "REQUESTED",
        "lines": [
            {
                "order_line": "1",
                "order_item_id": "98",
                "reason": "Wrong",
                "reason_description": "I dont like",
                "payments": [
                    {
                        "details": {
                            "cost_gross": "34.64",
                            "cost_net": "32",
                            "cost_vat": "2.64",
                            "vat_rate": "8.25",
                            "vat_detail": [
                                {
                                    "type": "VAT",
                                    "amount": "2.64",
                                    "rate": "8.25"
                                }
                            ]
                        },
                        "status": {
                            "code": "REFUNDED",
                            "name": "REFUNDED"
                        }
                    }
                ]
            }
        ],
        "custom_attributes": []
    }
}

Auto Approve Return enabled:

Return reported event will be thrown.

magento.postsales.return_management.reported

{
    "return": {
        "sales_channel_id": "ST1",
        "order_id": "000000255",
        "source_id": "SOU1",
        "user": "userA",
        "rma": "RMA-CS-000000255-1",
        "custom_attributes": [],
        "status": {
            "code": "REQUESTED",
            "name": "REQUESTED",
            "reason_code": "CSRREQUEST",
            "date": "2018-03-15T14:43:54+00:00"
        },
        "lines": [
            {
                "id": "98",
                "line_number": 1,
                "sku": "24-MB04",
                "status": "REQUESTED",
                "custom_attributes": [],
                "reason": "Wrong",
                "reason_description": "I dont like"
            }
        ]
    }
}

The event return updated is thrown

magento.postsales.return_management.updated

{
    "return": {
        "sales_channel_id": "ST1",
        "order_id": "000000255",
        "source_id": "SOU1",
        "user": "userA",
        "rma": "RMA-CS-000000255-1",
        "custom_attributes": [],
        "status": {
            "code": "REQUESTED",
            "name": "REQUESTED",
            "reason_code": "CSRREQUEST",
            "date": "2018-03-15T15:03:04+00:00"
        },
        "lines": [
            {
                "id": "98",
                "line_number": 1,
                "sku": "24-MB04",
                "status": "REQUESTED",
                "custom_attributes": [],
                "reason": "Wrong",
                "reason_description": "I dont like"
            }
        ]
    }
}

The command authorize will be automatically sent:

magento.postsales.return_management.authorize

{
    "return": {
        "sales_channel_id": "ST1",
        "order_id": "000000257",
        "source_id": "SOU1",
        "user": "userA",
        "custom_attributes": [],
        "lines": [
            {
                "id": "98",
                "line_number": 1,
                "custom_attributes": [],
                "reason": "Wrong",
                "reason_description": "I don't like"
            }
        ]
    }
}

Return reported event will be thrown.

magento.postsales.return_management.reported

{
    "return": {
        "sales_channel_id": "ST1",
        "order_id": "000000255",
        "source_id": "SOU1",
        "user": "userA",
        "rma": "RMA-CS-000000255-1",
        "custom_attributes": [],
        "status": {
            "code": "APPROVED",
            "name": "APPROVED",
            "reason_code": "CSRREQUEST",
            "date": "2018-03-15T14:43:54+00:00"
        },
        "lines": [
            {
                "id": "98",
                "line_number": 1,
                "sku": "24-MB04",
                "status": "APPROVED",
                "custom_attributes": [],
                "reason": "Wrong",
                "reason_description": "I dont like"
            }
        ]
    }
}

Refund reported event will be thrown.

magento.postsales.refund_management.reported


    "refund": {
        "order_id": "000000257",
        "store_id": "200001",
        "sales_channel_id": "ST1",
        "credit_note_number": "CES224",
        "credit_note_date": "2018-03-15T15:48:28+00:00",
        "status": {
            "code": "RELEASED",
            "name": "RELEASED",
            "reason_code": "REQUESTED",
            "reason_name": "REQUESTED",
            "date": "2018-03-15T15:48:28+00:00"
        },
        "refund_type": "Return",
        "rma": "RMA-CS-000000257-1",
        "user": "LOGISTICS",
        "refund_reason": "REQUESTED",
        "lines": [
            {
                "order_line": "1",
                "order_item_id": "98",
                "reason": "Wrong",
                "reason_description": "I don't like",
                "payments": [
                    {
                        "details": {
                            "cost_gross": "34.64",
                            "cost_net": "32",
                            "cost_vat": "2.64",
                            "vat_rate": "8.25",
                            "vat_detail": [
                                {
                                    "type": "VAT",
                                    "amount": "2.64",
                                    "rate": "8.25"
                                }
                            ]
                        },
                        "status": {
                            "code": "REFUNDED",
                            "name": "REFUNDED"
                        }
                    }
                ]
            }
        ],
        "custom_attributes": []
    }
}

Return updated will be thrown:

magento.postsales.return_management.updated

{
    "return": {
        "sales_channel_id": "ST1",
        "order_id": "000000257",
        "source_id": "SOU1",
        "user": "userA",
        "rma": "RMA-CS-000000257-1",
        "custom_attributes": [],
        "status": {
            "code": "APPROVED",
            "name": "APPROVED",
            "reason_code": "CSRREQUEST",
            "date": "2018-03-15T15:48:30+00:00"
        },
        "lines": [
            {
                "id": "98",
                "line_number": 1,
                "sku": "24-MB04",
                "status": "APPROVED",
                "custom_attributes": [],
                "reason": "Wrong",
                "reason_description": "I don't like"
            }
        ]
    }
}

And finally refund updated will be thrown:

magento.postsales.refund_management.updated

 {
     "refund": {
         "order_id": "000000257",
         "store_id": "200001",
         "sales_channel_id": "ST1",
         "credit_note_number": "CES224",
         "credit_note_date": "2018-03-15T15:48:28+00:00",
         "status": {
             "code": "RELEASED",
             "name": "RELEASED",
             "reason_code": "REQUESTED",
             "reason_name": "REQUESTED",
             "date": "2018-03-15T15:48:28+00:00"
         },
         "refund_type": "Return",
         "rma": "RMA-CS-000000257-1",
         "user": "LOGISTICS",
         "refund_reason": "REQUESTED",
         "lines": [
             {
                 "order_line": "1",
                 "order_item_id": "98",
                 "reason": "Wrong",
                 "reason_description": "I don't like",
                 "payments": [
                     {
                         "details": {
                             "cost_gross": "34.64",
                             "cost_net": "32",
                             "cost_vat": "2.64",
                             "vat_rate": "8.25",
                             "vat_detail": [
                                 {
                                     "type": "VAT",
                                     "amount": "2.64",
                                     "rate": "8.25"
                                 }
                             ]
                         },
                         "status": {
                             "code": "REFUNDED",
                             "name": "REFUNDED"
                         }
                     }
                 ]
             }
         ],
         "custom_attributes": []
     }
 }