its not exactly what you are looking for, but this will give you an idea how to implement loyalty points
Thanks!!
G.