Bridge API DocsBridge API Docs
Bridge API Docs
Woocommerce plugin

Callback Events

Understand callback events and webhooks for the WooCommerce plugin

Callback Events

The Bridge WooCommerce Plugin uses callbacks to receive real-time payment notifications and update order statuses automatically.

Overview

Callbacks are HTTP POST requests sent to your WooCommerce site when payment events occur. The plugin automatically handles these callbacks to update order statuses and send notifications.

Callback URL

Default Callback URL

https://your-site.com/wc-api/bridge_callback

Custom Callback URL

You can set a custom callback URL in the plugin settings, but the default URL is recommended.

Callback Events

Payment Success

Triggered when a payment is successfully completed.

Event Data:

{
  "event_type": "payment_success",
  "transaction_id": "79",
  "order_id": "1234",
  "status": "000",
  "status_desc": "Transaction Successful",
  "network_transaction_id": "57537797464",
  "amount": 0.1,
  "currency_code": "GHS",
  "customer_number": "0541234567",
  "reference": "Transfer to momo",
  "timestamp": "2025-08-31T23:45:00Z"
}

Plugin Actions:

  • Update order status to "Processing"
  • Add order note with transaction details
  • Send confirmation email to customer
  • Send SMS notification (if enabled)

Payment Failure

Triggered when a payment fails.

Event Data:

{
  "event_type": "payment_failure",
  "transaction_id": "80",
  "order_id": "1235",
  "status": "001",
  "status_desc": "Transaction Failed",
  "network_transaction_id": "61962982397",
  "amount": 0.1,
  "currency_code": "GHS",
  "customer_number": "0541234567",
  "reference": "Transfer to momo",
  "timestamp": "2025-08-31T23:46:00Z"
}

Plugin Actions:

  • Update order status to "Failed"
  • Add order note with failure reason
  • Send failure notification to customer
  • Send SMS notification (if enabled)

Payment Pending

Triggered when a payment is still being processed.

Event Data:

{
  "event_type": "payment_pending",
  "transaction_id": "81",
  "order_id": "1236",
  "status": "002",
  "status_desc": "Transaction Pending",
  "network_transaction_id": "pending_12345",
  "amount": 0.1,
  "currency_code": "GHS",
  "customer_number": "0541234567",
  "reference": "Transfer to momo",
  "timestamp": "2025-08-31T23:47:00Z"
}

Plugin Actions:

  • Keep order status as "Pending Payment"
  • Add order note with pending status
  • Send pending notification to customer

Payment Cancelled

Triggered when a payment is cancelled.

Event Data:

{
  "event_type": "payment_cancelled",
  "transaction_id": "82",
  "order_id": "1237",
  "status": "003",
  "status_desc": "Transaction Cancelled",
  "network_transaction_id": "cancelled_12345",
  "amount": 0.1,
  "currency_code": "GHS",
  "customer_number": "0541234567",
  "reference": "Transfer to momo",
  "timestamp": "2025-08-31T23:48:00Z"
}

Plugin Actions:

  • Update order status to "Cancelled"
  • Add order note with cancellation reason
  • Send cancellation notification to customer

Callback Processing

Automatic Processing

The plugin automatically processes callbacks and:

  1. Validates the callback data
  2. Updates the order status
  3. Adds order notes
  4. Sends notifications
  5. Logs the event

Manual Processing

You can also process callbacks manually by:

  1. Going to WooCommerce > Bridge > Callbacks
  2. Viewing recent callbacks
  3. Manually processing failed callbacks

Callback Security

Signature Verification

The plugin verifies callback signatures to ensure authenticity:

// Verify callback signature
$signature = $_SERVER['HTTP_X_BRIDGE_SIGNATURE'];
$payload = file_get_contents('php://input');
$expected_signature = hash_hmac('sha256', $payload, $secret_key);

if (!hash_equals($expected_signature, $signature)) {
    wp_die('Invalid signature', 'Unauthorized', 401);
}

IP Whitelisting

You can whitelist Bridge IP addresses for additional security:

