Installation

Registration

To get started with Connect, you will need to register your app through the HandCash developer dashboard.



Permissions

During the registration, you will be asked to select permissions that will be required by your app. Below are all the available permissions:


Pay


Process user payments

Public Profile


View the user's public profile: 'handle', 'displayName', and 'avatarUrl'.

Private Profile


Connect with the user's private profile: 'email' and 'phoneNumber'.

Friends


Fetch the user's friends list.

Decrypt & Encrypt


Generate an encryption/decryption keypair.

PublicProfile is enabled by default for all applications.



Initialize the SDK

Install the SDK module to your project:

npm install --save @handcash/handcash-connect


Import the module and initialize:

const {HandCashConnect} = require('@handcash/handcash-connect');
const handCashConnect = new HandCashConnect('<app-id>');


Generate the oauth url:

const redirectionLoginUrl =  handCashConnect.getRedirectionUrl();


Initialize the user’s cloud account:

const account = handCashConnect.getAccountFromAuthToken(token);

This must be initialized using the authToken from the earlier authorization. See our authorization page for a full walkthrough.



View user profile:

const { publicProfile } = await account.profile.getCurrentProfile();

console.log(`Hey ${publicProfile.handle}, welcome to HandCash Connect!`);


Make a payment:

const payParameters = {
    payments: [{ destination: 'nosetwo', currencyCode: 'DUR', sendAmount: 25 }]
};    
  
await account.wallet.pay(payParameters);

Explore our documentation for more features!


In the next section, we’ll be prompting the user for authorization.