@jesehl/dragonpay-sdk
v1.0.0
Published
SDK for easy integration with Dragonpay payment services
Maintainers
Readme
Dragonpay SDK - Minimal Guide 🐉
Install
npm install @dragonpay/sdkUsage
Create Payment Link
const { DragonpaySDK } = require('@dragonpay/sdk');
const dp = new DragonpaySDK({
merchantId: 'YOUR_ID',
secretKey: 'YOUR_KEY',
environment: 'test'
});
// Create payment
dp.createInvoice({
amount: 1000,
currency: 'PHP',
description: 'Test item',
email: '[email protected]',
txnId: 'ORDER-123'
})
.then(result => console.log('Payment URL:', result.url))
.catch(error => console.log('Error:', error));Check Payment Status
// Use the refNo you got from createInvoice
dp.getInvoiceStatus('REF-123')
.then(status => console.log('Status:', status.status))
.catch(error => console.log('Error:', error));Payment Status Codes
S= SuccessF= FailedP= PendingU= Unknown
Common Questions 🤔
What are the possible payment statuses?
S= Success (Yay! Payment received)F= Failed (Something went wrong)P= Pending (Still waiting for payment)U= Unknown (Try checking again)R= RefundedK= ChargebackV= VoidedA= Authorized
How do I go live?
- Test everything using
environment: 'test' - When ready, get your production credentials from Dragonpay
- Change to
environment: 'production' - That's it!
What currencies are supported?
Right now, only PHP (Philippine Peso) is supported.
Need Help? 🆘
- Check Dragonpay's website: https://dragonpay.ph
- Email them at: [email protected]
- Or check their API docs for more details
Example Project 📝
Here's a complete example you can copy-paste:
const { DragonpaySDK } = require('@dragonpay/sdk');
// Setup
const dragonpay = new DragonpaySDK({
merchantId: 'YOUR_MERCHANT_ID',
secretKey: 'YOUR_SECRET_KEY',
environment: 'test'
});
// Create a payment function
async function sellSomething() {
try {
// 1. Create the payment
const payment = await dragonpay.createInvoice({
amount: 1000,
currency: 'PHP',
description: 'Awesome Product',
email: '[email protected]',
txnId: `ORDER-${Date.now()}` // Create unique order ID
});
console.log('✅ Payment Created!');
console.log('Send this link to customer:', payment.url);
console.log('Reference Number:', payment.refNo);
// 2. Check its status after a while
setTimeout(async () => {
const status = await dragonpay.getInvoiceStatus(payment.refNo);
console.log('Payment Status:', status.status);
}, 5000); // Wait 5 seconds before checking
} catch (error) {
console.log('❌ Error:', error.message);
}
}
// Run it!
sellSomething();That's all you need to know! Happy coding! 🎉
