Gravity Forms + Stripe Cancel Account, Update Billing & More

Alternatives to Stripe + More for Gravity Forms

Gravity Forms for WordPress has an add-on for Stripe, and that add-on allows you to setup subscription payments for your customers.

However, there’s no way for a customer to go in and cancel their subscription or, if their payment fails, to update their payment plan. At least not right out of the box.

There’s a paid plugin out there called Gravity + More which I’ve used for years. I purchased it maybe three years ago and used it on a client’s site, a personal site of my own, and then was installing it on yet another site I’m developing that gives people access to their own travel blog, on a high-end WP Engine server, for a few bucks a month. The plugin just wasn’t working for me, and through the process of requesting support I discovered the following:

Support just wasn’t there anymore. It took two days to receive my first reply, which was nothing more than a one liner of a question. The plugin’s author didn’t look into my issue at all, but blew it off for another 24 hour delay to responding. As I’m paying for the plugin, this was unacceptable to me. After a week, we were no closer to getting the problem solved and so I decided to go out and build this all on my own.

The plugin doesn’t inform you of updates. Unlike every other WP plugin out there, when there’s an update for Gravity + More, there’s absolutely no way to know about it other than to write the author and ask if there’s an update. That’s just sloppy. I asked about this multiple times and was never given an answer.

Because of this, the other sites that I used the plugin on were broken, unbeknownst to me. Both sites rarely have billing updates or cancellations – they just so happen to provide a subscription service few people ever want to cancel. I found this quite alarming, to be honest, and the plugin author, again, never acknowledged any of my questions on this.

For someone we’re entrusting our e-commerce gateway to, I just don’t think it’s cool for glaring issues like this to not only go unfixed, but for her to not even acknowledge them at all over multiple emails. That said, I can only imagine the plugin is working for other people…or at least the plugin’s author tells me it is. But it didn’t work for me across two different setups, and taking a week for her to even look at my code or site was just too long for a paid plugin.

So, without further ado, here’s the free walk through for those of you who don’t mind putting a little work in yourselves.

Install Gravity Forms

Firstly, you’ll need a copy of Gravity Forms. Buy it, install it, and then also get the User Registration and Stripe add-ons installed.

To do that, once Gravity Forms is installed, go to Forms > Add-Ons and find them in the list.

Install the User Registration and Stripe add-ons for Gravity Forms.

Next, setup a form that includes at least:

Name or Username field.

Email address.

A Product and/or Total Field.

A Credit Card field.

An example of the fields we need.

Now that we’ve got our form fields setup, we can move onto the functionality.

User Registration

Go to Settings > User Registration for the form.

Add a new user registration feed on that screen.

Give it any Name.

Choose Create User.

For the User Settings, make sure to set a Username and Email field, and change the Role to whatever you want it to be (while Subscriber is fine, you may want to create something new like “Stripe Customer”, if you intend on giving them particular permissions after they pay).

Setup Stripe

You’ll first need to go to Forms > Settings and then choose Stripe to get your various API keys setup, and then copy the web hook Gravity Forms provides back into your Stripe account. They walk you through how to do all of this, but you’ll of course need a Stripe.com account.

Next, back in our form, go to Settings > Stripe. Create a new feed and you’ll end up on a page like this:

In this example, you can already see my existing feeds. You’ll just see a prompt to create a new feed if this is your first time.

Create a new feed, you’ll get a page like this:

This is where we’ll setup our Stripe feed.

Set the Name to whatever you want to describe your feed to be.

Set Transaction Type to Subscription.

From the Recurring amount? field, choose either your form total or one of your product fields.

Setup Billing Cycle, Setup Fee, and the Trial fields as you require. If you want a setup fee, you’ll need another product field in your form.

Under Customer Information, set the Email field to your corresponding email form field from your Gravity Form.

Description might be their name, or the product field. This will appear in Gravity Forms and so may be helpful to you in some other way not related to this tutorial.

Great, save the settings!

At this point, we can register users and charge them a recurring subscription. However, that’s all default functionality and not going to really serve the purpose. At this point, the customer can’t cancel or change their credit card information.

Note that Stripe is really smart, though, and if a user’s credit card gets reissued, but keeps the same numbers (i.e., they just get a new expiration date), Stripe works with banks to auto-update this info, so the user doesn’t have to go in and update it again.

Let’s continue to the magic!

Saving Stripe Customer ID to a WordPress Custom User Meta Field

We now need to associate our WordPress user with a Stripe Customer ID. In functions.php, add the following two snippets:

The first code snippet there automatically logs the user in after they’ve registered, and the second saves their Stripe ID as user meta to their account. Now, we have the user’s WP account tied directly to their Stripe ID. Note that if you didn’t do this right from the beginning, i.e. you’ve already got users, then you’ll need to go in and manually add these. Or maybe you could write a script, but I won’t be covering that here. Just find the user by their email address in Stripe, and create a custom meta field for them with the key of _stripe_customer_id and the value as their Stripe Customer ID.

Updating Billing Information

Next, let’s create a form so that they can update their billing info.

This form will need the following fields:

Credit Card.

Email, if you want to send notifications.

Product, which can be set to anything above 50 cents. We won’t actually be charging them anything, this is to put a “hold” / authorization on their account, allowing us to change their credit card info, but doesn’t actually capture / charge the amount.

