Getting Started
Integrate user wallets, trigger payments, and manage digital items with Handcash Connect.
Handcash Connect
Enable users to connect their Handcash wallets to your application, trigger payments, and manage digital items on their behalf. Handcash Connect offers seamless integration of blockchain functionalities, enhancing your application’s capabilities and user experience.
Get Your App Credentials
Before you begin, obtain your application credentials by following the Getting Started with the Developer Dashboard guide. These credentials are essential for integrating Handcash services into your application.
Install the SDK
To start using Handcash Connect, install the SDK via npm:
Import and Initialize the Module
Import the Handcash Connect module and initialize it using your appId
and appSecret
:
Authentication Flow
To access a user’s account for making payments and retrieving their profiles, you need them to authorize your app. Here’s how the authentication flow works:
1. Redirect the User to HandCash for Authorization
Generate the redirection URL using the SDK:
Alternatively, you can compose the URL manually:
Redirecting the user to redirectionLoginUrl
will take them to HandCash, where they will be prompted to grant permissions to your app.
2. User Grants or Denies Permissions
At HandCash, the user will see a prompt asking them to grant permissions to your app. They can either accept or decline access.
App authorization preview in the HandCash App
3. Handle the Redirection Back to Your App
After the user makes a selection, they will be redirected back to your app’s Authorization Success URL or Authorization Failed URL, which you specified in your app settings.
-
If the user accepts, they will be redirected to:
-
If the user declines, they will be redirected to:
4. Retrieve the authToken and Initialize the User Account
Extract the authToken from the query parameters of the redirection URL. Use this token to initialize the user’s account:
Important: Keep the authToken secure. Do not expose it in client-side code or logs.
Custom Redirection Parameters
If you need to pass custom parameters through the authentication process (e.g., to maintain state), you can include them when generating the redirection URL:
Security Considerations
- Protect the authToken: Store the authToken securely on your server. Do not expose it in client-side code or logs.
- HTTPS: Ensure that all redirection URLs use HTTPS to protect user data during transmission.
- Session Management: Use secure session management practices to associate the authToken with the user’s session in your application.
- Token Expiration: Be aware that the authToken may expire. Implement error handling to manage token expiration and re-authentication if necessary.
Summary of the Authentication Flow
- Your App Redirects the User: Redirect the user to HandCash using the authorization URL.
- User Authenticates and Grants Permissions: The user logs in to HandCash (if not already logged in) and grants permissions to your app.
- HandCash Redirects Back to Your App: After authorization, HandCash redirects the user back to your specified success or failure URL, including the authToken if successful.
- Your App Uses the authToken: Use the authToken to initialize the user’s account with the HandCash Connect SDK.
- Interact with the User’s Account: Utilize the SDK to access user data and perform actions on their behalf.
App Gallery
Complete the app submission form in Developer Dashboard to be included in the Handcash App Gallery