public void OnSuccess(Token token) { try { // Send token to your own web service //var stripeBankAccount = token.BankAccount; //var stripeCard = token.Card; //var stripeCreated = token.Created; TokenId = token.Id; //var stripeLiveMode = token.Livemode; //var stripeType = token.Type; //var stripeUsed = token.Used; var currencyCode = ListUtils.SettingsSiteList?.StripeCurrency ?? "USD"; CustomerSession.InitCustomerSession(this); CustomerSession.Instance.SetCustomerShippingInformation(this, new ShippingInformation()); CustomerSession.Instance.AddProductUsageTokenIfValid(TokenId); // Create the PaymentSession PaymentSession = new PaymentSession(this); PaymentSession.Init(this, GetPaymentSessionConfig()); var priceInt = Convert.ToInt32(Price) * 100; Stripe.CreateSource(SourceParams.CreateAlipaySingleUseParams(priceInt, currencyCode.ToLower(), EtName.Text, UserDetails.Email, "stripe://payment_intent_return"), this); } catch (Exception e) { Methods.DisplayReportResultTrack(e); AndHUD.Shared.Dismiss(this); } }
public Checkout(Client client) : base(client) { IsApiKeyRequired = true; _payments = new Payments(this); _paymentMethods = new PaymentMethods(this); _paymentDetails = new PaymentDetails(this); _paymentSession = new PaymentSession(this); _paymentsResult = new PaymentsResult(this); }
public async Task Notify(PaymentSession session) { var credentials = _configuration.GetSection("Settings").GetSection("MarketMailCredentials"); string username = credentials.GetSection("Username").Value; string password = credentials.GetSection("Password").Value; var message = ConfigureMessage(username, session); var client = ConfigureClient(username, password); await Task.Run(() => client.Send(message)); }
public async Task Notify(PaymentSession session) { var messageModel = MapToMessage(session); messageModel.Hash = GenerateHash(messageModel); var bodyWithHash = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(messageModel)); await Task.Run(() => _channel.BasicPublish(exchange: ExchangeName, routingKey: RoutingKey, basicProperties: null, body: bodyWithHash)); Console.WriteLine(" [x] Sent {0}", messageModel); }
private string GenerateMessage(PaymentSession session) { var generateMessage = $"Hello!\nYou've successfully paid for your order №{session.ID}\nYour keys are:\n"; foreach (GameKey gameKey in session.GameKeys) { generateMessage += gameKey.Key + "\n"; } return(generateMessage); }
private MailMessage ConfigureMessage(string username, PaymentSession session) { MailAddress from = new MailAddress(username, "GameKeys Store"); MailAddress to = new MailAddress(session.Client.Username); MailMessage m = new MailMessage(from, to); m.Subject = "Purchase confirmation"; m.Body = GenerateMessage(session); return(m); }
private Message MapToMessage(PaymentSession session) { var game = session.GameKeys.First().Game; var marketShare = double.Parse(_configuration.GetSection("Settings").GetSection("MarketShare").Value); var message = new Message(); message.VendorUrl = game.Vendor.Username; message.GameName = game.Name; message.KeysCount = session.GameKeys.Count; message.Take = session.GameKeys.Count * game.Price * (1 - marketShare); message.Commission = marketShare; return(message); }
public IntegrationDto Integration([FromBody] IntegrationRequestModel requestModel) { var integration = this._integrationRepository.GetByKey(requestModel.IdentifyingToken); var paymentSession = new PaymentSession { IntegrationId = integration.Id, UniqueReference = Guid.NewGuid(), WhenStarted = DateTime.UtcNow }; this._paymentSessionRepository.Create(paymentSession); return(new IntegrationDto(paymentSession.UniqueReference, integration.Currency, integration.Schemes, integration.Methods, new CardPaymentIntegration(this.Url.Action("CardHost", "CardHost", new { identifyingToken = requestModel.IdentifyingToken }, Request.Scheme)))); }
public async Task <PaymentSessionViewModel> PreparePaymentSession(string clientUserName, PurchaseDto purchaseDto) { var client = _context.Users.Single(c => c.Username == clientUserName); var availableKeys = LoadAvailableKeys(clientUserName, purchaseDto); var paymentSession = new PaymentSession { Date = DateTime.Now, GameKeys = new List <GameKey>(), Client = client }; for (int i = 0; i < purchaseDto.GameCount; i++) { AttachKeyToSession(paymentSession, availableKeys[i]); } _context.PaymentSessions.Add(paymentSession); await _context.SaveChangesAsync(); return(_mapper.Map <PaymentSessionViewModel>(paymentSession)); }
public async Task <ActionResult <Guid> > CreateSession([FromBody] PaymentSessionInputInfo info) { if (info == null) { return(BadRequest()); } PaymentSession paymentSession = new PaymentSession { Cost = info.Sum, SessionId = Guid.NewGuid(), PaymentAppointment = info.PaymentAppointement, SessionRegistrationTime = DateTime.Now, LifeSpanInMinute = 60, }; context.PaymentSessions.Add(paymentSession); await context.SaveChangesAsync(); return(Ok(paymentSession.SessionId)); }
public void OnCreate(Bundle savedInstanceState, StripeConfig stripeConfig) { _stripeConfig = stripeConfig; PaymentConfiguration.Init(_stripeConfig.ApiKey); var stripeRemoteService = new StripeRemoteService(_stripeConfig, _restHttpClient, _logManager, _jsonSerializer); CustomerSession.InitCustomerSession(new StripeEphemeralKeyProvider(stripeRemoteService)); _paymentSession = new PaymentSession(CrossCurrentActivity.Current.Activity); var config = new PaymentSessionConfig.Builder() .SetShippingInfoRequired(false) .SetShippingMethodsRequired(false) .Build(); _paymentSession.Init(new PaymentSessionListener(), config, savedInstanceState); StripeManager.Initialize(stripeRemoteService, _stripeConfig); }
private void AttachKeyToSession(PaymentSession session, GameKey key) { session.GameKeys.Add(key); key.IsActivated = true; }