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: "[email protected]",
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: "[email protected]",
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")
-
Requests
- Create payment request
- Update payment request
- Fetch payment request
- List payment requests
- Verify payment request
- Send Notification
- Payment request total
- Finalize payment request
- Archive payment request
- Tests
-
Customers
- Create Customer
- List Customers
- Fetch Customer
- Update Customer
- Validate Customer
- Whitelist/Blacklist Customer
- Deactivate Authorization
- Tests
-
Products
- Create Product
- List Products
- Fetch Product
- Update Product
- Tests
-
Dedicated Virtual Accounts
- Create Dedicated Virtual Account
- Assign Dedicated Virtual Account
- List Dedicated Accounts
- Fetch Dedicated Account
- Requery Dedicated Account
- Deactivate Dedicated Account
- Split Dedicated Account Transaction
- Remove Split from Dedicated Account
- 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
-
Miscellanous
To run the tests, clone the repository
git clone https://github.com/Ahdeyyy/paystack-api.git
bun test