npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chapa-payment-sdk-nest

v0.0.2

Published

A NestJS SDK for integrating with the Chapa.co payment system.

Downloads

7

Readme

Here’s a basic template for your README.md file to document how to use your Chapa.co payment SDK with Nest.js:

markdown Copy code

Chapa Payment SDK for Nest.js

Overview

This SDK provides a set of services for integrating Chapa payment gateway into your Nest.js application. It includes functionality for initializing and verifying payments using the Chapa API.

Installation

To install the SDK, add it to your project via npm or yarn:

npm install @your-scope/chapa-payment-sdk
# or
yarn add @your-scope/chapa-payment-sdk
Configuration
Environment Variables: You need to set the following environment variables in your .env file:

env
Copy code
CHAPA_API_KEY=your_chapa_api_key
CHAPA_ENVIRONMENT=sandbox
CHAPA_API_KEY: Your Chapa API key.
CHAPA_ENVIRONMENT: Environment to use, either sandbox or production.
Module Setup: Import the ChapaModule in your Nest.js application module:

typescript
Copy code
import { Module } from '@nestjs/common';
import { ChapaModule } from '@your-scope/chapa-payment-sdk';

@Module({
  imports: [ChapaModule],
  // other modules, controllers, and providers
})
export class AppModule {}
Usage
Payment Initialization
To initialize a payment, use the ChapaService provided by the SDK:

typescript
Copy code
import { Injectable } from '@nestjs/common';
import { ChapaService } from '@your-scope/chapa-payment-sdk';

@Injectable()
export class PaymentService {
  constructor(private readonly chapaService: ChapaService) {}

  async createPayment(paymentData: any) {
    return this.chapaService.initializePayment(paymentData);
  }
}
Payment Verification
To verify a payment, use the ChapaService:

typescript
Copy code
import { Injectable } from '@nestjs/common';
import { ChapaService } from '@your-scope/chapa-payment-sdk';

@Injectable()
export class PaymentService {
  constructor(private readonly chapaService: ChapaService) {}

  async verifyPayment(transactionId: string) {
    return this.chapaService.verifyPayment(transactionId);
  }
}
Utility Functions
The SDK also provides utility functions via ChapaUtilsService:

typescript
Copy code
import { Injectable } from '@nestjs/common';
import { ChapaUtilsService } from '@your-scope/chapa-payment-sdk';

@Injectable()
export class UtilityService {
  constructor(private readonly chapaUtilsService: ChapaUtilsService) {}

  generateTransactionReference() {
    return this.chapaUtilsService.generateTxRef();
  }

  validateEmail(email: string) {
    return this.chapaUtilsService.validateEmail(email);
  }
}
Controllers
Use the provided controller methods to handle payment-related routes:

typescript
Copy code
import { Controller, Post, Body } from '@nestjs/common';
import { ChapaService } from '@your-scope/chapa-payment-sdk';

@Controller('payments')
export class PaymentsController {
  constructor(private readonly chapaService: ChapaService) {}

  @Post('initialize')
  async initializePayment(@Body() paymentData: any) {
    return this.chapaService.initializePayment(paymentData);
  }

  @Post('verify')
  async verifyPayment(@Body('transactionId') transactionId: string) {
    return this.chapaService.verifyPayment(transactionId);
  }
}
License
This project is licensed under the MIT License. See the LICENSE file for details.

Contributing
Feel free to open issues or submit pull requests. Please ensure your contributions adhere to the project's coding standards.

Contact
For any questions or support, please contact [your email].

arduino
Copy code

This template includes installation instructions, configuration setup, usage examples, and