Written by Jase Clamp Friday, 26 August 2011 14:20
How to setup RS Forms Pro for Authorize.net payments
1. SSL in place
The first thing you have to do is get yourself an SSL certificate and make sure that is configured. Then you have to make sure that when you send people to the form, that the link is HTTPS. It is possible to PHP code in the form to sense this and automatically redirect but we have not bothered with this.
2. Build the form
You need to create your form and add at least the minimum required billing fields. You can ask for much more information however. Your minimum fields should be:
- First Name
- Last Name
- Card Type (pull down)
- Expiration (text, tell them to enter mm/yy format)
- Credit Card Number
- Billing steet
You may also want to ask for their email address, phone number, company name etc.Take note of what you NAME each field as you'll need to incorporate the field names into the credit card processing script.
3. Add the credit card processing scripts
In RS Form, go to the tab called "scripts".
To the "Script called on form display" add:
This is the script that will check to see if the form has already been submitted and if it's being returned with a credit card processing error. If so this script assumes an attempt has already been made and shows the error to the user.
To the "Script called on form process" add:
This script does all the heavy lifting. You have to edit this script a lot. Every where it says $_POST['form']['whatever'] - you have to change it to what you used for that actual field when you built the form. So if you NAMED your "amount" field "amt" then you should put that in the code.Pay attention to the part at the beginning, it is checking for your required fields. You need to set those to what your required fields actually are.
To the "Script called after form has been processed" add:
This is the post processing script. If the card ran successfully it allows the form data to save to the database. If it did not it will redirect to reload the form with the credit card error message so the user can try again.
You need to especially note where it says "formId=X" this is where you set what your formId is or else it will not redirect back to the correct form. At the end of the script it wipes the CC number so you're not saving it in your database. Look at where it says where 'FieldName' = '??' you have to change it to what you called your credit card number field. Its important to do this step. It will wipe all field submissions from all forms with that feild name.
4. Test and tweak
Don't forget to edit your user and admin emails. You have to manually include the fields in the email that you want to send. I've provided instructions here to build this form from scratch but if you want to take a shot at just installing my backup version into your RS Form, I've provided the file here. Be warned however, if your version of RS Form does not match, this may not work.