pay function