diam-pay-sdk
v1.1.1
Published
A Node.js SDK for interacting with Diam-Pay APIs.
Readme
The Diam-Pay SDK is a Node.js library for interacting with the Diam-Pay Payment Gateway APIs, enabling easy integration of payment processing features into your Node.js applications.
Installation
Install the Diam-Pay SDK with npm: npm install diam-pay-sdk
Usage
Initialize the SDK const DiamPaySDK = require('diam-pay-sdk'); const sdk = new DiamPaySDK();
Set Your API Key
Before using the SDK methods that require authorization, you need an API key. You can generate this by calling the createOrganisationToken method and using the response's apiKey. Here's how to set up your API key after generating it:
Create Account
const accountDetails = { org_name: "YourOrgName", user_id: "YourUserId", type: "user" };
sdk.createAccount(accountDetails) .then(response => console.log('Account created:', response)) .catch(error => console.error('Error creating account:', error));
Create Organisation Token
const orgDetails = { org_name: "YourOrgName" };
sdk.createOrganisationToken(orgDetails) .then(response => console.log('Organisation token created:', response)) .catch(error => console.error('Error creating organisation token:', error));
Generate Deposit Address
const depositDetails = { userId: "YourUserId", userOrg: "YourOrgName", asset: "BTC", // Use "ETH" or "BSC" as needed network: "1" // Use "1" for BTC, "2" for ETH, "3" for BSC };
sdk.generateDepositAddress(depositDetails) .then(response => console.log('Deposit address generated:', response)) .catch(error => console.error('Error generating deposit address:', error));
Transfer Asset
const transferDetails = { senderUserId: "SenderUserId", senderOrg: "SenderOrgName", recipientUserId: "RecipientUserId", recipientOrg: "RecipientOrgName", amount: "1", asset: "ETHwUSDT" // Specify the asset to transfer };
sdk.transferAsset(transferDetails) .then(response => console.log('Asset transfer initiated:', response)) .catch(error => console.error('Error transferring asset:', error));
WebSocket Listeners
const btcListener = sdk.connectToBtcListener();
btcListener.on('message', (data) => { console.log('BTC Listener data:', data); });
const ethListener = sdk.connectToEthListener();
ethListener.on('message', (data) => { console.log('ETH Listener data:', data); });
Contributing
Contributions are welcome! If you discover a bug or have a feature suggestion, please open an issue in the project's GitHub repository.
License
This SDK is licensed under the ISC license. Full license details are available in the LICENSE file in the source repository.