// Allowed IP addresses
$allowed_ips = [
    '203.0.113.1',
    '203.0.113.2',
    '203.0.113.3'
];

$client_ip = $_SERVER['REMOTE_ADDR'];
if (!in_array($client_ip, $allowed_ips)) {
    wp_die('Unauthorized IP', 'Forbidden', 403);
}

Callback Logging

Log Files

Callbacks are logged in:

/wp-content/uploads/bridge-logs/callbacks-YYYY-MM-DD.log

Log Format

[2025-08-31 23:45:00] SUCCESS: Payment callback received for order 1234
[2025-08-31 23:46:00] ERROR: Invalid signature for callback
[2025-08-31 23:47:00] INFO: Payment status updated for order 1235

Log Levels

  • SUCCESS: Successful callback processing
  • ERROR: Callback processing failed
  • INFO: General callback information
  • DEBUG: Detailed debugging information

Testing Callbacks

Test Callback URL

Use our test endpoint to verify your callback URL:

curl -X POST "https://your-site.com/wc-api/bridge_callback" \
  -H "Content-Type: application/json" \
  -H "X-Bridge-Signature: test_signature" \
  -d '{
    "event_type": "payment_success",
    "transaction_id": "test_123",
    "order_id": "1234",
    "status": "000",
    "status_desc": "Test Transaction",
    "amount": 1.00,
    "currency_code": "GHS"
  }'

Test with Webhook.site

  1. Go to webhook.site
  2. Copy the provided URL
  3. Use it as your callback URL for testing
  4. Make a test payment
  5. Check webhook.site for the callback data

Test in Sandbox Mode

  1. Enable test mode in plugin settings
  2. Use test API credentials
  3. Make test payments
  4. Verify callbacks are received

Troubleshooting Callbacks

Common Issues

Issue: Callbacks not received

Possible Causes:

  • Callback URL not accessible
  • SSL certificate issues
  • Firewall blocking requests
  • Plugin not activated

Solutions:

  1. Check callback URL accessibility
  2. Verify SSL certificate
  3. Check firewall settings
  4. Ensure plugin is active

Issue: Invalid signature errors

Possible Causes:

  • Secret key mismatch
  • Payload corruption
  • Header issues

Solutions:

  1. Verify secret key in plugin settings
  2. Check payload format
  3. Verify signature header

Issue: Order not updating

Possible Causes:

  • Order ID mismatch
  • Database issues
  • Plugin conflicts

Solutions:

  1. Check order ID in callback data
  2. Verify database connectivity
  3. Disable conflicting plugins

Debug Mode

Enable debug mode to troubleshoot callback issues:

  1. Go to WooCommerce > Settings > Bridge
  2. Enable "Debug Mode"
  3. Check logs in /wp-content/uploads/bridge-logs/

Callback Monitoring

Monitor callback health:

  1. Go to WooCommerce > Bridge > Callbacks
  2. View recent callback activity
  3. Check for failed callbacks
  4. Review error messages

Callback Retry Policy

Automatic Retries

Bridge automatically retries failed callbacks:

  • Retry Count: 3 attempts
  • Retry Interval: 5 minutes
  • Timeout: 30 seconds per attempt

Manual Retries

You can manually retry failed callbacks:

  1. Go to WooCommerce > Bridge > Callbacks
  2. Find the failed callback
  3. Click "Retry"
  4. Check the result

Best Practices

1. Monitor Callback Health

  • Check callback logs regularly
  • Monitor failed callbacks
  • Set up alerts for callback failures

2. Handle Callback Failures

  • Implement retry logic
  • Log all callback attempts
  • Notify administrators of failures

3. Secure Callback Endpoint

  • Use HTTPS only
  • Verify signatures
  • Implement IP whitelisting
  • Rate limit requests

4. Test Regularly

  • Test callbacks in sandbox mode
  • Verify all event types
  • Test error scenarios
  • Monitor production callbacks

Support

If you need help with callbacks:

  1. Check Logs: Review callback logs for errors
  2. Test Callbacks: Use our test tools
  3. Contact Support: Email support@thebridgesolutions.com
  4. Include Details: Provide callback logs and error messages