feat: resolve card bin
Feature/resolve card bin
This commit is contained in:
commit
b7c346d95e
8 changed files with 77 additions and 4 deletions
|
|
@ -1,8 +1,9 @@
|
|||
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
|
||||
import { VerificationService } from '../services/verification.service';
|
||||
import {
|
||||
PsResolveAccountRequestModel,
|
||||
PsResolveAccountResponseModel,
|
||||
PsResolveCardBinResponseModel,
|
||||
PsValidateAccountRequestModel,
|
||||
PsValidateAccountResponseModel
|
||||
} from '@devtools-bp/nestjs-paystack';
|
||||
|
|
@ -25,4 +26,11 @@ export class VerificationController {
|
|||
): Observable<PsValidateAccountResponseModel> {
|
||||
return this.verificationService.validateAccount(payload);
|
||||
}
|
||||
|
||||
@Get('decision/bin/:bin')
|
||||
resolveCardBin(
|
||||
@Param('bin') bin: string
|
||||
): Observable<PsResolveCardBinResponseModel> {
|
||||
return this.verificationService.resolveCardBin(bin);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
|
|||
import {
|
||||
PsResolveAccountRequestModel,
|
||||
PsResolveAccountResponseModel,
|
||||
PsResolveCardBinResponseModel,
|
||||
PsValidateAccountRequestModel,
|
||||
PsValidateAccountResponseModel,
|
||||
PsVerificationService
|
||||
|
|
@ -23,4 +24,8 @@ export class VerificationService {
|
|||
): Observable<PsValidateAccountResponseModel> {
|
||||
return this.psVerificationService.validateAccount(payload);
|
||||
}
|
||||
|
||||
resolveCardBin(bin: string): Observable<PsResolveCardBinResponseModel> {
|
||||
return this.psVerificationService.resolveCardBin(bin);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,10 +144,10 @@ export class TransactionController {
|
|||
- [ ] **Charge**
|
||||
- [ ] **Disputes**
|
||||
- [ ] **Refunds**
|
||||
- [ ] **Verification** ⏳
|
||||
- [ ] **Verification** <span style="color:green;">✔</span>
|
||||
- [x] Resolve Account Number <span style="color:green;">✔</span>
|
||||
- [x] Validate Account <span style="color:green;">✔</span>
|
||||
- [ ] Resolve Card BIN ⏳
|
||||
- [x] Resolve Card BIN <span style="color:green;">✔</span>
|
||||
- [ ] **Miscellaneous**
|
||||
|
||||
## Contributing
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
"url": "https://github.com/brianpooe/devtools-bp/issues",
|
||||
"email": "brian.method@gmail.com"
|
||||
},
|
||||
"homepage": "https://github.com/brianpooe/devtools-bp/tree/main/libs/ns-paystack#readme",
|
||||
"homepage": "https://github.com/brianpooe/devtools-bp/tree/main/libs/nestjs-paystack#readme",
|
||||
"keywords": [
|
||||
"nestjs",
|
||||
"paystack",
|
||||
|
|
|
|||
|
|
@ -2,3 +2,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';
|
||||
export * from './ps-resolve-card-bin-response.model';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
import { PsBaseModel } from '../common';
|
||||
|
||||
export interface PsResolveCardBinResponseModel extends PsBaseModel {
|
||||
data: PsResolveCardBinResponseDataModel;
|
||||
}
|
||||
|
||||
export interface PsResolveCardBinResponseDataModel {
|
||||
bin: string;
|
||||
brand: string;
|
||||
sub_brand: string;
|
||||
country_code: string;
|
||||
country_name: string;
|
||||
card_type: string;
|
||||
bank: string;
|
||||
linked_bank_id: number;
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import { TestBed } from '@automock/jest';
|
|||
import {
|
||||
PsResolveAccountRequestModel,
|
||||
PsResolveAccountResponseModel,
|
||||
PsResolveCardBinResponseModel,
|
||||
PsValidateAccountRequestModel,
|
||||
PsValidateAccountResponseModel
|
||||
} from '../../models';
|
||||
|
|
@ -90,4 +91,35 @@ describe(PsVerificationService.name, function () {
|
|||
expect(observerSpy.getLastValue()).toEqual(response.data);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveCardBin', () => {
|
||||
it("should get more information about a customer's card", () => {
|
||||
// Arrange
|
||||
const input = '539983';
|
||||
const response: AxiosResponse<PsResolveCardBinResponseModel> =
|
||||
fromPartial({
|
||||
data: fromPartial({
|
||||
status: true,
|
||||
message: 'Bin resolved',
|
||||
data: {
|
||||
bin: '539983',
|
||||
brand: 'Mastercard',
|
||||
sub_brand: '',
|
||||
country_code: 'NG',
|
||||
country_name: 'Nigeria',
|
||||
card_type: 'DEBIT',
|
||||
bank: 'Guaranty Trust Bank',
|
||||
linked_bank_id: 9
|
||||
}
|
||||
})
|
||||
});
|
||||
httpService.get.mockReturnValueOnce(of(response));
|
||||
|
||||
// Act
|
||||
const observerSpy = subscribeSpyTo(service.resolveCardBin(input));
|
||||
|
||||
// Act
|
||||
expect(observerSpy.getLastValue()).toEqual(response.data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { CustomHttpService } from '../custom-http/custom-http.service';
|
|||
import {
|
||||
PsResolveAccountRequestModel,
|
||||
PsResolveAccountResponseModel,
|
||||
PsResolveCardBinResponseModel,
|
||||
PsValidateAccountRequestModel,
|
||||
PsValidateAccountResponseModel
|
||||
} from '../../models';
|
||||
|
|
@ -38,4 +39,14 @@ export class PsVerificationService {
|
|||
.post<PsValidateAccountResponseModel>('bank/validate', payload)
|
||||
.pipe(handleResponseAndError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get more information about a customer's card
|
||||
* @param bin - First 6 characters of card
|
||||
*/
|
||||
resolveCardBin(bin: string): Observable<PsResolveCardBinResponseModel> {
|
||||
return this.httpService
|
||||
.get<PsResolveCardBinResponseModel>(`decision/bin/${bin}`)
|
||||
.pipe(handleResponseAndError());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue