Initialize checkout sessions and verify payment completion using the Kroxt SDK.
Call baas.payment.initializeTransaction(options) to generate a Paystack checkout authorization URL and reference:
const checkout = await baas.payment.initializeTransaction({
amount: 500000, // Amount in minor units (5,000 NGN = 500000 kobo)
email: "customer@example.com",
currency: "NGN", // Optional, defaults to NGN
callbackUrl: "https://myapp.com/payment/callback",
metadata: {
orderId: "ORD-8912",
customNote: "Order payment for digital item",
},
});
console.log("Authorization URL:", checkout.authorizationUrl);
console.log("Transaction Reference:", checkout.reference);
// Redirect user to Paystack checkout URL
window.location.href = checkout.authorizationUrl;| Option Parameter | Type | Description |
|---|---|---|
| amount | number | Amount in minor currency units (e.g. kobo for NGN, cents for USD). Required. |
| string | Customer email address. Required. | |
| currency | string | Currency code (defaults to "NGN"). |
| reference | string | Unique transaction reference. Auto-generated by Kroxt if omitted. |
| callbackUrl | string | URL to redirect user after checkout completes. |
| planCode | string | Paystack plan code (\`PLN_xxx\`) for initiating subscription payments. |
| metadata | Record<string, any> | Custom key-value metadata stored alongside the transaction. |
Call baas.payment.verifyTransaction(reference) on your return/callback page to verify payment completion and update database status:
// Verify transaction by reference
const verification = await baas.payment.verifyTransaction("kroxt_1723648123_a9b1c");
if (verification.verification.gatewayStatus === "success") {
console.log("Payment Verified Successfully!");
console.log("Customer:", verification.verification.customer.email);
console.log("Paid Amount:", verification.verification.amount / 100);
} else {
console.warn("Payment status:", verification.verification.gatewayStatus);
}Call baas.payment.listTransactions(query) to retrieve past transactions with optional email or status filters:
const logs = await baas.payment.listTransactions({
status: "success",
email: "customer@example.com",
page: 1,
limit: 20,
});
console.log("Total successful transactions:", logs.total);
console.log("Transactions page 1:", logs.transactions);