Javascript SDK

Prev Next

The latest service changes have not yet been reflected in this content. We will update the content as soon as possible. Please refer to the Korean version for information on the latest updates.

Available in Classic and VPC

This guide describes how to use the GAMEPOT Javascript SDK to integrate GAMEPOT on the web. You can integrate the game and dashboard by installing the SDK and configuring the environment.

The requirements for using the GAMEPOT SDK for Javascript are as follows.

  • Minimum specifications: Chrome 4, IE 8, Firefox 3.5, Safari 4, Opera 10.50, etc.

Install SDK and configure environment

How to configure basic settings to use JavaScript SDK is as follows.

  1. Download gamepot-sdk-javascript-lastest.min.js.
  2. Add the downloaded file, gamepot-sdk-javascript-lastest.min.js between the head and head.
    <head><script src="gamepot-sdk-javascript-lastest.min.js"></script></head>
    
    // Or you can use a CDN link directly. (Recommended)    
     <head><script src="https://gamepot.gcdn.ntruss.com/gamepot-sdk-javascript-lastest.min.js"></script></head>
    

GAMEPOT Javascript SDK is offered as an npm package and also accessible via yarn.

# using npm
npm install gamepot

# using yarn
yarn add gamepot

Console Setting Guide for Social Media Log-ins: Download

Available log-ins: Google/Facebook/Apple log-ins

For Apple logins, the GAMEPOT Dashboard > Project settings > General > Apple ID login field should be filled in.
The address of the domain you're logging in from should be listed in GAMEPOT Dashboard > Project settings > General > WEB- Allowed domains.

Reset

To allow run it once the web page loading is done, reset within window.onload = function() {...} or $(ducement).ready(function() {...}) if you’re using jQuery.


<!-- YOUR WEB HTML CODES -->
<script>
window.onload = function () {
    // Project ID can be found in the GAMEPOT Dashboard.
    var project_id = 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxx';
    var gamepotConfig = {
      // Common
      api_url: "https://gpapps.gamepot.ntruss.com",
      api_key: "XXXXXXXXXXXXX",
      // If you're using Google login, enter your Google API client ID as follows.
      google_signin_client_id:"XXXXXXXXXX-XXXXXXXXXXX.apps.googleusercontent.com",
      // If you're using Facebook login, enter your Facebook app ID as follows.
      facebook_app_id: "XXXXXXXXXX",
      // If you wish to use Apple Log-in, type the Service ID of the Apple console and domain address you’re accessing from. (If not applicable, leave it blank).
      apple_client_id: "XXXXXXXXXX",
      apple_redirect_uri: "https://XXXXXXXXXX"
};
GP.initialize(project_id, gamepotConfig);
};
</script>
Attribute Description
project_id GAMEPOT Dashboard Project ID
api_url URL associated with GAMEPOT dashboard (It is https://gpapps.gamepot.ntruss.com by default. However, this address may be different for managed product customers, so you may need to contact GAMEPOT.)
api_key Authentication key issued by GAMEPOT (Dashboard > Project settings > API key)
google_signin_client_id Web Application ID within the Google console
facebook_app_id Facebook app ID
apple_client_id Services ID created in the Apple console
apple_redirect_uri Domain address you're attempting to log-in from

Error handling

The error handling is the same for all. If there is an error, a message, such as function (user, error) { }, is displayed and if there is no error, a success is returned.

GP.login(GP.ChannelType.EMAIL, function (user, error) { 
        if(error) { // Login failure 
            alert(error.message); // Failure message 
            return;
        } 
        alert(user);
});

Login, logout

You can integrate Google, Facebook, and Apple ID login SDKs.

log in

The login UI must be implemented by the developer; it connects when a user clicks the login button.

Social Platform Log-ins

// Define login type.
// GP.ChannelType.GOOGLE : Google
// GP.ChannelType.FACEBOOK : Facebook
// GP.ChannelType.APPLE : Apple ID
// GP.ChannelType.KAKAO : Kakao

// Call when the Facebook Log-in button was pressed.
GP.login(GP.ChannelType.FACEBOOK, function (user, error) {
  if (error) {
    alert(error); // Error message
    return;
  }
    // Login completed
    alert(user);
});

The social login will automatically sign you up for the game at the same time you log in. If you don't want the signup, you can add the following option.

GP.setAuthSignup(false);

USER Data Class

ID type desc
id string Member ID
token string Login token (JWT)
nickname string Nickname
provider string Social login type
providerId string Social login ID
verify string Authentication
agree string Agreement to Terms

Email login

GP.signin("email", username, password, function(user, err) {
  if(err) {
      alert(err.message);
    } else {
      alert(user.id);
    }
});

Email signup

GP.signup("email", username, password, name, function(user, err) {
    if(err) {
      alert(err.message);
    } else {
      alert(user);
    }
});

Log out

It logs the current member account out.

GP.logout(function (result, error) {
     if (error) {
            alert(error.message);
     }
    // Log out successful
});

Withdraw from membership

GP.withdraw(function (result, error) {
    if (error) {
         alert(error.message);
    }
    // Membership withdrawal succeeded
});

Check if they're a member via a social account

After logging-in, check if the social account is connected with a GAMEPOT member .

GP.linkingByUser(channeltype, function( user, error) {
    if(error) {
        alert(`${error.code}-${error.message}`); // Error message
        return false;
    }
    if(user == null)
        alert('Account doesn't exist')
   else if(user.member_id.id)
        alert(user.member_id.id);       // Returns ID
});

USER Data Class

ID type desc
member_id.id string GAMEPOT member ID
username string Social ID

4. Plugin

GAMEPOT supports various eternal module connection services apart from the basic functions.
Supporting modules

  • Identification (DANAL)
  • Overseas PG(Xsolla)
  • Domestic PG (DANAL)

Identity verification

The cell phone identification service is to check the user’s identification through an authentication process using their registered cell phone. (Only in Korea)

 GP.Identity('[Identity verification code]',{},function(resp) {
  if(resp.success) {
    alert(resp.orderId); 
  } else {
    alert(resp.error);
  }
});

External payment

The equation that shows the payment window for external PGs, including Xsolla or DANAL

function Payment(key) {
    GP.Payment(key,
      {
        userId: "[USERID]",
        productId : "[ITEMID]",
        name: "[ITEMNAME]",
        buyer_name: "[Customer name]",
        buyer_email: "[Customer EMAIL]",
    },function(resp) {
        if(resp.success) {
          alert(resp.orderId);
        } else {
          alert(resp.error);
        }
      })
  }
Attribute Description
userId GAMEPOT member ID
productId Product code
name Item name
buyer_name Customer name (option)
buyer_email Customer email (option)
playerId Player ID (option)
serverId Server ID (option)
userdata User data (option)