A wrapper for the Paystack API with types.
npm install @ahdeyy/paystack
pnpm add @ahdeyy/paystack
yarn add @ahdeyy/paystack
bun add @ahdeyy/paystack
After using an API, check if the status of the call is true to work with the success response
import { Paystack } from "@ahdeyy/paystack"
// create the paystack object
const paystack = new Paystack(secret_key)
const created_request = await paystack.payment_request.create({
amount: 10000,
description: "Payment for goods",
due_date: "2022-12-31",
customer: "customer id",
})
// Check the status of the response
if (created_request.status) {
// Work with the response success data
} else {
// Work with the response error data
}
const paystack = new Paystack(secret_key)
const created_request = await paystack.payment_request.create({
amount: 10000,
description: "Payment for goods",
due_date: "2022-12-31",
customer: "customer id",
})
const updated_request = await paystack.payment_request.update({
amount: 10000,
description: "Payment for goods",
due_date: "2022-12-31",
customer: "customer id",
})
const fetched_request = await paystack.payment_request.fetch("request id")
const list = await paystack.payment_request.list(query)
const verified_request = await paystack.payment_request.verify("request id")
const sent_notification = await paystack.payment_request.sendNotification(
"request id"
)
const total = await paystack.payment_request.total()
const finalized_request = await paystack.payment_request.finalize("request id")
const archived_request = await paystack.payment_request.archive("request id")
const customer = await paystack.customer.create({
email: "test@mail.com",
first_name: "john",
last_name: "doe",
})
const customer = await paystack.customer.list({ perPage: 10, page: 1 })
const customer = await paystack.customer.fetch(customers_email)
const customer = await paystack.customer.validate(customer_code, {
country,
type,
account_number,
bvn,
bank_code,
first_name,
last_name,
})
const customer = await paystack.customer.update(customer_code, { phone })
const customer = await paystack.customer.whitelist_blacklist({
customer: customer_code,
risk_action: "deny",
})
const customer = await paystack.customer.deactivate_authorization(
Authorization_code
)
const product = await paystack.product.create({
name: "sakura",
description: "cherry blossom",
price: 10000,
currency: "NGN",
})
const product = await paystack.product.list({ perPage: 10, page: 1 })
const product = await paystack.product.fetch(product_id)
const product = await paystack.product.update(product_id, { price: 69420 })
const response = await paystack.dva.create({ customer: import.meta.env.CUSTOMER_CODE ?? '' })
const response = await paystack.dva.assign({
email: "janedoe@test.com",
first_name: "Jane",
middle_name: "Karen",
last_name: "Doe",
phone: "+2348100000000",
preferred_bank: "test-bank",
country: "NG"
})
const response = await paystack.dva.list({ active: true, currency: "NGN" });
const response = await paystack.dva.fetch("foo")
const response = await paystack.dva.requery({ account_number: "98897", provider_slug: "wema-bank" });
const response = await paystack.dva.deactivate("foo")
const response = await paystack.dva.split({ customer: "janey" })
const response = await paystack.dva.remove_split("bar")
const response = await paystack.dva.fetch_bank_providers();
const response = await paystack.miscellaneous.list_banks({ country: "nigeria", use_cursor: true, perPage: 40 })
const response = await paystack.miscellaneous.list_countries()
const response = await paystack.miscellaneous.list_states("US")
-
[x] Requests
- [x] Create payment request
- [x] Update payment request
- [x] Fetch payment request
- [x] List payment requests
- [x] Verify payment request
- [x] Send Notification
- [x] Payment request total
- [x] Finalize payment request
- [x] Archive payment request
- [x] Tests
-
[x] Customers
- [x] Create Customer
- [x] List Customers
- [x] Fetch Customer
- [x] Update Customer
- [x] Validate Customer
- [x] Whitelist/Blacklist Customer
- [x] Deactivate Authorization
- [x] Tests
-
[x] Products
- [x] Create Product
- [x] List Products
- [x] Fetch Product
- [x] Update Product
- [x] Tests
-
[ ] Dedicated Virtual Accounts
- [x] Create Dedicated Virtual Account
- [x] Assign Dedicated Virtual Account
- [x] List Dedicated Accounts
- [x] Fetch Dedicated Account
- [x] Requery Dedicated Account
- [x] Deactivate Dedicated Account
- [x] Split Dedicated Account Transaction
- [x] Remove Split from Dedicated Account
- [x] Fetch Bank Providers
- [ ] Tests
-
[ ] Transactions
-
[ ] Transaction Splits
-
[ ] Terminal
-
[ ] Apple Pay
-
[ ] Subaccounts
-
[ ] Plans
-
[ ] Subscriptions
-
[ ] Payment Pages
-
[ ] Settlements
-
[ ] Transfer Recipients
-
[ ] Transfers
-
[ ] Transfers Control
-
[ ] Bulk Charges
-
[ ] Integration
-
[ ] Charge
-
[ ] Disputes
-
[ ] Refunds
-
[ ] Verification
-
[x] Miscellanous
To run the tests, clone the repository
git clone https://github.com/Ahdeyyy/paystack-api.git
bun test