public PaymentController(IPaymentGateway paymentGateway, ICheapPaymentGateway cheapPaymentGateway, IExpensivePaymentGateway expensivePaymentGateway, IPremiumPaymentService premiumPaymentService)
 {
     _IPaymentGateway          = paymentGateway;
     _ICheapPaymentGateway     = cheapPaymentGateway;
     _IExpensivePaymentGateway = expensivePaymentGateway;
     _IPremiumPaymentService   = premiumPaymentService;
 }
Exemplo n.º 2
0
        public virtual IPaymentGateway CreatePaymentGateway(PaymentMethod method, Product product)
        {
            IPaymentGateway gateway = null;

            switch (method)
            {
            case PaymentMethod.PayPal:
                gateway = new Bank_PayPal();
                break;

            case PaymentMethod.ING:
                gateway = new Bank_ING();
                break;
                //case PaymentMethod.BEST_FOR_ME:
                //	if (product.Price < 50)
                //	{
                //		gateway = new BankTwo();
                //	}
                //	else
                //	{
                //		gateway = new BankOne();
                //	}
                //	break;
            }

            return(gateway);
        }
Exemplo n.º 3
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='payment'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Payment> ProcessPaymentAsync(this IPaymentGateway operations, ProcessPaymentRequest payment = default(ProcessPaymentRequest), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ProcessPaymentWithHttpMessagesAsync(payment, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 4
0
        public async Task ProcessPayment(PaymentDto paymentDto)
        {
            try
            {
                var payment = new Payment
                {
                    Amount           = paymentDto.Amount,
                    CardHolder       = paymentDto.CardHolder,
                    CreditCardNumber = paymentDto.CreditCardNumber,
                    ExpirationDate   = paymentDto.ExpirationDate,
                    PaymentState     = new PaymentState
                    {
                        PaymentStatus = PaymentStatus.Pending,
                    },
                    SecurityCode = paymentDto.SecurityCode,
                };
                await _paymentRepository.InsertAsync(payment);

                await _unitOfWork.SaveChangesAsync();

                IPaymentGateway paymentGateway = PaymentServiceHelper.GetPaymentGateway(payment.Amount);
                var             isProcessed    = await paymentGateway.ProcessPaymentAsync(paymentDto);

                payment.PaymentState.PaymentStatus = isProcessed ? PaymentStatus.Processed : PaymentStatus.Failed;
                await _unitOfWork.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 5
0
 public RefillBalanceCommand(IUnitOfWork uow, ICustomerRepository customerRepository, IPaymentGateway paymentGateway, ILog log)
 {
     _uow = uow;
     _customerRepository = customerRepository;
     _paymentGateway     = paymentGateway;
     _log = log;
 }
Exemplo n.º 6
0
        public void PreparePayment(Invoice invoice)
        {
            PaymentGatewayFactory factory = new PaymentGatewayFactory();

            this.gateway = factory.CreatePaymentGateway(invoice);
            this.gateway.PaymentGranularity(invoice);
        }
Exemplo n.º 7
0
 public ChainOfResponsibilityShould()
 {
     _paymentGateway    = Mock.Of <IPaymentGateway>();
     _creditCardHandler = new VisaCardHandler(_paymentGateway);
     _creditCardHandler.SetNext(new AmexCardHandler(_paymentGateway))
     .SetNext(new MastercardHandler(_paymentGateway));
 }
 public PostedOrderHandler(ILogger <PostedOrderHandler> logger, IRepository <Payment> paymentRepository, IBusClient busClient, IPaymentGateway gateway)
 {
     _paymentRepository = paymentRepository;
     _logger            = logger;
     _gateway           = gateway;
     _busClient         = busClient;
 }
Exemplo n.º 9
0
 public PaymentRequestController(IPaymentRequestModel paymentManager, IPaymentGateway paymentGatewayManager, IMapper mapper, ILogger <PaymentRequestController> logger)
 {
     _mapper                = mapper;
     _logger                = logger;
     _paymentManager        = paymentManager;
     _paymentGatewayManager = paymentGatewayManager;
 }
 public void SetUp()
 {
     _mockRepository = new MockRepository();
     _accountRepository = _mockRepository.StrictMock<IAccountRepository>();
     _transactionsRepository = _mockRepository.StrictMock<ITransactionsRepository>();
     _paymentGateway = _mockRepository.StrictMock<IPaymentGateway>();
 }
Exemplo n.º 11
0
 public void SetUp()
 {
     _mockRepository         = new MockRepository();
     _accountRepository      = _mockRepository.StrictMock <IAccountRepository>();
     _transactionsRepository = _mockRepository.StrictMock <ITransactionsRepository>();
     _paymentGateway         = _mockRepository.StrictMock <IPaymentGateway>();
 }
Exemplo n.º 12
0
        public virtual IPaymentGateway CreatePaymentGateway(PaymentMethod method, Product product)
        {
            IPaymentGateway gateway = null;

            switch (method)
            {
            case PaymentMethod.BANK_ONE:
                gateway = new BankOne();
                break;

            case PaymentMethod.BANK_TWO:
                gateway = new BankTwo();
                break;

            case PaymentMethod.BEST_FOR_ME:
                if (product.Price < 50)
                {
                    gateway = new BankTwo();
                }
                else
                {
                    gateway = new BankOne();
                }
                break;
            }
            return(gateway);
        }
Exemplo n.º 13
0
        /// <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));
            }
        }
Exemplo n.º 14
0
        public void Transaction(CardType card)
        {
            UKPaymentGateway factory = new UKPaymentGateway();

            gateway = factory.CreatePaymentGateway(card);
            gateway.MakePayment();
        }
Exemplo n.º 15
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Payment> GetPaymentAsync(this IPaymentGateway operations, string id = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetPaymentWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 16
0
        // Dokonywanie wypłaty
        // Wywołanie metody CreatePaymentGateway(...) zwraca nam obiekt utworzony
        // w zależności od wyboru rodzaju wypłaty przez klienta
        public void MakePayment(EPaymentMethod method, Operacja product)
        {
            PaymentGatewayFactory factory = new PaymentGatewayFactory();

            this.gateway = factory.CreatePaymentGateway(method, product);
            this.gateway.MakePayment(product);
        }
Exemplo n.º 17
0
        public virtual IPaymentGateway CreatePaymentGateway(PaymentMethod paymentMethod, Product product)
        {
            IPaymentGateway gateway = null;

            switch (paymentMethod)
            {
            case PaymentMethod.BankOne:
                gateway = new BankOne();
                break;

            case PaymentMethod.BankTwo:
                gateway = new BankTwo();
                break;

            case PaymentMethod.BestForMe:
                if (product.Price < 50)
                {
                    gateway = new BankTwo();
                }
                else
                {
                    gateway = new BankOne();
                }
                break;

            default:
                break;
            }

            return(gateway);
        }
 public ProcessTransactionService()
 {
     var container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle")));
     _accountRepository = container.Resolve<IAccountRepository>();
     _transactionsRepository = container.Resolve<ITransactionsRepository>();
     _paymentGateway = container.Resolve<IPaymentGateway>();
 }
Exemplo n.º 19
0
        public PaymentGatewayTest()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseSqlServer("Data Source=(local)\\SQLEXPRESS;Initial Catalog=PaymentGateway;Integrated Security=True;").Options;

            _context = new ApplicationDbContext(options);
            _context.Database.EnsureDeleted();
            _context.Database.EnsureCreated();

            if (_mapper == null)
            {
                var mappingConfig = new MapperConfiguration(mc =>
                {
                    mc.AddProfile(new AutoMapperProfile());
                });
                IMapper mapper = mappingConfig.CreateMapper();
                _mapper = mapper;
            }

            _cheapPaymentGateway     = new CheapPaymentGateway();
            _expensivePaymentGateway = new ExpensivePaymentGateway(_cheapPaymentGateway);
            _premiumPaymentGateway   = new PremiumPaymentGateway();
            _paymentRepo             = new PaymentRepository(_context);
            _paymentStateRepo        = new PaymentStateRepository(_context);
            _paymentGateway          = new PaymentGateway(_cheapPaymentGateway, _expensivePaymentGateway, _premiumPaymentGateway, _paymentRepo, _paymentStateRepo, _mapper);
        }
Exemplo n.º 20
0
        public PaymentWorkerActor(IPaymentGateway payementGateway)
        {
            _paymentGateway = payementGateway;

            Receive <SendPaymentMessage>(message => SendPayment(message));
            Receive <PaymentReceipt>(message => HandlePaymentReceipt(message));
        }
Exemplo n.º 21
0
        public async Task <string> PrepareOrderForUnAuthenticatedCustomer([FromBody] OrderViewModel orderDetails)
        {
            DateTime startTime = DateTime.Now;

            if (!ModelState.IsValid)
            {
                List <string> errorList = (from item in ModelState.Values
                                           from error in item.Errors
                                           select error.ErrorMessage).ToList();
                string errorMessage = JsonConvert.SerializeObject(errorList);
                throw new PartnerDomainException(ErrorCode.InvalidInput).AddDetail("ErrorMessage", errorMessage);
            }

            // Validate & Normalize the order information.
            OrderNormalizer orderNormalizer = new OrderNormalizer(ApplicationDomain.Instance, orderDetails);

            orderDetails = await orderNormalizer.NormalizePurchaseSubscriptionOrderAsync().ConfigureAwait(false);

            // prepare the redirect url so that client can redirect to PayPal.
            string redirectUrl = string.Format(CultureInfo.InvariantCulture, "{0}/#ProcessOrder?ret=true&customerId={1}", Request.RequestUri.GetLeftPart(UriPartial.Authority), orderDetails.CustomerId);

            // execute to paypal and get paypal action URI.
            IPaymentGateway paymentGateway = PaymentGatewayConfig.GetPaymentGatewayInstance(ApplicationDomain.Instance, Resources.NewPurchaseOperationCaption);
            string          generatedUri   = await paymentGateway.GeneratePaymentUriAsync(redirectUrl, orderDetails).ConfigureAwait(false);

            // Track the event measurements for analysis.
            Dictionary <string, double> eventMetrics = new Dictionary <string, double> {
                { "ElapsedMilliseconds", DateTime.Now.Subtract(startTime).TotalMilliseconds }
            };

            ApplicationDomain.Instance.TelemetryService.Provider.TrackEvent("api/order/NewCustomerPrepareOrder", null, eventMetrics);

            return(generatedUri);
        }
Exemplo n.º 22
0
        public void MakePayment(PaymentMethod method, Product product)
        {
            PaymentGatewayFactory2 factory2 = new PaymentGatewayFactory2();

            this.gateway = factory2.CreatePaymentGateway(method, product);

            this.gateway.MakePayment(product);
        }
Exemplo n.º 23
0
 public ShoppingService(int customerId, IStockRepository stockRepository, IDiscountService discountService, IPaymentGateway paymentGateWay, ILogger logger)
 {
     this.customerId  = customerId;
     _stockRepository = stockRepository;
     _discountService = discountService;
     _logger          = logger;
     _paymentGateWay  = paymentGateWay;
 }
Exemplo n.º 24
0
 public PaymentService(IPaymentRepository paymentRepository, IPaymentStateRepository paymentStateRepository, IUnitOfWork UWO, IMapper mapper, IPaymentGateway paymentGateway)
 {
     _paymentRepository      = paymentRepository;
     _paymentStateRepository = paymentStateRepository;
     _UOW            = UWO;
     _mapper         = mapper;
     _paymentGateway = paymentGateway;
 }
        public ProcessTransactionService()
        {
            var container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle")));

            _accountRepository      = container.Resolve <IAccountRepository>();
            _transactionsRepository = container.Resolve <ITransactionsRepository>();
            _paymentGateway         = container.Resolve <IPaymentGateway>();
        }
Exemplo n.º 26
0
        public OrderService(IPersister persister, IWebContext webContext,
			IPaymentGateway paymentGateway, IOrderMailService orderMailService)
        {
            _persister = persister;
            _webContext = webContext;
            _paymentGateway = paymentGateway;
            _orderMailService = orderMailService;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CapturePayment"/> class.
        /// </summary>
        /// <param name="paymentGateway">The payment gateway to use for capturing payments.</param>
        /// <param name="authorizationCode">The authorization code to capture.</param>
        public CapturePayment(IPaymentGateway paymentGateway, string authorizationCode)
        {
            paymentGateway.AssertNotNull(nameof(paymentGateway));
            authorizationCode.AssertNotEmpty(nameof(paymentGateway));

            this.PaymentGateway    = paymentGateway;
            this.AuthorizationCode = authorizationCode;
        }
Exemplo n.º 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommerceOperations"/> class.
        /// </summary>
        /// <param name="applicationDomain">An application domain instance.</param>
        /// <param name="customerId">The customer ID who owns the transaction.</param>
        /// <param name="paymentGateway">A payment gateway to use for processing payments resulting from the transaction.</param>
        public CommerceOperations(ApplicationDomain applicationDomain, string customerId, IPaymentGateway paymentGateway) : base(applicationDomain)
        {
            customerId.AssertNotEmpty(nameof(customerId));
            paymentGateway.AssertNotNull(nameof(paymentGateway));

            CustomerId     = customerId;
            PaymentGateway = paymentGateway;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CapturePayment"/> class.
        /// </summary>
        /// <param name="paymentGateway">The payment gateway to use for capturing payments.</param>
        /// <param name="acquireAuthorizationCallFunction">The function to call to obtain the authorization code.</param>
        public CapturePayment(IPaymentGateway paymentGateway, Func <string> acquireAuthorizationCallFunction)
        {
            paymentGateway.AssertNotNull(nameof(paymentGateway));
            acquireAuthorizationCallFunction.AssertNotNull(nameof(acquireAuthorizationCallFunction));

            this.PaymentGateway = paymentGateway;
            this.AcquireInput   = acquireAuthorizationCallFunction;
        }
Exemplo n.º 30
0
        public void VykonejPlatbu(PaymentMethod method, Product product)
        {
            FactoryTwo2 factory = new FactoryTwo2();

            this.gateway = factory.CreatePaymentGateway(method, product);

            this.gateway.MakePayment(product);
        }
        public PaymentWorkerActor(IPaymentGateway paymentGateway)
        {
            _paymentGateway = paymentGateway;

            Receive<SendPaymentMessage>(message => HandleSendPayment(message));
            Receive<PaymentReceipt>(message => HandlePaymentReceipt(message));
            Receive<ProcessStashedPaymentsMessage>(message => HandleUnstash());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AuthorizePayment"/> class.
        /// </summary>
        /// <param name="paymentGateway">The payment gateway to use for authorization.</param>
        /// <param name="amountToCharge">The amount to charge.</param>
        public AuthorizePayment(IPaymentGateway paymentGateway, decimal amountToCharge)
        {
            paymentGateway.AssertNotNull(nameof(paymentGateway));
            amountToCharge.AssertPositive(nameof(amountToCharge));

            this.Amount         = amountToCharge;
            this.PaymentGateway = paymentGateway;
        }
Exemplo n.º 33
0
 public AtmForm()
 {
     InitializeComponent();
     _atmRepository  = new AtmRepository();
     _paymentGateway = new PaymentGateway();
     _atm            = _atmRepository.GetById(1);
     NotifyClient(string.Empty);
 }
Exemplo n.º 34
0
 // dependency injection of repository.
 public BookingService(BookingRepositoryMongoDB repository,
                       IPaymentGateway paymentGateway,
                       IPriceCalculator priceCalculator)
 {
     this.repository      = repository;
     this.paymentGateway  = paymentGateway;
     this.priceCalculator = priceCalculator;
 }
Exemplo n.º 35
0
        public CreditCardService(IPaymentGateway paymentGateway, ICommandDispatcher commandDispatcher, IMessageService messageService, IHttpWebUtility httpWebUtility, ISerializer serializer, ILogger logger)
        {
            this._paymentGateway = paymentGateway;
            this._commandDispatcher = commandDispatcher;
            this._messageService = messageService;
            this._httpWebUtility = httpWebUtility;
            this._serializer = serializer;
            this._logger = logger;

            this._ewayUrl = ConfigurationManager.AppSettings["Eway_Url"];
            this._authorisation = ConfigurationManager.AppSettings["Eway_Auth"];
            this._websiteUrl = ConfigurationManager.AppSettings["Website_Url"];
        }
Exemplo n.º 36
0
        public PayPalService(IPaymentGateway paymentGateway, ICommandDispatcher commandDispatcher, IMessageService messageService, IQueryDispatcher queryDispatcher, ILogger logger)
        {
            this._payPalUrl = ConfigurationManager.AppSettings["PayPal_Url"];
            this._payPalClientId = ConfigurationManager.AppSettings["PayPal_ClientId"];
            this._payPalSecret = ConfigurationManager.AppSettings["PayPal_Secret"];
            this._websiteUrl = ConfigurationManager.AppSettings["Website_Url"];

            if (ConfigurationManager.AppSettings["PayPal_IsSandbox"] != null)
            {
                this._isSandbox = bool.Parse(ConfigurationManager.AppSettings["PayPal_IsSandbox"]);
            }

            this._paymentGateway = paymentGateway;
            this._commandDispatcher = commandDispatcher;
            this._messageService = messageService;
            this._queryDispatcher = queryDispatcher;
            this._logger = logger;
        }
Exemplo n.º 37
0
        public CommerceConfiguration(SiteSettings siteSettings)
        {
            configPrefix = "Site"
                + siteSettings.SiteId.ToInvariantString()
                + "-";

            LoadConfigSettings();

            PaymentGatewayProvider gatewayProvider =  PaymentGatewayManager.Providers[PrimaryPaymentGateway];
            if (gatewayProvider != null)
            {
                paymentGateway = gatewayProvider.GetPaymentGateway();
            }
        }
 public ProcessTransactionService(IAccountRepository accountRepository, ITransactionsRepository transactionsRepository, IPaymentGateway paymentGateway)
 {
     _accountRepository = accountRepository;
     _transactionsRepository = transactionsRepository;
     _paymentGateway = paymentGateway;
 }
Exemplo n.º 39
0
        private void ProcessPaymentThroughPaymentGateway(IPaymentGateway gateway)
        {
            // Update billing details
            if (User.BillingDetails == null)
                User.BillingDetails = new BillingDetails();
            User.BillingDetails.FirstName = txtFirstName.Text.Trim();
            User.BillingDetails.LastName = txtLastName.Text.Trim();
            User.BillingDetails.Address = txtAddress.Text.Trim();
            User.BillingDetails.City = txtCity.Text.Trim();
            User.BillingDetails.State = txtState.Text.Trim();
            User.BillingDetails.Zip = txtZip.Text.Trim();
            User.BillingDetails.Country = txtCountry.Text.Trim();
            User.BillingDetails.Phone = txtPhone.Text.Trim();
            if (txtCardNumber.Text.IndexOf("XXXX") < 0)
                User.BillingDetails.CardNumber = txtCardNumber.Text.Trim();
            try
            {
                User.BillingDetails.CardExpirationMonth = Convert.ToInt32(ddMonth.SelectedItem.Text);
                User.BillingDetails.CardExpirationYear = Convert.ToInt32(ddYear.SelectedItem.Text);
            }
            catch (FormatException)
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "errorAlert",
                                                            String.Format("<script>var alert_string = {0}';</script>",
                                                                          "Invalid expiration date!"));
                return;
            }

            User.Update();

            if (radioCredits.Checked)
            {
                int planID = Convert.ToInt32(rlCreditPackages.SelectedItem.Value);
                CreditsPackage package = CreditsPackage.Fetch(planID);
                if (package == null)
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "errorAlert",
                                                                String.Format("<script>var alert_string = '{0}';</script>",
                                                                              "Selected credits package is not in the database"));
                    return;
                }

                TransactionDetails transactionDetails = TransactionDetails.FromBillingDetails(
                    User.BillingDetails);
                transactionDetails.Amount = Convert.ToDecimal(package.Price);
                eGatewayResponse gatewayResponse = gateway.SubmitTransaction(User.Username, transactionDetails,
                                                                             "Purchased credits (" +
                                                                             package.Price.ToString("c") + ", " +
                                                                             DateTime.Now.ToShortDateString() + ")");
                switch (gatewayResponse)
                {
                    case eGatewayResponse.Approved:
                        User.Credits += package.Quantity;
                        User.Update(true);
                        Response.Redirect("ThankYou.aspx");
                        return;
                    case eGatewayResponse.Declined:
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "errorAlert",
                                                                    String.Format("<script>var alert_string = '{0}';</script>",
                                                                                  Lang.Trans(
                                                                                      "Your credit card has been declined!")));
                        return;
                    case eGatewayResponse.Error:
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "errorAlert",
                                                                    String.Format("<script>var alert_string = '{0}';</script>",
                                                                                  Lang.Trans(
                                                                                      "There has been an error while processing your transaction!")));
                        return;
                }
            }
            else
            {
                int planID = Convert.ToInt32(rlPlans.SelectedItem.Value);

                //if cancellation selected
                if (planID == Int32.MaxValue && activeSubscription != null)
                {
                    Subscription.RequestCancellation(activeSubscription.ID);
                    return;
                }

                if (ActiveSubscription != null)
                {
                    ActiveSubscription.PlanID = planID;
                    ActiveSubscription.PaymentProcessor = radiolistPaymentMethods.SelectedValue;
                    ActiveSubscription.Update();

                    ((PageBase)Page).CurrentUserSession.BillingPlanOptions = null;
                    ((PageBase)Page).StatusPageMessage = Lang.Trans("Your subscription has been changed successfully!");
                    Response.Redirect("ShowStatus.aspx");
                }

                //gets selected plan data
                BillingPlan plan = BillingPlan.Fetch(planID);
                if (plan == null)
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "errorAlert",
                                                                String.Format("<script>var alert_string = '{0}';</script>",
                                                                              "Selected billing plan is not in the database"));
                    return;
                }

                int subscriptionID = Subscription.Create(User.Username, plan.ID, gateway.Name);
                Subscription newSubscription = Subscription.Fetch(subscriptionID);


                TransactionDetails transactionDetails = TransactionDetails.FromBillingDetails(
                    User.BillingDetails);
                transactionDetails.Amount = Convert.ToDecimal(plan.Amount);
                eGatewayResponse gatewayResponse = gateway.SubmitTransaction(User.Username, transactionDetails,
                                                                             "First subscription fee (" +
                                                                             plan.Amount.ToString("c") + ", " +
                                                                             DateTime.Now.ToShortDateString() + ")");
                switch (gatewayResponse)
                {
                    case eGatewayResponse.Approved:
                        newSubscription.Activate(DateTime.Now, plan);
                        var billingPlanOptions = ((PageBase)Page).CurrentUserSession.BillingPlanOptions;
                        if (billingPlanOptions.MaxEcardsPerDay.AllowCredits)
                        {
                            ((PageBase)Page).CurrentUserSession.Credits += billingPlanOptions.MaxEcardsPerDay.Credits;
                            ((PageBase)Page).CurrentUserSession.Update();
                        }
                        Response.Redirect("ThankYou.aspx");
                        return;
                    case eGatewayResponse.Declined:
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "errorAlert",
                                                                    String.Format("<script>var alert_string = '{0}';</script>",
                                                                                  Lang.Trans(
                                                                                      "Your credit card has been declined!")));
                        return;
                    case eGatewayResponse.Error:
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "errorAlert",
                                                                    String.Format("<script>var alert_string = '{0}';</script>",
                                                                                  Lang.Trans(
                                                                                      "There has been an error while processing your transaction!")));
                        return;
                }
            }
        }
Exemplo n.º 40
0
 public static Order CreateOrder(
     Store store,
     Cart cart, 
     IPaymentGateway gateway, 
     string currencyCode, 
     string paymentMethod)
 {
     return CreateOrder(
         store,
         cart,
         gateway.RawResponse,
         gateway.TransactionId,
         gateway.ApprovalCode,
         currencyCode,
         paymentMethod,
         OrderStatus.OrderStatusFulfillableGuid);
 }
        public PaymentWorkerActor(IPaymentGateway paymentGateway)
        {
            _paymentGateway = paymentGateway;

            Receive<SendPaymentMessage>(message => SendPayment(message));
        }