G
SkunkGlobal
/Docs/CRM/Payment Processors

Payment Processors

Connect your payment processors to SkunkCRM to automatically create contacts and deals when customers make purchases. Perfect for e-commerce, SaaS, and service businesses.

Stripe Integration

Stripe has excellent webhook support for real-time payment notifications.

Setup Steps

  1. Create Webhook Token in SkunkCRM:

    • Go to SkunkCRM → Webhooks
    • In the Incoming Webhook Tokens section, click "Create Token"
    • Enter token name: "Stripe Integration"
    • Copy the complete webhook URL provided
  2. Configure Stripe Webhooks:

    • Log into your Stripe Dashboard
    • Go to Developers → Webhooks
    • Click "Add endpoint"
    • Endpoint URL: https://yoursite.com/wp-json/skunkcrm/v1/webhook/{your-token}
    • Listen to: Select specific events (recommended)
  3. Select Events:

    • customer.created - New customer accounts
    • payment_intent.succeeded - Successful payments
    • invoice.payment_succeeded - Subscription payments
    • customer.subscription.created - New subscriptions

Webhook Data Processing

SkunkCRM automatically processes Stripe webhook data:

Customer Created:

{
  "action": "create_contact",
  "data": {
    "name": "Customer Name",
    "email": "customer@example.com",
    "stripe_customer_id": "cus_abc123",
    "source": "stripe",
    "status": "customer"
  }
}

Payment Succeeded:

{
  "action": "create_deal",
  "data": {
    "contact_email": "customer@example.com",
    "title": "Stripe Payment",
    "value": 99.00,
    "status": "won",
    "source": "stripe",
    "payment_id": "pi_abc123"
  }
}

Custom Stripe Integration

For more control, process Stripe webhooks in your application first:

// Stripe webhook handler
$payload = file_get_contents('php://input');
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
$endpoint_secret = 'whsec_your_signing_secret';

try {
    $event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret);
    
    switch ($event['type']) {
        case 'customer.created':
            $customer = $event['data']['object'];
            
            // Send to SkunkCRM
            $contact_data = [
                'contact' => [
                    'name' => $customer['name'],
                    'email' => $customer['email'],
                    'phone' => $customer['phone'],
                    'source' => 'stripe',
                    'stripe_customer_id' => $customer['id']
                ]
            ];
            
            sendToSkunkCRM($contact_data);
            break;
            
        case 'payment_intent.succeeded':
            $payment = $event['data']['object'];
            
            // Create deal in SkunkCRM
            $deal_data = [
                'action' => 'create_deal',
                'data' => [
                    'title' => 'Stripe Payment - ' . $payment['id'],
                    'value' => $payment['amount'] / 100, // Convert cents
                    'status' => 'won',
                    'source' => 'stripe'
                ]
            ];
            
            sendToSkunkCRM($deal_data);
            break;
    }
} catch(\Exception $e) {
    http_response_code(400);
    exit();
}

function sendToSkunkCRM($data) {
    $webhook_url = 'https://yoursite.com/wp-json/skunkcrm/v1/webhook/your-token';
    
    wp_remote_post($webhook_url, [
        'body' => json_encode($data),
        'headers' => ['Content-Type' => 'application/json']
    ]);
}

PayPal Integration

PayPal uses IPN (Instant Payment Notification) for webhook-style notifications.

Setup Steps

  1. Create Webhook Token in SkunkCRM
  2. Configure PayPal IPN:
    • Log into PayPal account
    • Go to Account Settings → Notifications
    • Notification URL: https://yoursite.com/wp-json/skunkcrm/v1/webhook/{your-token}

PayPal IPN Processing

PayPal sends form-encoded data, so you'll need a custom handler:

// PayPal IPN to SkunkCRM handler
add_action('init', function() {
    if (isset($_POST['txn_type']) && $_GET['paypal_ipn'] === 'true') {
        // Verify IPN with PayPal
        $raw_post_data = file_get_contents('php://input');
        $raw_post_array = explode('&', $raw_post_data);
        
        // Process PayPal data
        $contact_data = [
            'contact' => [
                'name' => $_POST['first_name'] . ' ' . $_POST['last_name'],
                'email' => $_POST['payer_email'],
                'source' => 'paypal',
                'paypal_payer_id' => $_POST['payer_id']
            ]
        ];
        
        // Send to SkunkCRM webhook
        sendToSkunkCRM($contact_data);
    }
});

WooCommerce Integration

WooCommerce has built-in webhook support for order events.

Setup Steps

  1. Enable WooCommerce Webhooks:

    • Go to WooCommerce → Settings → Advanced → Webhooks
    • Click "Create webhook"
  2. Configure Webhook:

    • Name: "SkunkCRM Integration"
    • Status: Active
    • Topic: Select events (order.created, customer.created)
    • Delivery URL: https://yoursite.com/wp-json/skunkcrm/v1/webhook/{your-token}
    • Secret: (optional, for verification)

Webhook Topics

Recommended Topics:

  • order.created - New orders placed
  • order.completed - Orders marked as complete
  • customer.created - New customer accounts

Processing WooCommerce Data

WooCommerce sends detailed order data:

