示例#1
0
    public int GetPercentage(PaymentProcessor processor)
    {
        var allProportions = GetAllProportions();

        var proportion = GetProportion(allProportions, processor);

        if (proportion == null)
        {
            return(0);
        }

        //We have records
        decimal totalIn    = proportion.TotalIn.ToDecimal();
        decimal totalInSum = allProportions.Sum(elem => elem.TotalIn.ToDecimal());

        if (totalInSum == 0)
        {
            return(100);
        }

        int percent = Convert.ToInt32((totalIn / totalInSum) * 100);

        return(percent);
    }
示例#2
0
    /// <summary>
    /// FROM AP
    /// </summary>
    /// <param name="request"></param>
    public static void RejectRequest(PayoutRequest request)
    {
        Member User = new Member(request.Username);

        try
        {
            PaymentProcessor processor = PaymentAccountDetails.GetFromStringType(request.PaymentProcessor);
            PaymentProportionsManager.UndoMemberPaidOut(request.Amount, processor, User);
        }
        catch
        {
            //processor = custom processor
        }

        request.IsPaid           = true;
        request.PaymentProcessor = "REJECTED";
        request.Save();

        User.MoneyCashout -= request.Amount;
        User.AddToMainBalance(request.Amount, "Payout rejected");
        User.Save();

        History.AddCashoutRejection(User.Name, request.Amount.ToString());
    }
 protected EquipmentCommand(IEquipmentAccessor equipmentAccessor,
                            IInventoryAccessor inventoryAccessor,
                            IMateriaAccessor materiaAccessor,
                            IStatusHubEmitter statusHubEmitter,
                            PartyStatusViewModel partyStatusViewModel,
                            GameDatabase gameDatabase,
                            GilBank gilBank,
                            ITwitchClient twitchClient,
                            EquipmentData <T> equipmentData,
                            Func <CommandSettings, string[]> commandWordsSelector,
                            PaymentProcessor paymentProcessor)
     : base(commandWordsSelector, x => x.EquipmentSettings.Enabled)
 {
     _equipmentAccessor    = equipmentAccessor;
     _inventoryAccessor    = inventoryAccessor;
     _materiaAccessor      = materiaAccessor;
     _statusHubEmitter     = statusHubEmitter;
     _partyStatusViewModel = partyStatusViewModel;
     _gameDatabase         = gameDatabase;
     _gilBank          = gilBank;
     _twitchClient     = twitchClient;
     _equipmentData    = equipmentData;
     _paymentProcessor = paymentProcessor;
 }
        public void Arrange()
        {
            _paymentsClient = new Mock <IPaymentsEventsApiClient>();
            _mediator       = new Mock <IMediator>();
            _mediator.Setup(x => x.SendAsync(It.IsAny <GetCurrentPeriodEndRequest>())).ReturnsAsync(new GetPeriodEndResponse {
                CurrentPeriodEnd = new Domain.Models.Payments.PeriodEnd {
                    Id = "123456"
                }
            });
            _mediator.Setup(x => x.SendAsync(It.IsAny <GetAllEmployerAccountsRequest>())).ReturnsAsync(new GetAllEmployerAccountsResponse {
                Accounts = new List <Account> {
                    new Account {
                        Id = ExpectedAccountId
                    }
                }
            });

            _logger = new Mock <ILogger>();

            _configuration = new PaymentsApiClientConfiguration();

            _messagePublisher = new Mock <IMessagePublisher>();
            _paymentProcessor = new PaymentProcessor(_paymentsClient.Object, _mediator.Object, _messagePublisher.Object, _logger.Object, _configuration);
        }
示例#5
0
        static void Main(string[] args)
        {
            PaymentProcessor paymentProcessor = new PaymentProcessor();

            for (int i = 0; i <= 10; i++)
            {
                TransactionModel result = null;

                try
                {
                    result = paymentProcessor.MakePayment($"Demo{ i }", i);

                    if (result != null)
                    {
                        Console.WriteLine(result.TransactionAmount);
                    }
                    else
                    {
                        Console.WriteLine($"Null value for item { i }");
                    }
                }
                catch (IndexOutOfRangeException ex)
                {
                    Console.WriteLine($"Skipped invalid record { ex.InnerException?.Message }");
                }
                catch (FormatException ex) when(i != 5)
                {
                    Console.WriteLine($"Formatting issue { ex.InnerException?.Message }");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Payment skipped for payment with { i } items { ex.InnerException?.Message }");
                }
            }
            Console.ReadLine();
        }
