Stripe PaymentIntent Incomplete – send variables?
-
Everything is working as it should with Forminator and Stripe, we are seeing the preliminary PaymentIntents that show Incomplete.
Question we have is if someone starts the form (a paginated form, with selections that update the calculation field) we see that new PaymentIntents are generated, which is expected, but would it be possible to have other variables transmitted during those PaymentIntent refreshes? One of our early fields prior to cost selection is e-mail, it would be nice to have that sent with the PaymentIntent so we could see if someone starts registration but doesn’t finish.
Screenshot of Stripe transaction
-
Hope you are doing well today.
I asked our developers to review your question. I’m not sure if we have a hook that can be used when the payment intent is created.
We will get back to you as soon as we have more information.
Best Regards
AminWe got further feedback from our development team.
You can use the following hook to trigger your custom functions while the payment intent is created or updated.
forminator_stripe_payment_intent_optionsBest Regards,
AminThanks. It appears to be working, thank you.
Do you know, is it possible to tie these intents back to actual Stripe product ids?<?php
/**
* Plugin Name: Forminator - Add Custom Stripe Metadata
* Description: Adds multiple form fields (email, names, donation, division) to the Stripe PaymentIntent metadata.
* Version: 1.0
* Author: temeculapony
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Add custom metadata to Forminator Stripe Payment Intent
*
* @param array $options The options array sent to Stripe.
* @param mixed $stripe_field The second argument (which is the stripe field settings).
*
* @return array
*/
add_filter( 'forminator_stripe_payment_intent_options', 'wpmudev_add_custom_stripe_metadata', 10, 2 );
function wpmudev_add_custom_stripe_metadata( $options, $stripe_field ) {
// --- Configuration ---
// Set your specific form ID here.
$target_form_id = ####; // <--- MAKE SURE YOU CHANGE THIS ID
// Set the field ID of your email field
$email_field_id = 'email-1';
// --- End Configuration ---
// Get the form ID from the $_POST data
if ( ! isset( $_POST['form_id'] ) ) {
return $options; // Not a Forminator submission we care about
}
$submitted_form_id = intval( $_POST['form_id'] );
// Check if it's the correct form
if ( $submitted_form_id == $target_form_id ) {
// --- 1. Initialize Metadata Array ---
if ( ! isset( $options['metadata'] ) ) {
$options['metadata'] = array();
}
// --- 2. Add Static Product IDs (NEW) ---
$options['metadata']['id'] = 'prod_TJtdO2geBAgauB';
$options['metadata']['donation_product_id'] = 'prod_TJtgcXJCFP4EbT';
// --- 3. Add Email ---
if ( isset( $_POST[ $email_field_id ] ) && ! empty( $_POST[ $email_field_id ] ) ) {
$receipt_email = sanitize_email( $_POST[ $email_field_id ] );
if ( is_email( $receipt_email ) ) {
$options['receipt_email'] = $receipt_email; // Still try to set this
$options['metadata']['form_email'] = (string) $receipt_email;
}
}
// --- 4. Add Donation (number-1) ---
// We check against '' to allow a "0" value to be saved
if ( isset( $_POST['number-1'] ) && $_POST['number-1'] !== '' ) {
$options['metadata']['Donation'] = (string) $_POST['number-1'];
}
// --- 5. Add Registrant Name (name-1) ---
if ( isset( $_POST['name-1'] ) && ! empty( $_POST['name-1'] ) ) {
$options['metadata']['Registrant_Name'] = (string) $_POST['name-1'];
}
// --- 6. Add Player 1 Name (name-2) ---
if ( isset( $_POST['name-2'] ) && ! empty( $_POST['name-2'] ) ) {
$options['metadata']['Player_1_Name'] = (string) $_POST['name-2'];
}
// --- 7. Add Player 1 Division (hidden-6) ---
if ( isset( $_POST['hidden-6'] ) && ! empty( $_POST['hidden-6'] ) ) {
$options['metadata']['Player_1_Division'] = (string) $_POST['hidden-6'];
}
// --- 8. Add Players 2-6 (Loop) ---
for ( $i = 2; $i <= 6; $i++ ) {
$player_name_field = 'name-2-' . $i;
$player_div_field = 'hidden-6-' . $i;
$player_metadata_key_name = 'Player_' . $i . '_Name';
$player_metadata_key_div = 'Player_' . $i . '_Division';
// Get Player Name
if ( isset( $_POST[ $player_name_field ] ) && ! empty( $_POST[ $player_name_field ] ) ) {
$options['metadata'][ $player_metadata_key_name ] = (string) $_POST[ $player_name_field ];
}
// Get Player Division
if ( isset( $_POST[ $player_div_field ] ) && ! empty( $_POST[ $player_div_field ] ) ) {
$options['metadata'][ $player_metadata_key_div ] = (string) $_POST[ $player_div_field ];
}
}
} // end if $submitted_form_id == $target_form_id
// Always return the options, even if unmodified
return $options;
}I pinged our developers to review your query. We will post an update here as soon as more information is available.
Kind Regards,
KrisHi @temeculapony,
Sorry for the delay regarding this.
Regarding your query, if it is a one-time purchase, please note that there is no associated Product ID.
In the case of a subscription plan, a Product ID will be automatically linked with the subscription. Also, please be aware that the event ‘forminator_stripe_payment_intent_options’ will not be triggered for subscriptions.
I hope the above helps in moving forward.
However, for any further advise regarding the above aspects will require custom coding. I’m afraid providing the custom code will be outside the scope of support. For that, you’ll need to hire a developer to provide the required custom code for you. WordPress provides a jobs directory here https://jobs.wordpress.net/
If you need further advice about it, feel free to email us at [email protected] using the following subject.
“Subject: ATTN: WPMU DEV support – wp.org”
Regards,
Nithin
We haven’t heard from you in a while, I’ll go and mark this thread as resolved. If you have any additional questions or require further help, please let us know!
Kind Regards,
Kris
The topic ‘Stripe PaymentIntent Incomplete – send variables?’ is closed to new replies.