nestjs-mangopay
v4.0.0
Published
Injectable Mangopay service for Nestjs
Downloads
33
Maintainers
Readme
Implementing the MangopayModule from this package you gain access to Mangopay service through dependency injection with minimal setup.
Getting Started
Prerequisites
This lib requires Node.js >=14.17.0, NestJS ^9.0.0, mangopay2-nodejs-sdk ^1.33.0.
Instalation
$ npm install --save nestjs-mangopay$ yarn add nestjs-mangopayTo use Mangopay service we need to register module for example in app.module.ts
import { MangopayModule } from 'nestjs-mangopay';
@Module({
imports: [
MangopayModule.register({
clientId: process.env.MANGOPAY_CLIENT_ID,
clientApiKey: process.env.MANGOPAY_API_KEY,
baseUrl: process.env.MANGOPAY_API_URL,
}),
],
})
export class AppModule {}import { MangopayModule } from 'nestjs-mangopay';
@Module({
imports: [
MangopayModule.registerAsync({
userFactory: () => ({
clientId: process.env.MANGOPAY_CLIENT_ID,
clientApiKey: process.env.MANGOPAY_API_KEY,
baseUrl: process.env.MANGOPAY_API_URL,
})
}),
],
})
export class AppModule {}Example usage in service.
import { MangopayService } from 'nestjs-mangopay';
@Injectable()
export class AppService {
public constructor(private readonly mangopayService: MangopayService) {}
async createUser() {
return this.mangopayService.Users.create({
FirstName: 'Victor',
LastName: 'Hugo',
Address: '1 rue des Misérables, Paris',
Birthday: 1300186358,
Nationality: 'FR',
CountryOfResidence: 'FR',
Occupation: 'Writer',
ProofOfIdentity: null,
ProofOfAddress: null,
PersonType: 'NATURAL',
Email: '[email protected]',
Tag: 'custom tag',
});
}
}Services
- CardPreAuthorizations
- CardRegistrations
- Cards
- DisputeDocuments
- Disputes
- Events
- Hooks
- KycDocuments
- PayIns
- PayOuts
- Refunds
- Responses
- Transfers
- Users
- Wallets
import { MangopayService } from 'nestjs-mangopay';
@Injectable()
export class AppService {
public constructor(private readonly mangopayService: MangopayService) {}
async getUsers() {
return this.mangopayService.Users.getAll();
}
}For full Service API see Mangopay Node SDK reference here
Testing
Example of testing can be found here.
