Quick Start

  1. Sign up to Spiff. Go to Hub.spiff.com.au and create an account
  2. Create a integration by going to Partners => Integrations => Create new Integration Select Bespoke API (or Wordpress if you are setting up a workdpress store) and name your integration and save Note: If you are a developer and do not plan to handover the integration to a customer you can choose to use our sandbox checkbox. If you do not select sandbox, you will need to select a plan by entering your payment details to activate the integration.
  3. Take note of your Key and Secret, inside your new integration page. You will need this for the steps below
  4. Create a product in Spiff and then link it to your new integration.
  5. Now you are ready to add the Spiff Javascript API to your site by adding this snippet:
<script type="text/javascript" async src="https://assets.spiff.com.au/api.js"></script>
  1. Paste this into your site. Replace the integration product ID and currency code.
<script>
window.addEventListener('SpiffApiReady', function () {
    const product = new window.Spiff.IntegrationProduct('<ENTER YOUR INTEGRATION PRODUCT ID HERE>');
    product.on('ready', () => {
        if (pageSessionId === undefined) {
            pageSessionId = window.Spiff.Analytics.createPageSession();
        }
        const transactionOptions = {
            presentmentCurrency: '<ENTER THE 3-LETTER ISO CODE OF YOUR CURRENCY HERE>',
            product: product,
            shouldCreateDesignProduct: true,
            pageSessionId
        };
        const transaction = new window.Spiff.Transaction(transactionOptions);
        transaction.on('complete', async (result) => {
            console.log(result);
        });
        transaction.execute();
    });
    product.confirmActive();
});
</script>

The integration id for the product you are wanting to test can either be found in the product or the Integrations page.

The code as it is will immediately launch a workflow and upon completion of a workflow will log its results to the console. To ultimately complete integrating with Spiff you will need to modify the code to store the results of the workflow and, if you want the workflow to launch on button press rather than immediately, you will need to add the button and hook it up yourself.

  1. Place an order through the REST API. Orders look like this:
POST /api/v2/orders HTTP/1.1
Host: api.spiff.com.au
Date: Mon, 23 Apr 2012 12:45:19 GMT
Authorization: SOA <ENTER YOUR SOA HERE>
Content-Type: application/json
{
    "autoPrint":false,
    "orderItems":[
        {"amountToOrder":1,"transactionId":"<ENTER YOUR TRANSACTION ID HERE>"}
    ]
}

The transaction ID is an ID that is returned on completion of the workflow. The SOA is calculated like so:

${ClientKey}:${Base64EncodedRequestSignature}

The request signature is computed from a hmac hash value of the following appeneded strings. To generate this hash the client secret should be used as the hash key.

${RequestMethod}\n${MD5(RequestBody)}\n${RequestContentType}\n${RequestDate}\n${RequestPath}

See this example implementation of this operation.