@etransfer/core v1.10.1
@etransfer/core
This package integrates the main business functions of etransfer deposit and withdrawal, such as obtaining authorization tokens, initiating withdrawals, etc.
You only need to quote this package to easily access the etransfer deposit and withdrawal functions.
Installation
Using NPM
npm install @etransfer/core
Using Yarn
yarn add @etransfer/core
Prerequisites
Package.json Scripts
Script | Description |
---|---|
clean | Uses rm to remove dist/ |
build | Uses tsc to build package and dependent packages |
lint | Uses eslint to lint package |
lint:fix | Uses eslint to check and fix any warnings |
format | Uses prettier to format the code |
How to use
See the @etransfer/example
for usage examples.
See more Developer Documentation.
Init
import { eTransferCore } from '@etransfer/core';
import { IStorageSuite } from '@etransfer/types';
class Store implements IStorageSuite {
async getItem(key: string) {
return localStorage.getItem(key);
}
async setItem(key: string, value: string) {
return localStorage.setItem(key, value);
}
async removeItem(key: string) {
return localStorage.removeItem(key);
}
}
eTransferCore.init({
etransferUrl: 'etransfer service url',
etransferAuthUrl: 'etransfer authorization service url' ,
storage: new Store()
});
Get authorization
// Get new authorization from the interface, hang on the request header and set data to storage.
await eTransferCore.getAuthTokenFromApi()
// Get authorization from storage, if the data expired, get new authorization from the interface.
await eTransferCore.getAuthToken();
Withdraw
// First, as shown above, init eTransferCore.
// Then, as shown above, get authorization and hang on the request header.
// Then, you can withdraw with correct params.
const { orderId, transactionId} = await eTransferCore.sendWithdrawOrder();
8 months ago
8 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago