
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@enviabledev/paystack-api
Advanced tools
A modern, fully-typed, and efficient Node.js library for interacting with the Paystack API. Built with TypeScript, it provides a clean, class-based interface to all Paystack resources, complete with robust error handling and helper utilities. This library is developed and maintained by Enviable Transport Services Software Developemnt Team.
npm install @enviabledev/paystack-api
To get started, initialize the client with your Paystack secret key.
import paystack from '@enviabledev/paystack-api';
// Initialize the client with your secret key
const paystackClient = paystack('YOUR_PAYSTACK_SECRET_KEY');
// Example: Verify a transaction
async function verifyTransaction(reference) {
try {
const response = await paystackClient.transaction.verify(reference);
console.log(response.data.status); // e.g., 'success'
console.log(response.data.customer.email);
} catch (error) {
console.error(error);
}
}
verifyTransaction('your_transaction_reference');
This library provides access to all Paystack API resources through the paystackClient object.
Handles batch processing of charges.
paystackClient.bulkCharge.create(payload): Initiates a new bulk charge
CreateBulkChargePayload - An object with a charges property, which is an array of objects containing authorization (string), amount (number), and optional reference (string)paystackClient.bulkCharge.list(params): Lists bulk charge batches
ListBulkChargesParams (optional) for pagination (perPage, page) and filtering (status, from, to)paystackClient.bulkCharge.get(id): Retrieves a single bulk charge batch
paystackClient.bulkCharge.getCharges(id, params): Retrieves all charges within a batch
ListBulkChargeChargesParams (optional) for pagination and filteringpaystackClient.bulkCharge.pause(batchCode): Pauses a running bulk charge batch
paystackClient.bulkCharge.resume(batchCode): Resumes a paused bulk charge batch
Handles tokenization and charging of payment instruments.
paystackClient.charge.tokenize(payload): Creates a reusable token from card details
TokenizePayload with email and a card object (number, cvv, expiry_month, expiry_year)paystackClient.charge.charge(payload): Initiates a new charge
ChargePayload with email, amount, and payment details (e.g., authorization_code, pin, bank)paystackClient.charge.submitPin(payload): Submits a PIN to continue a charge
SubmitPinPayload with pin and referencepaystackClient.charge.submitOtp(payload): Submits an OTP to complete a charge
SubmitOtpPayload with otp and referencepaystackClient.charge.submitPhone(payload): Submits a phone number to continue a charge
SubmitPhonePayload with phone and referencepaystackClient.charge.submitBirthday(payload): Submits a birthday to continue a charge
SubmitBirthdayPayload with birthday (YYYY-MM-DD) and referencepaystackClient.charge.submitAddress(payload): Submits an address to continue a charge
SubmitAddressPayload with reference, address, city, state, and zip_codepaystackClient.charge.checkCharge(reference): Checks the status of a pending charge
Manages integration settings.
paystackClient.controlPanel.getSessionTimeout(): Gets the payment session timeout for your integration
paystackClient.controlPanel.updateSessionTimeout(payload): Updates the payment session timeout
UpdateSessionTimeoutPayload with timeout in secondsManages customer information.
paystackClient.customer.create(payload): Creates a new customer
CreateCustomerPayload containing email, and optional first_name, last_name, phone, metadatapaystackClient.customer.list(params): Lists customers
ListCustomersParams (optional) for pagination and filteringpaystackClient.customer.get(id): Retrieves a customer's details
paystackClient.customer.update(id, payload): Updates a customer's details
UpdateCustomerPayloadpaystackClient.customer.validate(id, payload): Validates a customer's identity
ValidateCustomerPayloadpaystackClient.customer.setRiskAction(payload): Whitelists or blacklists a customer
SetRiskActionPayload with customer (code or email) and risk_action ('allow' or 'deny')paystackClient.customer.deactivateAuthorization(payload): Deactivates a customer's authorization
DeactivateAuthorizationPayload with authorization_codeManages dedicated virtual bank accounts.
paystackClient.nuban.create(payload): Creates a dedicated virtual account
CreateNubanPayload for a new or existing customerpaystackClient.nuban.list(params): Lists dedicated virtual accounts
ListNubansParams (optional) for filteringpaystackClient.nuban.get(id): Retrieves a single dedicated virtual account
paystackClient.nuban.requery(params): Requeries a dedicated virtual account to check for transfers
RequeryNubanParams with account_number, provider_slug, and datepaystackClient.nuban.deactivate(id): Deactivates a dedicated virtual account
paystackClient.nuban.removeSplit(payload): Removes a split configuration from a dedicated account
RemoveNubanSplitPayload with account_numberpaystackClient.nuban.listAvailableProviders(): Gets a list of available providers for dedicated accounts
Accesses miscellaneous data like banks and countries.
paystackClient.misc.listBanks(params): Gets a list of all supported banks
ListBanksParams (optional) for filtering by country, currency, etc.paystackClient.misc.listCountries(): Gets a list of all supported countries
paystackClient.misc.listStates(params): Gets a list of states for a country
ListStatesParams with country codeManages hosted payment pages.
paystackClient.paymentPage.create(payload): Creates a new payment page
CreatePaymentPagePayload with name and other optional fieldspaystackClient.paymentPage.list(params): Lists payment pages
ListPaymentPagesParams (optional) for pagination and date range filteringpaystackClient.paymentPage.get(id): Retrieves a payment page
paystackClient.paymentPage.update(id, payload): Updates a payment page
UpdatePaymentPagePayloadpaystackClient.paymentPage.checkSlugAvailability(slug): Checks if a URL slug is available
paystackClient.paymentPage.addProducts(id, payload): Adds products to a payment page
AddProductsToPaymentPagePayload with an array of product IDsManages professional invoices.
paystackClient.paymentRequest.create(payload): Creates a new payment request (invoice)
CreatePaymentRequestPayload with customer, amount, and due_datepaystackClient.paymentRequest.list(params): Lists payment requests
ListPaymentRequestsParams (optional) for filteringpaystackClient.paymentRequest.get(id): Retrieves a payment request
paystackClient.paymentRequest.verify(code): Verifies the payment status of a payment request
paystackClient.paymentRequest.notify(id): Sends a notification reminder for a payment request
paystackClient.paymentRequest.getTotals(): Gets total payment request volume and paid count
paystackClient.paymentRequest.finalize(id): Finalizes a draft payment request
paystackClient.paymentRequest.update(id, payload): Updates a payment request
UpdatePaymentRequestPayloadpaystackClient.paymentRequest.archive(id): Archives a payment request
Manages subscription plans.
paystackClient.plan.create(payload): Creates a new subscription plan
CreatePlanPayload with name, amount, and intervalpaystackClient.plan.list(params): Lists subscription plans
ListPlansParams (optional) for filteringpaystackClient.plan.get(id): Retrieves a subscription plan
paystackClient.plan.update(id, payload): Updates a subscription plan
UpdatePlanPayloadManages refunds for transactions.
paystackClient.refund.create(payload): Initiates a refund for a transaction
CreateRefundPayload with transaction reference and optional amountpaystackClient.refund.list(params): Lists refunds
ListRefundsParams (optional) for filteringpaystackClient.refund.get(id): Retrieves a single refund
Retrieves settlement information.
paystackClient.settlement.list(params): Lists settlements made to your bank accounts
ListSettlementsParams (optional) for filteringpaystackClient.settlement.getTransactions(id, params): Gets transactions associated with a settlement
ListSettlementTransactionsParams (optional)Manages subaccounts for split payments.
paystackClient.subaccount.create(payload): Creates a new subaccount
CreateSubaccountPayload with business_name, settlement_bank, account_number, and percentage_chargepaystackClient.subaccount.list(params): Lists subaccounts
ListSubaccountsParams (optional)paystackClient.subaccount.get(id): Retrieves a subaccount
paystackClient.subaccount.update(id, payload): Updates a subaccount
UpdateSubaccountPayloadManages customer subscriptions.
paystackClient.subscription.create(payload): Creates a new subscription
CreateSubscriptionPayload with customer and planpaystackClient.subscription.list(params): Lists subscriptions
ListSubscriptionsParams (optional) for filtering by customer or planpaystackClient.subscription.get(id): Retrieves a subscription
paystackClient.subscription.enable(payload): Enables a subscription
ToggleSubscriptionPayload with code and tokenpaystackClient.subscription.disable(payload): Disables a subscription
ToggleSubscriptionPayload with code and tokenpaystackClient.subscription.generateManageLink(code): Generates a link to manage a subscription
paystackClient.subscription.sendManageEmail(code): Sends a subscription management email
Manages financial transactions.
paystackClient.transaction.initialize(payload): Initializes a new transaction
InitializeTransactionPayload with email and amountpaystackClient.transaction.verify(reference): Verifies the status of a transaction
paystackClient.transaction.list(params): Lists transactions
ListTransactionsParams (optional) for pagination and filteringpaystackClient.transaction.get(id): Retrieves a transaction
paystackClient.transaction.chargeAuthorization(payload): Charges a customer using a saved authorization
ChargeAuthorizationPayload with email, amount, and authorization_codepaystackClient.transaction.viewTimeline(id): Gets the timeline of a transaction
paystackClient.transaction.totals(params): Gets transaction totals
ListTransactionsParams (optional) for date range filteringpaystackClient.transaction.export(params): Exports a list of transactions
ListTransactionsParams (optional) for filteringManages money transfers to bank accounts.
paystackClient.transfer.create(payload): Initiates a new transfer
CreateTransferPayload with source, amount, and recipientpaystackClient.transfer.list(params): Lists transfers
ListTransfersParams (optional)paystackClient.transfer.get(idOrCode): Retrieves a transfer
paystackClient.transfer.finalize(payload): Finalizes a transfer that requires an OTP
FinalizeTransferPayload with transfer_code and otppaystackClient.transfer.bulk(payload): Initiates a bulk transfer
BulkTransferPayloadpaystackClient.transfer.verify(reference): Verifies the status of a transfer
Manages transfer settings and balance.
paystackClient.transferControl.checkBalance(): Checks the available balance on your integration
paystackClient.transferControl.getBalanceLedger(): Gets the balance ledger for your integration
paystackClient.transferControl.resendOtp(payload): Resends an OTP for a transfer
ResendOtpPayload with transfer_code and reasonpaystackClient.transferControl.disableOtp(): Disables the OTP requirement for transfers
paystackClient.transferControl.finalizeDisableOtp(payload): Finalizes the process of disabling OTP
FinalizeDisableOtpPayload with otppaystackClient.transferControl.enableOtp(): Enables the OTP requirement for transfers
Manages transfer recipients.
paystackClient.transferRecipient.create(payload): Creates a new transfer recipient
CreateTransferRecipientPayload with type and namepaystackClient.transferRecipient.createBulk(payload): Creates multiple transfer recipients in bulk
CreateBulkTransferRecipientsPayloadpaystackClient.transferRecipient.list(params): Lists transfer recipients
ListTransferRecipientsParams (optional)paystackClient.transferRecipient.get(idOrCode): Retrieves a transfer recipient
paystackClient.transferRecipient.update(idOrCode, payload): Updates a transfer recipient
UpdateTransferRecipientPayloadpaystackClient.transferRecipient.remove(idOrCode): Deletes a transfer recipient
Verifies customer and payment details.
paystackClient.verification.resolveAccount(payload): Resolves a bank account to get the account holder's name
ResolveAccountPayload with account_number and bank_codepaystackClient.verification.validateAccount(payload): Validates a bank account
ValidateAccountPayloadpaystackClient.verification.resolveBin(bin): Gets information about a card's Bank Identification Number (BIN)
The library provides an Express middleware to securely handle incoming webhook events. It verifies the Paystack signature and emits an event.
import express from 'express';
import paystack from '@enviabledev/paystack-api';
const app = express();
const paystackClient = paystack('YOUR_PAYSTACK_SECRET_KEY');
// Use the middleware to verify and parse webhooks
// IMPORTANT: This must be placed before any other body-parsing middleware like express.json()
app.post('/webhook', paystackClient.events.middleware);
// Listen for a specific event
paystackClient.events.on('charge.success', (data) => {
console.log('Charge successful!');
console.log(data); // The event data object
});
// Start your server
app.listen(3000, () => console.log('Server running on port 3000'));
The FeeHelper class calculates the total amount to charge a customer to cover Paystack's processing fees.
import paystack from '@enviabledev/paystack-api';
const FeeHelper = paystack.feeHelper; // Get the FeeHelper class
// Use default Paystack fees
const feeCalculator = new FeeHelper();
// The amount you want to receive in kobo
const desiredAmountKobo = 10000; // ₦100.00
// The amount you need to charge the customer
const amountToCharge = feeCalculator.addFeesTo(desiredAmountKobo);
console.log(amountToCharge); // e.g., 10152 (₦101.52)
The library throws custom errors to help you handle different failure scenarios gracefully:
import paystack from '@enviabledev/paystack-api';
const { PaystackAPIError, NetworkError } = paystack.errors;
const paystackClient = paystack('YOUR_SECRET_KEY');
async function getCustomer() {
try {
const customer = await paystackClient.customer.get('non_existent_id');
} catch (error) {
if (error instanceof PaystackAPIError) {
console.error(`API Error: ${error.message}`);
console.error(`Status Code: ${error.statusCode}`);
if (error.statusCode === 404) {
console.log("This customer could not be found.");
}
} else if (error instanceof NetworkError) {
console.error(`Network Error: ${error.message}`);
// You could implement retry logic here
} else {
console.error(`An unexpected error occurred:`, error);
}
}
}
getCustomer();
This is a note to all team members, update the readme file when you make any changes to an endpoint or add a new endpoint
MIT
FAQs
A type-safe Paystack API library for Node.js
We found that @enviabledev/paystack-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.