Support Log in

28. Stripe Webhooks

Developer Guide
Prefer video? Watch the Fillin Forge tutorials 9 short guides covering every feature Watch

Stripe sends events to POST /wp-json/formforge/v1/stripe/webhook.

Signature Verification

php
$payload = file_get_contents( 'php://input' );
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'] ?? '';

// Parse: t=1705762522,v1=abc123def456...
$parts = [];
foreach ( explode( ',', $sig_header ) as $item ) {
    list( $key, $value ) = explode( '=', $item, 2 );
    $parts[ $key ] = $value;
}

// Reject events older than 5 minutes
if ( abs( time() - (int) $parts['t'] ) > 300 ) {
    return new WP_REST_Response( [ 'error' => 'Timestamp too old' ], 400 );
}

// HMAC verification
$signed_payload = $parts['t'] . '.' . $payload;
$expected = hash_hmac( 'sha256', $signed_payload, $webhook_secret );
if ( ! hash_equals( $expected, $parts['v1'] ) ) {
    return new WP_REST_Response( [ 'error' => 'Signature mismatch' ], 400 );
}

Handled Events

EventAction
payment_intent.succeededMarks payment_status as succeeded and adds _payment data, for a payment made for the same form. A submission that holds the payment in one of its payment fields goes through the same checks as at submit (this form and field, the currency, the amount kept with the submission, one payment for one submission), and a row that is paid, refunded or kept for another amount is not raised by the event
payment_intent.payment_failedMarks payment_status as failed
charge.refundedReads data.object.payment_intent and marks payment_status as refunded

Webhook Setup in Stripe Dashboard

  1. Go to Stripe Dashboard > Developers > Webhooks
  2. Click “Add endpoint”
  3. Enter URL: https://example.com/wp-json/formforge/v1/stripe/webhook
  4. Select events: payment_intent.succeeded, payment_intent.payment_failed, charge.refunded
  5. Copy the signing secret (whsec_...) to Fillin Forge settings

—

Forge AI Assistant Online

Hi! I'm the Fillin Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs