The requirement is to pass some custom fields collected on an order form, have the user pay via PayPal, and then pass those custom fields to an external script so that it can provision the service.
An external script is often required if you are not using Membership software such as iMember360 or CustomerHub that is tightly integrated with Infusionsoft using tags. An external script can be used to set up users on membership site such as WishlistMember, aMember, S2Member or maybe an external mobile service that is provisioned via an API. Typically the script will require user details (email, first name, last name, etc) and some service related information (service tier, membership level, etc). The former are standard Infusionsoft fields; the latter will be custom fields.
Setting Up The Custom Fields
- Set up some custom fields on the contact record for the data you want to capture
- Add those fields to the order form
- Edit the HTTP Post in your campaign sequence and add the custom fields using the Merge Fields facility
On SubscriptionBoss, edit the subscription, and in the Extra Order Information section, add the custom fields in a comma delimited list using their database name. For example, Contact0_custom_bill, Contact0_custom_ben, Contact0_custom_loobyloo
Custom Fields Flow
The order of events is:
- User fills in order form with email, first name, last name, address and custom fields
- User clicks PayPal button which goes to PayPal via SB
- User logs in on PayPal and agrees to pay
- PayPal sends approval to SB
- SB takes payment, adds contact address and custom fields, order and payment to IS
- SB runs IS order success actions
- Order Success action set adds tag which triggers Campaign Sequence that contains the HTTP Post
- HTTP Post sends custom fields as extra parameters to the external script
- External script runs and provisions service, writing back service information (e.g. password) to Infusionsoft and sets tag on completion
- Campaign Sequence is triggered by the tag to run any actions required to inform the user that the service is ready (i.e a welcome email)
With a credit card order, it is the same for steps 1 and 7-10: steps 2-6 and replaced by a single step where the the user fills in credit card details and pays and IS creates the order. So the interaction with the external script is identical however the buyer pays.
Tips For Writing External Scripts
These tips are based on increasing resilience and security of your external scripts that interact with Infusionsoft.
The URL is typically of the form https://yoursite.com/yourscript?licence=abd123&product=4&tag=345
The merged parameters are typically ContactId, Email, FirstName, LastName, plus any custom fields.
On the script I check a couple of things to reduce the risk of processing spoofed orders:
- The license matches the last 6 digits of the Infusionsoft API code
- The referrer IP address is an Infusionsoft one
The script saves the ContactId as the user key since the email address can change in the future. This will ensure any updates such as upgrades or downgrades get applied to the correct user even if their email address changes in the future.
The script might do something like generate a password, create a membership record on WordPress, then write the username and password back to custom fields in Infusionsoft.
Added Reliability – Confirm On Completion
When complete the script adds a tag (345 in this example). This signals that the job has completed successfully and that the service has been provisioned,
The tag corresponds to a goal Product X Ordered completed in the campaign and can trigger further actions like the welcome email.
This is good practice for 2 reasons:
- It avoids a potential race condition when your script generates a password but IS fires off the welcome email prematurely before the script completes with a missing password
- It means that if the script fails then the order is not marked as completed and hence it is stuck as a open order which you can report on on your dashboard. You can then reprocess simply by restarting the campaign sequence.