devtools-bp/libs/ns-paystack
semantic-release-bot 9ecb8f9299 chore(release): ns-paystack-v1.0.0 [skip ci]
# 1.0.0 (2023-06-04)

### Bug Fixes

* error handling status codes ([cac97d4](cac97d4487))
* formatting for github action ([f07aae5](f07aae52be))
* naming models and lib paths ([bc53cd4](bc53cd4873))
* **ns-paystack:** add branches to release config for semantic versioning ([78e92c8](78e92c8072))
* **ns-paystack:** add pkgRoot to the plugins section ([0e37805](0e3780587b))
* **ns-paystack:** added branches to release config ([78eb7be](78eb7be96f))
* **ns-paystack:** added release object to package.json ([97b4956](97b4956206))
* **ns-paystack:** extended release config base js ([e067e45](e067e45a18))
* **ns-paystack:** marked repo to public ([64e525a](64e525a435))
* **ns-paystack:** remove github push ([52ad323](52ad323e49))
* **ns-paystack:** remove private field from package json ([d02bc77](d02bc77f96))
* **ns-paystack:** replace folder packages to libs ([27b2353](27b2353a4e))
* **ns-paystack:** replaced sample library name from semantic versioning command ([b09b464](b09b4642d8))
* **ns-paystack:** update package.json for semantic versioning to recognize ([89d2fdd](89d2fdd3b3))
* **ns-paystack:** update publish config to access public ([3e3ca34](3e3ca344b0))
* **ns-paystack:** update release config ([7bca4d7](7bca4d7f9d))
* **ns-paystack:** updated assets for semantic release git ([c8455f9](c8455f9a4f))
* **ns-paystack:** updated package.json ([5df0933](5df09338cc))
* route paths ([f5e1e5d](f5e1e5dfee))

### Features

* add dynamic module ([dcbd3ba](dcbd3ba509))
* add fetch transaction ([8a285e2](8a285e23b3))
* add list transactions ([349ff35](349ff3587c))
* add paystack lib and demo app ([1ee0bd9](1ee0bd9f42))
* added charge transaction endpoint ([1316ed1](1316ed1a54))
* added export transaction ([c3dec33](c3dec330cb))
* added partial debit ([856c716](856c716903))
* added semantic release versioning ([6aac837](6aac837933))
* added view transaction timeline ([f837129](f83712964d))
* transaction api ([8fe8ba0](8fe8ba09ad))
* verify transaction ([aba11ba](aba11ba468))
2023-06-04 15:24:40 +00:00
..
src test: added empty test for handle response and error func 2023-06-03 18:54:26 +02:00
.eslintrc.json feat: add paystack lib and demo app 2023-05-23 19:36:28 +02:00
CHANGELOG.md chore(release): ns-paystack-v1.0.0 [skip ci] 2023-06-04 15:24:40 +00:00
jest.config.ts feat: add paystack lib and demo app 2023-05-23 19:36:28 +02:00
package.json fix(ns-paystack): update publish config to access public 2023-06-04 17:03:11 +02:00
project.json fix(ns-paystack): update release config 2023-06-04 15:28:11 +02:00
README.md docs: added authors 2023-06-03 17:46:39 +02:00
release.config.js fix(ns-paystack): add pkgRoot to the plugins section 2023-06-04 16:29:31 +02:00
tsconfig.json feat: add paystack lib and demo app 2023-05-23 19:36:28 +02:00
tsconfig.lib.json feat: add paystack lib and demo app 2023-05-23 19:36:28 +02:00
tsconfig.spec.json feat: add paystack lib and demo app 2023-05-23 19:36:28 +02:00

ns-paystack

The wrapper provides a convenient way to integrate Paystack payment functionality into your NestJS applications.

Installation

npm install @bp-devtools/ns-paystack

or

yarn add @bp-devtools/ns-paystack

Configuration

To use the ns-paystack, you need to provide your Paystack API key. You can obtain the API key from the Paystack dashboard. Once you have the API key, you can configure the wrapper in your NestJS application.

import { Module } from '@nestjs/common';

import { NsPaystackModule } from '@bp-devtools/ns-paystack';
import { ConfigService } from '@nestjs/config';
import { TransactionsService } from './transactions/services/transactions.service';
import { TransactionController } from './transactions/controllers/transaction.controller';

@Module({
  imports: [
    NsPaystackModule.register({
      secretKey: 'PAYSTACK_SECRET_KEY'
    })
  ],
})
export class AppModule {
}

Using async registration to access environment variables

import { Module } from '@nestjs/common';

import { NsPaystackModule } from '@bp-devtools/ns-paystack';
import { ConfigService } from '@nestjs/config';

@Module({
  imports: [
    NsPaystackModule.registerAsync({
      useFactory: (configService: ConfigService) => {
        return {
          secretKey: configService.get('PAYSTACK_SECRET_KEY')
        };
      },
      inject: [ConfigService]
    })
  ]
})
export class AppModule {
}

Usage

In Service

import { Injectable } from '@nestjs/common';
import {
  PsTransactionsService,
  PsInitializeTransactionRequestModel,
  PsInitializeTransactionResponseModel,
} from '@bp-devtools/ns-paystack';

@Injectable()
export class TransactionsService {
  constructor(
    private readonly psTransactionsService: PsTransactionsService
  ) {
  }

  initializeTransaction(
    payload: PsInitializeTransactionRequestModel
  ): Promise<PsInitializeTransactionResponseModel> {
    return this.psTransactionsService.initializeTransaction(payload);
  }
}

In Controller

import { Body, Controller, Post } from '@nestjs/common';
import {
  PsFetchTransactionResponseModel,
  PsInitializeTransactionRequestModel,
  PsInitializeTransactionResponseModel,
} from '@bp-devtools/ns-paystack';
import { TransactionsService } from '../services/transactions.service';

@Controller('transaction')
export class TransactionController {
  constructor(private readonly transactionsService: TransactionsService) {
  }

  @Post('initialize')
  initialize(
    @Body() payload: PsInitializeTransactionRequestModel
  ): Promise<PsInitializeTransactionResponseModel> {
    return this.transactionsService.initializeTransaction(payload);
  }
}

API ENDPOINTS

  • Transactions
    • Initialize Transaction
    • Verify Transaction
    • List Transaction
    • Fetch Transaction
    • Charge Transaction
    • View Transaction Timeline
    • Transaction Totals
    • Export Transaction
    • Partial Debit
  • Transaction Splits
    • Create Split
    • List Split
    • Fetch Split
    • Update Split
    • Add/Update Subaccount Split
    • Remove Subaccount from Split
  • Terminal
  • Customers
  • Dedicated Virtual Accounts
  • Apple Pay
  • Subaccounts
  • Plans
  • Subscriptions
  • Products
  • Payment Pages
  • Payment Requests
  • Settlements
  • Transaction Recipients
  • Transfers
  • Transfers Control
  • Bulk Charges
  • Integration
  • Charge
  • Disputes
  • Refunds
  • Verification
  • Miscellaneous

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.

License

The bp-devtools monorepo is released under the MIT License. Please make sure you understand its terms and conditions when using the libraries and tools provided in this repository.

Authors