Stripe

Use Stripe to process your one-time and recurring payments. Stripe enhances the user experience by allowing users to stay on your site while securely making a payment.

In order to use Stripe, you will need an SSL connection. You can use an unencrypted connection for testing purposes, however.

Download and install

  1. This add-on requires Formidable Forms Pro. If you haven't already done so, install and activate Formidable Forms Pro.
  2. Download the latest version of the Stripe plugin.
  3. In your WordPress admin, go to 'Plugins' → 'Add New' and click the 'Upload Plugin' button at the top of the page.
  4. Upload the zip file you just downloaded in step one. Once the plugin is installed, click 'Activate Plugin' or go to the 'Plugins' page, find 'Formidable Stripe' and click 'Activate'.
  5. In your WordPress admin, go to Formidable → Global Settings → Plugin Licenses and add your license key.

Set up Stripe API

Now that the Stripe plugin is activated you'll need to connect your Stripe account. To do this follow the steps below.

  1. Go to the Formidable → Global settings → Stripe tab, and add your API keys.
    Stripe Global Settings
    Your keys can be found on your Stripe Account → API Keys page.
    Stripe API Keys
  2. If you would like to use recurring subscriptions or refund payments from stripe.com, your site will need to receive notifications from Stripe. To enable these notifications, go to your Stripe Account → Webhooks page, and add the link shown at the bottom of your Formidable → Global settings → Stripe tab. The link will look like this:
    https://example.com/wp-admin/admin-ajax.php?action=frm_strp_event

    Stripe Webhook

Set up a form to take Stripe payments

Once you have Stripe activated and you have connected your Stripe account, you can set up a form to take Stripe payments. Follow the directions below to collect Stripe payments with a Formidable form.

  1. Go into edit the form you would like to use with Stripe. Click on "Settings" → "Form Actions" → "Collect a Payment".
    Stripe Add Form Action
  2. Give your Payment action a Label for easy reference. This label will only be seen on the back-end.Stripe Form Action - Label
  3. Give your Payment action a Description to attach to the payment. This information will be sent to Stripe along with the payment. You can either type in a description, or use a field from your form to set the description dynamically. If you would like to use a field for the description, click into the Description box and then click your field in the right sidebar. This will insert a value like [3130] for your Description setting.
    Stripe Form Action - Description
  4. Set the Amount for the payment. You can either type in an amount, or use a field from your form to calculate the amount. If you would like to use a field for the amount, click into the amount box and then click your field in the right sidebar. This will insert a value like [3138] for your Amount setting.
    Stripe Form Action - Amount
    It may be helpful to use field calculations to calculate a total in your form.
  5. Next, make sure you have a Credit Card field in your form so that Stripe can process payment. If you do not have a Credit Card field in your form, you will be reminded to add a credit card field to your form.
    Stripe Form Action - Credit Card Missing
  6. Your Payment Type can be one-time or recurring. You can add multiple actions to your form if you would like both one-time and recurring payments. If you would like to allow either a one-time payment or recurring subscription, be sure to add conditional logic to both actions so they will only trigger at the times you would like.
    Stripe Form Action - Payment Type One TimeIf you have chosen a reccurring payment type, you will see the following options:
    Stripe Form Action - Payment Type Reoccuring
  7. Your Customer Info fields can be associated with field values in your form.
    Stripe Customer Info
    If you would like to pass a custom address to Stripe, you will need to add an Address field to your form.
  8. You can also change field values automatically when a payment is completed, fails, or is refunded. Anything you set here will be also be triggered with every payment in a subscription.
    Stripe After Payment
    For example, if you are creating posts, and would only like the post published when it is paid, use the After Payment settings. When the Payment is Completed, set your post status field to "publish". When Failed, set it back to "draft."

Trigger Actions after Payment

There are several actions that can be triggered after a payment is complete or fails. Emails, Twilio (text messages), and MailChimp actions are currently setup to work this way. In each of these actions, you'll find now options in the "Trigger this action after ____" setting. If you would like an email to be sent after the payment is complete, uncheck "Create" and check "Successful Payment."

With recurring payments, each payment will trigger one of these actions ("Successful Payment" or "Failed Payment").

Show a list of subscriptions

If you would like to show your users a list of their subscriptions, along with cancellation links, insert [frm-subscriptions] on a page. If a user is logged in, they will see their subscriptions listed here.

As an admin, you can see all the subscriptions on the Formidable -> Payments -> Subscriptions page.
Stripe List Subscriptions

Each subscription can be canceled from here as well.
Stripe View Subscription

Troubleshooting

The Stripe Token is missing.

If you see this error message appear, it may mean that you have not added a credit card field to your form which is required in order for payment to process.

It also may be due to an incorrect API key. Please review the steps above to make sure your API keys are setup and saved accurately. If you continue getting this message, please create a new ticket in the help desk.

This error message also shows if you have more than one payment form on the same page. This is a current limitation of the Stripe addon that we hope to improve in the future.

Additional Customizations

Change the user role

The only change needed in the example is the user role the user should have: $new_role = 'contributor';

Similar hooks are fired each time the status on a payment changes. These hooks work exactly the same way, but simply fire at different times.
frm_payment_status_complete
frm_payment_status_refunded
frm_payment_status_failed

You may want to add another function to change the role back if a payment fails or is refunded. This example changes the user role when the payment is completed. With a recurring payment, this hook will be fired each time a payment is completed.

add_action( 'frm_payment_status_complete', 'frm_change_the_role' );
function frm_change_the_role( $atts ) {
  $new_role = 'contributor';
  $entry = isset( $atts['entry'] ) ? $atts['entry'] : $atts['payment']->item_id;
  if ( is_numeric( $entry ) ) {
    $entry = FrmEntry::getOne( $entry );
  }

  $user_id = $entry->user_id;
  if ( ! empty( $user_id ) ) {
    $user = get_userdata($user_id);
    if ( ! $user ) {
        return; //don't continue if user doesn't exist
    }

    $updated_user = (array) $user;

    // Get the highest/primary role for this user  
    $user_roles = $user->roles;
    $user_role = array_shift( $user_roles );
    if ( $user_role == 'administrator' ) {
        return; //make sure we don't downgrade any admins
    }

    $updated_user['role'] = $new_role;
	
    wp_update_user( $updated_user );
  }
}