PactSafe

The PactSafe Developer Hub

Welcome to the PactSafe developer hub. You'll find comprehensive guides and documentation to help you start working with PactSafe as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Guides

Prompting your user on login

If you're executing contracts with a click-through, you will also want to make sure that your users/customers are up to date on the latest agreement when they login to your app. Luckily, with PactSafe we've made it super easy to check on your user to make sure they're up to date. We'll cover:

  • How to check whether your user has accepted the latest versions of your contracts
  • How to embed and process acceptance of updated Versions of your Contracts

What you need

To get started, you need:

  1. Published Contracts in your PactSafe account (How to Embed a Contract)
  2. A Group created dedicated to the login flow (How to create a Group)
  3. A bit of coding knowledge (Getting started with ps.js) including APIs, JSON, and JavaScript

Flow for acceptance

In order to get acceptance of an updated version of a contract, you'll want to follow the below flow:

User logs in => Check if they're on latest versions => If no, present with contract => on valid acceptance, redirect to app

Once the user logs into your app, you'll want to run a quick call to the PactSafe Activity API with the following syntax:

GET /latest?sig={signer_id}&sid={site_id}&gkey={group_key}

That will give you a very simple response with a true/false value for each contract in your Group:

{
    "282": true,
    "1241": false
}

If any value returns false, you'll want to redirect your user to an interstitial page that will render the Contracts based on your Group key. On the page you've redirected your user to, you'll want to include a <div> where the PactSafe JavaScript library will populate with the right agreement. You can use this JavaScript snippet as an example of how to set your signer_id and load the Group onto your page:

<script type="text/javascript">
// add _ps('create') call too!
_ps('load', 'login-group-key', { container_selector: "div-from-above" });
_ps('set', 'signer_id', '<YOUR_ID>');
// the 'valid' event fires when all Contracts have been executed
_ps.on('valid', function(){
  // redirect the user
});
</script>

Note: Make sure in your Group configuration that you've set "Display All" to "false":

Voila! Got questions? Email us at help@pactsafe.com!