Example #1
0
        public async Task <IActionResult> CreateAccount(DfpCreateAccountInputClaims input)
        {
            if (input == null || !input.Validate())
            {
                return(Conflict(new B2CErrorResponseContent("Cannot deserialize input claims")));
            }

            var correlationId = dfpService.NewCorrelationId;
            var signUpId      = dfpService.NewCorrelationId;

            var response = await dfpService.CreateAccount(input, correlationId, signUpId);

            if (!response.Status)
            {
                return(Conflict(new B2CErrorResponseContent(response.Message, $"Correlation Id : {correlationId}")));
            }

            var result = response.Data?.ResultDetails?.FirstOrDefault();

            if (result == null)
            {
                return(Conflict(new B2CErrorResponseContent(response.Message, $"Correlation Id : {correlationId}")));
            }

            var botScore  = result.Scores.FirstOrDefault(x => x.ScoreType == "Bot")?.ScoreValue ?? 0;
            var riskScore = result.Scores.FirstOrDefault(x => x.ScoreType == "Bot")?.ScoreValue ?? 0;

            return(Ok(new DfpCreateAccountOutputClaims()
            {
                CorrelationId = correlationId, SignUpId = signUpId, Decision = result.Decision, BotScore = botScore, RiskScore = riskScore
            }));
        }
Example #2
0
        public async Task <(bool Status, string Message, DfpAccountActionResponse Data)> CreateAccount(DfpCreateAccountInputClaims input, string correlationId, string signUpId)
        {
            var endpoint = $"/v1.0/action/account/create/{signUpId}";

            var createAccountInput = new
            {
                Metadata = new
                {
                    TrackingId        = Guid.NewGuid().ToString(),
                    SignUpId          = signUpId,
                    CustomerLocalDate = DateTime.Now,
                    MerchantTimeStamp = DateTime.Now,
                    AssessmentType    = "Protect"
                },
                User = new
                {
                    Username  = input.Email,
                    FirstName = input.FirstName,
                    LastName  = input.LastName,
                    Language  = input.Language,
                    UserType  = "Consumer",
                },
                SsoAuthenticationProvider = new
                {
                    DisplayName            = input.DisplayName,
                    AuthenticationProvider = input.DisplayName
                },
                Email = new[] {
                    new
                    {
                        EmailValue       = input.Email,
                        IsEmailValidated = input.IsEmailValidated,
                        IsEmailUsername  = input.IsEmailUsername,
                        EmailType        = "Primary"
                    }
                },
                Device = new
                {
                    IpAddress       = input.IpAddress,
                    DeviceContextId = input.DeviceContextId,
                    Provider        = "DFPFingerprinting"
                },

                Name    = "AP.AccountCreation",
                Version = "0.5"
            };

            return(await PostAsync <DfpAccountActionResponse>(endpoint, createAccountInput, correlationId));
        }