Nodejs SDK for Eversend payments API
$ npm install --save @eversend/node-sdk
const eversendClient = require('@eversend/node-sdk') ({clientId: "clientId", clientSecret: "clientSecret"});
You can get your clientId and clientSecret from the settings section in the dashboard
Get all wallets
const wallets = await eversendClient.wallets.getWallets();
Get one wallet
const usdWallet = await eversendClient.wallets.getWallet({ id: "USD" });
Get all transactions
const transactions = await eversendClient.transactions.fetchTransactions({ page: 1, limit: 10});
If page and limit are not set, the default of 1 and 10 are used respectively.
Get one transaction
const transaction = await eversendClient.transactions.fetchTransaction({ id: "EVS12345678" });
To exchange from one wallet to another, you first have to generate a quotation. This returns a token with a 30s timeout that you can use to make the exchange.
Get exchange quotation
const quotation = await eversendClient.exchanges.getQuotation({ from: "USD", to: "UGX", amount: 10.0, });
Exchange currency
const exchange = await eversendClient.exchanges.createExchange({ quotationToken: "dhhsggajjshhdhdhd", transactionRef: "EVS-12345678", // optional field });
Get beneficiaries
const beneficiaries = await eversendClient.beneficiaries.getBeneficiaries({ page: 1, limit: 10 });
If page and limit are not set, the default of 1 and 10 are used respectively.
Get single beneficiary
const beneficiary = await eversendClient.beneficiaries.getBeneficiaries({ id: 100 });
Create a beneficiary
const beneficiary = await eversendClient.beneficiaries.addBeneficiary({ firstName: "John", lastName: "Okello", country: "UG", // Alpha-2 country code phoneNumber: "+256712345678", // Should be in international format bankAccountName: "John Okello", bankAccountNumber: "12345678", bankName: "Stanbic Bank", bankCode: 1234 // You can get the bank code from payouts.getDeliveryBanks() });
Note that all bank fields are optional if bank payments will not be required Delete a beneficiary
const beneficiary = await eversendClient.beneficiaries.deleteBeneficiary({ id: 100 });
Get collection fees
const collectionFees = await eversendClient.collections.getCollectionFees({ amount: 1000, currency: "KES", method: "momo" });
Get collection OTP
Required when initiating mobile money collections
const collectionOTP = await eversendClient.collections.getCollectionOTP({ phone: "+256712345678" });
Initiate Mobile Money collection
eversendClient.collections.initiateMomoCollection({ phone: "+256712345678", amount: 1000, country: "UG", currency: "UGX", otpPin: 123456, // From phone number passed in Get Collection OTP otpPinId: "dg524fhsgfde", // From Get Collection OTP transactionRef: "EVS-12345678", // Optional transaction ref generated by you customer: { name: "John Okello" } // Optional customer object with your metadata });
Get payout quotation
const quotation = await eversendClient.payouts.getQuotation({ amount: 100, amountType: "SOURCE", // amountType can be SOURCE or DESTINATION sourceWallet: "USD", destinationCountry: "KE", destinationCurrency: "KES" });
amountTyperefers to whether you want amount to representsourceWallet(SOURCE) ordestinationCurrency(DESTINATION)
Pay existing beneficiary
const payout = eversendClient.payouts.payoutExistingBeneficiary({ beneficiaryId: 100, quotationToken: "token", transactionRef: "EVS-12345678" // Optional transaction ref generated by you });
Pay new beneficiary
const payout = eversendClient.payouts.payoutNewBeneficiary({ firstName: "John", lastName: "Okello", country: "UG", // Alpha-2 country code phoneNumber: "+256712345678", // Should be in international format bankAccountName: "John Okello", bankAccountNumber: "12345678", bankName: "Stanbic Bank", bankCode: 1234, // You can get the bank code from payouts.getDeliveryBanks() quotationToken: "token", transactionRef: "EVS-12345678" // Optional transaction ref generated by you });
Get delivery countries
const countries = await eversendClient.payouts.getDeliveryCountries()
Get delivery banks
const banks = await eversendClient.payouts.getDeliveryBanks({ country: "UG" });
Create a card user
const createUser = await eversendClient.card.createCardUser({ firstName: "John", lastName: "Okello", email: "[email protected]", phoneNumber: "+256712345678", // Should be in international format but optional });
Note that phone number field is optional
Get card users
const cardUsers = await eversendClient.card.getCardUsers({ page: 1, limit: 10 });
If page and limit are not set, the default of 1 and 10 are used respectively.
Create a card
const card = await eversendClient.card.createCard({ title: "Netflix payment" // Reason for creating the card, which you can use to identify why you created the card color: "blue" // could be blue, black, purple, yellow, orange amount: 1000, // Amount to be added to card currency: "USD", //The currency which the card creation amount will be deducted from. Use USD brand: "visa", // could be visa, mastercard });
Get all cards
const cards = await eversendClient.card.getAllCards({ page: 1, // optional limit: 10, // optional status, // optional query, // optional from, // optional to, // optional });
If page and limit are not set, the default of 1 and 10 are used respectively.
Get single card details
const card = await eversendClient.card.getSingleCardDetails({ cardId });
Get single card transactions
const singleCardTransactions = await eversendClient.card.fetchSingleCardTransaction({ cardId, status, // optional query, // optional from, // optional to, // optional type // optional page: 1, // optional limit: 10, // optional });
Get all card transactions
const cardTransactions = await eversendClient.card.fetchAllCardsTransaction({ status, // optional query, // optional from, // optional to, // optional type // optional page: 1, // optional limit: 10, // optional });
Fund a card
const fundCard = await eversendClient.card.fundCard({ amount, cardId, currency });
Withdraw from a card
const withDrawCard = await eversendClient.card.cardWithdrawal({ amount, cardId, currency });
Freeze a card
const freezeCard = await eversendClient.card.freezeCard({ cardId });
Unfreeze a card
const unfreezeCard = await eversendClient.card.unfreezeCard({ cardId });
Delete a card
const deleteCard = await eversendClient.card.deleteCard({ cardId });
Get card analytics
const cardAnalytics = await eversendClient.card.getCardsAnalytics({ from, // optional to, // optional });
Contributions are welcome and encouraged. Learn more about our contribution guidelines here
MIT © Eversend