public async Task <ActionResult <CreatePaymentAuthorizationResultViewModel> > CreatePaymentAuthorization( [FromBody] CreatePaymentAuthorizationRequestViewModel body) { if (_environment.IsProduction()) { return(NotFound()); } var result = new CreatePaymentAuthorizationResultViewModel(); try { var response = await _aiiaService.CreatePaymentAuthorization(User, body); result.AuthorizationId = response.AuthorizationId; result.AuthorizationUrl = response.AuthorizationUrl; } catch (AiiaClientException e) { result.ErrorDescription = e.Message; } return(Ok(result)); }
public async Task <CreatePaymentAuthorizationResponse> CreatePaymentAuthorization(ClaimsPrincipal principal, CreatePaymentAuthorizationRequestViewModel request) { var currentUserId = principal.FindFirst(ClaimTypes.NameIdentifier).Value; var user = _dbContext.Users.FirstOrDefault(x => x.Id == currentUserId); if (user == null) { throw new UserNotFoundException(); } var paymentAuthorizationRequest = new CreatePaymentAuthorizationRequest() { Culture = request.Culture, PaymentIds = request.PaymentIds.ToArray(), RedirectUrl = GetPaymentAuthorizationRedirectUrl(), }; return(await CallApi <CreatePaymentAuthorizationResponse>($"v2/accounts/{request.SourceAccountId}/payment-authorizations", paymentAuthorizationRequest, HttpMethod.Post, user.AiiaTokenType, user.AiiaAccessToken)); }