Dealer finance only deal

Found the car and agreed on a price only if the vehicle is financed and I am concern of incurring prepayment penalty if I pay off the loan. I live in NJ and question if this practice is legal