finished buy api, now just logics