I know it's an old post, but there's a problem with the step 3. It should be like this:
var form = $('this.agreementsForm') ? $('this.agreementsForm') : $('payment.form');
I know it's an old post, but there's a problem with the step 3. It should be like this:
var form = $('this.agreementsForm') ? $('this.agreementsForm') : $('payment.form');