Devices
Device Registration Overview
The ZATCA (Fatoora) e-invoicing system requires device registration before submitting invoices. This guide covers all aspects of device implementation and management.
Implementation Steps
1. Add Device Trait
First, add the HasZatcaDevice
trait to your model:
2. Available Device Methods
The HasZatcaDevice
trait provides several methods for device management:
Device Registration Process
Basic Registration
Using Device Facade
The Device Facade provides high-level methods for device management:
Device Database Schema
The devices_zatca
table stores all device-related information:
id
Primary Key
Unique identifier
deviceable_type
String
Model type
deviceable_id
Integer
Model ID
request_id
String
ZATCA request ID
status
String
Device status
disposition_message
Text
Status message
binary_security_token
Text
Security token
secret
Text
Device secret
errors
JSON
Error messages
private_key
Text
Private key
public_key
Text
Public key
csr_content
Text
CSR content
created_at
Timestamp
Creation date
updated_at
Timestamp
Last update date
Security Considerations
Device Security Features
Private Key Protection
Secure storage of device private keys
Encryption at rest
Access control through Laravel policies
Token Management
Secure handling of binary security tokens
Automated token refresh
Token validation on each request
Error Handling
Comprehensive error logging
Secure error message storage
Error tracking and monitoring
Best Practices
Device Registration
Always validate OTP before registration
Store device credentials securely
Implement proper error handling
Device Management
Regularly check device status
Implement automatic device reactivation
Monitor device errors and warnings
Security
Use environment variables for sensitive data
Implement proper access controls
Regular security audits
Common Issues and Solutions
Device Registration Issues
Invalid OTP
Ensure OTP is valid and not expired
Verify OTP format matches ZATCA requirements
Registration Failures
Check company data completeness
Verify network connectivity
Validate API credentials
Device Activation
Ensure proper activation sequence
Check for missing credentials
Verify device status before use
Environment Configuration
Add these device-related variables to your .env
file:
Error Handling Examples
Additional Resources
API Reference
Troubleshooting Guide
Last updated