示例#6
0
        public PaymentResultDisplay AuthorizePayment(PaymentRequest request)
        {
            var processor = new PaymentProcessor(MerchelloContext, request);
            var authorize = processor.Authorize();

            var result = new PaymentResultDisplay()
            {
                Success = authorize.Payment.Success,
                Invoice = authorize.Invoice.ToInvoiceDisplay(),
                Payment = authorize.Payment.Result.ToPaymentDisplay(),
                ApproveOrderCreation = authorize.ApproveOrderCreation
            };

            if (!authorize.Payment.Success)
            {
                authorize.Payment.Result.AuditPaymentDeclined();
            }
            else
            {
                authorize.Payment.Result.AuditPaymentAuthorize(authorize.Invoice);
            }

            return(result);
        }
 public AbaFileReport(BankRun bankRun, PaymentProcessor paymentProcessor, PaymentMethod paymentMethod, PaymentContext dataContext, ILogger logger) : base(bankRun, paymentProcessor, paymentMethod, dataContext, logger)
 {
     Debits        = new List <PaymentSchedule>();
     Credits       = new List <PaymentSchedule>();
     fileExtension = "aba";
 }
示例#8
0
        static void SimulatePayment(PaymentModel paymentModel, int hours)
        {
            decimal amoutToPay = PaymentProcessor.CalculatePayment(paymentModel, hours);

            Console.WriteLine($"You will get paid ${amoutToPay} for your work: ");
        }
示例#9
0
 public CoinbaseHandler(HttpContext context, PaymentProcessor processor)
     : base(context, processor)
 {
 }
示例#10
0
 public MakoCommand(PaymentProcessor paymentProcessor)
     : base(x => x.MakoCommandWords, x => x.MenuSettings.EnableMakoCommand)
 {
     _paymentProcessor = paymentProcessor;
 }
 public abstract object GetMerchantsForExport(IList <Merchant> merchants, PaymentProcessor paymentProcessor, string providerId = null);
示例#12
0
 public SolidTrustPayHandler(HttpContext context, PaymentProcessor processor)
     : base(context, processor)
 {
 }
示例#13
0
        public PaymentResultDisplay AuthorizePayment(PaymentRequestDisplay request)
        {
            var processor = new PaymentProcessor(MerchelloContext, request);
            var authorize = processor.Authorize();

            var result = new PaymentResultDisplay()
            {
                Success = authorize.Payment.Success,
                Invoice = authorize.Invoice.ToInvoiceDisplay(),
                Payment = authorize.Payment.Result.ToPaymentDisplay(),
                ApproveOrderCreation = authorize.ApproveOrderCreation
            };

            if (!authorize.Payment.Success)
            {
                authorize.Payment.Result.AuditPaymentDeclined();
            }
            else
            {
                authorize.Payment.Result.AuditPaymentAuthorize(authorize.Invoice);
            }

            return result;
        }
 public UnlockCommand(PaymentProcessor paymentProcessor)
     : base(new[] { "BrendanUnlock" }, x => true)
 {
     _paymentProcessor = paymentProcessor;
 }
示例#15
0
 public PayeerHandler(HttpContext context, PaymentProcessor processor)
     : base(context, processor)
 {
 }
示例#16
0
 public MenuCommand(ColorPaletteCollection paletteCollection, PaymentProcessor paymentProcessor)
     : base(x => x.MenuCommandWords, x => x.MenuSettings.Enabled)
 {
     _paletteCollection = paletteCollection;
     _paymentProcessor  = paymentProcessor;
 }
