sagapay
v2.2.5
Published
sagapay.net a free cryptocurrency payment gateway dedicated towards web3 development
Downloads
11
Maintainers
Readme
Sagapay API Client
A simple npm package to interact with Sagapay's API for deposit, withdrawal, and balance check.
Installation
Install the package using npm:
npm i sagapay
Usage
First, import the package in your project:
Initialize
const SagapayAPI = require("sagapay");
Now, initialize the client with your API key and secret:
const client = new SagapayAPI('your_api_key', 'your_api_secret');
Check Balance
To check the balance, use the checkBalance method:
`(async () => { const token_id = 'your_token_id';
const response = await sagapay.checkBalance(token_id); console.log(response); })();`
Deposit
To create a deposit, use the deposit method:
`(async () => { const token_id = 'your_token_id'; const amount = 100; const ipn_url = 'your_ipn_url'; const udf = 'your_udf or null';
const response = await sagapay.deposit(token_id, amount, ipn_url, udf); console.log(response); })();`
Withdraw
To create a withdrawal, use the withdraw method:
`(async () => { const token_id = 'your_token_id'; const amount = 100; const withdrawal_address = 'your_withdrawal_address'; const ipn_url = 'your_ipn_url'; const udf = 'your_udf';
const response = await sagapay.withdraw(token_id, amount, withdrawal_address, ipn_url, udf); console.log(response); })();`
IPN Validation
To validate the IPN signature, use the validateIPN method in Node.js:
const isValid = client.validateIPN(request, 'secret_key');
console.log('IPN is valid:', isValid);
Replace 'your_api_key' and 'your_api_secret' with the actual values provided by Sagapay. Never expose api_secret to the client side.