Capture Stripe Customer Email From Webhook

Which GF hook would be appropriate to use for capturing a customer email which was used on the Stripe Checkout (hosted page)?

Would li to save (append to form data) the customer email which comes from the Stripe Webhook, so that the customer isn’t asked twice for their email. How would I access that value and append to form?

Thank you

Hi @x07xl5lm
To capture the customer email from the Stripe Checkout hosted page and save it to the form data in Gravity Forms, you can use the gform_after_submission hook. This hook is triggered after a form submission has been completed and allows you to perform custom actions such as modifying the submission data or triggering an event.

Here’s an example of how you can use this hook to access the customer email from the Stripe Webhook and append it to the form data:

add_action( 'gform_after_submission', 'capture_customer_email', 10, 2 );
function capture_customer_email( $entry, $form ) {
  // Get the Stripe customer email from the webhook
  $stripe_customer_email = $_POST['data']['object']['customer_email'];

  // Append the customer email to the form data
  $entry['stripe_customer_email'] = $stripe_customer_email;
  GFAPI::update_entry( $entry );
}

This code should be in your WordPress theme’s functions.php file or a custom plugin.

You can then use the stripe_customer_email field in your Gravity Forms form to display or save the customer email.

I hope this helps! Let me know if you have any questions.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.