1.0.1 • Published 8 months ago

daraza-pay v1.0.1

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

Daraza Payment Service

A flexible TypeScript library for making mobile payments via the Daraza API.

Installation

npm install daraza-pay

Usage

import { PaymentService } from 'daraza-pay';

// Initialize the service
const paymentService = new PaymentService({
  apiKey: 'YOUR_API_KEY'
});

// Make a payment
async function makePayment() {
  try {
    const result = await paymentService.requestToPay({
      amount: 1000,
      phone: '0712345678'
    });

    if (result.code === 'Success') {
      console.log('Payment successful:', result.message);
    } else {
      console.error('Payment failed:', result.message);
    }
  } catch (error) {
    console.error('Payment error:', error);
  }
}

License

MIT

Key Improvements:
1. Removed UI-specific code
2. Created a reusable service class
3. Added phone number normalization
4. Implemented error handling
5. Provided type safety with TypeScript
6. Included comprehensive documentation

To publish:
1. Replace placeholders (API key, author name, etc.)
2. `npm login`
3. `npm publish`
1.0.1

8 months ago

1.0.0

8 months ago