Step 1 - Include SDK
Adding gateway javascript sdk in the web app & initialization
Gateway provides a JS sdk to be included in your client side code. The sdk is compatible with all major browsers and JS libraries/frameworks
To get started, include sdk’s JS file before your main webapp
<script src="https://gateway.smallcase.com/scdk/2.0.0/scdk.js"
type="text/javascript">
</script>
Step 2 - Initialize gateway session
Once the sdk has loaded, you will have access to scDK class in the webapp’s JS global scope
An instance of scDK class scGateway
can be initialized to access client side sdk methods
const scGateway = new scDK({
gateway: <gateway_name>,
smallcaseAuthToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJndWVzdCI6dHJ1ZX0.4-iEdgi3W5_xy7Svj4Sj-FWAe5qMrW3u371FnbjJxQ8',
config: {
amo: true
}
})
To enable after market orders(AMO) by passing a boolean value to the amo
key in the config
object in the initialization
Step 3 - Create transactionId
A transactionId is required for the interactions with brokers
TransactionId is created via backend APIs
Interactions & respective APIs below -
- To place a single or basket stock transaction - API example
- to place a smallcase order or setup SIP - API example
- Holdings import -
Step 4 - Trigger transaction
Use triggerTransaction
method to start the gateway transaction
It accepts two parameters -
- transactionId
Eg: TRX_652377470a134a80ac6c56d19ef3416c - brokers
array of supported brokers, usealiceblue
,angelbroking
,axis
,edel
,fivepaisa
,hdfc
,iifl
,kite
,trustline
&upstox
All brokers are shown if the key is missing/empty
scGateway.triggerTransaction({
transactionId: <transactionId>,
brokers: ['kite', 'hdfc']
})
.then(res => res)
.catch(err => err)
Step 5 - Save order response
Order response is shared in the .then
block of the triggerTransaction
promise as well as over API webhooks
Check response structure here
In case the transaction is not placed with the broker, any error is available in the .catch
block
List of transaction errors is available here
Broker Account Opening
Trigger the signup
method to start the account opening signup flow.
It accepts an optional parameter -
userDetails
can have one or more of the following string keys containing user details:name
- Full nameemail
- Email addresscontact
- Contact numberpinCode
- Pin code
The keys inside the userDetails
object are optional.
And for all relevant keys passed to the signup method, gateway will pre-populated relevant user data in the signup flow, ensuring a smooth user experience
Example usage
scGateway.signup({
name: 'Chuck Noris',
email: '[email protected]',
contact: '9876543210',
pinCode: '123456',
})
.then(() => { console.log("signup flow has now ended") });
Note: In order to trigger signup flow, an instance of scDK class scGateway must be initialized.
Updated a day ago