Skip to content

Custom Unlock

If you already run a paywall, and you want to continue to lock and unlock the content yourself, you can use a Custom Unlock method. SmartWall will still push dynamic options and content, but will work as if it were a payment system and will not lock and unlock content by itself. You will have the control.

This method extends from javascript integration, but do different in several ways from the usual implementation.

SDK v1 will be deprecated in the coming months, we suggest that you update your integration to SDK v2. More in Upgrading to v2.

Payment method behavior:

You can use the SmartWall as a payment method only. You handle yourself where SmartWall will appear within your articles as well as in which articles it will be active. After the user unlocks the wall, the user will be redirected to a callback URL of your choice (configured via the dashboard).

You can add a userId and an articleId parameter when initializing the SmartWall. These parameters will be used in the token to identify the article to unlock for each user."

The token you will receive is a JSON Web Token signed with the secret encrypted key that you can find on your dashboard.

new SmartWallSDK({
    smartWallId: 'your-smartwall-id',
    userId: 123456,
    articleId: 123456

The token will be send as a GET parameter called token and will look like this eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjM0NTYiLCJhcnRpY2xlSWQiOiIxMjM0NTYiLCJ0eXBlIjoidmlkZW8iLCJpYXQiOjE1MDEyNDQyOTksImV4cCI6MTUwMTI0NDM1OSwiaXNzIjoiU3dpc3NQYXkifQ.ehWNyCZ-qwxjRTOUfbWz4wH2FWKHKElmdeBHuG0y0Hc

Once decoded with base64 it will contain information like the following.

  "userId": "123456",
  "articleId": "123456",
  "numberArticle": 1,
  "type": "video",
  "iat": 1501244299,
  "exp": 1501244359,
  "iss": "Smartwall"

If the signature is valid and the token has not expired you can grant the access to the user.

Override callback after an unlock

When you use the SmartWall as a payment method, the SmartWall will call your callback URL after a successful unlock. If you want to change the behavior of that call you can change it line in the following example:

new SmartWallSDK({
    smartWallId: 'your-smartwall-id',
    onCallback: function(token, callbackUrl) {
        console.log('token', token); // this will output the callback token
        console.log('callbackUrl', callbackUrl);  // this will output the callback URL