All courses offered on Lagunita (https://lagunita.stanford.edu/courses) are free of charge. Learners do not have to pay for the course or pay to earn the Statement of Accomplishment. Many courses can opt in to offer the Statement of Accomplishment but not all do.
As long as you meet the minimum requirements set by the instructor by the end of the course, you can earn a Statement of Accomplishment.
Keep in mind that while the course content comes from Stanford instructors, these courses do not convey any college or university credit. The Statement of Accomplishment is proof that you completed a free Stanford online course with the minimum passing score.