Now go to Settings > Stripe for this form, and we’ll create a new feed.

These settings are important! See below.

Important! Name the new setting Update Credit Card. You can name this whatever you want, really, but you need to remember the name exactly as we’ll use it later.

Transaction type should be Products and Services this time around.

Payment Amount needs to be the product field we setup with our $0.50 or more amount.

First, we get the user’s Stripe ID, then we configure it so that our “Update Credit Card” feed, that we just created, only changes their credit card info…it doesn’t actually charge them. Note the highlighted bit of text in the code snippet above, which is where we use our feed name that I told you to remember.

You’re getting there!

To test at this point, go ahead and complete both forms. After you complete the form that registers the user, look in Stripe at the Customers tab and find the new entry. Then submit the billing update form and look again, the credit card number will have changed (be sure to use a different card the second time).

Now you can configure Stripe to send them a notification if there card gets cancelled, too, linking back to this form on your site!

Allow Customers to Cancel

This part is super easy, just add the following to your functions.php:

You could perform any function here really, but in this case we’re (see the highlighted section), changing their role to Subscriber. That’s why I stated you may want to create a new role in the form settings early on in this section (where you setup the User Registration feed). That way, they’d be downgraded but not cancelled, and you could then provide additional forms or manual interactions where you upgrade them again if they start their Stripe subscription again.

Helpful? Would love to see what you do with this in the comments!

Want support? Unlike Stripe + More, I’m not charging a dime for this little tutorial, and likewise, I’m not providing free support either. If you’d like to hire me, feel free to get in touch and we’ll see what we can do.

Hi Nathan, thanks for sharing this! I’m fairly new to Gravity Forms and was investigating GF and Stripe for a “listings” website I’m working on. I ran into the same issues, and your solution definitely adds some of the functionality I need!

A couple questions though — I’m not 100% sure I fully understand the cancellation process. I see how that function downgrades their role, but what action does the user have to take to trigger that role downgrade being called? And further, how does the “role downgrade” also cancel their Stripe subscription?

One issue I’m having, is the ‘gform_stripe_customer_after_create’ action seems to be firing before the ‘auto login’ function, so it doesn’t have a user id to attach the stripe customer ID to. Anybody else having this problem?

It’s working correctly on my end. While I’m not 100% on the where and when of how all of this stuff gets triggered via Gravity Forms, maybe you need to give them different priorities or have them switched around in the code?

Thanks for the easy to understand and helpful article. Do you happen to know if there is a way to retrieve the current credit card information from Stripe? I’d love to be able to display the current payment method card type, expiration date, and last 4 digits if possible.

I was also working on allowing users to cancel from a form and unfortunately the cancel subscription hook runs right away and doesnt wait for period end…
Even if you set the hook for the wait_till_end.

Thanks for this! I was also working with the same plugin and had a rather snarky experience with customer support. I thought I rubbed them the wrong way for some reason – but – glad to see I wasn’t the only one.

It might be possible to send along some hidden field’s worth of data, but how would that user ever be associated with that data again if they can’t login? They’d need to know the value of that hidden field and type it in again, or you’d need to do some custom coding to say “If this email address exists, update this user instead of creating a new one.”

Thanks for this, Nathan! We’ve been looking for a way to make this work.

I am able to get the new user account created with the recurring payment in Stripe, but I’m having trouble with the update of payment info. I did notice that I’m not seeing a meta field in the user profile for Stripe customer number, so I checked, and there doesn’t seem to be any usermeta in the database for Stripe customer number. Was that usermeta field something that I should have created manually? I’m seeing “update_user_meta” in the second function, but it seems like if “_stripe_customer_id” has not already been created as a meta field, it won’t do anything? Or maybe I’m misunderstanding this…?

Hi Nathan! I did include that. I realized that what was happening was the one form was not creating the user account AND saving the ID. What finally worked for me was creating a separate form just to create the user account (I’m using just email & pw fields), then set the confirmation for that form as a redirect to my subscription form, where the user just continues on, and everything works beautifully!

I know we are going to be implementing this on a number of sites! So handy! Thanks again for sharing!

Hi Nathan great blog, found it really helpful. Just wanted to add that I, like Bet Hannon, had to split this into 2 forms to get the updating to work. You can register users using your form no problem, but when it comes to updating the details it doesn’t send the updated to stripe. If you split the register user process into a form that then on sucess passes to a payment form, and this form updates the user details it all seems to work. Just wanted to let people know thats what worked for me.
You’ve saved me a lot of time though so great work, really appreciate it!

This article is so helpful for newbies like me. I do have a question about cancellation. It appears the code you included is to downgrade a customer after cancellation. How would I allow for a customer to cancel their subscription themselves? Timing doesn’t matter, I just want them to be able to cancel themselves (I assume using a simple form) and it stops the recurring charge from stripe.

Great article! Thanks.
I implemented gravity forms stripe addon with gravity forms on one of my sites. However, there is one particular issue that has been buggin me lately.

After all is setup. I tried to do a test transaction. However, I receive an error saying “Received unknown parameter: name”

Could you please help me out. Please shed some light. I am new to wordpress and doesn’t have that much of knowledge on payment gateways. I am using Gravity forms and it’s addon for stripe to get do this subscription model.