In this article, we’re going to consider how orders are processed in a Spree Commerce-based store. We’ll elaborate on a typical procedure and what you should know when working with a custom one.
Authorization and withdrawal
Processing of credit card payments consists of two steps: authorization and withdrawal. A Payment is considered authorized when the provider of a credit card confirms that the owner of the credit card has enough funds to make the purchase, whereas successful withdrawal of a payment assumes that the customer has transferred a specific amount of money to the provider.
In some E-commerce platforms, withdrawal is carried out automatically right after the authorization procedure while the other platforms require customers to check each authorized payment and confirm the withdrawal of funds manually. As a rule, the latter option is considered the default one.
Automatic or manual withdrawal?
Choosing between these two options depends on the type of business you have. If you’re dealing with large volumes of orders, which require fast processing and a minimum amount of customer involvement, then the automatic withdrawal is your choice.
However, if you need to often clarify purchases with customers or the time period between the moment of creating orders to their delivery is quite long or the orders require some additional processing outside Spree Commerce, then you should go for manual withdrawal.
State of order
Every order in Spree Commerce can be in one of the three states:
- Control (confirmation)
Most of the actions that take place here are directed at gathering information about the customer. One of the most important steps in this state is “Payment”. At this point, the store gathers customer’s payment information, e.g. the information about their credit card. However, you shouldn’t confuse this step with the state “Payment”, since no actions are carried out with the credit card.
When the order reached its final step, it’s sent to the system. After it’s saved, the order becomes available to admins and managers of the store in the admin panel. This means that the order is now ready to be processed on the store’s side.
This state is more complex than the previous one, because the order is always completed in several transactions. Oftentimes, an order initiates more than one payment. Sometimes there are also situations when one payment is authorized while the other one is declined. Each of the payments is processed independently and has its own state (also independent), which is recorded in Spree Commerce.
The state “Payment” contains the following steps.
Control means that the order isn’t ready for payment yet. Processing means that the order has been sent to the payment gateway for authorization of the payment. If the response is positive, the payment is considered authorized. Then, it receives the status “pending”, in which it waits till the funds from the credit card will be received. If the transaction is successful, the order is completed. If the withdrawal of funds fails, the order receives the status void.
The general statuses of a payment (at all stages of the order). The combination of the statuses of all payments linked to order, comprise the total payment status of the order — managers and administrators see in the admin panel. Based on these statuses, they can perform further actions on payments and orders.
The possible statuses of a payment:
- Debt: when the funds are insufficient to cover the total price of the order. For example, if one of two payments that are connected to the order weren’t paid, or the only payment that is expected to made hasn’t been paid (needs to be confirmed by the buyer).
- Paid: when the withdrawn funds fully cover the price of the order (the order is ready for delivery).
- Credit (credit debt): this status is assigned if the buyer charged more money than it’s displayed in the order (refund is required). Also, this status can be mistakenly assigned after all payments for the order were deleted.
- Void: when one of the payments connected to the order receives an error (is cancelled).
The same goes as with payments, there can be multiple deliveries connected to one order. Different parts of an order can be delivered in different ways, at different times, to different addresses. In this article, we will assume that the order has only one delivery connected to it.
As with payments, the combination of the statuses of deliveries gives the overall order status. In most cases, the following statuses:
- Ready: when the items are prepared and can be delivered to the customer.
- Pending: the delivery cannot be completed (waiting for stock availability).
- Delivered: the items are delivered to the customer, the delivery is complete.
Let’s consider how to work with orders in a step-by-step way:
- Log in to the admin panel of the store. You will be redirected to the page with orders. The last completed orders will be displayed at the top of the list of orders.
- Select the order for payment. Select the order to be processed (usually it’s the orders with the payment status “Debt” or “Failed”, click directly on this link). You will be taken to the payment page associated with the selected order.
- Withdrawal of funds. In most cases, it’s a simple operation with payments ready for withdrawal. If an order has a payment with an error, you can edit the amount of payment or create a new payment to record the receipt of funds from the outside, which has not been at Spree Commerce. When the sum of payments corresponds to the price of the order, you’ll see that it’ll receive the status paid (you can see it in the list of orders).
- Select the order for delivery. In the orders list, click on the “Edit” button you will be redirected to the edit page of the order, you will be able to edit any information about the order, including its specification, apply discounts, and change the delivery information.
- Delivery. In the admin panel, you should see the following: “[Code] order ready from [warehouse]” and the delivery button. By clicking the button, the status of the order will be updated to Delivered.
As you can see, everything is pretty simple. Spree Commerce allows for customizing any elements in the system, including the procedure of making orders and their statuses. In other words, with an adequate amount of resources and time, you can easily change the out-of-the-box functionality to fit your needs and requirements.
Just like any E-commerce platform, Spree Commerce is based on certain assumptions about how a typical process of making orders works. In most cases, the functionality of the out-of-the-box version is enough. However, the key to the sweet spot is the ability to customize Spree Commerce to fit the business processes of your company and the ability to customize the business processes of the company for maximum efficiency from automation of business. If you have any questions related to Spree Commerce, we’d be more than happy to help!
Processing Orders In Spree Commerce was originally published in JetRuby on Medium, where people are continuing the conversation by highlighting and responding to this story.
This post first appeared on JetRuby Agency - Featured Technical Stories Based In Our Experience, please read the originial post: here