centro-sdk
v1.2.7
Published
SDK for interacting with the Centro API for gift card linking and balance checking.
Maintainers
Readme
Centro SDK
This is the official SDK for interacting with the Centro API, designed to facilitate gift card linking and balance checking within your applications.
Installation
To install the SDK, use npm or yarn:
npm install centro-sdk
# or
yarn add centro-sdkUsage
Initialize the SDK
const { CentroLink } = require('centro-sdk'); // If using UMD, or use specific import if bundling for ES Modules
// Access the SDK via the global CentroLink object
const sdk = CentroLink;
sdk.init({
apiKey: 'YOUR_CENTRO_API_KEY',
});Add Account / Open Linking UI
Use the addAccount method to open a popup window where users can link their gift cards. This method also handles the process of creating a link_token and managing the popup.
sdk.addAccount({
clientName: 'Your App Name', // Optional: Name to display in the linking UI
clientLogo: 'https://your-app.com/logo.png', // Optional: Logo URL to display in the linking UI
onSuccess: (data) => {
console.log('Account linked successfully:', data);
},
onFailure: (error) => {
console.error('Error during account linking process:', error);
},
});Sync Account
Use the syncAccount method to synchronize data for a previously linked account, typically to get the latest balance or status.
sdk.syncAccount({
accountID: 'your_account_id', // The accountID received from addAccount onSuccess callback
onSuccess: (data) => {
console.log('Account synced successfully:', data);
// data will contain updated account information, e.g., current balance
// Example: { accountID: "acc_xxx", data: { balance: 100.50 } }
},
onFailure: (error) => {
console.error('Error during account sync process:', error);
},
});License
This project is licensed under the MIT License - see the LICENSE file for details.
