public void Tokenization_Create_Token_Using_Checking_Information_Request_Returns_Successfully() { // Arrange var request = new TokenCheckRequest { PublicKey = "278DCC4B-85FE-485D-AFDD-9927AC4CA229", Check = new Check { FirstName = "John", LastName = "Smith", RoutingNumber = "222371863", AccountNumber = "123456", }, DeveloperApplication = new DeveloperApplication { DeveloperId = 12345678, Version = "1.2" } }; var apiContext = new APIContext(); var controller = new PreVaultController(); // Act var response = controller.ProcessRequest <TokenCheckResponse>(apiContext, request); // Assert Assert.IsNotNull(response); Assert.IsTrue(response.Success); }
public Task <TokenCheckResponse> CheckAsync(TokenCheckRequest tokenCheckRequest, CancellationToken cancellationToken = default(CancellationToken)) { if (tokenCheckRequest == null) { throw new ArgumentNullException(nameof(tokenCheckRequest)); } return(InternalCheckAsync(tokenCheckRequest, cancellationToken)); }
private async Task <TokenCheckResponse> InternalCheckAsync(TokenCheckRequest tokenCheckRequest, CancellationToken cancellationToken = default(CancellationToken)) { if (!_tokenTtlChecker.IsValid(tokenCheckRequest.RegistrationDate)) { return(TokenCheckResponse.Invalid); } var tokenRegistration = await _databaseContext.TokenRegistrations.GetAsync(tokenCheckRequest.Token, tokenCheckRequest.RegistrationDate, cancellationToken); if (tokenRegistration == null) { return(TokenCheckResponse.Invalid); } if (!_tokenGenerator.IsValid(new Card(tokenRegistration.CardNumber, tokenCheckRequest.Cvv), tokenCheckRequest.RegistrationDate, tokenRegistration.Id)) { return(TokenCheckResponse.Invalid); } return(TokenCheckResponse.Valid); }
public async Task <TokenCheckResponse> Post([FromBody] TokenCheckRequest tokenCheckRequest, CancellationToken cancellationToken = default(CancellationToken)) { return(await _tokenCheckService.CheckAsync(tokenCheckRequest, cancellationToken)); }