Click on any error scenario below to see how the error message is displayed to users.
Not enough tickets available
Error Data:
{ "code": "INSUFFICIENT_TICKETS", "message": "Endast 3 lotter tillgängliga", "available_tickets": 3, "requested_qty": 5, "sold_tickets_count": 97, "max_tickets": 100 }
Payment succeeded but only partial allocation
{ "code": "PARTIAL_ALLOCATION", "message": "Betalningen genomfördes delvis innan lotteriet nådde maximalt antal lotter", "allocated_tickets": [ 98, 99, 100 ], "refund_amount": 100, "requested_qty": 5, "allocated_qty": 3 }
Payment succeeded but no tickets allocated
{ "code": "ALLOCATION_FAILED", "message": "Inga lotter kunde allokeras, full återbetalning skickas", "refund_amount": 250, "requested_qty": 5 }
Partial allocation but automatic refund failed
{ "code": "PARTIAL_ALLOCATION_REFUND_FAILED", "message": "Betalningen genomfördes delvis men automatisk återbetalning misslyckades", "allocated_tickets": [ 98, 99 ], "refund_amount": 150, "requested_qty": 5, "allocated_qty": 2, "refund_error": "Network timeout when contacting Swish refund API" }
No allocation and automatic refund failed
{ "code": "ALLOCATION_FAILED_REFUND_FAILED", "message": "Inga lotter kunde allokeras och automatisk återbetalning misslyckades", "refund_amount": 250, "requested_qty": 5, "refund_error": "Swish API returned error code 500" }
Payment already exists for this mobile number
{ "code": "PAYMENT_EXISTS", "message": "En Swishbetalning finns redan för detta nummer", "mobile": "46701234567", "swish_error_code": "PAYMENT_ALREADY_IN_PROGRESS", "swish_error_message": "A payment request already exists for this mobile number" }
Geographic validation failed
{ "code": "INVALID_GEO", "message": "Du befinner dig inte i ett tillåtet område för detta lotteri", "type": "OUTSIDE_ALLOWED_KOMMUNER", "user_kommun": "Uppsala" }
Lottery is not active for purchases
{ "code": "LOTTERY_NOT_ACTIVE", "message": "Lotteriet är inte aktivt för köp" }
Swish payment failed
{ "code": "SWISH_PAYMENT_FAILED", "message": "Ett fel har inträffat när betalningen skickades till Swish", "swish_status_code": 422, "swish_error_code": "PAYEE_NOT_ENROLLED", "swish_error_message": "Payee not enrolled in Swish" }
Payment failed for unknown reason
{ "code": "PAYMENT_FAILED", "message": "Betalningen misslyckades", "swish_status": "DECLINED" }
These error messages correspond to the new structured error responses from the backend API:
POST /lotteries/[slug]/transactions
GET /lotteries/[slug]/transactions/[id]