public override Task <PaymentResult> ProcessPayment(PaymentModel paymentModel) { var cloneObj = paymentModel.Clone(); if (cloneObj.Order.Installment.HasValue && (cloneObj.Order.Installment == 1 || cloneObj.Order.Installment == 0)) { cloneObj.Order.Installment = null; } if (cloneObj.Order.CurrencyCode.IsEmpty()) { cloneObj.Order.CurrencyCode = "949"; } return(base.ProcessPayment(cloneObj)); }
public async override Task <PaymentResult> ProcessPayment(PaymentModel paymentModel) { var cloneObj = paymentModel.Clone(); string orderId = cloneObj.Order.OrderId.PadLeft(cloneObj.Use3DSecure ? 20 : 24, '0'); if (cloneObj.Order.Installment.HasValue && (cloneObj.Order.Installment == 1 || cloneObj.Order.Installment == 0)) { cloneObj.Order.Installment = null; } cloneObj.Order.Total *= 100; cloneObj.Order.OrderId = orderId; if (cloneObj.Order.CurrencyCode.IsEmpty()) { cloneObj.Order.CurrencyCode = "TL"; } if (cloneObj.Use3DSecure) { string template = TemplateHelper.ReadEmbedResource($"{EmbededDirectory}.3D_before.xml"); string postData = TemplateHelper.PrepaireXML(new ViewModel { CreditCard = cloneObj.CreditCard, Order = cloneObj.Order, Use3DSecure = true, Configuration = ProviderConfiguration, SessionId = cloneObj.SessionId }, template); var post = GetPostForm(); post.Content = postData; Log.Information("ProcessPayment - YKB Use3DSecure - POST"); HTTPClient client = new HTTPClient(EndPointConfiguration.BaseUrl); var result = await client.Post(EndPointConfiguration.ApiEndPoint, post, Handler3D); if (result.Status) { cloneObj.Attributes.Add(new SanalPosTRAttribute { Key = "Data1", Value = result.Data1 }); cloneObj.Attributes.Add(new SanalPosTRAttribute { Key = "Data2", Value = result.Data2 }); cloneObj.Attributes.Add(new SanalPosTRAttribute { Key = "Sign", Value = result.Sign }); } else { return(new PaymentResult { Status = result.Status, Error = result.Error, ErrorCode = result.ErrorCode }); } } return(await base.ProcessPayment(cloneObj)); }
private async Task CreatePaymentModel(Table table, bool missingApprenticeshipId = false) { var payments = table.CreateSet <ProviderPayment>().ToList(); var jobId = TestSession.GenerateId(); var paymentHistory = new List <PaymentModel>(); foreach (var providerPayment in payments) { var apprenticeship = TestSession.Apprenticeships[CommitmentIdentifierB]; var payment = new PaymentModel { JobId = jobId, CollectionPeriod = providerPayment.ParsedCollectionPeriod, DeliveryPeriod = providerPayment.ParsedDeliveryPeriod.Period, Ukprn = TestSession.Provider.Ukprn, LearnerUln = learnerB.Uln, LearnerReferenceNumber = learnerB.LearnRefNumber, SfaContributionPercentage = 0.95m, TransactionType = providerPayment.TransactionType, ContractType = ContractType.Act1, PriceEpisodeIdentifier = PriceEpisodeIdentifierB, LearningAimPathwayCode = 1, LearningAimReference = "ZPROG001", LearningAimStandardCode = 0, IlrSubmissionDateTime = DateTime.Now, LearningAimFundingLineType = "19+ Apprenticeship (Employer on App Service)", LearningAimFrameworkCode = 418, LearningAimProgrammeType = 20, AccountId = apprenticeship?.AccountId, TransferSenderAccountId = apprenticeship?.TransferSendingEmployerAccountId, StartDate = DateTime.UtcNow, PlannedEndDate = DateTime.UtcNow, ActualEndDate = DateTime.UtcNow, CompletionStatus = 1, CompletionAmount = 9000M, InstalmentAmount = 600M, NumberOfInstalments = 12, ReportingAimFundingLineType = "19+ Apprenticeship (Employer on App Service) Levy funding", ApprenticeshipEmployerType = ApprenticeshipEmployerType.Levy, LearningStartDate = TestSession.FM36Global.Learners[1].LearningDeliveries.First().LearningDeliveryValues.LearnStartDate, ApprenticeshipId = missingApprenticeshipId && (providerPayment.LevyPayments < 0 || providerPayment.SfaCoFundedPayments < 0 || providerPayment.EmployerCoFundedPayments < 0) ? null : apprenticeship?.Id, ApprenticeshipPriceEpisodeId = missingApprenticeshipId && (providerPayment.LevyPayments < 0 || providerPayment.SfaCoFundedPayments < 0 || providerPayment.EmployerCoFundedPayments < 0) ? null : apprenticeship?.ApprenticeshipPriceEpisodes.First().Id, }; if (providerPayment.LevyPayments != 0) { var levyPayment = payment.Clone(); levyPayment.CollectionPeriod = providerPayment.ParsedCollectionPeriod.Clone(); levyPayment.EventId = Guid.NewGuid(); levyPayment.Amount = providerPayment.LevyPayments; levyPayment.FundingSource = FundingSourceType.Levy; paymentHistory.Add(levyPayment); } if (providerPayment.SfaCoFundedPayments != 0) { var sfaCoFundedPayments = payment.Clone(); sfaCoFundedPayments.CollectionPeriod = providerPayment.ParsedCollectionPeriod.Clone(); sfaCoFundedPayments.EventId = Guid.NewGuid(); sfaCoFundedPayments.Amount = providerPayment.SfaCoFundedPayments; sfaCoFundedPayments.FundingSource = FundingSourceType.CoInvestedSfa; paymentHistory.Add(sfaCoFundedPayments); } if (providerPayment.EmployerCoFundedPayments != 0) { var employerCoFundedPayments = payment.Clone(); employerCoFundedPayments.CollectionPeriod = providerPayment.ParsedCollectionPeriod.Clone(); employerCoFundedPayments.EventId = Guid.NewGuid(); employerCoFundedPayments.Amount = providerPayment.EmployerCoFundedPayments; employerCoFundedPayments.FundingSource = FundingSourceType.CoInvestedEmployer; paymentHistory.Add(employerCoFundedPayments); } } await DataContext.Payment.AddRangeAsync(paymentHistory); await DataContext.SaveChangesAsync().ConfigureAwait(false); }