Gravity Forms Coupons for Stripe Subscriptions - workaround not working

Skip to first unread message

barbara schendel

Mar 23, 2018, 12:50:10 PM3/23/18
to Minneapolis St. Paul WordPress User Group
Hey all,

We are using Gravity Forms that lets people sign up for an account -- these forms take payment and sign people up for recurring billing in Stripe. 

The problem is that the client also offers coupons for these subscriptions, but these coupons do not work with Stripe Subscriptions. You get an error on form submit. This is a known issue, because the coupon also has to exist on Stripe in order to be applied to subscriptions. But when you add a matching coupon in Stripe, the discount is taken twice -- once by Gravity Forms, and again by Stripe. So instead of taking 40% off, Gravity Forms takes 40% off, and then Stripe takes another 40% off. 

There is a workaround to this that can be found here and Gravity Forms support is the one that referred me to there -- this is supposed to modify the form total sent to Stripe, so that the un-discounted amount is sent to Stripe. (that way the discount will only be applied once, at Stripe).  I have implemented the workaround but it does not work. A matching coupon was created in Stripe and the workaround-plugin containing their code can be seen below. But the discount is still being taken twice. (and GF support now says since this workaround plugin was not written by them they can't offer any help)

I have logging turned on in Gravity Forms, and here are the lines in the log that shows the workaround-plugin's debugging messages, and as you can see it shows the incorrect number in "total field before discount"  
(in thinking this over, it makes sense to me that the total field should be updated as soon as the coupon is applied, so of course it takes the wrong (discounted instead of un-discounted) amount! I'm actually surprised this code ever worked in the first place. But maybe Samuel Aguilera knows something that I don't) 

What would you change in this function to get it to retrieve the correct "total field before discount" and sends that to Stripe? 
I considered inserting the product field there instead but I can't do that because we have two products on a conditional depending on how many users they are signing up. (here is a screenshot of form)

To explain the code a little, there are four forms on the website that needed this functionality (4 forms because each has slightly different pricing) so I had to modify the code to be applied to all four forms -- but the Total field ID is 9 on all four forms so I did not have to alter the function itself, just duplicate the add_filter lines.

Any help would be much appreciated! Thanks!


Here is the workaround plugin code:

Plugin Name: GF - Stripe Coupon corrector
Description: So that the original amount for the Total field, without the discount, will be passed to Stripe and there the Stripe coupon will be applied (for subscriptions)
Author: Wizzy Wig Design
Author URI:
Version: 0.13
License: GPL v2 -

// from

/* Change 10 in gform_submission_data_pre_process_payment_10 to your form id number (e.g. gform_submission_data_pre_process_payment_1 form id 1)
or remove the _10 to apply this to all forms */
add_filter( 'gform_submission_data_pre_process_payment_3', 'modify_submission_data', 10, 4 ); /* monthly license */
add_filter( 'gform_submission_data_pre_process_payment_4', 'modify_submission_data', 10, 4 ); /* annual license */
add_filter( 'gform_submission_data_pre_process_payment_9', 'modify_submission_data', 10, 4 ); /* colonial life */
add_filter( 'gform_submission_data_pre_process_payment_10', 'modify_submission_data', 10, 4 ); /* colonial life with pricing tiers */

function modify_submission_data( $submission_data, $feed, $form, $entry ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );

// Change 5 in the following line to the id of your Total field
$total_field = rgar( $entry, '9' );
GFCommon::log_debug( __METHOD__ . '(): Amount in Total field before discount: ' . $total_field );

$submission_data['payment_amount'] = $total_field;
GFCommon::log_debug( __METHOD__ . '(): Original Total amount passed to Stripe: ' . $submission_data['payment_amount'] );

return $submission_data;

Toby Cryns

Mar 27, 2018, 1:28:25 PM3/27/18
to Minneapolis St. Paul WordPress User Group

I have the same question and have been struggling with this for a while.  

My "For Dummies" solution is to just manually adding subscriptions via  I'd love to use a Gravity Forms + Stripe solution to this coupons problem!

Reply all
Reply to author
0 new messages