Login on Web

❗️

Use it only for reference! This version of checkout is deprecated!

This is the classic version of Cleeng's classic checkout. For more updated information about the checkout process, please refer to the MediaStore SDK topic

This tutorial explains the JavaScript functions used for the following:

  • Login only
  • Auto-login
  • Logging out
  • Getting information on a logged-in customer

1. Login only

loginOnly() is a part of authentication. It is like the checkout but without any offer made, so there is no payment component. For simple loginOnly usage we recommend using the HTML version, which doesn't require any coding by you.

Usage

This example shows a simple overlay checkout trigger.

CleengApi.checkout({
    displayType: "overlay",
    publisherId: 123456654,
    completed : function(result){}
});

The example below shows an inline checkout inside a #my-container element. This also triggers the option for the customer to choose an offer.

CleengApi.checkout({
    displayType: "inline",
    containerId: "my-container",
    publisherId: 321123321,
    locale: "fr_FR",
    completed : function(result){}
});

2. Auto-login

You can use the autologin() function to improve the experience for returning customers. If a user is logged in to the Cleeng platform but they don't have an access token, this function can be used to obtain it automatically. When the call succeeds (that is, the user is logged in to the Cleeng Platform), a cookie with their token is set.

Syntax
CleengApi.autologin(callback);

Example

CleengApi.autologin(function(result) {
        if (result.success) {
            alert("Success! Obtained token: " + result.customerToken);
        }
    });

3. Logging out

For logging out use the logout() call.

Syntax

CleengApi.logout(callback);

Example

CleengApi.logout(function(result) {
      if (result.success) {
          alert('You have been successfully logged out');
      }
  });

Example response

[
  {
      "success": true
  }
]

4. Getting information on a logged-in customer

To get useful information about a logged-in customer, use the getCustomer() call.

Syntax

CleengApi.getCustomer(callback);
Example
CleengApi.getCustomer(function(result) {
    if (result) {
        alert("Welcome " + result.displayName + " !");
    }
});

Example response

{
    country: "US"
    currency: "USD"
    displayName: "John Developer"
    firstName: "John"
    id: "123168578"
    lastName: "Developer"
    locale: "en_US"
}

Did this page help you?