# WordPress

## Features

* Provides Billflow embeds as WordPress Widgets
  * Pricing Page
  * Signup Form
  * Subscription Management Portal
* Uses WordPress user authentication
* Creates users on signup using the widget
* Stripe Webhooks
  * Create WordPress users on Stripe customer created event

{% hint style="warning" %}
Does not integrate with "Ultimate Member Plugin" role system
{% endhint %}

## Supported Pages

* Plan Picker
* Checkout Form
* Customer Portal
* Pricing Page
* Invoice Portal

## Requirements

PHP 7.1 on the WordPress hosting.

## Installation

There are 2 primary ways that you can install the WordPress plugin.&#x20;

### **Method 1 - The plugin store**

Install via your WordPress site's admin panel under `http://your_wp_domain.com/wp-admin/plugin-install.php?s=servicebot&tab=search&type=term`

* Replace `your_wp_domain.com` with your actual domain
* Click install button
* Then click activate button

{% hint style="info" %}
If you see error saying "Cannot create directory" or "Permission error", this is because your server may not be setup properly, please try method 2 below.
{% endhint %}

### **Method 2 - Upload to your server**

Install by downloading the plugin from [here](http://wordpress.org/plugins/servicebot).

* Extract the downloaded Zip file
* Upload the Extracted folder to your sever under **`/wp-content/plugins/[upload extracted folder here]`** via FTP or other methods available in your hosting setup.
* Log into your WordPress site and go to **`/wp-admin/plugins.php`** and enable “Billflow"&#x20;

Then go to **`/wp-admin/admin.php?page=servicebot_plugins`** and [setup Billflow configuration.](https://docs.servicebot.io/subscription-portal/integrations/wordpress#step-1-configure-global-settings)

## Configuration

### Step 1: Configure Global Settings

Global settings apply to all widgets as the default settings unless overridden in the Widget settings.

#### Settings

| Field                     | Description                                                                                     |
| ------------------------- | ----------------------------------------------------------------------------------------------- |
| Secret Key                | Test mode secret key. Go [here to view](https://dashboard.servicebot.io/integrations/wordpress) |
| Create WP user on signup? | Check this box to create a WordPress user on signup from the widget.                            |

### Step 2: Optionally Configure Stripe Webhooks

#### Stripe Webhooks Settings

You can optionally use the Stripe Webhooks handler that comes with this plugin to create WordPress users when a Stripe Customer is created.&#x20;

> Another use case for this is when you are not signing up users with our WordPress Widgets, but users are signed up from another source, such as ClickFunnel pages. You can let those customers user your WordPress site for our customer portal embed to see their subscriptions.

First, you need to configure the Webhook handler in your Stripe dashboard. Go [here to configure](https://dashboard.stripe.com/webhooks).

{% hint style="info" %}
You will need to do this for both Live and Test mode.
{% endhint %}

1. Click on the `Add endpoint` button
2. Paste `https://your_wp_domain.com/billflow/v1/stripe-hooks` into the Endpoint URL input box &#x20;
3. Select one of the following create events
   1. `customer.created`- allow all of your Stripe customers to be able to have an account on your WordPress site to view their subscriptions.
   2. `customer.subscription.created` - allow only those Stripe customers who signed up for a service that matches your WordPress Billflow Plugin's service setting.
4. Click `Add endpoint` to save

{% hint style="info" %}
Please only use one of the create events and not both.&#x20;
{% endhint %}

![Configure the Webhook handler in Stripe ](https://3989701610-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MEUoaSM3Rb7cfrwwBCO%2F-MJ4-X3PCI3oa6xFLT2Y%2F-MJ40tocf9x-DamhJ0NH%2Fwp1.png?alt=media\&token=0d2c8dfa-34c0-4d6f-b950-7c3783382d2b)

### Other Supported Events

| Stripe Webhook Event          | Description                                                                                                                              |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| customer.subscription.updated | By enabling this event, our WP plugin will handle the event on user change plan, and update WP user roles if it was setup in the plugin. |
| customer.subscription.deleted | By enabling this event, our WP plugin will handle the event on user subscription cancelation, the WP user roles will be removed.         |

Then, you need to configure the WordPress plugin with the following keys:

| Fields                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Stripe Test Secret Key  | Test Secret Key from your Stripe dashboard. Go [here to view](https://dashboard.stripe.com/test/apikeys)                                                                                                                                                                                                                                                                                                                                                                                            |
| Stripe Live Secret Key  | Live Secret Key from your Stripe dashboard. Go [here to view](https://dashboard.stripe.com/apikeys)                                                                                                                                                                                                                                                                                                                                                                                                 |
| Stripe Test Signing Key | <p>Test Signing Key to verify that the events were sent by Stripe. </p><p>Go<a href="https://dashboard.stripe.com/webhooks"> here and select</a> the Webhook you configured for this integration. </p><p><code>See how:</code> <img src="https://3989701610-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MEUoaSM3Rb7cfrwwBCO%2F-MJ4-X3PCI3oa6xFLT2Y%2F-MJ41-kA4QurFlBGFJB5%2Fwp2.png?alt=media&#x26;token=dad3a50f-8da4-47d4-a105-a7d933f63bea" alt="" data-size="original"> </p> |
| Stripe Live Signing Key | <p>Test Signing Key to verify that the events were sent by Stripe. </p><p>Go<a href="https://dashboard.stripe.com/webhooks"> here and select</a> the Webhook you configured for this integration. </p><p><code>See how:</code> <img src="https://3989701610-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MEUoaSM3Rb7cfrwwBCO%2F-MJ4-X3PCI3oa6xFLT2Y%2F-MJ4121qW4QWWx9z-G2M%2Fwp3.png?alt=media&#x26;token=94103d27-37b4-4552-ab32-f84a4bc3fc37" alt="" data-size="original"> </p> |
| Live Mode               | Check this box to listen to live mode Stripe webhooks                                                                                                                                                                                                                                                                                                                                                                                                                                               |

Now, your Stripe Webhook handler should be working.&#x20;

You can verify by creating a customer in the Stripe dashboard then going to your WordPress site and checking if the user is created. (Webhooks may have a couple minute delay)

## Next: Add your Widget

Click next to see how to add your widget
