Example #1
0
        static void Main(string[] args)
        {
            var processor = PaymentProcessor.Create(args.Length > 0);
            var baker     = new Baker(processor);

            while (true)
            {
                baker.TakeOrder();
            }
        }
Example #2
0
        /// <summary>
        /// Online Payment from Server
        /// @ejb.interface-method view-type="both"
        /// Called from MPayment processOnline
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="C_Payment_ID"></param>
        /// <param name="C_PaymentProcessor_ID"></param>
        /// <param name="trxName"></param>
        /// <returns>true if approvedc</returns>
        public bool PaymentOnline(Ctx ctx, int C_Payment_ID, int C_PaymentProcessor_ID, Trx trxName)
        {
            MPayment          payment = new MPayment(ctx, C_Payment_ID, trxName);
            MPaymentProcessor mpp     = new MPaymentProcessor(ctx, C_PaymentProcessor_ID, null);

            log.Info("[" + _no + "] " + payment + " - " + mpp);
            _paymentCount++;
            bool approved = false;

            try
            {
                PaymentProcessor pp = PaymentProcessor.Create(mpp, payment);
                if (pp == null)
                {
                    payment.SetErrorMessage("No Payment Processor");
                }
                else
                {
                    approved = pp.ProcessCC();
                    if (approved)
                    {
                        payment.SetErrorMessage(null);
                    }
                    else
                    {
                        payment.SetErrorMessage("From " + payment.GetCreditCardName()
                                                + ": " + payment.GetR_RespMsg());
                    }
                }
            }
            catch (Exception e)
            {
                log.Log(Level.SEVERE, "", e);
                payment.SetErrorMessage("Payment Processor Error");
            }
            payment.Save();
            return(approved);
        }