zithara/webhook
最新稳定版本:1.0.3
Composer 安装命令:
composer require zithara/webhook
包简介
Zithara Magento 2 plugin for syncing Customers, Orders and Cart data from merchants magento ecommerce to Zithara.AI CRM.
README 文档
README
Overview
The Zithara Webhook module enables real-time data synchronization between Magento 2 and Zithara's API. It handles various events including cart operations, customer actions, and order processing.
Features
- Real-time cart synchronization
- Customer event tracking
- Order status updates
- Secure API authentication
- Queue-based processing
- Robust error handling and logging
Architecture
Core Components
1. Event Observers
- Cart Events (
CartSave,CartUpdate, etc.) - Customer Events (
CustomerSave,CustomerLogin, etc.) - Order Events (
OrderCreate,OrderUpdate, etc.) - Payment Events (
PaymentCapture,PaymentRefund, etc.)
2. Queue System
- Message Publishers
- Queue Processors
- Event-specific handlers
3. API Integration
- Authentication management
- API endpoints configuration
- Request/Response handling
Directory Structure
app/code/Zithara/Webhook/
├── Block/
│ └── Adminhtml/
│ └── Config/
│ └── Edit/
│ └── Form.php
├── Controller/
│ └── Adminhtml/
│ └── Config/
│ ├── Index.php
│ └── Save.php
├── Helper/
│ └── Data.php
├── Model/
│ ├── Config.php
│ ├── Config/
│ │ └── ApiEndpoints.php
│ ├── Queue/
│ │ ├── Api/
│ │ │ └── ZitharaApiClient.php
│ │ ├── CartProcessor.php
│ │ ├── CustomerProcessor.php
│ │ ├── OrderProcessor.php
│ │ └── WebhookProcessor.php
│ └── ResourceModel/
│ └── Config/
│ └── Collection.php
├── Observer/
│ ├── Cart/
│ │ ├── CartAddProduct.php
│ │ ├── CartDelete.php
│ │ ├── CartRemoveItem.php
│ │ ├── CartSave.php
│ │ └── CartUpdate.php
│ ├── Customer/
│ │ ├── CustomerAddressSave.php
│ │ ├── CustomerDelete.php
│ │ ├── CustomerEdit.php
│ │ ├── CustomerLogin.php
│ │ ├── CustomerLogout.php
│ │ └── CustomerSave.php
│ ├── Order/
│ │ ├── OrderCancel.php
│ │ ├── OrderCreate.php
│ │ ├── OrderPayment.php
│ │ ├── OrderRefund.php
│ │ └── OrderUpdate.php
│ └── Payment/
│ ├── PaymentCapture.php
│ ├── PaymentFail.php
│ └── PaymentVoid.php
└── etc/
├── adminhtml/
│ ├── menu.xml
│ └── routes.xml
├── communication.xml
├── config.xml
├── crontab.xml
├── db_schema.xml
├── di.xml
├── events.xml
├── module.xml
├── queue_consumer.xml
├── queue_publisher.xml
└── queue_topology.xml
Configuration
Admin Configuration
Path: Stores > Configuration > Zithara > Webhook Settings
General Settings
- Enable/Disable Module
- API Credentials
- Client ID
- Client Secret
- Event Selection
- Retry Settings
- Maximum Retries
- Retry Delay
Queue Configuration
- Queue Names:
zithara.webhook.eventszithara.customer.eventszithara.order.eventszithara.cart.events
API Integration
Authentication
The module uses OAuth2 for API authentication:
- Obtains access token using client credentials
- Manages token expiration and refresh
- Securely stores credentials
Endpoints
Base URL: https://dev-pos-api.zithara.com/v1
Available Endpoints:
/generate-access-token- Authentication/cart- Cart operations/customer- Customer operations/order- Order operations
Data Formats
Cart Data Structure
{
"customer": {
"platform_customer_id": "string",
"first_name": "string",
"last_name": "string",
"name": "string",
"whatsapp_phone_number": "string",
"email": "string|false",
"custom_attributes": {}
},
"cart_item": [
{
"platform_cart_item_id": "string",
"price": "float",
"product_id": "integer",
"quantity": "float"
}
],
"cart": {
"currency": "string",
"platform_cart_id": "string",
"name": "string",
"created_at": "datetime",
"total_tax": "float",
"total_price": "float",
"shopify_customer_id": "integer"
}
}
Event Handling
Cart Events
checkout_cart_save_aftercheckout_cart_update_items_aftercheckout_cart_product_add_aftercheckout_cart_deletesales_quote_remove_item
Customer Events
customer_save_aftercustomer_logincustomer_logoutcustomer_address_save_aftercustomer_delete_after
Order Events
sales_order_save_aftersales_order_place_afterorder_cancel_aftersales_order_creditmemo_save_after
Payment Events
sales_order_payment_paysales_order_payment_capturesales_order_payment_voidpayment_cancel
Error Handling
Logging
- Location:
var/log/zithara_webhook.log - Log Levels:
- ERROR: Critical failures
- WARNING: Non-critical issues
- INFO: Important operations
- DEBUG: Detailed debugging
Retry Mechanism
- Failed events are requeued
- Configurable retry attempts
- Exponential backoff
Installation
Requirements
- Magento 2.4.x
- PHP 7.4 or higher
- RabbitMQ/MySQL for queue management
Steps
- Copy module to
app/code/Zithara/Webhook - Enable module:
bin/magento module:enable Zithara_Webhook bin/magento setup:upgrade bin/magento setup:di:compile bin/magento cache:clean
- Configure module in admin panel
- Set up cron jobs
Troubleshooting
Common Issues
-
Queue Processing Issues
- Check RabbitMQ connection
- Verify queue consumer is running
- Check for queue backlog
-
API Connection Issues
- Verify credentials
- Check API endpoint availability
- Review SSL certificates
-
Event Processing Issues
- Check event observer registration
- Verify event data structure
- Review error logs
Debug Mode
Enable debug logging in admin configuration for detailed troubleshooting.
Security
Data Protection
- Sensitive data encryption
- Secure credential storage
- Token-based authentication
Best Practices
- Input validation
- Error handling
- Rate limiting
- Audit logging
Performance
Optimization
- Asynchronous processing
- Batch processing
- Queue management
- Cache utilization
Monitoring
- Queue length
- Processing time
- Error rates
- API response times
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2024-12-27