Amazon.com Inc. agreed to pay $2.5 billion in penalties and refunds and change its process for how to cancel its Prime subscription to settle a lawsuit by the US Federal Trade Commission.