Hi everyone! I’m hoping someone could help me figure this out
The premise:
I am using an embedded Stripe CC field (Elements) to create a subscription form. This is a non-recurring subscription, with 1 single payment at the beginning, and the subscription expires 1 year later. When the user hits “submit” on the sign-up form, I need to send an adjusted timestamp over to Stripe, along with the customer data, which says “Hey Stripe, set this subscription up to automatically cancel at the 1 year mark.” I’m thinking I can leverage this filter: https://docs.gravityforms.com/gform_stripe_subscription_params_pre_update_customer/#cancel-at-specified-date-time
Here’s what I’ve done so far, and what I need help with:
I grabbed the timestamp via regular PHP, and added 1 year to it. How do I take this adjusted timestamp and send it off to Stripe with all the other subscription entry info that the user has just submitted, to ensure that Stripe uses that timestamp as the cancelation date? This is where I am so far, but feeling unsure:
$date_one_year_later = gmdate("Y-m-d", strtotime("+1 year"));
add_filter( 'gform_stripe_subscription_params_pre_update_customer', 'stripe_subscription_cancel_at', 10, 7 );
function stripe_subscription_cancel_at( $subscription_params, $customer, $plan, $feed, $entry, $form, $trial_period_days ) {
// cancel subscription one year after current timestamp
$subscription_params['cancel_at'] = strtotime( $date_one_year_later );
return $subscription_params;
}
Another idea that might work, but I’m not sure:
If I set the “Billing Cycle” to 1 year in my Stripe feed, could I use this filter as-is, and wham-bam, problem solved? The subscription would just be canceled 1 year later? https://docs.gravityforms.com/gform_stripe_subscription_cancel_at_period_end/