FoxyCart's SSO allows customers who are already logged into your website to proceed through to checkout without needing to re-enter their username and password. This allows for far greater integration options, and can provide for a significantly improved checkout flow if you have customers who may already be logged into an external system. In order to prevent possible security issues, SSO checkouts still require the customer to enter the CSC when using a saved credit card.
Because of how FoxyCart's SSO functionality works it actually allows for a few interesting options besides straight single sign-on:
The basic idea of SSO is as follows:
COOKIE
headers).Before we get to the details of an SSO implementation, it's important to understand what we consider “best practices” when it comes to SSO. The most important piece that people often miss is that users can be created from You → FoxyCart (via the API) and from FoxyCart → You (via the instant datafeed).
There are two related but unique user creation flows, then:
We strongly recommend allowing both options. Though there are situations where you may require a login prior to allowing a customer to add items to their cart (or even to see pricing), in most situations it will only hurt your sales if you require users to create an account prior to completing the checkout. Also, FoxyCart's checkout is arguably one of the most streamlined user registration forms around, and if the customer is going to be entering information you might as well just have them enter it in one place.
Read the above overview first. Then take note of some of the details below.
checkout
request submitted to FoxyCart, the checkout will redirect back to your shared-authentication endpoint unless a valid authentication token (fc_auth_token
) is passed in.checkout
redirects the user back to your shared-authentication endpoint two additional values are passed in as well, as GET
parameters:fcsid
: The user's FoxyCart session id. This is necessary to maintain the session across domains, particularly important when a store is not using a custom subdomain and the user has third-party cookies disabled.timestamp
: The epoch time on the FoxyCart server. It is important to note that this value is basically provided just in case you want to confirm that times are synched properly. This value should not be used for anything but confirming that the timestamp
you hash and return (below) is indeed in the future as far as FoxyCart is concerned.
If shared-authentication is enabled, the checkout will not load unless a valid fc_auth_token
(and other supporting information) is passed in by your endpoint when it redirects the user. Here's what the checkout expects and requires.
fc_auth_token
: The authentication token is a SHA-1 hash of the FoxyCart customer ID (available through the API), the expiration timestamp, and the store's FoxyCart API key. These values are separated by |
(the pipe symbol). Here's what it might look like in PHP:$auth_token = sha1($customer_id . '|' . $timestamp . '|' . $foxycart_api_key);
or in Ruby:
Digest::SHA1.hexdigest("#{customer_id}|#{timestamp}|#{foxycart_api_key}")
timestamp
value you hash must match the timestamp
value you send in the clear (below). Again, the timestamp
provided to your endpoint must not be used when passed back to FoxyCart, as that timestamp will already be in the past.fcsid
: The FoxyCart session ID. This is necessary to prevent issues with users with 3rd party cookies disabled and stores that are not using a custom subdomain.fc_customer_id
: INTEGER. The customer ID, as determined and stored when the user is first created or synched using the API. NOTE: If a customer is not authenticated and you would like to allow them through to checkout, enter a customer ID of 0
(the number).timestamp
: INTEGER, epoch time. The future time that this authentication token will expire. If a customer makes a checkout request with an expired authentication token, then FoxyCart will redirect them to the endpoint in order to generate a new token.The completed redirect might look something like this (in PHP):
$redirect_complete = 'https://yourdomain.foxycart.com/checkout?fc_auth_token=' . $auth_token . '&fcsid=' . $fcsid . '&fc_customer_id=' . $customer_id . '×tamp=' . $timestamp; header('Location: ' . $redirect_complete);
setTimeout()
to match your expiration setting alerting your user that their checkout session is about to expire to let your customers know that their session is about to (or has already) expired.If you're convinced that FoxyCart is broken because you can't get SSO working, it's possible, but unlikely. Check a few common causes:
is_anonymous
bit should be 0). You cannot send the checkout a guest user, since guest users cannot be reused (by design).checkout
and not cart
.&
or =
.If you still can't get it working, please post in our forum and we'll be happy to help.