示例#17
0
 public void Setup()
 {
     _mockDao   = new Mock <IPaymentDao>();
     _processor = new PaymentProcessor(
         _mockDao.Object);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="processor">The payment processor used for the
 /// transaction.</param>
 /// <param name="wasAuthorized">The authorization outcome from the
 /// payment processor. If the transaction has not yet been approved
 /// or denied, do not include this field.</param>
 /// <param name="declineCode">The decline code as provided by your
 /// payment processor. If the transaction was not declined, do not
 /// include this field.</param>
 public Payment(
     PaymentProcessor? processor = null,
     bool? wasAuthorized = null,
     string declineCode = null
     )
 {
     Processor = processor;
     WasAuthorized = wasAuthorized;
     DeclineCode = declineCode;
 }
示例#19
0
 public AdvCashHandler(HttpContext context, PaymentProcessor processor)
     : base(context, processor)
 {
 }
示例#20
0
        public PaymentResultDisplay CapturePayment(PaymentRequestDisplay request)
        {
            var processor = new PaymentProcessor(MerchelloContext, request);

            var capture = processor.Capture();

            var result = new PaymentResultDisplay()
            {
                Success = capture.Payment.Success,
                Invoice = capture.Invoice.ToInvoiceDisplay(),
                Payment = capture.Payment.Result.ToPaymentDisplay(),
                ApproveOrderCreation = capture.ApproveOrderCreation
            };

            if (!capture.Payment.Success)
            {
                capture.Payment.Result.AuditPaymentDeclined();
            }
            else
            {
                capture.Payment.Result.AuditPaymentCaptured(request.Amount);
            }

            return result;
        }
示例#21
0
        /// <summary>
        /// Returns a payment result for an refund operation
        /// 
        /// GET /umbraco/Merchello/PaymentApi/RefundPayment/
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="PaymentDisplay"/>.
        /// </returns>
        public PaymentResultDisplay RefundPayment(PaymentRequestDisplay request)
        {
            var processor = new PaymentProcessor(MerchelloContext, request);

            var refund = processor.Refund();

            var result = new PaymentResultDisplay()
            {
                Success = refund.Payment.Success,
                Invoice = refund.Invoice.ToInvoiceDisplay(),
                Payment = refund.Payment.Result.ToPaymentDisplay(),
                ApproveOrderCreation = refund.ApproveOrderCreation
            };

            if (refund.Payment.Success)
            {
               refund.Payment.Result.AuditPaymentRefunded(request.Amount);
            }

            return result;
        }
示例#22
0
 public LocalBitcoinsHandler(HttpContext context, PaymentProcessor processor)
     : base(context, processor)
 {
 }
示例#23
0
        public PaymentResultDisplay VoidPayment(PaymentRequestDisplay request)
        {
            var processor = new PaymentProcessor(MerchelloContext, request);

            var voided = processor.Void();

            var result = new PaymentResultDisplay()
            {
                Success = voided.Payment.Success,
                Invoice = voided.Invoice.ToInvoiceDisplay(),
                Payment = voided.Payment.Result.ToPaymentDisplay(),
                ApproveOrderCreation = voided.ApproveOrderCreation
            };

            if (voided.Payment.Success)
            {
                voided.Payment.Result.AuditPaymentVoided();
            }

            return result;
        }
示例#24
0
 public static void Add(int userId, Money nowIn, Money nowOut, PaymentProcessor processor)
 {
 }
        public void ProcessOrder(OrderData orderData)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    Customer customer = _StoreRepository.GetCustomerByEmail(orderData.CustomerEmail);
                    if (customer == null)
                    {
                        throw new ApplicationException(string.Format("No customer on file with email {0}.", orderData.CustomerEmail));
                    }

                    // Decrease product inventories
                    foreach (OrderLineItemData lineItem in orderData.LineItems)
                    {
                        Product product = _StoreRepository.Products.Where(item => item.Sku == lineItem.Sku).FirstOrDefault();
                        if (product == null)
                        {
                            throw new ApplicationException(string.Format("Sku {0} not found in store inventory.", lineItem.Sku));
                        }

                        Inventory inventoryOnHand = _StoreRepository.ProductInventory.Where(item => item.Sku == lineItem.Sku).FirstOrDefault();
                        if (inventoryOnHand == null)
                        {
                            throw new ApplicationException(string.Format("Error attempting to determine on-hand inventory quantity for product {0}.", lineItem.Sku));
                        }

                        if (inventoryOnHand.QuantityInStock < lineItem.Quantity)
                        {
                            throw new ApplicationException(string.Format("Not enough quantity on-hand to satisfy product {0} purchase of {1} units.", lineItem.Sku, lineItem.Quantity));
                        }

                        inventoryOnHand.QuantityInStock -= lineItem.Quantity;
                        Console.WriteLine("Inventory for product {0} reduced by {1} units.", lineItem.Sku, lineItem.Quantity);
                    }

                    // Update customer records with purchase
                    foreach (OrderLineItemData lineItem in orderData.LineItems)
                    {
                        for (int i = 0; i < lineItem.Quantity; i++)
                        {
                            customer.Purchases.Add(new PurchasedItem()
                            {
                                Sku = lineItem.Sku, PurchasePrice = lineItem.PurchasePrice, PurchasedOn = DateTime.Now
                            });
                        }
                        Console.WriteLine("Added {0} unit(s) or product {1} to customer's purchase history.", lineItem.Quantity, lineItem.Sku);
                    }

                    // Process customer credit card
                    double amount = 0;
                    foreach (OrderLineItemData lineItem in orderData.LineItems)
                    {
                        amount += (lineItem.PurchasePrice * lineItem.Quantity);
                    }
                    PaymentProcessor paymentProcessor = new PaymentProcessor();
                    bool             paymentSuccess   = paymentProcessor.ProcessCreditCard(customer.Name, orderData.CreditCard, orderData.ExpirationDate, amount);
                    if (!paymentSuccess)
                    {
                        throw new ApplicationException(string.Format("Credit card {0} could not be processed.", orderData.CreditCard));
                    }

                    scope.Complete();
                }

                // Send invoice email
                Mailer mailer = new Mailer();
                mailer.SendInvoiceEmail(orderData);
            }
            catch (Exception)
            {
                Mailer mailer = new Mailer();
                mailer.SendRejectionEmail(orderData);
                throw;
            }
        }
 public StatusEffectCommand(ITwitchClient twitchClient, PartyStatusViewModel partyStatus,
                            IStatusAccessor statusAccessor, PaymentProcessor paymentProcessor,
                            IStatusHubEmitter statusHubEmitter)
     : base(twitchClient, partyStatus, statusAccessor, paymentProcessor, statusHubEmitter, AllWords)
 {
 }
