Order online and Pay Later With Sitecore Commmerce


Does your company want to offer online ordering with the ability to pay later? XCentium is the first to offer this capability with Sitecore Experience Commerce.  

A lot of shops have started offering Pay Later option to customers. For example, when you are making a reservation for hotel room, you are given an option to Pay Later. If your store allows Pick up in store, the customer may just want to pay in store while picking up the merchandise, but don’t forget, the customer would like to place an order online because he/she found the right product. Also, pay later is a very common scenario in B2B.

Let me talk through the various steps of allowing a Pay Later payment option using Sitecore Commerce Engine.

 

Plugin:

You can have a look at the plugin here

If you need access to github repo, just send us an email.

 

Implementation

The ootb payment methods are Federated or Giftcard. If you notice, both of these payment components are derived from a base component called PaymentComponent (Sitecore.Commerce.Plugin.Payments.PaymentComponent). When an order is being created, a validation is performed where the order balance must match the payment total. The order balance is selected from the cart totals and the payment total is selected from PaymentTotal component of the order. The PaymentTotal is the sum of all the components that are derived from PaymentComponent base class.

So in order to allow a pay later payment option, there has to be a component added to cart (before it is converted to an order) that derives from Sitecore.Commerce.Plugin.Payments.PaymentComponent and it should hold the balance that the customer has to pay.

Let us call this component - PayLaterComponent

 

    public class PayLaterComponent : PaymentComponent
    {
        public DateTime DateCreated { get; set; }

        public PayLaterComponent(Money money) : base(money)
        {
            DateCreated = DateTime.UtcNow;
        }
    }

How to set this component

On the payment page you present the user with four payment options :

  1. Pay Now using Credit Card.
  2. Pay Now using Gift Card,
  3. Pay Later (in Store or Online)
  4. Pay Now using Crypto (#hodl)  (Check my blog here Cryptocurrencies and Sitecore Commerce)

User selects Pay Later, in the back end you will call a custom commerce api (Let's say /api/AddPayLaterPaymentToOrder), this API will perform some basic validations (as in Federated Payment option) and adds a new component to the cart, the one that we declared above. The value will be equal to the order total with tax and shipping. 

This is how the core logic in the block looks like

// Get the current cart

var cartId = arg.CartId;
FindEntityArgument findEntityArgument = new FindEntityArgument(typeof(Cart), cartId, false);
Cart cart = await _findEntityPipeline.Run(findEntityArgument, context) as Cart; // Add the paylater component to cart var amount = decimal.Parse(arg.Amt); PayLaterComponent payLaterComponent = new PayLaterComponent(new Money(context.CommerceContext.CurrentCurrency(), amount)); cart.Components.Add(payLaterComponent);

 

 

After this block, of course you will persist the cart using PersistCartBlock. BUT before persisting the cart, remember to call the pipelines ICalculateCartLinesPipeline and ICalculateCartPipeline so that the totals are appropriately calculated on the cart

 

That's it, you can now let the customers successfully checkout using a pay later option on the website. 

 

Now what? How do i accept a payment for the order when the customer is ready to pay (either via order history online or in store)

 

To allow the customer pay for the order (not cart anymore, see my blog here to check out how to make changes on a submitted order) or allow them to call and pay through an admin portal, we need a new api in the commerce that will do the following:

 

1. Accept the Federated Payment

2. Remove the Paylater component or Add a negative Paylater component for auditing

 

After this block, of course you will persist the cart using PersistCartBlock. BUT before persisting the cart, remember to call the pipelines ICalculateCartLinesPipeline and ICalculateCartPipeline so that the totals are appropriately calculated on the cart

 

There are other things that can be implemented based on your shop requirements:

 

1. Do not allow the shipment of product if payment has not been received (unless Pick up in store)

2. A minion that notifies the user that Payment is due and merchandise won't be shipped until payment is received.

3. If the order is time sensitive, then do not allow pay later.

4. Do not allow pay later on Back-ordered items. 

5. Allow Pay later for orders only when fulfillment type is picked up in store.

6. If you offer pick up in store, then adding a pay later in store option can offer a great experience for a customer.

 

 Sitecore Commerce Engine is ready for any challenge coming its way and allows you to stay ahead of your competitors. Elevate the experience.

 

buy now pay later

 

 

SEARCH ARTICLES