if the ball if significantly smaller than the square, compare their positions when they collide : you'll see of which side the ball is nearest.
you can also do this if the ball is bigger, but you'll have to take in account the speed of the ball : you determine the position of the "front" of the ball then you compare it to the position of the square.