public async Task <IActionResult> VerifyTransactionStatus(VerifyTransactionStatusInput input) { if (input == null || !input.Validate()) { return(Conflict(new B2CErrorResponseContent("Cannot deserialize input claims"))); } var token = new VerificationToken(appSettings); token.Decrypt(input.VerificationToken); var statusResponse = await httpService.GetAsync <JumioTransactionStatus>($"{jumioSettings.BaseUrl}/api/netverify/v2/scans/{token.TransactionReference}"); if (!statusResponse.Status) { return(Conflict(new B2CErrorResponseContent(statusResponse.Message))); } else if (statusResponse.Data.Status == Constants.JumioTransactionStatus.Pending) { token.Message = $"The document verification is still pending. (Status {statusResponse.Data.Status})"; return(Ok(new VerifyTransactionStatusOutput() { Status = "RETRY", VerificationToken = token.GenerateToken() })); } else if (statusResponse.Data.Status == Constants.JumioTransactionStatus.Failed) { token.Message = $"The document uploading has failed. (Status {statusResponse.Data.Status})"; return(Ok(new VerifyTransactionStatusOutput() { Status = "FAILED", VerificationToken = token.GenerateToken() })); } var dataResponse = await httpService.GetAsync <JumioTransactionData>($"{jumioSettings.BaseUrl}/api/netverify/v2/scans/{token.TransactionReference}/data"); if (!dataResponse.Status) { return(Conflict(new B2CErrorResponseContent(dataResponse.Message))); } else if (dataResponse.Data?.Document?.Status != Constants.JumioDocumentStatus.ApprovedVerified) { token.Message = dataResponse.Data?.Document == null ? $"Document failed. (Status {dataResponse.Data?.Document?.Status})" : $"Document failed. (Status {dataResponse.Data.Document.Type} - {dataResponse.Data.Document.Status})"; return(Ok(new VerifyTransactionStatusOutput() { Status = "FAILED", VerificationToken = token.GenerateToken() })); } token.Message = $"Document verified successfully. (Status {dataResponse.Data?.Document?.Status})"; token.IsVerified = true; return(Ok(new VerifyTransactionStatusOutput() { Status = "SUCCESS", VerificationToken = token.GenerateToken() })); }
public IActionResult ValidateVerificationToken(ValidateVerificationTokenInput input) { if (input == null || !input.Validate()) { return(Conflict(new B2CErrorResponseContent("Cannot deserialize input claims"))); } var token = new VerificationToken(appSettings); token.Decrypt(input.VerificationToken); if (token.ObjectId != input.ObjectId || token.TransactionReference != input.TransactionReference) { return(Conflict(new B2CErrorResponseContent("Invalid Token"))); } return(Ok(new ValidateVerificationTokenOutput() { Success = token.IsVerified, Message = string.IsNullOrEmpty(token.Message) ? null : token.Message })); }