FoxyCart's SSO allows you to send an authenticated user from your own site to your FoxyCart checkout without needing to re-enter their username (email address) and password. In order to increase security and greatly reduce security risks, shared-authentication checkouts still require the customer to enter certain aspects of their payment information. As of v051, a shared-authentication customer can re-use a previously saved credit card, but the CSC must be entered.
This allows for a few interesting options in addition to just shared-authentication:
The basic idea of SSO is as follows:
COOKIE
headers).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);
Note that if you append any additional fields after the required fields above you still must separate the values with an ampersand (&
). For example, if you're pre-populating the checkout fields:
$redirect_complete = 'https://yourdomain.foxycart.com/checkout?fc_auth_token=' . $auth_token . '&fcsid=' . $fcsid . '&fc_customer_id=' . $customer_id . '×tamp=' . $timestamp . '&customer_name=' . $customer_name; 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:
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.