1.0.0 • Published 11 months ago

@jesehl/dragonpay-sdk v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

Dragonpay SDK - Minimal Guide 🐉

Install

npm install @dragonpay/sdk

Usage

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: 'buyer@email.com',
  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 = Success
  • F = Failed
  • P = Pending
  • U = 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 = Refunded
  • K = Chargeback
  • V = Voided
  • A = Authorized

How do I go live?

  1. Test everything using environment: 'test'
  2. When ready, get your production credentials from Dragonpay
  3. Change to environment: 'production'
  4. 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: support@dragonpay.ph
  • 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: 'customer@email.com',
      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! 🎉

1.0.0

11 months ago