示例#27
0
    private PaymentProportions GetProportion(List <PaymentProportions> allProportions, PaymentProcessor processor)
    {
        var proportion = from a in allProportions where a.Processor == processor select a;

        return(proportion.FirstOrDefault());
    }
示例#28
0
 public RainbowCommand(PaymentProcessor paymentProcessor)
     : base(x => x.RainbowCommandWords, x => x.MenuSettings.EnableRainbowCommand)
 {
     _paymentProcessor = paymentProcessor;
 }
示例#29
0
        public static void TransferToBalance(string username, Money money, string from, string transId, string targetBalance,
                                             bool isViaRepresentative = false, string cryptoCurrencyInfo = "")
        {
            Exceptions.HandleNonMsgEx(() =>
            {
                //Add income to stats
                if (!isViaRepresentative)
                {
                    Statistics.Statistics.AddToCashflow(money);
                }

                bool successful = (money >= AppSettings.Payments.MinimumTransferAmount);

                PaymentProcessor paymentProcessor = PaymentAccountDetails.GetFromStringType(from);
                Money moneyWithoutFee             = money;

                if (!isViaRepresentative &&
                    (targetBalance == "Purchase Balance" || targetBalance == "Cash Balance" || targetBalance == "Marketplace Balance"))
                {
                    moneyWithoutFee = PaymentAccountDetails.GetAmountWithoutFee(from, money);
                }

                if (successful)
                {
                    Member user = new Member(username);
                    if (targetBalance == "Purchase Balance")
                    {
                        user.AddToPurchaseBalance(moneyWithoutFee, from + " transfer");
                    }
                    else if (targetBalance == "Cash Balance")
                    {
                        user.AddToCashBalance(moneyWithoutFee, from + " transfer");
                    }
                    else if (targetBalance == "Traffic Balance")
                    {
                        user.AddToTrafficBalance(money, from + " transfer");
                    }
                    else if (targetBalance == "Marketplace Balance")
                    {
                        user.AddToMarketplaceBalance(moneyWithoutFee, from + " transfer");
                    }
                    else if (targetBalance == "Points Balance")
                    {
                        user.AddToPointsBalance(moneyWithoutFee.ConvertToPoints(), from + " transfer");
                    }
                    user.SaveBalances();

                    if (targetBalance == "Purchase Balance" || targetBalance == "Cash Balance" || targetBalance == "Marketplace Balance")
                    {
                        //Update payment proportions
                        PaymentProportionsManager.MemberPaidIn(moneyWithoutFee, paymentProcessor, user);
                    }

                    //Add history
                    History.AddTransfer(username, moneyWithoutFee, from, targetBalance);

                    //TryAchievement
                    bool shouldBeSaved = user.TryToAddAchievements(
                        Achievements.Achievement.GetProperAchievements(
                            Achievements.AchievementType.AfterTransferringOnceAmount, moneyWithoutFee.GetTotals()));

                    if (shouldBeSaved)
                    {
                        user.Save();
                    }

                    //Check the contests
                    Contests.ContestManager.IMadeAnAction(Contests.ContestType.Transfer, user.Name, moneyWithoutFee, 0);
                    PurchasedItem.Create(user.Id, moneyWithoutFee, 1, "Transfer to " + targetBalance, PurchasedItemType.Transfer);

                    //Referral commission for sponsors when user does Cash Balance deposit
                    Titan.CashBalanceCrediter Crediter = (Titan.CashBalanceCrediter)Titan.CrediterFactory.Acquire(user, Titan.CreditType.CashBalanceDeposit);
                    Crediter.TryCreditReferer(moneyWithoutFee);
                }

                //AddLog
                if (!isViaRepresentative)
                {
                    CompletedPaymentLog.Create(paymentProcessor, "Transfer to " + targetBalance, transId, false, username, moneyWithoutFee,
                                               money - moneyWithoutFee, successful, cryptoCurrencyInfo);
                }
            });
        }
