World:setCallbacks
Sets functions for the collision callbacks during the world update.

Four Lua functions can be given as arguments. The value nil removes a function.

When called, each function will be passed three arguments. The first two arguments are the colliding fixtures and the third argument is the Contact between them. The postSolve callback additionally gets the normal and tangent impulse for each contact point. See notes.

If you are interested to know when exactly each callback is called, consult a Box2d manual
World:setCallbacks( beginContact, endContact, preSolve, postSolve )
beginContact function Gets called when two fixtures begin to overlap.
endContact function Gets called when two fixtures cease to overlap. This will also be called outside of a world update, when colliding objects are destroyed.
preSolve (nil) function Gets called before a collision gets resolved.
postSolve (nil) function Gets called after the collision has been resolved.