Home » Docs » Connecting to Stripe

Connecting to Stripe

Learn how to connect your site to Stripe.

Test Mode

Stripe provides a Test Mode you can use for testing your site’s integration with the Stripe platform. This is great for testing payments on your site before launching it into production.

When Test Mode is enabled in Members Only, you can make test payments using example credit cards Stripe provides for testing. The transactions are mocked and no actual money changes hands, but it works the same and lets you confirm things are working and get a feel for the flow before going live.

Enable Test Mode in Members Only by selecting the checkbox.

Stripe API Keys

To connect your Stripe account Members Only, you need to enter your Stripe API keys in the Members Only settings page on your WordPress site. You can get your Stripe API keys from your Stripe account dashboard.

These API keys are required for Members Only to communicate with Stripe, for things such as:

  • Retrieving a list of products and related prices, which is used in the Stripe Checkout block so you can select which Product and Price the button is for.
  • Retrieving a checkout session to determine if it was successfully completed.
  • Retrieving the list of subscriptions and their statuses for display in a member’s Account dashboard.
  • Cancelling a subscription if a member chooses to cancel in their Account dashboard.
  • Creating the required webhook so Stripe can send events to your site.
  • Processing webhook events that Stripe sends to your site.

You need to configure all of these keys for Members Only to work in both Test and Live modes. (Live mode is when Test mode is turned off.)

Once you have copied your API keys to the Members Only settings page, scroll to the bottom and click Save Changes.

When you click Save Changes above, Members Only will do the following:

  • Save the API keys you provided
  • Check to see if your Stripe account has the Webhook entry (see Webhooks below) required by Members Only to process events that Stripe sends to your site.
  • If the webhook does not exist, Members Only will create it, get the Webhook Signing Secret from the webhook that was just created, and save the Webhook Signing Secret to your Members Only settings.

When the settings are saved, Members Only reloads the settings page. You can then confirm that the API keys were saved and the Webhook Signing Secret was also saved.

Webhooks

When events happen in your Stripe account, such as a purchase, subscription renewal, subscription cancellation, etc. it will send a webhook to your site. Members Only listens for these events and uses them to ensure the membership features of your website are operating properly.

For example, if a user’s membership to your site expires, Members Only will use this event data to ensure the user can no longer access member-only content the next time they log in.

When Stripe sends a webhook to your site, Members Only checks the payload for the Webhook Signing Secret and verifies that it matches. If it doesn’t match, Members Only will ignore the webhook event. This prevents spoofing attempts by hackers and ensures Members Only processes only legitimate webhooks.

Note: if you “roll” or change your Webhook Signing Secret on the Stripe side, you will need to copy the new one to the Members Only settings page. Stripe does not send the updated secret via webhook to your site, therefore the only way for Members Only to know about that change is for you to update the value in the Members Only settings page. If you do not provide Members Only with the updated Webhook Signing Secret, webhook events will not be processed.