Account class
The Account
class is a client for interacting with the Kross API's account-related endpoints. It extends the KrossClientBase class
and provides methods for checking account information, registering and verifying accounts, and initiating and canceling withdrawals.
Constructor
Methods
- check()
- register()
- verify()
- withdrawInit()
- withdrawCancel()
- withdrawVerify()
Hooks
- useAccountHooks()
The Account
class constructor accepts a KrossClientOptions object as its only argument. This object is used to configure the underlying Axios instance that makes the HTTP requests to the Kross API.
import { Account } from 'kross-sdk';
const account = new Account({
baseURL: 'https://api.kross.com',
accessId: 'afsdfsdfjsdfsd',
secretKey: 'sdfsdfsdfsdfsdf',
});
- check()
The check()
method is used to check the status of an account.
account.check({
bankId,
accountNumber,
name,
});
bankId
- The ID of bank.
accountNumber
: Account number of the user
name
: name of the user
Return a response on success
{
bankOwnerName: string;
bankSearch: string;
realBankOwnerName: string;
tid: number;
}
- register()
The register()
method is used to register a new account.
account.register({
bankId,
accountNumber,
name,
initial,
user_id,
});
bankId
- ID of the bank account.
accountNumber
- Account Number of the user.
name
- Name of the user.
intial
- true or false if it intial registeration or updation of bank details
Return a response on success
{
memAccntno: string;
tid: number;
}
- verify()
The verify()
method is used to verify an account.
account.verify({
code,
user_id
});
verification_code
- The verification code received by the account owner.
user_id
- User id of the logged in user
Return a response on success
{
memAccntno: string;
tid: number;
}
- withdrawInit()
The withdrawInit()
method is used to initiate a withdrawal from account.
account.withdrawInit({
amount ,
member_no
});
account_id
- The ID of the account from which to withdraw.
amount
- The amount to withdraw.
member_no
- member_no of the user
Return a response on success
{
tid: number;
idempotency_key: string;
}
- withdrawVerify()
The withdrawVerify()
method is used to initiate a withdrawal from account.
account.withdrawVerify({
verify_code,
idempotency_key
});
verifiy_code
- verification code received on withdrawInit.
idempotency_key
- idempotency_key from withdrawInit
Return a response on success
{
tid: number;
verifyWord: string;
}
- withdrawCancel()
The withdrawCancel()
method is used to initiate a withdrawal from account.
account.withdrawCancel({
idempotency_key
});
idempotency_key
- idempotency_key from withdrawInit
Return a response on success
{
tid: number;
}
Hooks
- useAccountHooks()
The useAccountHooks()
method is used to return the react-query hooks for check(), verify(), register() and methods above.
const {check} = user.useAccountHooks();
const {
mutate: accountCheck,
data: accountCheckData,
status: accountCheckingStatus,
} = check();
accountCheck(
{
bankId: '011',
accountNumber: '123466789757866',
name: 'username' || 'none',
},
{
onSuccess: () => {},
onError: error => {},
},
);
Return a response with react-query hooks for check()
, verify()
, register()
and methods above.