Purchase

Making a Purchase
After placing an order, once the client has filled in all mandatory fields and confirmed the purchase by clicking the button, pass the order information to Sailplay via the purchase creation method in the Sailplay API (method: purchases/new).
The process of making an order itself is similar to cart calculation in terms of parameter structure: the difference is that calculation does not fix the purchase, whereas the purchase creation method records the result as a completed purchase.
You can create a purchase by passing the same parameters to /purchases/new/ as in /marketing-actions/calc/.
However, if you pass the order composition again, there is a risk that the final cost will differ from the last calculation.
Therefore, it is recommended when creating a purchase to pass the id from the last /marketing-actions/calc/ calculation in the cart_id parameter, instead of the full order composition.
Order Confirmation
Important: until the purchase is confirmed, the client will not be able to use the accrued points.
The most common confirmation logic for offline stores is via a return period (for example, 14 days). If the product has not been returned within the return period, the purchase is considered confirmed. Such a scenario can be configured in Sailplay via an automatic rule.
In online stores, the logic often differs: a purchase may be considered confirmed:
- upon delivery to the pickup point / delivery address
- upon payment
If confirmation should depend on an event/action rather than time, use the order confirmation method in the Sailplay API (method: purchases/confirm).
Partial and Full Order Return
If after placing an order the client decides to remove one or more positions, pass the information to Sailplay via the partial return method in the Sailplay API (method: purchases/returns/create).
This is necessary to:
- deduct accrued points for the returned positions
- return to the balance points that were deducted against the cost of these positions
If the client completely cancels the order after placement, it is recommended to use the purchase deletion method in the Sailplay API (method: purchases/delete). In this case, similar to a partial return, the points for the order will be fully returned.