Esempio n. 1
0
        /// <summary>
        /// 根据支付接口的安装ID获得支付插件
        /// </summary>
        /// <param name="paymentInfoId"></param>
        /// <returns></returns>
        public IPayment GetPayment(int paymentInfoId)
        {
            var paymentInfo = DbProvider.GetByID<PaymentInfo>(paymentInfoId);

            if (paymentInfo == null) return null;

            var paymentManager = new PaymentManager();

            IPayment payment = paymentManager.GetPlugins(paymentInfo.ClassName);

            if (payment == null) return null;

            //InfoToPayment(paymentInfo, payment);

            return payment;
        }
Esempio n. 2
0
        /// <summary>
        /// 取得所有有效的支付方式
        /// </summary>
        /// <returns></returns>
        public ICollection<IPayment> GetEffectPayments()
        {
            IQueryable<PaymentInfo> paymentInfos = DbProvider.D<PaymentInfo>().Where(x => x.IsEffect).OrderByDescending(x=>x.Sort);

            var paymentManager = new PaymentManager();

            var result = new List<IPayment>();

            foreach (PaymentInfo paymentInfo in paymentInfos) {
                IPayment payment = paymentManager.GetPlugins(paymentInfo.ClassName);

                if (payment == null) continue;

                payment.Logo = paymentInfo.Logo;
                payment.Sort = paymentInfo.Sort;
                payment.FeeType = paymentInfo.FeeType;
                payment.FeeAmount = paymentInfo.FeeAmount;
                payment.Config = paymentInfo.Config;

                result.Add(payment);
            }

            return result;
        }
Esempio n. 3
0
        public PaymentResponse RequestPaymentReversal(string transactionId)
        {
            PaymentManager paymentManager = new PaymentManager(_baseUrl, _entityId, _authentication, _testMode, _logger);

            return(paymentManager.RequestPaymentReversal(transactionId));
        }
Esempio n. 4
0
 public Success()
 {
     InitializeComponent();
     Utils.PdfCreator.CreateCheck();
     PaymentManager.ResetValue();
 }
Esempio n. 5
0
 /// <summary>
 /// Gets the PaymentMethodDto of DIBS.
 /// </summary>
 /// <returns>The DIBS payment method.</returns>
 public static PaymentMethodDto GetDIBSPaymentMethod()
 {
     return(PaymentManager.GetPaymentMethodBySystemName(DIBSSystemName, SiteContext.Current.LanguageName));
 }
        public IActionResult CardPayment([FromBody] CardPaymentRequest value)
        {
            var paymentManger = new PaymentManager(_context);

            return(Ok(paymentManger.CardPayment(value)));
        }