示例#30
0
 /// <summary>
 /// Returns proportions for particular processor
 /// </summary>
 /// <param name="processor"></param>
 /// <returns>Proportions for particular user</returns>
 private List <PaymentProportions> GetProportions(PaymentProcessor processor)
 {
     var where = TableHelper.MakeDictionary("Processor", (int)processor);
     where.Add("UserId", user.Id);
     return(TableHelper.SelectRows <PaymentProportions>(where));
 }
示例#31
0
 public MainWindowVm(PaymentProcessor paymentProcessor)
 {
     _paymentProcessor = paymentProcessor;
 }
示例#32
0
        public void ThrowException_CardNameIsEmptyOrNull()
        {
            var paymentProcessor = new PaymentProcessor();

            Assert.ThrowsAny <Exception>(() => paymentProcessor.ChargeCreditCard(""));
        }
示例#33
0
        public static string ProcessForm(HttpContext context)
        {
            File.WriteAllText(Constants.logDir + DateTime.UtcNow.Millisecond.ToString() + ".txt"
                              , "req recieved");
            StringBuilder bogusreason = new StringBuilder();

            if (context.Request.RequestType == "POST")
            {
                //verify receiver
                if (string.Compare(context.Request.Params["receiver_email"], receiverEmail, true) != 0)
                {
                    bogusreason.Append("invalid receiver");
                }



                string deviceId = context.Request.Params["option_selection1"];

                string appId = context.Request.Params["option_selection2"];

                string transactionId = context.Request.Params["txn_id"];

                if (string.IsNullOrEmpty(transactionId))
                {
                    bogusreason.Append("invalid trans id");
                }

                //verify payment status
                string paymentStatus = context.Request.Params["payment_status"];
                if (string.Compare(paymentStatus, Constants.successPaymentSatus, true) != 0)
                {
                    bogusreason.Append("payment status not complete");
                }
                else
                {//check it is not repeated transaction id
                    //verify txn_id is not repeated
                    bool isRepeated = PaymentProcessor.IsCompletedTransId(transactionId);
                    if (isRepeated)
                    {
                        bogusreason.Append("repeated transaction Id");
                    }
                }

                string firstName = context.Request.Params["first_name"];

                string lastName = context.Request.Params["last_name"];



                //verify trans type
                if (String.Compare(context.Request.Params["txn_type"],
                                   "web_accept", false) != 0)
                {
                    bogusreason.Append("invalid tran type");
                }

                string payAmountStr = context.Request.Params["mc_gross"];

                double payAmount;

                if (!double.TryParse(payAmountStr, out payAmount) || payAmount < minAmount)
                {
                    bogusreason.Append("payment not enough");
                }

                if (string.Compare(context.Request.Params["mc_currency"], currencyCode, true) != 0)
                {
                    bogusreason.Append("invalid currency");
                }

                string payerEMail = context.Request.Params["payer_email"];


                if (bogusreason.Length == 0)
                {
                    PaymentProcessor.AddTransactionInfo(new Payment(appId, transactionId, deviceId, paymentStatus, payAmount.ToString(), payerEMail, null, firstName, lastName));
                }
                else
                {
                    File.WriteAllText(Constants.logDir + DateTime.UtcNow.Ticks.ToString(),
                                      bogusreason.ToString());
                }

                return(null);
            }

            return(null);
        }
示例#34
0
 public PaymentHandler(HttpContext context, PaymentProcessor processor)
 {
     this.context   = context;
     this.processor = processor;
 }
示例#35
0
 public RevolutHandler(HttpContext context, PaymentProcessor processor) : base(context, processor)
 {
 }