Updated to support both live and test endpoint responses.