Credid Card Capture Type for Shippable and non-Shippable Products - Ecommerce - Ecommerce - Progress Community

Credid Card Capture Type for Shippable and non-Shippable Products


Credid Card Capture Type for Shippable and non-Shippable Products

  • Credid Card Capture Type for Shippable and non-Shippable Products
  • We presently sell a number of on-demand training videos and documents that use the "Service" product type. The products are immediately available to the customer after they have completed checkout and payment process so our credit card payment method (Authorize.Net AIM) uses the "Authorize and Capture" payment type. 

     Since many of our orders come in outside of our business hours this works well for us; there's no need to manually process the order and the customer has instant access to their purchased content.

    We're about to start adding shippable goods to our product catalog.  I'm guessing that using "Authorize and Capture" before shipping the product is a no-no and that I should be using the "Authorize" payment type for shippable products.  I'm running SF 6.1 and there doesn't seem to be a way to set payment type by product category.

    Anyone have advice on how to best handle this? 

    Thanks -- Steve

  • Hello Steve,

    In order to achieve your needs you can try the following solution:
    1) Create two or more Payment Methods with different options you need.

    2) Create a new class inheriting PaymentStep and add the following code sample:
    using System;
    using System.Linq;
    using System.Web;
    using System.Web.Script.Serialization;
    using System.Web.UI.WebControls;
    using Telerik.Sitefinity.Configuration;
    using Telerik.Sitefinity.Ecommerce.Orders.Model;
    using Telerik.Sitefinity.Modules.Ecommerce;
    using Telerik.Sitefinity.Modules.Ecommerce.BusinessServices;
    using Telerik.Sitefinity.Modules.Ecommerce.Catalog;
    using Telerik.Sitefinity.Modules.Ecommerce.Orders;
    using Telerik.Sitefinity.Modules.Ecommerce.Orders.Configuration;
    using Telerik.Sitefinity.Modules.Ecommerce.Orders.Web.UI.CheckoutViews;
    namespace SitefinityWebApp.Examples
        public class CustomPayment : PaymentStep
            protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
                CartOrder shoppingCart = this.GetShoppingCartForUser(base.OrdersManager);
                // Check for at least one shippable product in the shopping cart
                CartDetail cartDetail = shoppingCart.Details.Where(d => d.IsShippable == true).SingleOrDefault();
                var availablePaymentMethods = EcommerceBusinessServicesFactory
                    .GetApplicablePaymentMethods(base.CheckoutState, this.GetShoppingCartForUser(base.OrdersManager))
                if (cartDetail != null// At least one shippable product is available in the Cart
                    var paymentMethod = availablePaymentMethods
                        .Where(po => po.Title == "method 1")
                    var isFreePayment = false; // Implement logic for free payment, if needed
                    if (paymentMethod != null)
                        bool methodSelected = false;
                        if (isFreePayment)
                            var listItem = new ListItem(Telerik.Sitefinity.Localization.Res.Get<OrdersResources>().Free, Guid.Empty.ToString());
                            listItem.Attributes["data-notsupportingcc"] = Convert.ToString(true);
                            this.PaymentMethodList.SelectedIndex = 0;
                            var listItem = new ListItem(paymentMethod.Title, paymentMethod.Id.ToString());
                            if (paymentMethod.PaymentMethodType == PaymentMethodType.Offline
                                || !IsPaymentMethodSupportingCards(paymentMethod))
                                listItem.Attributes["data-notsupportingcc"] = Convert.ToString(true);
                            if (!methodSelected)
                                this.PaymentMethodList.SelectedIndex = 0;
            public static bool IsPaymentMethodSupportingCards(PaymentMethod paymentMethod)
                var serializer = new JavaScriptSerializer();
                var paymentProcessorConfig = Config.Get<PaymentProcessorConfig>().PaymentProcessorProviders.Values.Where(x => x.IsActive && x.Id.ToString() == paymentMethod.PaymentProcessorId.ToString().ToUpperInvariant()).FirstOrDefault();
                if (paymentProcessorConfig != null)
                    Type settingsType = paymentProcessorConfig.SettingsType;
                    dynamic settings = serializer.ConvertToType(serializer.Deserialize(paymentMethod.PaymentProcessorSettings, settingsType), settingsType);
                    return (settings.ProcessorCreditCards != null && settings.ProcessorCreditCards.Length != 0);
                return false;
            public Guid GetShoopingCartId()
                HttpCookie shoppingCartCookie = HttpContext.Current.Request.Cookies[EcommerceConstants.OrdersConstants.ShoppingCartIdCookieName];
                if (shoppingCartCookie == null || string.IsNullOrWhiteSpace(shoppingCartCookie.Value))
                    return Guid.Empty;
                if (!shoppingCartCookie.Value.IsGuid())
                    throw new InvalidOperationException("cartOrderId string cannot be parsed as a GUID; please provide a valid cartOrderId value.");
                return new Guid(shoppingCartCookie.Value);
            public CartOrder GetShoppingCartForUser(OrdersManager ordersManager)
                Guid shoppingCartId = GetShoopingCartId();
                CartOrder shoppingCart = ordersManager.TryGetCartOrder(shoppingCartId);
                if (shoppingCart == null)
                    shoppingCartId = Guid.NewGuid();
                    shoppingCart = ordersManager.CreateCartOrder(shoppingCartId, null);
                return shoppingCart;

    3) Go to Design > Widget Templates > Checkout and register the CustomPayment
    in my case the example is in folder Examples:
    <%@ Register TagPrefix="custom" Namespace="SitefinityWebApp.Examples" Assembly="SitefinityWebApp" %>

    and update the Shipping options:
    <telerik:RadPageview id="paymentView" runat="server" CssClass="sfStep2Wrp">
     <custom:CustomPayment id="paymentStep" runat="server" />

    4) Build the solution.

    In that way the payment options will depends on the product/s in the shopping cart.

    Only one (appropriate) payment method will be added and displayed on Payment step or the list of Payment methods needed in case of extending the logic above.

    Svetoslav Manchev
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
  • Hi Svetoslav,

    Thanks!  It may take a couple of days until I'm able to give this a go.  I'll report back once I've had a chance to test it.