Esempio n. 7
0
        public WizardSettings SaveData(WizardModel wizardModel)
        {
            try
            {
                var(email, passwordHash, lng, timeZone, promocode, amiid, subscribeFromSite) = wizardModel;

                var tenant   = TenantManager.GetCurrentTenant();
                var settings = SettingsManager.Load <WizardSettings>();
                if (settings.Completed)
                {
                    throw new Exception("Wizard passed.");
                }

                if (!string.IsNullOrEmpty(SetupInfo.AmiMetaUrl) && IncorrectAmiId(amiid))
                {
                    //throw new Exception(Resource.EmailAndPasswordIncorrectAmiId); TODO
                }

                if (tenant.OwnerId == Guid.Empty)
                {
                    Thread.Sleep(TimeSpan.FromSeconds(6)); // wait cache interval
                    tenant = TenantManager.GetTenant(tenant.TenantId);
                    if (tenant.OwnerId == Guid.Empty)
                    {
                        Log.Error(tenant.TenantId + ": owner id is empty.");
                    }
                }

                var currentUser = UserManager.GetUsers(TenantManager.GetCurrentTenant().OwnerId);

                if (!UserManagerWrapper.ValidateEmail(email))
                {
                    throw new Exception(Resource.EmailAndPasswordIncorrectEmail);
                }

                if (string.IsNullOrEmpty(passwordHash))
                {
                    throw new Exception(Resource.ErrorPasswordEmpty);
                }

                SecurityContext.SetUserPasswordHash(currentUser.ID, passwordHash);

                email = email.Trim();
                if (currentUser.Email != email)
                {
                    currentUser.Email            = email;
                    currentUser.ActivationStatus = EmployeeActivationStatus.NotActivated;
                }
                UserManager.SaveUserInfo(currentUser);

                if (!string.IsNullOrWhiteSpace(promocode))
                {
                    try
                    {
                        PaymentManager.ActivateKey(promocode);
                    }
                    catch (Exception err)
                    {
                        Log.Error("Incorrect Promo: " + promocode, err);
                        throw new Exception(Resource.EmailAndPasswordIncorrectPromocode);
                    }
                }

                if (RequestLicense)
                {
                    TariffSettings.SetLicenseAccept(SettingsManager);
                    MessageService.Send(MessageAction.LicenseKeyUploaded);

                    LicenseReader.RefreshLicense();
                }

                settings.Completed = true;
                SettingsManager.Save(settings);

                TrySetLanguage(tenant, lng);

                tenant.TimeZone = TimeZoneConverter.GetTimeZone(timeZone).Id;

                TenantManager.SaveTenant(tenant);

                StudioNotifyService.SendCongratulations(currentUser);
                StudioNotifyService.SendRegData(currentUser);

                if (subscribeFromSite && TenantExtra.Opensource && !CoreBaseSettings.CustomMode)
                {
                    SubscribeFromSite(currentUser);
                }

                return(settings);
            }
            catch (BillingNotFoundException)
            {
                throw new Exception(UserControlsCommonResource.LicenseKeyNotFound);
            }
            catch (BillingNotConfiguredException)
            {
                throw new Exception(UserControlsCommonResource.LicenseKeyNotCorrect);
            }
            catch (BillingException)
            {
                throw new Exception(UserControlsCommonResource.LicenseException);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
        public void BindData()
        {
            //reward points
            if (OrderManager.RewardPointsEnabled && !this.Cart.IsRecurring)
            {
                int     rewardPointsBalance    = NopContext.Current.User.RewardPointsBalance;
                decimal rewardPointsAmountBase = OrderManager.ConvertRewardPointsToAmount(rewardPointsBalance);
                decimal rewardPointsAmount     = CurrencyManager.ConvertCurrency(rewardPointsAmountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                if (rewardPointsAmount > decimal.Zero)
                {
                    string rewardPointsAmountStr = PriceHelper.FormatPrice(rewardPointsAmount, true, false);
                    cbUseRewardPoints.Text  = GetLocaleResourceString("Checkout.UseRewardPoints", rewardPointsBalance, rewardPointsAmountStr);
                    pnlRewardPoints.Visible = true;
                }
                else
                {
                    pnlRewardPoints.Visible = false;
                }
            }
            else
            {
                pnlRewardPoints.Visible = false;
            }

            //payment methods
            int?filterByCountryId = null;

            if (NopContext.Current.User.BillingAddress != null && NopContext.Current.User.BillingAddress.Country != null)
            {
                filterByCountryId = NopContext.Current.User.BillingAddress.CountryId;
            }

            bool hasButtonMethods    = false;
            var  boundPaymentMethods = new PaymentMethodCollection();
            var  paymentMethods      = PaymentMethodManager.GetAllPaymentMethods(filterByCountryId);

            foreach (var pm in paymentMethods)
            {
                switch (pm.PaymentMethodType)
                {
                case PaymentMethodTypeEnum.Unknown:
                case PaymentMethodTypeEnum.Standard:
                {
                    if (!Cart.IsRecurring || PaymentManager.SupportRecurringPayments(pm.PaymentMethodId) != RecurringPaymentTypeEnum.NotSupported)
                    {
                        boundPaymentMethods.Add(pm);
                    }
                }
                break;

                case PaymentMethodTypeEnum.Button:
                {
                    //PayPal Express is placed here as button
                    if (pm.SystemKeyword == "PayPalExpress")
                    {
                        if (!Cart.IsRecurring || PaymentManager.SupportRecurringPayments(pm.PaymentMethodId) != RecurringPaymentTypeEnum.NotSupported)
                        {
                            hasButtonMethods = true;
                        }
                    }
                }
                break;

                default:
                    break;
                }
            }

            if (boundPaymentMethods.Count == 0)
            {
                if (hasButtonMethods)
                {
                    phSelectPaymentMethod.Visible  = false;
                    pnlPaymentMethodsError.Visible = false;

                    //no reward points in this case
                    pnlRewardPoints.Visible = false;
                }
                else
                {
                    phSelectPaymentMethod.Visible  = false;
                    pnlPaymentMethodsError.Visible = true;
                    lPaymentMethodsError.Text      = GetLocaleResourceString("Checkout.NoPaymentMethods");

                    //no reward points in this case
                    pnlRewardPoints.Visible = false;
                }
            }
            else if (boundPaymentMethods.Count == 1)
            {
                phSelectPaymentMethod.Visible  = true;
                pnlPaymentMethodsError.Visible = false;
                dlPaymentMethod.DataSource     = boundPaymentMethods;
                dlPaymentMethod.DataBind();
            }
            else
            {
                phSelectPaymentMethod.Visible  = true;
                pnlPaymentMethodsError.Visible = false;
                dlPaymentMethod.DataSource     = boundPaymentMethods;
                dlPaymentMethod.DataBind();
            }
        }
        //Exercise (E2) Do CheckOut
        public ActionResult CheckOut(CheckOutViewModel model)
        {
            // ToDo: declare a variable for CartHelper
            CartHelper ch = new CartHelper(Cart.DefaultName);

            int orderAddressId = 0;

            // ToDo: Addresses (an If-Else)
            if (CustomerContext.Current.CurrentContact == null)
            {
                // Anonymous... one way of "doing it"... for example, if no other address exist
                orderAddressId = ch.Cart.OrderAddresses.Add(
                    new OrderAddress
                {
                    CountryCode        = "SWE",
                    CountryName        = "Sweden",
                    Name               = "SomeCustomerAddress",
                    DaytimePhoneNumber = "123456",
                    FirstName          = "John",
                    LastName           = "Smith",
                    Email              = "*****@*****.**",
                });
            }
            else
            {
                // Logged in
                if (CustomerContext.Current.CurrentContact.PreferredShippingAddress == null)
                {
                    // no pref. address set... so we set one for the contact
                    CustomerAddress newCustAddress =
                        CustomerAddress.CreateForApplication(AppContext.Current.ApplicationId);
                    newCustAddress.AddressType        = CustomerAddressTypeEnum.Shipping; // mandatory
                    newCustAddress.ContactId          = CustomerContext.Current.CurrentContact.PrimaryKeyId;
                    newCustAddress.CountryCode        = "SWE";
                    newCustAddress.CountryName        = "Sweden";
                    newCustAddress.Name               = "new customer address"; // mandatory
                    newCustAddress.DaytimePhoneNumber = "123456";
                    newCustAddress.FirstName          = CustomerContext.Current.CurrentContact.FirstName;
                    newCustAddress.LastName           = CustomerContext.Current.CurrentContact.LastName;
                    newCustAddress.Email              = "*****@*****.**";

                    // note: Line1 & City is what is shown in CM at a few places... not the Name
                    CustomerContext.Current.CurrentContact.AddContactAddress(newCustAddress);
                    CustomerContext.Current.CurrentContact.SaveChanges();

                    // ... needs to be in this order
                    CustomerContext.Current.CurrentContact.PreferredShippingAddress = newCustAddress;
                    CustomerContext.Current.CurrentContact.SaveChanges(); // need this ...again

                    // then, for the cart
                    orderAddressId = ch.Cart.OrderAddresses.Add(new OrderAddress(newCustAddress));
                }
                else
                {
                    // there is a preferred address set (and, a fourth alternative exists... do later )
                    OrderAddress orderAddress =
                        new OrderAddress(CustomerContext.Current.CurrentContact.PreferredShippingAddress);

                    // then, for the cart
                    orderAddressId = ch.Cart.OrderAddresses.Add(orderAddress);
                }
            }

            // Depending how it was created...
            OrderAddress address = ch.FindAddressById(orderAddressId.ToString());

            // ToDo: Define Shipping
            ShippingMethodDto.ShippingMethodRow theShip =
                ShippingManager.GetShippingMethod(model.SelectedShipId).ShippingMethod.First();

            int shippingId = ch.Cart.OrderForms[0].Shipments.Add(
                new Shipment
            {                                          // ...removing anything?
                ShippingAddressId      = address.Name, // note: use no custom prefixes
                ShippingMethodId       = theShip.ShippingMethodId,
                ShippingMethodName     = theShip.Name,
                ShipmentTotal          = theShip.BasePrice,
                ShipmentTrackingNumber = "My tracking number",
            });

            // get the Shipping ... check to see if the Shipping knows about the LineItem
            Shipment firstOrderShipment = ch.Cart.OrderForms[0].Shipments.FirstOrDefault();

            // First (and only) OrderForm
            LineItemCollection lineItems = ch.Cart.OrderForms[0].LineItems;

            // ...basic now... one OrderForm - one Shipping
            foreach (LineItem lineItem in lineItems)
            {
                int index = lineItems.IndexOf(lineItem);
                if ((firstOrderShipment != null) && (index != -1))
                {
                    firstOrderShipment.AddLineItemIndex(index, lineItem.Quantity);
                }
            }


            // Execute the "Shipping & Taxes - WF" (CartPrepare) ... and take care of the return object
            WorkflowResults resultPrepare     = ch.Cart.RunWorkflow(OrderGroupWorkflowManager.CartPrepareWorkflowName);
            List <string>   wfMessagesPrepare = new List <string>(OrderGroupWorkflowManager.GetWarningsFromWorkflowResult(resultPrepare));


            // ToDo: Define Shipping
            PaymentMethodDto.PaymentMethodRow thePay = PaymentManager.GetPaymentMethod(model.SelectedPayId).PaymentMethod.First();
            Payment firstOrderPayment = ch.Cart.OrderForms[0].Payments.AddNew(typeof(OtherPayment));

            // ... need both below
            firstOrderPayment.Amount            = firstOrderShipment.SubTotal + firstOrderShipment.ShipmentTotal; // will change...
            firstOrderPayment.BillingAddressId  = address.Name;
            firstOrderPayment.PaymentMethodId   = thePay.PaymentMethodId;
            firstOrderPayment.PaymentMethodName = thePay.Name;
            // ch.Cart.CustomerName = "John Smith"; // ... this line overwrites what´s in there, if logged in


            // Execute the "Payment activation - WF" (CartCheckout) ... and take care of the return object
            // ...activates the gateway (same for shipping)
            WorkflowResults resultCheckout     = ch.Cart.RunWorkflow(OrderGroupWorkflowManager.CartCheckOutWorkflowName, false);
            List <string>   wfMessagesCheckout = new List <string>(OrderGroupWorkflowManager.GetWarningsFromWorkflowResult(resultCheckout));
            //ch.RunWorkflow("CartValidate") ... can see this (or variations)

            string        trackingNumber = String.Empty;
            PurchaseOrder purchaseOrder  = null;

            // Add a transaction scope and convert the cart to PO
            using (var scope = new Mediachase.Data.Provider.TransactionScope())
            {
                purchaseOrder = ch.Cart.SaveAsPurchaseOrder();
                ch.Cart.Delete();
                ch.Cart.AcceptChanges();
                trackingNumber = purchaseOrder.TrackingNumber;
                scope.Complete();
            }

            // Housekeeping below (Shipping release, OrderNotes and save the order)
            OrderStatusManager.ReleaseOrderShipment(purchaseOrder.OrderForms[0].Shipments[0]);

            OrderNotesManager.AddNoteToPurchaseOrder(purchaseOrder, DateTime.UtcNow.ToShortDateString() + " released for shipping", OrderNoteTypes.System, CustomerContext.Current.CurrentContactId);

            purchaseOrder.ExpirationDate = DateTime.UtcNow.AddDays(30);
            purchaseOrder.Status         = OrderStatus.InProgress.ToString();

            purchaseOrder.AcceptChanges(); // need this here, else no "order-note" persisted


            // Final steps, navigate to the order confirmation page
            StartPage        home = _contentLoader.Service.Get <StartPage>(ContentReference.StartPage);
            ContentReference orderPageReference = home.Settings.orderPage;

            string passingValue = trackingNumber;

            return(RedirectToAction("Index", new { node = orderPageReference, passedAlong = passingValue }));
        }
Esempio n. 10
0
        public IPurchaseOrder CreatePurchaseOrderForKlarna(string klarnaOrderId, CheckoutOrder order, ICart cart)
        {
            var paymentRow = PaymentManager.GetPaymentMethodBySystemName(Constants.KlarnaCheckoutSystemKeyword, _languageService.GetPreferredCulture().Name).PaymentMethod.FirstOrDefault();

            var payment = cart.CreatePayment(_orderGroupFactory);

            payment.PaymentType       = PaymentType.Other;
            payment.PaymentMethodId   = paymentRow.PaymentMethodId;
            payment.PaymentMethodName = Constants.KlarnaCheckoutSystemKeyword;
            payment.Amount            = cart.GetTotal(_orderGroupCalculator).Amount;
            payment.Status            = PaymentStatus.Pending.ToString();
            payment.TransactionType   = TransactionType.Authorization.ToString();

            cart.AddPayment(payment, _orderGroupFactory);

            var billingAddress = new AddressModel
            {
                Name               = $"{order.BillingCheckoutAddress.StreetAddress}{order.BillingCheckoutAddress.StreetAddress2}{order.BillingCheckoutAddress.City}",
                FirstName          = order.BillingCheckoutAddress.GivenName,
                LastName           = order.BillingCheckoutAddress.FamilyName,
                Email              = order.BillingCheckoutAddress.Email,
                DaytimePhoneNumber = order.BillingCheckoutAddress.Phone,
                Line1              = order.BillingCheckoutAddress.StreetAddress,
                Line2              = order.BillingCheckoutAddress.StreetAddress2,
                PostalCode         = order.BillingCheckoutAddress.PostalCode,
                City               = order.BillingCheckoutAddress.City,
                CountryName        = order.BillingCheckoutAddress.Country
            };

            payment.BillingAddress = _addressBookService.ConvertToAddress(billingAddress, cart);

            cart.ProcessPayments(_paymentProcessor, _orderGroupCalculator);

            var totalProcessedAmount = cart.GetFirstForm().Payments.Where(x => x.Status.Equals(PaymentStatus.Processed.ToString())).Sum(x => x.Amount);

            if (totalProcessedAmount != cart.GetTotal(_orderGroupCalculator).Amount)
            {
                throw new InvalidOperationException("Wrong amount");
            }

            if (payment.HasFraudStatus(FraudStatus.PENDING))
            {
                payment.Status = PaymentStatus.Pending.ToString();
            }

            _cartService.RequestInventory(cart);

            var orderReference = _orderRepository.SaveAsPurchaseOrder(cart);
            var purchaseOrder  = _orderRepository.Load <IPurchaseOrder>(orderReference.OrderGroupId);

            _orderRepository.Delete(cart.OrderLink);

            if (purchaseOrder == null)
            {
                _klarnaCheckoutService.CancelOrder(cart);

                return(null);
            }
            else
            {
                _klarnaCheckoutService.Complete(purchaseOrder);
                purchaseOrder.Properties[Klarna.Common.Constants.KlarnaOrderIdField] = klarnaOrderId;

                _orderRepository.Save(purchaseOrder);
                return(purchaseOrder);
            }
        }
Esempio n. 11
0
    protected void Display_AddEdit()
    {
        IPaymentGateway gatewayService = ObjectFactory.GetPaymentGateway();
        PaymentGatewayData paymentGateway = null;
        PaymentManager cmsPaymentManager = new PaymentManager();
        System.Collections.IEnumerator paymentProviders = cmsPaymentManager.Providers.GetEnumerator();
        int gatewayIndex = 0;
        string defaultName = "";

        paymentGateway = m_iID > 0 ? (gatewayService.GetItem(this.m_iID)) : (new PaymentGatewayData());

        while (paymentProviders.MoveNext())
        {

            string currentGatewayName = "";

            PaymentGatewayProvider currentData = paymentProviders.Current as PaymentGatewayProvider;
            if (paymentProviders.Current != null)
            {

                if (paymentGateway.Name.ToLower() == currentData.Name.ToLower())
                {
                    chk_check.Enabled = cmsPaymentManager.Providers[currentData.Name].SupportsCheckPayments;
                }
                if (gatewayIndex == 0)
                {
                    defaultName = currentData.Name;
                }

                if (currentData.Name.ToLower() != "google" && currentData.Name.ToLower() != "paypal")
                {

                    supportsCards.Add(cmsPaymentManager.Providers[currentData.Name].SupportsCreditCardPayments);
                    supportsChecks.Add(cmsPaymentManager.Providers[currentData.Name].SupportsCheckPayments);

                    currentGatewayName = currentData.Name;
                    drp_GatewayName.Items.Add(currentGatewayName);
                    if (paymentGateway.Name == currentGatewayName)
                    {
                        drp_GatewayName.SelectedIndex = gatewayIndex;
                    }
                    gatewayIndex++;

                }

            }

        }

        drp_GatewayName.Attributes.Add("onchange", "UpdateOptions(this);");
        if (paymentGateway.Id == 0 && drp_GatewayName.Items.Count > 0)
        {

            if (!cmsPaymentManager.Providers[defaultName].SupportsCreditCardPayments)
            {
                chk_cc.Enabled = false;
            }
            if (!cmsPaymentManager.Providers[defaultName].SupportsCheckPayments)
            {
                chk_check.Enabled = false;
            }
            drp_GatewayName.SelectedIndex = 0;

        }

        // txt_name.Enabled = ((m_iID = 0) Or (m_iID > 0 And paymentGateway.IsCustom))
        lbl_id.Text = paymentGateway.Id.ToString();
        chk_default.Checked = paymentGateway.IsDefault;
        txt_uid.Text = paymentGateway.UserId;
        txt_viewpwd.Visible = false;
        txt_pwd.Text = ProtectPassword(paymentGateway.Password);
        txt_spare1.Text = paymentGateway.CustomFieldOne;
        txt_spare2.Text = paymentGateway.CustomFieldTwo;
        chk_cc.Checked = paymentGateway.AllowsCreditCardPayments;
        chk_check.Checked = paymentGateway.AllowsCheckPayments;
        tr_id.Visible = m_iID > 0;
        chk_default.Enabled = m_iID == 0;
    }
Esempio n. 12
0
        /// <summary>
        /// 根据支付接口的Key,获得支付接口
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public IPayment GetPayment(string key)
        {
            lock (_asnyLock)
            {
                var paymentInfo = DbProvider.D<PaymentInfo>().FirstOrDefault(x => x.ClassName == key);

                if (paymentInfo == null) return null;

                var paymentManager = new PaymentManager();

                IPayment payment = paymentManager.GetPlugins(paymentInfo.ClassName);

                if (payment == null) return null;

                //InfoToPayment(paymentInfo, payment);

                return payment;
            }
        }
Esempio n. 13
0
    protected void Display_View()
    {
        IPaymentGateway gatewayService = ObjectFactory.GetPaymentGateway();
        PaymentGatewayData paymentGateway = null;
        PaymentManager cmsPaymentManager = new PaymentManager();
        System.Collections.IEnumerator paymentProviders = cmsPaymentManager.Providers.GetEnumerator();
        int gatewayIndex = 0;

        paymentGateway = gatewayService.GetItem(this.m_iID);

         while (paymentProviders.MoveNext())
        {
            PaymentGatewayProvider currentData = paymentProviders.Current as PaymentGatewayProvider;
            drp_GatewayName.Items.Add(currentData.Name);
            if (paymentGateway.Name == currentData.Name)
            {
                drp_GatewayName.SelectedIndex = gatewayIndex;
            }
            gatewayIndex++;

        }

        lbl_id.Text = paymentGateway.Id.ToString();
        chk_default.Checked = paymentGateway.IsDefault;
        txt_uid.Text = paymentGateway.UserId;
        txt_viewpwd.Text = ProtectPassword(paymentGateway.Password);
        txt_pwd.Visible = false;
        txt_spare1.Text = paymentGateway.CustomFieldOne;
        txt_spare2.Text = paymentGateway.CustomFieldTwo;
        chk_cc.Checked = paymentGateway.AllowsCreditCardPayments;
        chk_check.Checked = paymentGateway.AllowsCheckPayments;
        drp_GatewayName.Enabled = false;
        chk_default.Enabled = false;
        txt_uid.Enabled = false;
        txt_pwd.Enabled = false;
        txt_spare1.Enabled = false;
        txt_spare2.Enabled = false;
        chk_cc.Enabled = false;
        chk_check.Enabled = false;

        m_bIsDefault = paymentGateway.IsDefault;
    }
Esempio n. 14
0
        public object Post(CreatePaymentModel model)
        {
            var manager = new PaymentManager(model.Apikey);

            return(manager.CreatePayment(model));
        }
Esempio n. 15
0
        public object Get(string apikey)
        {
            var manager = new PaymentManager(apikey);

            return(manager.GetPaymentsList());
        }
        public ActionResult Buy(StartPage currentPage)
        {
            var cart   = LoadOrCreateCart();
            var market = _currentMarket.GetCurrentMarket();
            // Add shipping
            var shippingMethod = ShippingManager.GetShippingMethodsByMarket
                                     (market.MarketId.Value, false).ShippingMethod.FirstOrDefault();

            cart.OrderAddresses.Clear();
            cart.OrderForms.First().Shipments.Clear();
            cart.OrderForms.First().Payments.Clear();

            var shippingAddress = cart.OrderAddresses.AddNew();

            FillInAddress(shippingAddress);

            var shipment   = new Shipment();
            var shipmentId = cart.OrderForms.First().Shipments.Add(shipment);

            shipment.ShippingMethodId   = shippingMethod.ShippingMethodId;
            shipment.ShippingMethodName = shippingMethod.Name;
            shipment.SubTotal           = shippingMethod.BasePrice;

            // LineItem

            ContentReference theRef     = _refConv.GetContentLink("Long-Sleeve-Shirt-White-Small_1");
            VariationContent theContent = _contentLoader.Get <VariationContent>(theRef);
            LineItem         li         = CreateLineItem(theContent, 2, 22);

            var orderForm = cart.OrderForms.First();

            orderForm.LineItems.Add(li);
            var index = orderForm.LineItems.IndexOf(li);

            cart.OrderForms.First().Shipments.First().AddLineItemIndex(index, li.Quantity);


            //var liId = cart.OrderForms.First().LineItems.Add(li);
            //PurchaseOrderManager.AddLineItemToShipment(cart, 1, shipment, 2);

            // Add a pay method
            var paymentMethod = PaymentManager.GetPaymentMethodsByMarket(market.MarketId.Value)
                                .PaymentMethod.First();
            // Add Payment
            var payment = cart.OrderForms.First().Payments.AddNew(typeof(OtherPayment));

            payment.Amount            = 42; // ((IOrderGroup)cart).GetTotal(_totti).Amount;// .SubTotal.Amount;
            payment.PaymentMethodName = paymentMethod.Name;
            payment.PaymentMethodId   = paymentMethod.PaymentMethodId;
            payment.Status            = PaymentStatus.Pending.ToString();
            payment.TransactionID     = "transactionId";

            // No activations of Ship&Pay&Tax-providers in this example

            // Do the purchase
            using (var scope = new Mediachase.Data.Provider.TransactionScope())
            {
                OrderReference oRef = _orderRepository.SaveAsPurchaseOrder(cart);
                // I want to do this _orderRepository.Delete(cart);
                //_orderRepository.Delete(((IOrderGroup)cart).OrderLink);
                scope.Complete();
            }

            return(Content("Done"));
        }
 public void DeleteTokenWithTokenNumber(string tokenNumber)
 {
     PaymentManager.DeleteTokenWithTokenNumber(tokenNumber);
 }
 /// <summary>
 /// Stores the credit card information at the provider and generates a tokenNumber.
 /// </summary>
 /// <param name="creditCard"></param>
 /// <param name="expirationDate"></param>
 /// <returns></returns>
 public string StoreCreditCardInformation(int billingAccountId, string creditCard, int expirationMonth, int expirationYear)
 {
     return(PaymentManager.StoreCreditCard(billingAccountId, creditCard, expirationMonth, expirationYear));
 }
Esempio n. 19
0
        private IEnumerable <PaymentMethodDto.PaymentMethodRow> GetPaymentMethods()
        {
            PaymentMethodDto paymentDto = PaymentManager.GetPaymentMethodsByMarket(_currentMarket.GetCurrentMarket().MarketId.Value);

            return(paymentDto.PaymentMethod.Rows.OfType <PaymentMethodDto.PaymentMethodRow>());
        }
 // Exercise (E1) creation of GetPaymentMethods(), GetShipmentMethods() and GetShippingRates() goes below
 // ToDo: Get IEnumerables of Shipping and Payment methods along with ShippingRates
 private IEnumerable <PaymentMethodDto.PaymentMethodRow> GetPaymentMethods()
 {
     return(new List <PaymentMethodDto.PaymentMethodRow>(
                PaymentManager.GetPaymentMethodsByMarket(MarketId.Default.Value).PaymentMethod));
 }
Esempio n. 21
0
 public OrderAdapter(PaymentManager manager, IOrderMailer mailer)
 {
     this.manager = manager;
     this.mailer  = mailer;
 }
Esempio n. 22
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Boolean proceed = true;

        String[]             items          = SessionVariableManager.getOrderItems();
        List <InventoryItem> orderInventory = new List <InventoryItem>();
        List <TextBox>       textboxes      = new List <TextBox>();

        OrderManager orderManager = new OrderManager();

        foreach (String item in items)
        {
            if (item != "")
            {
                orderInventory.Add(InventoryManager.getSingleItem(Convert.ToInt32(item)));
            }
        }
        foreach (RepeaterItem rptItem in rptOrderItem.Items)
        {
            textboxes.Add((TextBox)rptItem.FindControl("txtCount"));
        }

        if (orderInventory.Count == textboxes.Count)
        {
            for (int i = 0; i < orderInventory.Count; i++)
            {
                bool success = orderManager.addItemToOrder(orderInventory[i], Convert.ToInt32(textboxes[i].Text));
                if (!success)
                {
                    lblMessage.Text = "You cannot order more than we have in inventory. Please try again! (" + orderInventory[i].getProductName() + ")";
                    proceed         = false;
                    return;
                }
            }
        }
        PaymentInformation userCreditCard = PaymentManager.getUserCreditCard(Convert.ToInt32(ddlPaymentMethod.SelectedValue));

        orderManager.addPaymentInfo(userCreditCard);
        orderManager.setIsCollectOnDelivery(cbCollectOnDelivery.Checked);
        orderManager.setPaymentAmount(Convert.ToDouble(txtPaymentAmount.Text));
        if (proceed)
        {
            int orderNumber = orderManager.submitOrder();
            if (orderNumber > 0)
            {
                lblMessage.Text                        = "Thank you for your order. Your order number is " + orderNumber + ". Keep this number for reference.";
                btnCalculateOrder.Enabled              = false;
                btnSubmit.Enabled                      = false;
                paymentAmountValidator.Enabled         = false;
                paymentAmountRequiredValidator.Enabled = false;

                foreach (InventoryItem item in orderInventory)
                {
                    SessionVariableManager.removeItemFromCart(item.getInventoryId());
                }
            }
            else
            {
                lblMessage.Text = "Sorry, there was an error with your order. Please review your selection and try again.";
            }
        }
    }
Esempio n. 23
0
        /// <summary>
        /// This function saves the data from the formular and closes it
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_save_Click(object sender, EventArgs e)
        {
            bool    findCustomerSuccess = false;
            bool    saveSuccess         = false;
            bool    flagDbError         = false;
            string  numberAccount       = "";
            decimal amount           = 0;
            int     idAccount        = 0;
            string  accountRecipient = txt_accountRecipient.Text;

            string   informationTransmitted = txt_informationTransmitted.Text;
            string   personalInformation    = txt_personalInformation.Text;
            DateTime dateTemps = DTP_datePayment.Value;


            if (!string.IsNullOrEmpty(txt_amount.Text))
            {
                amount = Convert.ToDecimal(txt_amount.Text);
            }


            if ((string.IsNullOrEmpty(txt_accountRecipient.Text)) || (string.IsNullOrEmpty(txt_amount.Text)))
            {
                MessageBox.Show("les champs sont vides", "Erreur dans le formulaire", MessageBoxButtons.OK);
            }
            else
            {
                try
                {
                    activeAccount       = new Account(idAccount, numberAccount, amount, activeUser);
                    findCustomerSuccess = activeAccount.loadAccount(idAccount, numberAccount, amount);
                }
                catch (DbError)
                {
                    flagDbError = true;
                }
                if (findCustomerSuccess == true)
                {
                    if (txt_accountRecipient.Text == activeAccount.AccountNumber)
                    {
                        MessageBox.Show("Vous ne pouvez pas écrire votre numéro de compte", "Erreur dans le formulaire", MessageBoxButtons.OK);
                    }
                    else if ((Convert.ToDecimal(txt_amount.Text) > activeAccount.Amount))
                    {
                        MessageBox.Show("Le montant doit être moins élevé que votre solde, votre solde actuel : " + activeAccount.Amount, "Données incompatibles", MessageBoxButtons.OK);
                    }
                    else if (Convert.ToDecimal(txt_amount.Text) < 0)
                    {
                        MessageBox.Show("Le montant doit être positif", "Erreur dans le formulaire", MessageBoxButtons.OK);
                    }
                    else
                    {
                        try
                        {
                            activePayment = new PaymentManager(id, idAccount, accountRecipient, dateTemps, amount, informationTransmitted, personalInformation, idAccountRecipient);
                            saveSuccess   = activePayment.addPayment(activeAccount, idAccountRecipient, dateTemps, amount, informationTransmitted, personalInformation);
                        }
                        catch (DbError)
                        {
                            MessageBox.Show("Du à un problème avec notre serveur, vos données sont actuellement limitées voir indisponibles", "Problème de connexion");
                            flagDbError = true;
                        }
                        if (saveSuccess == true)
                        {
                            MessageBox.Show("Votre versement a été validé et enregistré ", "Enregistrement");
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                        if (saveSuccess == false && flagDbError == false)
                        {
                            MessageBox.Show("Destinataire Introuvable", "Problème d'importation", MessageBoxButtons.OK);
                        }
                    }
                }
            }
        }
Esempio n. 24
0
        public PaymentCallback Notify(RenderContext context)
        {
            var dic = GetRequestPost(context);

            if (dic.Count > 0)
            {
                var  data         = new AlipayData();
                bool signVerified = data.RSACheckV1(dic, this.Setting.PublicKey, this.Setting.Charset); //调用SDK验证签名
                if (signVerified)
                {
                    var  strPaymentRequestId = context.Request.GetValue("out_trade_no");
                    Guid paymentRequestId;
                    if (Guid.TryParse(strPaymentRequestId, out paymentRequestId))
                    {
                        var paymentRequest = PaymentManager.GetRequest(paymentRequestId, context);

                        decimal totalAmount = 0;//total amount
                        decimal.TryParse(context.Request.Get("total_amount"), out totalAmount);
                        var subject       = context.Request.Get("subject");
                        var paymentStatus = context.Request.Get("trade_status");

                        if (paymentRequest == null || this.Setting == null)
                        {
                            return(null);
                        }

                        var callback = new PaymentCallback()
                        {
                            RequestId = paymentRequestId,
                        };

                        if (totalAmount == Math.Round(paymentRequest.TotalAmount, 2) || subject == paymentRequest.Name)
                        {
                            if (paymentStatus == TradeStatus.TRADE_CLOSED)
                            {
                                callback.Status = PaymentStatus.Cancelled;
                            }
                            else if (paymentStatus == TradeStatus.TRADE_SUCCESS || paymentStatus == TradeStatus.TRADE_FINISHED)
                            {
                                callback.Status = PaymentStatus.Paid;
                            }
                            else if (paymentStatus == TradeStatus.WAIT_BUYER_PAY)
                            {
                                callback.Status = PaymentStatus.Pending;
                            }
                        }
                        else
                        {
                            callback.Status = PaymentStatus.NotAvailable;
                            //怎么让kooboo的前端打印输出“fail”
                        }

                        return(callback);
                    }
                    else
                    {
                        return(null);
                        //怎么让kooboo的前端打印输出“fail”
                    }
                }
            }

            return(null);
        }
Esempio n. 25
0
        public void BindData(bool isShoppingCart)
        {
            this.IsShoppingCart = isShoppingCart;
            var cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);

            if (cart.Count > 0)
            {
                //payment method (if already selected)
                int paymentMethodId = 0;
                if (NopContext.Current.User != null)
                {
                    paymentMethodId = NopContext.Current.User.LastPaymentMethodId;
                }

                //subtotal
                decimal  subTotalDiscountBase = decimal.Zero;
                Discount appliedDiscount      = null;
                //don't include checkout attributes on shopping cart page
                decimal subtotalBaseWithoutPromo = decimal.Zero;
                decimal subtotalBaseWithPromo    = decimal.Zero;
                string  SubTotalError            = ShoppingCartManager.GetShoppingCartSubTotal(cart,
                                                                                               NopContext.Current.User, out subTotalDiscountBase,
                                                                                               out appliedDiscount,
                                                                                               out subtotalBaseWithoutPromo, out subtotalBaseWithPromo);
                if (String.IsNullOrEmpty(SubTotalError))
                {
                    decimal subtotalWithoutPromo = CurrencyManager.ConvertCurrency(subtotalBaseWithoutPromo, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                    lblSubTotalAmount.Text     = PriceHelper.FormatPrice(subtotalWithoutPromo);
                    lblSubTotalAmount.CssClass = "productPrice";

                    //discount
                    if (subTotalDiscountBase > decimal.Zero)
                    {
                        decimal subTotalDiscount = CurrencyManager.ConvertCurrency(subTotalDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                        lblSubTotalDiscountAmount.Text = PriceHelper.FormatPrice(-subTotalDiscount, true, false);
                        phSubTotalDiscount.Visible     = true;
                    }
                    else
                    {
                        phSubTotalDiscount.Visible = false;
                    }
                }
                else
                {
                    //impossible scenario
                    lblSubTotalAmount.Text     = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout");
                    lblSubTotalAmount.CssClass = string.Empty;
                }

                //shipping info
                bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(cart);
                if (shoppingCartRequiresShipping)
                {
                    decimal?shoppingCartShippingBase = ShippingManager.GetShoppingCartShippingTotal(cart, NopContext.Current.User);
                    if (shoppingCartShippingBase.HasValue)
                    {
                        decimal shoppingCartShipping = CurrencyManager.ConvertCurrency(shoppingCartShippingBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                        lblShippingAmount.Text     = PriceHelper.FormatShippingPrice(shoppingCartShipping, true);
                        lblShippingAmount.CssClass = "productPrice";
                    }
                    else
                    {
                        lblShippingAmount.Text     = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout");
                        lblShippingAmount.CssClass = string.Empty;
                    }
                }
                else
                {
                    lblShippingAmount.Text     = GetLocaleResourceString("ShoppingCart.ShippingNotRequired");
                    lblShippingAmount.CssClass = string.Empty;
                }

                //payment method fee
                bool    displayPaymentMethodFee               = true;
                decimal paymentMethodAdditionalFee            = PaymentManager.GetAdditionalHandlingFee(paymentMethodId);
                decimal paymentMethodAdditionalFeeWithTaxBase = TaxManager.GetPaymentMethodAdditionalFee(paymentMethodAdditionalFee, NopContext.Current.User);
                if (paymentMethodAdditionalFeeWithTaxBase > decimal.Zero)
                {
                    decimal paymentMethodAdditionalFeeWithTax = CurrencyManager.ConvertCurrency(paymentMethodAdditionalFeeWithTaxBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                    lblPaymentMethodAdditionalFee.Text = PriceHelper.FormatPaymentMethodAdditionalFee(paymentMethodAdditionalFeeWithTax, true);
                }
                else
                {
                    displayPaymentMethodFee = false;
                }
                phPaymentMethodAdditionalFee.Visible = displayPaymentMethodFee;

                //tax
                bool displayTax = true;
                if (TaxManager.HideTaxInOrderSummary && NopContext.Current.TaxDisplayType == TaxDisplayTypeEnum.IncludingTax)
                {
                    displayTax = false;
                }
                else
                {
                    string  TaxError            = string.Empty;
                    decimal shoppingCartTaxBase = TaxManager.GetTaxTotal(cart, paymentMethodId, NopContext.Current.User, ref TaxError);
                    decimal shoppingCartTax     = CurrencyManager.ConvertCurrency(shoppingCartTaxBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                    if (String.IsNullOrEmpty(TaxError))
                    {
                        if (shoppingCartTaxBase == 0 && TaxManager.HideZeroTax)
                        {
                            displayTax = false;
                        }
                        else
                        {
                            lblTaxAmount.Text     = PriceHelper.FormatPrice(shoppingCartTax, true, false);
                            lblTaxAmount.CssClass = "productPrice";
                        }
                    }
                    else
                    {
                        lblTaxAmount.Text     = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout");
                        lblTaxAmount.CssClass = string.Empty;
                    }
                }
                phTaxTotal.Visible = displayTax;

                //total
                List <AppliedGiftCard> appliedGiftCards = null;
                int     redeemedRewardPoints            = 0;
                decimal redeemedRewardPointsAmount      = decimal.Zero;
                bool    useRewardPoints = false;
                if (NopContext.Current.User != null)
                {
                    useRewardPoints = NopContext.Current.User.UseRewardPointsDuringCheckout;
                }
                decimal?shoppingCartTotalBase = ShoppingCartManager.GetShoppingCartTotal(cart,
                                                                                         paymentMethodId, NopContext.Current.User,
                                                                                         out appliedGiftCards, useRewardPoints,
                                                                                         out redeemedRewardPoints, out redeemedRewardPointsAmount);
                if (shoppingCartTotalBase.HasValue)
                {
                    decimal shoppingCartTotal = CurrencyManager.ConvertCurrency(shoppingCartTotalBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                    lblTotalAmount.Text     = PriceHelper.FormatPrice(shoppingCartTotal, true, false);
                    lblTotalAmount.CssClass = "productPrice";
                }
                else
                {
                    lblTotalAmount.Text     = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout");
                    lblTotalAmount.CssClass = string.Empty;
                }

                //gift cards
                if (appliedGiftCards != null && appliedGiftCards.Count > 0)
                {
                    rptrGiftCards.Visible    = true;
                    rptrGiftCards.DataSource = appliedGiftCards;
                    rptrGiftCards.DataBind();
                }
                else
                {
                    rptrGiftCards.Visible = false;
                }

                //reward points
                if (redeemedRewardPointsAmount > decimal.Zero)
                {
                    phRewardPoints.Visible = true;

                    decimal redeemedRewardPointsAmountInCustomerCurrency = CurrencyManager.ConvertCurrency(redeemedRewardPointsAmount, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                    lRewardPointsTitle.Text    = string.Format(GetLocaleResourceString("ShoppingCart.Totals.RewardPoints"), redeemedRewardPoints);
                    lblRewardPointsAmount.Text = PriceHelper.FormatPrice(-redeemedRewardPointsAmountInCustomerCurrency, true, false);
                }
                else
                {
                    phRewardPoints.Visible = false;
                }
            }
            else
            {
                this.Visible = false;
            }
        }
 public void Init()
 {
     _paymentManager = new PaymentManager();
 }
Esempio n. 27
0
 public PaymentController()
 {
     Manager = new PaymentManager();
 }
Esempio n. 28
0
 public Tariff GetTariff()
 {
     return(PaymentManager.GetTariff(Tenant.TenantId));
 }
Esempio n. 29
0
 public PaymentAppService(IPaymentRepository repo, PaymentManager manager) : base(repo)
 {
     this.paymentManager = manager;
 }
Esempio n. 30
0
        public PaymentResponse RequestPayment(PaymentRequest request)
        {
            PaymentManager paymentManager = new PaymentManager(_baseUrl, _entityId, _authentication, _testMode, _logger);

            return(paymentManager.Request(request));
        }
Esempio n. 31
0
        public ActionResult Export(int payId)
        {
            PaymentManager pm      = new PaymentManager();
            Payment        payment = pm.LoadPayment(payId);

            #region 动态模板
            TTemplate template = new TTemplate();
            TRow      R1       = new TRow();
            TRow      R2       = new TRow();
            int       index1   = 3;
            int       index2   = 3;
            TCell     A        = new TCell("PersonId", "ID", 0, 0); A.RowSpan = 2; A.Width = 1;
            TCell     B        = new TCell("PersonName", "姓名", 0, 1); B.RowSpan = 2;
            TCell     C        = new TCell("PersonCode", "身份证", 0, 2); C.RowSpan = 2;
            R1.Cells.Add(A);
            R1.Cells.Add(B);
            R1.Cells.Add(C);
            foreach (PayItemDO item in payment.Items)
            {
                TCell cell = new TCell();
                cell.Name    = item.ItemName;
                cell.Caption = item.ItemCaption;
                if (item.IsLeaf == true)
                {
                    //cell.Width = 50;
                }
                if (item.ParentId == 0)
                {
                    cell.RowIndex    = 0;
                    cell.ColumnIndex = index1;
                    int colspan = 1;
                    foreach (PayItemDO pi in payment.Items)
                    {
                        if (pi.ParentId == item.ItemId)
                        {
                            colspan++;
                        }
                    }
                    if (colspan == 1)
                    {
                        cell.RowSpan = 2;
                        index1++;
                        index2++;
                    }
                    else
                    {
                        cell.ColSpan = colspan - 1;
                        index1       = index1 + cell.ColSpan;
                    }
                    R1.Cells.Add(cell);
                }
                else
                {
                    cell.RowIndex    = 1;
                    cell.ColumnIndex = index2;
                    index2           = index2 + 1;
                    R2.Cells.Add(cell);
                }
            }

            TSheet tsheet = new TSheet();
            tsheet.Name  = "Sheet1";
            tsheet.Title = "Sheet1";
            tsheet.Head.Rows.Add(R1);
            tsheet.Head.Rows.Add(R2);
            template.Sheets.Add(tsheet);
            #endregion

            IExcel  excel = ExcelFactory.CreateDefault();
            DataSet ds    = new DataSet();
            payment.DataSource.TableName = "Sheet1";
            ds.Tables.Add(payment.DataSource);
            POIStream stream = new POIStream();
            stream.AllowClose = false;
            excel.Write(stream, template, ds, ExcelExtendType.XLSX);
            stream.AllowClose = true;
            byte[] buffer = new byte[stream.Length];
            stream.Position = 0;
            stream.Read(buffer, 0, buffer.Length);
            stream.Close();

            HttpResponse context = System.Web.HttpContext.Current.Response;
            try
            {
                context.ContentType = "application/ms-excel";
                context.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xlsx", HttpUtility.UrlEncode(payment.PayTitle, System.Text.Encoding.UTF8)));
                context.BinaryWrite(buffer);
                context.Flush();
                context.End();
            }
            catch (Exception ex)
            {
                context.ContentType = "text/plain";
                context.Write(ex.Message);
            }
            return(null);
        }
Esempio n. 32
0
        /// <summary>
        /// 获得系统所有的支付方式接口
        /// </summary>
        /// <returns></returns>
        public ICollection<IPayment> GetPayments()
        {
            var paymentManager = new PaymentManager();

            IList<IPayment> payments = paymentManager.LoadPlugins();

            return payments;
        }
Esempio n. 33
0
 public PaymentsController()
 {
     PaymentService = new PaymentsService(AppService.Current.DataContextV2);
     PaymentManager = new PaymentManager(AppService.Current.DataContextV2, PaymentManagerConfiguration.Create());
 }
Esempio n. 34
0
        static void Main(string[] args)
        {
            Account sellerAccount;
            int     idSeller      = 0;
            string  accountSeller = "";
            decimal amountSeller  = 0;

            Account customerAccount;
            int     idCustomer      = 0;
            string  accountCustomer = "";
            decimal amountCustomer  = 0;

            User   seller;
            int    idSellerUser   = 0;
            string sellerName     = "";
            string sellerPassword = "";

            User   customer;
            int    idCustomerUser   = 0;
            string customerName     = "";
            string customerPassword = "";


            bool loginAccountSuccess = false;
            bool findCustomerSuccess = false;
            bool findSellerSuccess   = false;
            bool saveSuccess         = false;
            bool flagDbError         = false;


            int            idPayment = 0;
            int            id        = 0;
            PaymentManager activePayment;
            string         informationTransmitted = "";
            string         personnalInformation   = "";


            DateTime now = DateTime.Now;



            seller          = new User(idSellerUser, sellerName, sellerPassword);
            customer        = new User(idCustomerUser, customerName, customerPassword);
            sellerAccount   = new Account(idSeller, accountSeller, amountSeller, seller);
            customerAccount = new Account(idCustomer, accountCustomer, amountCustomer, customer);

            ///First, the function reads the arguments and it has to only have 3 or it displays a error message
            if (args.Length != 3)
            {
                Console.WriteLine("Remplisser les trois données necéssaires");
            }
            else
            {
                Console.WriteLine("request-payment " + args[0] + " " + args[1] + " " + args[2]);

                ///After, the function search the first account write and verify it's a seller account
                try
                {
                    sellerAccount     = new Account(idSeller, args[0], amountSeller, seller);
                    findSellerSuccess = sellerAccount.findAccount(idSeller, args[0], amountSeller, id);
                }
                catch (DbError)
                {
                    flagDbError = true;
                }
                if ((findSellerSuccess == false) || (!args[0].Contains("VA-")))
                {
                    Console.WriteLine("Aborted. invalid vendor account number");
                }
                else
                {
                    ///Then, the function search the second account write
                    try
                    {
                        customerAccount     = new Account(idCustomer, args[1], amountCustomer, customer);
                        findCustomerSuccess = customerAccount.findAccount(idCustomer, args[1], amountCustomer, id);
                    }
                    catch (DbError)
                    {
                        flagDbError = true;
                    }
                    if (findCustomerSuccess == false || args[0] == args[1])
                    {
                        Console.WriteLine("Aborted. invalid customer account number");
                    }
                    else
                    {
                        ///Finaly, the function verify the amount of the request and if it's over the amount of the second account, the request is cancel
                        if (Convert.ToDecimal(args[2]) > customerAccount.Amount || Convert.ToDecimal(args[2]) < 0)
                        {
                            Console.WriteLine("Aborted, invalid amount");
                        }
                        else
                        {
                            try
                            {
                                activePayment = new PaymentManager(idPayment, id, args[0], now, Convert.ToDecimal(args[2]), informationTransmitted, personnalInformation, idSeller);
                                saveSuccess   = activePayment.addPayment(customerAccount, idSeller, now, Convert.ToDecimal(args[2]), informationTransmitted, personnalInformation);
                            }
                            catch (DbError)
                            {
                                Console.WriteLine("Du à un problème avec notre serveur, vos données sont actuellement limitées voir indisponibles", "Problème de connexion");
                                flagDbError = true;
                            }
                            if (saveSuccess == true)
                            {
                                Console.WriteLine("Success, payment done");
                            }
                        }
                    }
                }
            }
        }
Esempio n. 35
0
        public object Get(string apikey, int paymentId)
        {
            var manager = new PaymentManager(apikey);

            return(manager.GetInfoAbountPayment(paymentId));
        }
        public void VerifyTransactionDetails(
            TransactionTypeString typeString,
            double amount,
            PaymentManager.CCType creditCardType,
            string ccNumber,
            string holderName,
            int eventId)
        {
            string detailDIVLocator = "//div[@id='pageContent']";
            string detailNameLocatorFormat = detailDIVLocator + "//th[text()='{0}']";
            string detailResponseLocatorFormat = detailNameLocatorFormat + "/following-sibling::td";

            VerifyTool.VerifyValue(
                StringEnum.GetStringValue(typeString),
                UIUtil.DefaultProvider.GetText(string.Format(detailResponseLocatorFormat, "Type:"), LocateBy.XPath),
                "Transaction type: {0}");

            VerifyTool.VerifyValue(
                MoneyTool.FormatMoney(amount),
                UIUtil.DefaultProvider.GetText(string.Format(detailResponseLocatorFormat, "Amount:"), LocateBy.XPath),
                "Transaction amount: {0}");

            VerifyTool.VerifyValue(
                creditCardType.ToString(),
                UIUtil.DefaultProvider.GetText(string.Format(detailResponseLocatorFormat, "Credit Card Type:"), LocateBy.XPath),
                "Transaction credit card type: {0}");

            VerifyTool.VerifyValue(
                Utility.GetEncryptedCCNumber(ccNumber),
                UIUtil.DefaultProvider.GetText(string.Format(detailResponseLocatorFormat, "Credit Card Number:"), LocateBy.XPath),
                "Transaction credit card number: {0}");

            VerifyTool.VerifyValue(
                holderName,
                UIUtil.DefaultProvider.GetText(string.Format(detailResponseLocatorFormat, "Cardholder Name:"), LocateBy.XPath),
                "Transaction cardholder name: {0}");
        }
Esempio n. 37
0
 public virtual IKlarnaServiceApi Create(IPayment payment, IMarket market)
 {
     return(Create(PaymentManager.GetPaymentMethod(payment.PaymentMethodId), market.MarketId));
 }