Checkout flow
Apply promotions, rewards and points to a cart, then record the purchase, at a register or in a web shop.
Every checkout request takes the cart in the same shape as POST /transactions: the member, grossValue and the products with sku, name, category, brand, quantity, price and grossValue. Each step returns the cart with its changes, and you pass that cart on to the next step. The cart collects what was applied in usedBenefits.
At the register
| Step | Request | What it does |
|---|---|---|
| 1 | POST /promotions/evaluate/mutation | Applies the member's promotions and returns the cart with new prices. |
| 2 | POST /rewards/evaluate/mutation | Applies the coupons and gift cards the member chose. Send the cart from step 1. |
| 3 | POST /transactions/calculate-deduction | Spreads a payment with points over the items. Send the cart from step 2 and points. |
| 4 | POST /transactions | Records the purchase and uses up the benefits. Send the final cart. |
Skip the steps you don't need. Without coupons, go straight from step 1 to step 3.
1. Promotions
Send the cart. The response has the adjusted prices, the discount per line and usedBenefits.promotions.
curl -X POST https://api.staging.scops-loyalty.com/promotions/evaluate/mutation \
-H "X-Api-Key: $SCOPS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"memberId": "MEMBER_ID",
"documentIdentifier": "INV-10482",
"grossValue": 12990,
"currency": "RSD",
"products": [
{ "sku": "HP-100", "name": "Wireless headphones", "brand": "Sony", "category": "Electronics", "quantity": 1, "price": 12990, "grossValue": 12990 }
]
}'2. Rewards
Send the data from step 1, and add the coupons and gift cards in claimedRewardId (one ID or a list). For a gift card, amount sets how much of its balance to use. Without it, the card covers as much as it can.
This step applies only rewards with Enable rules on. If your register calculates coupon discounts itself, skip this step and list the rewards in usedBenefits.rewards in step 4. Rewards explains both options.
3. Points
Send the cart from step 2 with points, the number of points the member wants to use. Scops Loyalty checks the balance in the default wallet, converts the points with its unit value and spreads the discount over the items by their value. The response has the new prices and usedBenefits.units.
4. Record the purchase
Send the final cart to POST /transactions. Scops Loyalty takes the points from the wallet, marks the rewards as used and counts the promotion uses. The purchase then runs through your active campaigns, which can give the member new points.
Add customAttributes.usedPoints with the points used, so financial analytics counts them.
In a web shop
A web order is paid when it's placed but finished later, for example after delivery. Scops Loyalty holds the member's benefits in the meantime.
- While the cart is open, run steps 1 to 3 from the register flow.
- When the order is placed, send
POST /transactions/web-orderwith yourorderId, thememberIdandusedBenefits. Points are blocked in the member's wallet, rewards are marked as used and promotion uses are counted. With points, also sendblockFor(for example{ "days": 30 }) orblockUntil. - When the order is finished, record it with
POST /transactionsand the same order ID incustomAttributes.orderId. The blocked points are spent, and the benefits aren't applied a second time. - If the order is canceled before that, send
POST /transactions/cancel-orderwith{ "orderCodes": ["WEB-0001"] }. The blocked points go back to the member, and the rewards and promotion uses are released. An order that was already recorded in step 3 can't be canceled this way.
Use your order number both as the orderId and as the transaction's documentIdentifier. Cancellations and returns then find everything the order used by that one code.
curl -X POST https://api.staging.scops-loyalty.com/transactions/web-order \
-H "X-Api-Key: $SCOPS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"orderId": "WEB-0001",
"memberId": "MEMBER_ID",
"blockFor": { "days": 30 },
"usedBenefits": {
"units": { "amount": 200 },
"rewards": [{ "claimedRewardId": "CLAIMED_REWARD_ID" }]
}
}'Returns
Record a return with POST /transactions, type: return and the original purchase's documentIdentifier in linkedTransactionId. A return campaign takes back the points the purchase earned.
To give the member back the points, rewards and promotion uses a purchase used, send POST /transactions/return-used-benefits with the purchase's documentIdentifier as orderCode, for example { "orderCode": "WEB-0001" }.