Add metadata to a Stripe Subscription

I have a form that creates a subscription on Stripe. It is putting all the metadata from the form feed on the customer object at Stripe. I want to add those fields to the Subscription object.

I have added the below to our custom themes functions.php file:

add_filter( 'gform_stripe_subscription_params_pre_update_customer', 'add_sub_metadata', 10, 7 );
function add_sub_metadata( $subscription_params, $customer, $plan, $feed, $entry, $form, $trial_period_days ) {
    GFCommon::log_debug( __METHOD__ . '(): running.' );
    $metadata = gf_stripe()->get_stripe_meta_data( $feed, $entry, $form, array() ); // Pass an empty array for $entry_meta
    $subscription_params['metadata'] = $metadata;
    GFCommon::log_debug( __METHOD__ . '(): The Entry => ' . print_r( $subscription_params, true ) );
    return $subscription_params;

I don’t see any indication that the function is running. Not that I am 100% sure where to look other than in Stripe.

Is the code correct? Better way to solve the problem?


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