pakasir-sdk
v1.0.5
Published
Pakasir SDK - Lightweight Pakasir Payment Gateway API Client Library
Maintainers
Readme
Pakasir Payment Gateway
SDK TypeScript ringan untuk integrasi pembayaran digital Indonesia pakasir.com. Dukung QRIS, Virtual Account multi-bank & PayPal dalam hitungan menit.
Installation · Quick Start · Configuration · Payment Methods · API Reference
📦 Installation
Install pakasir-sdk using your preferred package manager:
npm install pakasir-sdk
# or
pnpm add pakasir-sdk
# or
bun add pakasir-sdk⚡ Quick Start
Here is a minimal example to create a payment:
import { Pakasir } from 'pakasir-sdk';
const pakasir = new Pakasir({
slug: 'your-slug',
apikey: 'your-api-key',
});
const result = await pakasir.createPayment('qris', 'your-order-id', 10000);
console.log(result);🛠️ Configuration
The Pakasir constructor accepts a configuration object:
| Option | Type | Description |
| :------- | :------- | :---------------------------------------------------------- |
| slug | string | Required. Project slug. |
| apikey | string | Required. API key. |
💰 Payment Methods
For more information about payment methods, please visit Pakasir Biaya.
| Method | Code | Fee |
| -------------- | ---------------- | ---------------- |
| All Methods | all | Varies |
| QRIS | qris | 0.7% - 1% |
| PayPal | paypal | 1% (min Rp3.000) |
| BNI VA | bni_va | Rp3.500 |
| BRI VA | bri_va | Rp3.500 |
| CIMB Niaga VA | cimb_niaga_va | Rp3.500 |
| Maybank VA | maybank_va | Rp3.500 |
| Permata VA | permata_va | Rp3.500 |
| BNC VA | bnc_va | Rp3.500 |
| ATM Bersama VA | atm_bersama_va | Rp3.500 |
| Sampoerna VA | sampoerna_va | Rp2.000 |
| Artha Graha VA | artha_graha_va | Rp2.000 |
📖 API Reference
Quick Jump: Create Payment · Get Payment URL · Detail Payment · Cancel Payment · Simulation Payment · Watch Payment · Stop Watch
Create Payment
Create a new payment transaction via API.
const payment = await pakasir.createPayment('qris', 'ORDER-12345', 100_000, 'https://example.com/success');
console.log(payment);| Parameter | Type | Description |
| :------------- | :-------------- | :------------------------------------------------------- |
| method | PaymentMethod | Payment method code Payment Methods |
| order_id | string | Unique order ID (min 5 characters) |
| amount | number | Amount in Rupiah (min Rp500) |
| redirect_url | string? | Optional redirect URL after payment |
Get Payment URL
Generate payment URL without API call. Useful for client-side redirects.
const payment = pakasir.getPaymentUrl('qris', 'ORDER-12345', 100_000);
console.log(payment);Detail Payment
Retrieve current status of a payment.
const detail = await pakasir.detailPayment('ORDER-12345', 100_000);
console.log(detail);Cancel Payment
Cancel an existing pending payment.
const canceled = await pakasir.cancelPayment('ORDER-12345', 100_000);
console.log(canceled);Simulation Payment
Simulate a successful payment for testing purposes.
const simulated = await pakasir.simulationPayment('ORDER-12345', 100_000);
console.log(simulated);Watch Payment
Monitor payment status changes in real-time with polling.
pakasir.watchPayment('ORDER-12345', 100_000, {
interval: 3000,
timeout: 600000,
onStatusChange: (payment) => {
console.log('Status:', payment);
},
onError: (error) => console.error(error),
});| Option | Type | Default | Description |
| :--------------- | :---------------------------------- | :------- | :------------------------------- |
| interval | number | 3000 | Polling interval in milliseconds |
| timeout | number | 600000 | Auto-stop timeout (10 minutes) |
| onStatusChange | (payment: PaymentPayload) => void | - | Callback on status change |
| onError | (error: Error) => void | - | Callback on error |
Stop Watch
Manually stop watching a payment.
pakasir.stopWatch('ORDER-12345', 100_000);PaymentPayload Type
Response type returned by all payment methods:
type PaymentPayload = {
project: string;
order_id: string;
amount: number;
fee: number;
status: 'pending' | 'canceled' | 'completed';
total_payment: number;
payment_method: string;
payment_number: string | null;
payment_url: string | null;
redirect_url: string | null;
expired_at: string | Date | null;
completed_at: string | Date | null;
};🤝 Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create new branch:
git checkout -b feature/my-feature. - Commit your changes:
git commit -m 'Add some feature'. - Push to the branch:
git push origin feature/my-feature. - Open Pull Request.
🎯 Issues & Feedback
If you encounter any problems or have feature requests, please open an issue
- Buy me coffee ☕
- Ko-Fi
- Trakteer
- ⭐ Star the repo on GitHub
📜 License
Distributed under the MIT License. See LICENSE for details.
