Create Transaction
Create a purchase transaction for a user, automatically calculating and awarding loyalty points. This endpoint supports both earning points and redeeming points in a single transaction.
This is the primary endpoint for e-commerce integrations (WooCommerce, Shopify, etc.) to award and redeem points. It requires Shop API authentication.
Path Parameters
Language code (e.g., en, lt)
Authentication
API key from Partners Portal
API secret from Partners Portal
Request Body
Required Fields
User’s ID in the system (required if user_email not provided)
User’s email address (required if user_id not provided)
Unique order/transaction reference from your system Example: "WC-12345", "ORDER-2024-001"
Total order amount for points calculation Example: 49.99
Optional Fields
Manual points override (if not provided, calculated from card settings)
Transaction description (auto-generated if not provided)
Shop ID for multi-location tracking
Specific partner card template to use
Existing user loyalty card ID to use
Points Redemption
Number of points to redeem for discount
Discount amount applied via points redemption
Cart Items (for analytics)
Array of purchased products
Additional custom metadata
Response
Indicates if transaction was created successfully
Points earned from this purchase
User’s new total points balance
Loyalty card used/created
cURL - Basic
cURL - With Points Redemption
JavaScript
PHP - WooCommerce Integration
curl -X POST "https://staging-api.loyalty.lt/en/shop/transactions/create" \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key" \
-H "X-API-Secret: your_api_secret" \
-d '{
"user_email": "[email protected] ",
"order_id": "WC-12345",
"order_total": 49.99,
"currency": "EUR"
}'
Success Response (200)
Duplicate Order (409)
User Not Found (404)
Insufficient Points for Redemption (400)
Validation Error (422)
{
"success" : true ,
"message" : "Points awarded successfully" ,
"data" : {
"transaction_id" : 12345 ,
"points_awarded" : 500 ,
"points_balance" : 1750 ,
"loyalty_card_id" : 567 ,
"card_number" : "123-456-789" ,
"user_id" : 123 ,
"order_total" : 49.99 ,
"currency" : "EUR"
}
}
Points Calculation
Points are calculated based on the partner card’s configuration:
base_points = (order_total / currency_amount) × points_per_currency
visit_bonus = points_per_visit
total_points = round(base_points) + visit_bonus
If round_points_up is true, points are rounded up. Otherwise, rounded down.
Example Calculation
Card settings:
points_per_currency: 10
currency_amount: 1.00
points_per_visit: 5
round_points_up: true
For €15.50 order:
Base: (15.50 / 1.00) × 10 = 155 points
Visit bonus: +5 points
Total: 160 points
Automatic Card Creation
If the user doesn’t have a loyalty card for your partner:
System finds the partner’s default card template (auto_assign: true)
Creates a new loyalty card for the user
Awards initial bonus points (if configured)
Processes the transaction
Push Notifications
When points are awarded, users receive a push notification in their mobile app:
“Operacija atlikta”
: . Gavote taškų!
Alias Endpoint
For backward compatibility, this endpoint is also available as:
POST /{locale}/shop/transactions/award-points