{
  "action": "create_contact",
  "data": {
    "name": "John Doe",
    "email": "john@example.com",
    "phone": "+1234567890",
    "company": "Acme Corp",
    "source": "woocommerce",
    "woocommerce_customer_id": 123,
    "billing_address": {
      "street": "123 Main St",
      "city": "New York",
      "state": "NY",
      "zip": "10001"
    }
  }
}

Custom WooCommerce Handler

For more control, use WooCommerce hooks:

// WooCommerce to SkunkCRM integration
add_action('woocommerce_new_order', function($order_id) {
    $order = wc_get_order($order_id);
    
    $contact_data = [
        'contact' => [
            'name' => $order->get_billing_first_name() . ' ' . $order->get_billing_last_name(),
            'email' => $order->get_billing_email(),
            'phone' => $order->get_billing_phone(),
            'company' => $order->get_billing_company(),
            'source' => 'woocommerce',
            'order_total' => $order->get_total(),
            'woocommerce_order_id' => $order_id
        ]
    ];
    
    // Send to SkunkCRM
    sendToSkunkCRM($contact_data);
    
    // Also create a deal
    $deal_data = [
        'action' => 'create_deal',
        'data' => [
            'title' => 'WooCommerce Order #' . $order_id,
            'value' => $order->get_total(),
            'status' => 'won',
            'source' => 'woocommerce',
            'contact_email' => $order->get_billing_email()
        ]
    ];
    
    sendToSkunkCRM($deal_data);
});

Easy Digital Downloads

EDD supports webhooks for digital product sales.

Configuration

  1. Install EDD Webhooks Extension (if available)
  2. Configure Webhook:
    • URL: https://yoursite.com/wp-json/skunkcrm/v1/webhook/{your-token}
    • Events: Payment complete, customer created

Alternative: EDD Hooks

// EDD to SkunkCRM integration
add_action('edd_complete_purchase', function($payment_id) {
    $payment = new EDD_Payment($payment_id);
    
    $contact_data = [
        'contact' => [
            'name' => $payment->first_name . ' ' . $payment->last_name,
            'email' => $payment->email,
            'source' => 'edd',
            'edd_customer_id' => $payment->customer_id
        ]
    ];
    
    sendToSkunkCRM($contact_data);
});

Subscription Management

Handling Recurring Payments

For subscription businesses, track subscription events:

// Stripe subscription webhook handler
switch ($event['type']) {
    case 'customer.subscription.created':
        $subscription = $event['data']['object'];
        
        $contact_data = [
            'action' => 'update_contact',
            'data' => [
                'email' => $subscription['customer']['email'],
                'status' => 'subscriber',
                'subscription_status' => 'active',
                'subscription_plan' => $subscription['items']['data'][0]['price']['nickname']
            ]
        ];
        break;
        
    case 'customer.subscription.deleted':
        $subscription = $event['data']['object'];
        
        $contact_data = [
            'action' => 'update_contact',
            'data' => [
                'email' => $subscription['customer']['email'],
                'subscription_status' => 'cancelled'
            ]
        ];
        break;
}

Testing Payment Integrations

Stripe Test Mode

  1. Use Stripe test keys in your integration
  2. Test webhook endpoints with Stripe CLI:
    stripe listen --forward-to https://yoursite.com/wp-json/skunkcrm/v1/webhook/your-token
    

PayPal Sandbox

  1. Create PayPal Sandbox account
  2. Configure IPN simulator in PayPal developer tools
  3. Test with sandbox transactions

WooCommerce Testing

  1. Create test orders in WooCommerce
  2. Check webhook delivery logs
  3. Verify contacts created in SkunkCRM

Troubleshooting

Webhooks Not Firing

  1. Check payment processor logs - Most processors have webhook delivery logs
  2. Verify webhook URL - Ensure URL is correct and accessible
  3. Test manually - Use processor's webhook testing tools

Missing Customer Data

  1. Review field mapping - Check which fields the processor sends
  2. Handle missing fields - Use fallback values for optional fields
  3. Customer vs guest - Handle both registered and guest customers

Duplicate Contacts

  1. Email deduplication - Enable automatic duplicate prevention
  2. Update vs create - Use update actions for existing customers
  3. Unique identifiers - Store processor customer IDs for deduplication

Security Considerations

Webhook Verification

Stripe: Always verify webhook signatures:

$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
$event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret);

PayPal: Verify IPN with PayPal servers WooCommerce: Use webhook secrets for verification

Data Protection

  1. HTTPS only - Never use HTTP for payment webhooks
  2. Validate data - Sanitize all incoming payment data
  3. Log securely - Don't log sensitive payment information
  4. Rate limiting - Implement rate limiting on webhook endpoints

Next Steps

  • Test your integration - Process test payments to verify everything works
  • Monitor webhook delivery - Set up alerts for failed webhooks
  • Customer lifecycle - Use SkunkCRM automations to nurture payment customers
  • Analytics - Track payment conversion rates and customer lifetime value

::rest-api-banner::

Need to integrate a payment processor not covered here? Check our incoming webhooks guide for general webhook setup instructions.

Was this page helpful?