Use the Shipment Cancelled Function to manage cancellation requests. The function receives the shipment details, and the shipping system can update the status to “Cancelled” when applicable.
Cancellation can be declined if the shipment has already been dispatched or delivered.
On Salla Partners Portal, click on "+ Add New Function"Select the App Function you want to add, which is in this case the Shipment Creating Function. After selecting, add a name to the function.
Salla auto-generates starter code, which you can overwrite with the following implementation. This gives you a clean foundation to build your shipping logic and ensures the function behaves the way your integration needs.
Explanation
Full Code
1
Function definition
This function is autogenerated by Salla. It runs when Salla triggers Shipment Cancellation, receives the context data, and must return a GenericResponse object.
2
Cancel shipment in shipping company
Sends a POST request to the shipping company's API to cancel the shipment. The request includes the shipment data from the event payload.
3
Return success response
Returns a success response with the shipment data. This is autogenerated by Salla and confirms to Salla that the cancellation was processed.