public bool StripePay(string orderId, string stripeToken, string email) { var applicationManager = DomainHub.GetDomain <IApplicationManager>(); var order = applicationManager.GetOrder(orderId); var options = new StripeChargeCreateOptions { Amount = (int)(order.Amount * 100), Currency = EUR, SourceTokenOrExistingSourceId = stripeToken }; var service = new StripeChargeService(); var charge = service.Create(options); if (charge.Paid) { var payment = new DataAccess.Model.Storage.Payment { PartitionKey = orderId, ChargeId = charge.Id, RowKey = charge.Id, Time = DateTime.Now, Type = Stripe, Currency = charge.Currency, Amount = ((double)charge.Amount) / 100, Payer = charge.Customer?.Email ?? email }; PaymentTable.Insert(payment); } return(charge.Paid); }
public Session CreateStripePaySession(string orderId, string cancelledUrl, string succeededUrl) { var applicationManager = DomainHub.GetDomain <IApplicationManager>(); var application = applicationManager[orderId]; var unpaidAmount = this.GetUnpaidAmount(orderId); var currency = "eur"; var amount = (long)(100 * unpaidAmount); var options = new SessionCreateOptions { PaymentMethodTypes = new List <string> { "card" }, LineItems = new List <SessionLineItemOptions> { new SessionLineItemOptions { PriceData = new SessionLineItemPriceDataOptions { UnitAmount = amount, Currency = currency, ProductData = new SessionLineItemPriceDataProductDataOptions { Name = "GNIB/IRP Appointment Service", }, }, Quantity = 1, }, }, Mode = "payment", SuccessUrl = succeededUrl, CancelUrl = cancelledUrl, }; var service = new SessionService(); Session session = service.Create(options); var payment = new DataAccess.Model.Storage.Payment { PartitionKey = orderId, ChargeId = session.PaymentIntentId, RowKey = session.PaymentIntentId, Time = DateTime.Now, Type = Stripe, Currency = currency, Amount = ((double)session.AmountTotal) / 100, Payer = application.Email, Status = session.PaymentStatus }; PaymentTable.Insert(payment); return(session); }
public void AdminPay(string orderId, string chargeId, string type, string currency, double amount, string payer) { var payment = new DataAccess.Model.Storage.Payment { PartitionKey = orderId, ChargeId = chargeId, RowKey = chargeId, Time = DateTime.Now, Type = type, Currency = currency, Amount = amount, Payer = payer }; PaymentTable.Insert(payment); }