feat: added validate account api
Feature/validate account
This commit is contained in:
commit
f472f15db8
8 changed files with 92 additions and 5 deletions
|
|
@ -1,8 +1,10 @@
|
|||
import { Controller, Get, Query } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
||||
import { VerificationService } from '../services/verification.service';
|
||||
import {
|
||||
PsResolveAccountRequestModel,
|
||||
PsResolveAccountResponseModel
|
||||
PsResolveAccountResponseModel,
|
||||
PsValidateAccountRequestModel,
|
||||
PsValidateAccountResponseModel
|
||||
} from '@devtools-bp/nestjs-paystack';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
|
|
@ -16,4 +18,11 @@ export class VerificationController {
|
|||
): Observable<PsResolveAccountResponseModel> {
|
||||
return this.verificationService.resolveAccount(queryParamsPayload);
|
||||
}
|
||||
|
||||
@Post('bank/validate')
|
||||
validateAccount(
|
||||
@Body() payload: PsValidateAccountRequestModel
|
||||
): Observable<PsValidateAccountResponseModel> {
|
||||
return this.verificationService.validateAccount(payload);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ import { Injectable } from '@nestjs/common';
|
|||
import {
|
||||
PsResolveAccountRequestModel,
|
||||
PsResolveAccountResponseModel,
|
||||
PsValidateAccountRequestModel,
|
||||
PsValidateAccountResponseModel,
|
||||
PsVerificationService
|
||||
} from '@devtools-bp/nestjs-paystack';
|
||||
import { Observable } from 'rxjs';
|
||||
|
|
@ -15,4 +17,10 @@ export class VerificationService {
|
|||
): Observable<PsResolveAccountResponseModel> {
|
||||
return this.psVerificationService.resolveAccount(queryParamsPayload);
|
||||
}
|
||||
|
||||
validateAccount(
|
||||
payload: PsValidateAccountRequestModel
|
||||
): Observable<PsValidateAccountResponseModel> {
|
||||
return this.psVerificationService.validateAccount(payload);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ export class TransactionController {
|
|||
- [ ] **Refunds**
|
||||
- [ ] **Verification** ⏳
|
||||
- [x] Resolve Account Number <span style="color:green;">✔</span>
|
||||
- [ ] Validate Account ⏳
|
||||
- [x] Validate Account <span style="color:green;">✔</span>
|
||||
- [ ] Resolve Card BIN ⏳
|
||||
- [ ] **Miscellaneous**
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
export * from './ps-resolve-account-response.model';
|
||||
export * from './ps-resolve-account-request.model';
|
||||
export * from './ps-validate-account-request.model';
|
||||
export * from './ps-validate-account-response.model';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
export interface PsValidateAccountRequestModel {
|
||||
bank_code: string;
|
||||
country_code: string;
|
||||
account_number: string;
|
||||
account_name: string;
|
||||
account_type: string;
|
||||
document_type: string;
|
||||
document_number: string;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import { PsBaseModel } from '../../models';
|
||||
|
||||
export interface PsValidateAccountResponseModel extends PsBaseModel {
|
||||
data: PsValidateAccountRequestDataModel;
|
||||
}
|
||||
|
||||
export interface PsValidateAccountRequestDataModel {
|
||||
verified: boolean;
|
||||
verificationMessage: string;
|
||||
}
|
||||
|
|
@ -3,7 +3,9 @@ import { CustomHttpService } from '../custom-http/custom-http.service';
|
|||
import { TestBed } from '@automock/jest';
|
||||
import {
|
||||
PsResolveAccountRequestModel,
|
||||
PsResolveAccountResponseModel
|
||||
PsResolveAccountResponseModel,
|
||||
PsValidateAccountRequestModel,
|
||||
PsValidateAccountResponseModel
|
||||
} from '../../models';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
|
|
@ -55,4 +57,37 @@ describe(PsVerificationService.name, function () {
|
|||
expect(observerSpy.getLastValue()).toEqual(response.data);
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateAccount', () => {
|
||||
it('should confirm the authenticity of of a customers account number', () => {
|
||||
// Arrange
|
||||
const input: PsValidateAccountRequestModel = {
|
||||
bank_code: '632005',
|
||||
country_code: 'ZA',
|
||||
account_number: '0123456789',
|
||||
account_name: 'Ann Bron',
|
||||
account_type: 'personal',
|
||||
document_type: 'identityNumber',
|
||||
document_number: '1234567890123'
|
||||
};
|
||||
const response: AxiosResponse<PsValidateAccountResponseModel> =
|
||||
fromPartial({
|
||||
data: fromPartial({
|
||||
status: true,
|
||||
message: 'Personal Account Verification attempted',
|
||||
data: {
|
||||
verified: true,
|
||||
verificationMessage: 'Account is verified successfully'
|
||||
}
|
||||
})
|
||||
});
|
||||
httpService.post.mockReturnValueOnce(of(response));
|
||||
|
||||
// Act
|
||||
const observerSpy = subscribeSpyTo(service.validateAccount(input));
|
||||
|
||||
// Act
|
||||
expect(observerSpy.getLastValue()).toEqual(response.data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ import { Injectable } from '@nestjs/common';
|
|||
import { CustomHttpService } from '../custom-http/custom-http.service';
|
||||
import {
|
||||
PsResolveAccountRequestModel,
|
||||
PsResolveAccountResponseModel
|
||||
PsResolveAccountResponseModel,
|
||||
PsValidateAccountRequestModel,
|
||||
PsValidateAccountResponseModel
|
||||
} from '../../models';
|
||||
import { Observable } from 'rxjs';
|
||||
import { handleResponseAndError } from '../../helpers';
|
||||
|
|
@ -24,4 +26,16 @@ export class PsVerificationService {
|
|||
})
|
||||
.pipe(handleResponseAndError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm the authenticity of a customer's account number before sending money
|
||||
* @param payload
|
||||
*/
|
||||
validateAccount(
|
||||
payload: PsValidateAccountRequestModel
|
||||
): Observable<PsValidateAccountResponseModel> {
|
||||
return this.httpService
|
||||
.post<PsValidateAccountResponseModel>('bank/validate', payload)
|
||||
.pipe(handleResponseAndError());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue