buy function complete