Skip to content
Jaah edited this page Nov 3, 2020 · 26 revisions

Basic Setup

The UP SDK for JavaScript doesn't have any standalone files that need to be downloaded or installed. Instead, you simply need to include a short piece of regular JavaScript in your HTML.

<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script>
UP_SDK.init({
     "BIZ_ID": 73090796,
     "API_KEY": "e0cae0a32f33313f984da864cdee5db520bb144f",
     "USERNAME": "biz_adm_clients_iQUgwWoZeyTK",
     "ENV": "staging",
     "LANG":"en"
});
</script>
<script>
.... call SDK methods
</script>

Async way:

This will asynchronously load the SDK into your pages. The async load means that it does not block loading other elements of your page. You should insert the following snippet of code directly after the opening body tag on each page you want to load the SDK.

window.UPAsyncInit = ()=>{
       UP_SDK.init({
           BIZ_ID: <biz id>,
           API_KEY: <apikey>,
           USERNAME: <username>,
           ENV:"staging",
           LANG:"en"
       })
}

 
(function(d){
        var js, id = 'up-jssdk', ref = d.getElementsByTagName('script')[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "https://test-sdk.urbanpiper.com/";
        js.onload = UPAsyncInit;
        ref.parentNode.insertBefore(js, ref);
}(document));

👉 NOTE: For production, we recommend the usage of NPM (explained below).

NPM:

Run npm install upsdk

const UP_SDK = require('upsdk');
UP_SDK.init({
     "BIZ_ID": 76720224,
     "API_KEY": "aed73f0aee77471d360b69b1fc4346c37d0d3ca4",
     "USERNAME": "biz_adm_clients_IcEVXvDMlSAC",
     "ENV": "staging",
     "LANG":"jp"
})
export default UP_SDK;

Init

Initialize and set up the SDK. All other SDK methods must be called after this one.
init is a synchronous call and it returns certain persistent information that might be required later.
Any SDK method should be called after init call.

Required params:

{
  "BIZ_ID":  "23425345"
  "API_KEY": "bb30b3e53176f7b249bf0b16652a5afd0dc5f9de",
  "USERNAME": "biz_tst_vjUSsDcewHRIZCFjCARVZn",
  "ENV": <staging|production>,
  "LANG": "en"
}

You can change the language later on. - Language

Response structure

Response for all methods is:

{
   success: <true|false>,
   data: {    
   },
   error_message: "error message"
}

This doc covers the following topics:

  1. Authentication
  2. User
  3. Gallery
  4. Stores
  5. Checkout
    |------ Catalogue
    |------ Cart
    |------ Guest checkout
    |------ Order
  6. Payment gateway
Clone this wiki locally