public async Task <Invoice> GetByIdAsync(string invoiceId) { InvoiceModel invoice = await _payInvoiceClient.GetInvoiceAsync(invoiceId); Asset settlementAsset = await _lykkeAssetsResolver.TryGetAssetAsync(invoice.SettlementAssetId); PaymentRequestModel paymentRequest = null; if (!string.IsNullOrEmpty(invoice.PaymentRequestId)) { paymentRequest = await _payInternalClient.GetPaymentRequestAsync(invoice.MerchantId, invoice.PaymentRequestId); } return(new Invoice { Id = invoice.Id, Number = invoice.Number, ClientEmail = invoice.ClientEmail, ClientName = invoice.ClientName, Amount = invoice.Amount, DueDate = invoice.DueDate, Status = invoice.Status, SettlementAssetId = invoice.SettlementAssetId, SettlementAsset = settlementAsset, PaymentAssetId = invoice.PaymentAssetId, PaymentRequestId = invoice.PaymentRequestId, WalletAddress = paymentRequest?.WalletAddress, CreatedDate = invoice.CreatedDate, Note = invoice.Note }); }
public async Task NotifyStatusUpdateAsync(InvoiceStatusUpdateNotification notification) { if (!notification.Status.IsPaidStatus()) { return; } Invoice invoice = await _invoiceRepository.FindByPaymentRequestIdAsync(notification.PaymentRequestId); if (invoice == null) { PaymentRequestModel paymentRequest = await _payInternalClient.GetPaymentRequestAsync( notification.MerchantId, notification.PaymentRequestId); if (paymentRequest.Initiator != Constants.PaymentRequestInitiator) { return; } throw new InvoiceNotFoundException(); } await _emailService.Send(new PaymentReceivedEmail { MerchantId = invoice.MerchantId, EmployeeId = invoice.EmployeeId, InvoiceId = invoice.Id, InvoiceNumber = invoice.Number, PaidAmount = notification.Amount, PaymentAsset = notification.AssetId, PaidDate = notification.Date, Payer = invoice.ClientName }); }
public static PaymentRequestModel ToModel(this PaymentRequest entity) { if (entity == null) { return(null); } var model = new PaymentRequestModel { AisPaymentId = entity.AisPaymentId, ServiceProviderName = entity.ServiceProviderName, ServiceProviderBank = entity.ServiceProviderBank, ServiceProviderBic = entity.ServiceProviderBic, ServiceProviderIban = entity.ServiceProviderIban, Currency = entity.Currency, PaymentTypeCode = entity.PaymentTypeCode, PaymentAmount = entity.PaymentAmount, PaymentReason = entity.PaymentReason, ApplicantUinTypeId = entity.ApplicantUinTypeId, ApplicantUin = entity.ApplicantUin, ApplicantName = entity.ApplicantName, PaymentReferenceType = entity.PaymentReferenceType, PaymentReferenceNumber = entity.PaymentReferenceNumber, PaymentReferenceDate = DateTime.SpecifyKind(entity.PaymentReferenceDate, DateTimeKind.Utc), ExpirationDate = DateTime.SpecifyKind(entity.ExpirationDate, DateTimeKind.Utc), AdditionalInformation = entity.AdditionalInformation, AdministrativeServiceUri = entity.AdministrativeServiceUri, AdministrativeServiceSupplierUri = entity.AdministrativeServiceSupplierUri, AdministrativeServiceNotificationUrl = entity.AdministrativeServiceNotificationUrl, }; return(model); }
public async Task <StudentHistoryViewModel> GetHistoryAsync(string studentId) { var collectionRequest = new CollectionRequestModel("", "Modified", "True") { ParentId = studentId }; var collectionService = new CollectionService(new CollectionRepository(repository.Db)); var paymentRequest = new PaymentRequestModel("", "Modified", "True") { ParentId = studentId }; var paymentService = new PaymentService(new PaymentRepository(repository.Db)); List <CollectionViewModel> collections = await collectionService.SearchAsync(collectionRequest); List <PaymentViewModel> payments = await paymentService.SearchAsync(paymentRequest); List <StudentHistoryDetailViewModel> histories = new List <StudentHistoryDetailViewModel>(); histories.AddRange(collections.ConvertAll(x => new StudentHistoryDetailViewModel(x))); histories.AddRange(payments.ConvertAll(x => new StudentHistoryDetailViewModel(x))); StudentHistoryViewModel history = new StudentHistoryViewModel { Payments = payments, Collections = collections, CollectionTotal = collections.Sum(x => x.Total), PaymentTotal = payments.Sum(x => x.Amount), Histories = histories.OrderBy(x => x.Created).ToList() }; return(history); }
public async Task <PaymentRequestModel> CreatePaymentRequest(PaymentRequestModel data) { data.ID = Guid.NewGuid(); var result = this._repo.InsertPayments(data); return(await result); }
public ActionResult IndexPost(PaymentInfoModel model) { if (model == null || !ModelState.IsValid) { throw new ArgumentException("IndexPost"); } //Generate Unique Reference for Order var MerchantReference = "O" + DateTime.Now.ToString("yyyyMMddhhmm") + new Random().Next(1000); //build form to post to page StringBuilder sb = new StringBuilder(); sb.AppendFormat("<form id='EpaymentForm' action='{0}' method='post'>", EcentricHPP.Helpers.ConfigHelper.HPPLink()); var requestModel = new PaymentRequestModel(model.Amount, model.Currency, MerchantReference, model.TransactionType, model.UserID); PropertyInfo[] properties = requestModel.GetType().GetProperties(); foreach (var prop in properties) { string name = prop.Name; // Get string name object value = prop.GetValue(requestModel, null); // Get value sb.AppendFormat("<input type='hidden' name='{0}' value='{1}'/>", name, value); } sb.Append("</form>"); sb.Append("<script type='text/javascript'>document.getElementById('EpaymentForm').submit();</script>"); //write to response object Response.Write(sb.ToString()); return(View()); }
public PaymentRequestModel UpdatePayment(PaymentRequestModel model) { model.UpdatedDate = DateTime.Now; var updated = _requestRepository.UpdatePayment(model); return(updated); }
public async Task <string> SendPaymentRequest(PaymentRequestModel paymentRequest) { string modelStr = JsonConvert.SerializeObject(paymentRequest, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); var client = new HttpClient(); var uri = _settings.SendJsonPaymentRequestUri; Log.Information($"EPaymentJobService/SendPaymentRequest - uri: {uri}"); HttpContent content = new StringContent(modelStr, Encoding.UTF8, "application/json"); var request = CreatePaymentHttpRequest(HttpMethod.Post, uri, content); var response = await client.SendAsync(request); var jsonString = await response.Content.ReadAsStringAsync(); Log.Information($"EPaymentJobService/SendPaymentRequest - result: {jsonString}"); Log.Information($"EPaymentJobService/SendPaymentRequest - result code: {response.StatusCode}"); if (response.IsSuccessStatusCode) { return(jsonString); } else { return(null); } }
public async Task <SupplierHistoryViewModel> GetHistoryAsync(string supplierId) { var purchaseRequest = new PurchaseRequestModel("", "Modified", "True") { ParentId = supplierId }; var purchaseService = new PurchaseService(new PurchaseRepository(repository.Db)); var paymentRequest = new PaymentRequestModel("", "Modified", "True") { ParentId = supplierId }; var paymentService = new PaymentService(new PaymentRepository(repository.Db)); List <PurchaseViewModel> purchases = await purchaseService.SearchAsync(purchaseRequest); List <PaymentViewModel> payments = await paymentService.SearchAsync(paymentRequest); List <SupplierHistoryDetailViewModel> histories = new List <SupplierHistoryDetailViewModel>(); histories.AddRange(purchases.ConvertAll(x => new SupplierHistoryDetailViewModel(x))); histories.AddRange(payments.ConvertAll(x => new SupplierHistoryDetailViewModel(x))); SupplierHistoryViewModel history = new SupplierHistoryViewModel { Payments = payments, Purchases = purchases, PurchaseTotal = purchases.Sum(x => x.Total), PaymentTotal = payments.Sum(x => x.Amount), Histories = histories.OrderBy(x => x.Created).ToList() }; return(history); }
/// <summary> /// Call intended payment gateway. /// </summary> /// <param name="paymentRequestModel"></param> /// <returns></returns> private async Task <PaymentStatus> CallGatewayAsync(PaymentRequestModel paymentRequestModel) { var amount = paymentRequestModel.Amount; if (amount <= 20) { this._paymentGateway = this._serviceAccessor(Constants.CHEAP); return(await this.CallGatewayAsync(paymentRequestModel, 0, Constants.CHEAP)); } else if (amount > 20 && amount <= 500) // In requirement some ranges are missing like range between 20 and 21 , here in the condition assuming some ranges. { this._paymentGateway = this._serviceAccessor(Constants.EXPENSIVE); if (await this._paymentGateway.IsAvailableAsync()) { return(await this.CallGatewayAsync(paymentRequestModel, 0, Constants.EXPENSIVE)); } else { this._paymentGateway = this._serviceAccessor(Constants.CHEAP); return(await this.CallGatewayAsync(paymentRequestModel, 0, Constants.CHEAP)); } } else //if (amount > 500) { this._paymentGateway = this._serviceAccessor(Constants.PREMIUM); return(await this.CallGatewayAsync(paymentRequestModel, 3, Constants.PREMIUM)); } }
public IHttpActionResult PostPayment(PaymentRequestModel oCustomerPaymentRequest) { string sIPAddress = Request.GetOwinContext().Request.RemoteIpAddress; try { string userEmail = oUserRepo.GetUserEmail(oCustomerPaymentRequest.UserId).ToString(); if (String.IsNullOrEmpty(oCustomerPaymentRequest.coupon_code)) { oCustomerPaymentRequest.coupon_code = ""; } StripeCustomer stripeCustomer = oStripeCustomerHandler.CreateStripeCustomer(userEmail, oCustomerPaymentRequest.Token, oCustomerPaymentRequest.coupon_code); oUserRepo.UpdateUserWithStripeID(stripeCustomer.Id, oCustomerPaymentRequest.UserId); oAuth0User.SendUserVerificationEmail(oCustomerPaymentRequest.Auth0Id); oLogger.LogData("ROUTE: api/Payments/Capture; METHOD: POST; IP_ADDRESS: " + sIPAddress); return(Ok()); } catch (Exception ex) { oLogger.LogData("ROUTE: api/Payments; METHOD: POST; IP_ADDRESS: " + sIPAddress + "; EXCEPTION: " + ex.Message + "; INNER EXCEPTION: " + ex.InnerException); return(InternalServerError()); } }
public async Task <PaymentResponseModel> InitiatePayment(PaymentRequestModel payModel) { PaymentResponseModel dtoPayResponse = new PaymentResponseModel(); try { ARMvc.KnetService.RequestModel objRequest = new ARMvc.KnetService.RequestModel() { Amount = payModel.Amount, ReffNo = payModel.ReffNo, UDF1 = payModel.UDF1, UDF2 = payModel.UDF2, UDF3 = payModel.UDF3, UDF4 = payModel.UDF4, UDF5 = payModel.UDF5, KNETConfig = new ARMvc.KnetService.Configuration() { Language = ConfigSettings.KnetLanguage, AliasName = ConfigSettings.KnetAliasName, ResponseURL = string.Format(ConfigSettings.KnetResponseURL, payModel.Culture), ErrorURL = string.Format(ConfigSettings.KnetErrorURL), ResourcePath = ConfigSettings.KnetResourcePath, KnetCurrency = ConfigSettings.KnetCurrency } }; ARMvc.KnetService.ResponseModel objResponse = await new ARMvc.KnetService.KNETServiceClient().InitPaymentAsync(objRequest); dtoPayResponse = ObjectAutoMap.Map <ARMvc.KnetService.ResponseModel, PaymentResponseModel>(objResponse); } catch (Exception ex) { dtoPayResponse = ObjectAutoMap.Map <PaymentRequestModel, PaymentResponseModel>(payModel); dtoPayResponse.ErrorMessage = "Payment service is down. Please try again later"; } return(dtoPayResponse); }
public async Task <PaymentRequestModel> InsertPayments(PaymentRequestModel payment) { this.context.PaymentRequest.Add(payment); await this.context.SaveChangesAsync(); return(payment); }
public RaveService InitiatePay(Payment payment) { ConfigModel config = new ConfigModel() { Meta = new List <string>(), RedirectUrl = AppConstant.BaseUrl + "Landing", //callback to retrieve payment status Env = ConfigModel.LIVE, //or ConfigModel.LIVE (for production) PublicKey = AppConstant.PublicKey, SecretKey = AppConstant.SecretKey }; PaymentRequestModel request = new PaymentRequestModel() { CustomerEmail = payment.CustomerEmail, CustomerPhone = payment.CustomerPhone, Amount = payment.Amount, Country = "Nigeria", Currency = "NGN", CustomDescription = payment.CustomDescription, CustomerFirstname = payment.CustomerFirstname, CustomerLastname = payment.CustomerLastname, CustomTitle = payment.CustomTitle, CustomLogo = "https://cms.suregifts.com.ng/utilitypics/catholicarchdioceselagos.png", PayButtonText = "Pay Me" }; return(new RaveService(config, request)); }
public async Task <int> SubmitPayment(PaymentRequestModel requestModel) { if (!_currentUser.IsInRole("merchant")) { throw new UnauthorizedResourceAccessException("Only merchants can make payments"); } string idString = _currentUser.Claims .FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier).Value; requestModel.MerchantId = GetCurrentUserId() ?? 0; _validator.ValidateForServices(requestModel); var payment = _mapper.Map <Payment>(requestModel); payment.Submitted = DateTime.Now; payment.Status = PaymentStatus.NotSubmitted; payment.CardNumber = $"************{payment.CardNumber.Substring(12)}"; await _repository.AddPayment(payment); await _unitOfWork.Commit(); var command = _mapper.Map <SubmitPaymentCommand>(payment); await _bus.Publish(command); payment.Status = PaymentStatus.Submitted; await _unitOfWork.Commit(); return(payment.Id); }
public Payment DoPayment(PaymentRequestModel request) { //sepet toplam tutar double totalBasketPrice = request.BasketItems.Sum(b => Convert.ToDouble(b.Price)); //ödeme isteği var paymentRequest = new CreatePaymentRequest(); paymentRequest.Locale = Iyzipay.Model.Locale.TR.GetName(); paymentRequest.ConversationId = request.ConversationId; paymentRequest.Price = totalBasketPrice.ToString(); // Ödeme sepet tutarı. Kırılım tutarlar toplamı sepet tutarına eşit olmalı. Zorunlu paymentRequest.PaidPrice = "1"; // İndirim, vergi gibi değerlerin dahil edildiği, vade farkı önbcesi tutar değeri. Zorunlu paymentRequest.Installment = 1; //taksit. zorunlu paymentRequest.BasketId = HelperMethods.RandomString(5); paymentRequest.PaymentGroup = PaymentGroup.SUBSCRIPTION.ToString(); // Ödeme grubu, varsayılan PRODUCT. Geçerli değerler enum içinde sunulmaktadır: PRODUCT, LISTING, SUBSCRIPTION. Zorunlu değil paymentRequest.PaymentChannel = request.PaymentChannel.ToString(); //ödeme kanalı. zorunlu değil paymentRequest.Currency = Iyzipay.Model.Currency.TRY.ToString(); //para birimi. TL paymentRequest.CallbackUrl = "https://www.merchant.com/callback"; paymentRequest.PaymentCard = request.PaymentCard; //kart bilgileri paymentRequest.Buyer = request.Buyer; //alıcı bilgileri paymentRequest.BillingAddress = request.BillingAddress; //fatura adres bilgileri paymentRequest.BasketItems = request.BasketItems; //sepet bilgileri //ödeme işlemleri Payment paymentResponse = Create(paymentRequest); return(paymentResponse); }
public ActionResult Index() { long UserId = GetUserId(); CLayer.Address byAddress = BLayer.Address.GetAddressOnUserId(UserId); CLayer.Address adrs = BLayer.Address.GetPrimaryOnUser(UserId); PaymentRequestModel model = new PaymentRequestModel(); if (byAddress != null && adrs != null) { model.Name = byAddress.Firstname; model.Email = byAddress.Email; model.Mobile = adrs.Mobile; model.CityId = adrs.CityId; model.City = adrs.City; model.State = adrs.State; model.CountryId = adrs.CountryId; model.ZipCode = adrs.ZipCode; model.Address = adrs.AddressText; return(View(model)); } else { return(View(model)); } }
public IHttpActionResult PayInCashOrCredit(PaymentRequestModel model) { using (var context = new TasteContext()) { var order = context.Orders.FirstOrDefault(o => o.OrderId == model.OrderId); if (order != null) { double total = 0; var orderItems = context.OrderedDishes.Where(o => o.OrderId == model.OrderId && o.UserId == model.UserId); foreach (var od in orderItems) { var item = context.Dishes.FirstOrDefault(it => it.Id == od.DishId); if (item == null) { continue; } total += item.Price * od.Quantity; } order.Paid = true; order.TotalInPennies = Convert.ToInt32(total * 100); order.TaxInPennies = Convert.ToInt32(order.TotalInPennies * 0.0925); order.TipInPennies = 0; context.SaveChanges(); } return(Ok()); } }
public async Task <PaymentRequestResponseModel> PartnerPaymentAsync([FromBody] PaymentRequestModel request) { var paymentRequest = _mapper.Map <PaymentRequest>(request); var result = await _paymentsService.InitiatePartnerPaymentAsync(paymentRequest); return(_mapper.Map <PaymentRequestResponseModel>(result)); }
public string Post([FromForm] PaymentRequestModel paymentRequest) { var datenow = DateTime.Now; PaymentRequestsRepo.Create(paymentRequest); PaymentRequestsRepo.Save(); return($"OK"); }
public PaymentRequestModel StorePayment(PaymentRequestModel model) { model.CreatedDate = DateTime.Now; model.PaymentState = PaymentStatus.pending; var created = _requestRepository.StorePayment(model); return(created); }
public ActionResult Create() { PaymentRequestModel payment = new PaymentRequestModel() { Currency = Currency.EUR }; return(this.View(payment)); }
public string ProceedToPayment([FromBody] PaymentRequestModel model) { string requestString = JsonConvert.SerializeObject(model.PolicyRequest); string responseString = ApiHelper.MakeRequest(_apiConfiguration.Url + "travel/policy", _apiConfiguration.Username, _apiConfiguration.Password, "PUT", requestString); PolicyResponseModel policyResponse = JsonConvert.DeserializeObject <PolicyResponseModel>(responseString); string paymentForm = PaymentHelper.GenerateForm(policyResponse.PolicyNumber, (int)(Convert.ToDecimal(model.OfferResponse.PremiumRsd) * 100)); return(paymentForm); }
public async Task PostPayment([FromBody] PaymentRequestModel model) { var user = await _userService.GetUserByPrincipalAsync(User); if (user == null) { throw new UnauthorizedAccessException(); } await _userService.ReplacePaymentMethodAsync(user, model.PaymentToken, model.PaymentMethodType.Value); }
public async Task PutPayment(string id, [FromBody] PaymentRequestModel model) { var orgIdGuid = new Guid(id); if (!_currentContext.OrganizationOwner(orgIdGuid)) { throw new NotFoundException(); } await _organizationService.ReplacePaymentMethodAsync(orgIdGuid, model.PaymentToken); }
public async Task <IActionResult> Pay([FromBody] PaymentRequestModel request) { try { await Task.Delay(_delay); return(request.Balance >= request.Price ? Ok(new { Result = true, Balance = request.Balance - request.Price }) : Ok(new { Result = false, Balance = request.Balance })); } catch { return(BadRequest()); } }
public async Task <ActionResult> Create(PaymentRequestModel paymentRequestModel) { if (this.ModelState.IsValid) { PaymentRequest paymentRequest = new PaymentRequest(); paymentRequest.Amount = new Amount(paymentRequestModel.Currency, paymentRequestModel.Amount); paymentRequest.Description = paymentRequestModel.Description; paymentRequest.RedirectUrl = paymentRequestModel.RedirectUrl; await this._paymentClient.CreatePaymentAsync(paymentRequest); return(this.RedirectToAction("Index")); } return(this.View(paymentRequestModel)); }
public async Task <ActionResult> PayRent(PaymentRequestModel RQ) { UserModel objUser = Session[SessionConstants.UserSession] as UserModel; RQ.UDF1 = objUser.CardCode + "_" + objUser.CardName; RQ.Culture = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName; PaymentResponseModel objResponse = await new PaymentUtility().InitiatePayment(RQ); if (objResponse is PaymentResponseModel && string.IsNullOrEmpty(objResponse.ErrorMessage)) { Response.Redirect(objResponse.RedirectionURL); } return(View(@"~\Views\Rent\PayReciept.cshtml", objResponse)); }
private async Task <PaymentRequestModel> SavePaymentRequestAsync(PaymentRequestModel model) { if (model == null) { throw new NullReferenceException(nameof(model)); } var request = model.ToEntity(); await _context.PaymentRequest.AddAsync(request); await _context.SaveChangesAsync(); model.AisPaymentId = request.AisPaymentId; return(model); }
public async Task PostPayment([FromBody] PaymentRequestModel model) { var user = await _userService.GetUserByPrincipalAsync(User); if (user == null) { throw new UnauthorizedAccessException(); } await _userService.ReplacePaymentMethodAsync(user, model.PaymentToken, model.PaymentMethodType.Value, new TaxInfo { BillingAddressCountry = model.Country, BillingAddressPostalCode = model.PostalCode, }); }