/// <summary> /// Method validates input params and redirects to Vetuma payment service /// </summary> /// <param name="model">VetumaPaymentModel object</param> public void MakePayment(model.VetumaPaymentModel model) { if (model == null) { throw new ArgumentNullException("VetumaPaymentModel is null"); } PaymentRequest payment = VetumaServiceModelMapper.ToDbPaymentResultModel(model); bool isExtended = this.DbContext.Get<ApplicationForm>(o => o.ApplicationFormId == model.ApplicationId).IsExtension; payment.TransactionId = this.GetSetTransactionId(model.ApplicationId, true); // TODO add logic here payment.DirectToPolice = true; payment.OrderNumber = this.FormatOrderNumber(model.ApplicationId); // TODO: Get app Code from DB -> code that is id from Vetuma Payment int appcode = 8270; // test KAN_5 code ... get from DB payment.ReferenceNumber = this.FormatReferenceNumber(appcode, model.AuthorityOfficeLabel); payment.PaymentDescription = base.TxtModel.PaymentDescription; payment.MessageToSeller = base.TxtModel.MessageToSeller; payment.Language = VetumaServiceModelMapper.ToDbTransactionLanguage(Globalizer.CurrentUICultureLanguage.Value); payment.Amount = this.GetPayableAmount(model.ApplicationId); // Save to db this.SavePaymentRequestModel(payment, model.ApplicationId); // update application form status this.UpdateApplicationFormStatus(model.ApplicationId); // Make payment this.PaymentService.MakePayment(payment); }
/// <summary> /// Method maps VetumaPayment object from Web to DB objects. /// Method maps only necessary objects. All otherts that are not mapped will have default values /// If passed object is null method returns null /// </summary> /// <param name="model">VetumaPayment object (Web model)</param> /// <returns>VetumaPayment object</returns> public static PaymentRequest ToDbPaymentResultModel(model.VetumaPaymentModel model) { if (model == null) { return null; } return new PaymentRequest { Amount = model.Amount, Language = VetumaServiceModelMapper.ToDbTransactionLanguage(model.Language), UriLinks = VetumaServiceModelMapper.ToDBVetumaUriModel(model.UriLinks), TransactionId = model.TransactionId }; }
/// <summary> /// Method maps PaymentReslts object from DB to Web object. /// If passed object is null method returns null /// </summary> /// <param name="model">PaymentResultModel object</param> /// <returns>PaymentResult object</returns> public static PaymentResult ToDbPaymentResultModel(model.PaymentResultModel model) { if (model == null) { return null; } return new PaymentResult { ArchivingCode = model.ArchivingCode, OrderNumber = model.OrderNumber, PaymentId = model.PaymentId, ReferenceNumber = model.ReferenceNumber, Success = model.Success }; }
/// <summary> /// Method maps VetumaUriModel object from Web to DB objects. /// If passed object is null method returns null /// </summary> /// <param name="model">VetumaUriModel object (Web model)</param> /// <returns>VetumaUriModel object</returns> public static VetumaUriModel ToDBVetumaUriModel(model.VetumaUriModel model) { if (model == null) { return null; } return new VetumaUriModel { CancelUri = model.CancelUri, ErrorUri = model.ErrorUri, RedirectUri = model.RedirectUri }; }