Webhook Integration
Open Market uses webhooks to notify your application when a payment is successful. Only successful transactions trigger webhook notifications. This real-time notification system allows you to automatically update your application’s state, fulfill orders, or trigger other business processes.Webhook Authentication
Webhooks are authenticated using your private key. Each webhook request includes a signature in theopm-signature
header that you should validate to ensure the webhook is legitimate. This prevents unauthorized parties from sending fake webhook events to your endpoint.
Webhook Payload
When a payment is successful, we’ll send a POST request to your configured webhook URL with the following JSON payload:Handling Webhooks
Here’s an example of how to handle and validate webhooks:Best Practices for Webhooks
Signature Validation
Signature Validation
Always validate the webhook signature using your private key to ensure the request is from Open Market.
Idempotency
Idempotency
Implement idempotency checks using the
transaction_id
to avoid processing the same webhook multiple times.Error Handling
Error Handling
Implement proper error handling and logging for webhook processing failures.
Quick Response
Quick Response
Return a 200 status code quickly and process the webhook asynchronously if needed.
Retry Mechanism
Retry Mechanism
Implement a retry mechanism in case your server fails to process the webhook.
Webhook Use Cases
Basic Usage - For Beginners
Basic Usage - For Beginners
- Simple payment confirmation
- Update order status
- Send confirmation emails
- Basic logging of transactions
Intermediate Integration
Intermediate Integration
- Order fulfillment automation
- Inventory management
- Customer notification system
- Basic error handling and retries
- Simple database storage
Advanced Implementation - For Pros
Advanced Implementation - For Pros
- Distributed systems integration
- Queue-based processing
- Advanced error handling with retry mechanisms
- Load balancing and scaling
- Monitoring and alerting systems
- Data analytics and reporting
- Multi-region deployment
Enterprise Solutions
Enterprise Solutions
- Microservices architecture
- Event-driven systems
- High availability setup
- Disaster recovery
- Compliance and audit logging
- Advanced security measures
- Performance optimization
Testing Webhooks
During development, you can use tools like ngrok to test webhooks locally:Remember to update your webhook URL to your production URL before going live.