Esempio n. 1
0
        public static async Task <DomesticPaymentFluentResponse> SubmitAsync(this DomesticPaymentContext context)
        {
            context.ArgNotNull(nameof(context));
            try
            {
                DomesticPayment domesticPayment = context.Data ?? new DomesticPayment(
                    context.ConsentId.ArgNotNullElseInvalidOp("ConsentId not specified"));

                IList <FluentResponseMessage> validationErrors = new PaymentRequestValidator()
                                                                 .Validate(domesticPayment)
                                                                 .GetOpenBankingResponses();
                if (validationErrors.Count > 0)
                {
                    return(new DomesticPaymentFluentResponse(validationErrors));
                }

                CreateDomesticPayment i = new CreateDomesticPayment(
                    apiClient: context.Context.ApiClient,
                    mapper: context.Context.EntityMapper,
                    openBankingClientRepo: context.Context.ClientProfileRepository,
                    domesticConsentRepo: context.Context.DomesticConsentRepository,
                    apiProfileRepo: context.Context.ApiProfileRepository,
                    softwareStatementProfileService: context.Context.SoftwareStatementProfileService);

                OBWriteDomesticResponse4 resp = await i.CreateAsync(domesticPayment.ConsentId);

                return(new DomesticPaymentFluentResponse(resp.Data));
            }
            catch (AggregateException ex)
            {
                context.Context.Instrumentation.Exception(ex);

                return(new DomesticPaymentFluentResponse(ex.CreateErrorMessages()));
            }
            catch (Exception ex)
            {
                context.Context.Instrumentation.Exception(ex);

                return(new DomesticPaymentFluentResponse(ex.CreateErrorMessage()));
            }
        }
Esempio n. 2
0
 public static DomesticPaymentContext ConsentId(this DomesticPaymentContext context, string value)
 {
     context.ConsentId = value;
     return(context);
 }
Esempio n. 3
0
 public static DomesticPaymentContext Data(this DomesticPaymentContext context, DomesticPayment value)
 {
     context.Data = value;
     return(context);
 }