Alaveteli Pro Pricing

So you've got Pro running, how about asking users to support your work by paying for access to the advanced features?

This page describes the Pro Pricing feature. It explains how to set-up and configure a payment gateway which can take regular payments from pro users to grant them access to Alaveteli Professional.

The Pro Pricing feature is enabled with the ENABLE_PRO_PRICING configuration setting.

With the feature enabled, users will be able to submit their bank card details and subscribe to a recurring subscription plan which will give them access to all the professional features.

Payment gateway

For a payment gateway Alaveteli Professional uses Stripe. It is widely available around the world and is easy to configure and work with.

The main advantage of Stripe is that all payment information is entered and sent directly to Stripe. They never gets transmitted to or via your Alaveteli installation so the security and data protection of those details are not a concern for you.

Creating an account

Signing up for an account with Stripe is quick and easy. Initially your account will be a limited test account.

Before you can take payments you will need to activate your account. You will need to provide legal information on you and/or your company as well as your bank details in order receive payments.

Once approved by Stripe you’ll then be able to receive payments and Stripe will transfer the money directly into your bank account.

Stripe configuration

Stripe provides a secure and robust Application Programming Interface or API which Alaveteli Professional uses to communicate with Stripe. In order to use this we require some configuration settings from your Stripe dashboard.

Follow the instructions below to set this up for your Alaveteli installation.

API keys

For Alaveteli Professional to communicate securly with Stripe you’ll need to generate a pair of standard API keys and add the STRIPE_PUBLISHABLE_KEY and STRIPE_SECRET_KEY settings.

Webhook endpoint

Stripe uses webhooks to inform the Alaveteli installation of important events, such as when a users bank card can’t be charged or when a subscription has been cancelled.

The easiest way to set up the Webhook endpoint is using a rake task this can be run from the command console:

bash$ bin/rails stripe:create_webhook_endpoint
Webhook endpoint successfully created!
Add this line to your general.yml config file:
  STRIPE_WEBHOOK_SECRET: whdec_u60BqwV5r4V4U7WmVRTuBgoR1NrPv6E4

It outputs the value for STRIPE_WEBHOOK_SECRET which should be set in config/general.yml.

Setting up the subscription product

A subscription product in Stripe needs to be created. We recommend “Pro”, but this can have any name you wish but bear in mind that this name will be displayed to users.

Once a product is created you’ll then be asked to set-up its the pricing plan. The pricing plan should be have the ID of pro, be for a recurring quantity and without multiple price tiers. You should set a memorable nickname for the plan but, again, bear in mind that this will be displayed to users.

Currently we only support monthly or yearly billing interval.

It’s will be up to you to decide the price per unit and trial period.

Creating coupons

Coupons can be created on Stripe. There are no limitations on the types of coupons created as all price calculations and adjustments are done by Stripe.

One coupon you might want to make is the pro referral coupon. This is displayed to pro users and they are encouraged to share it with other interested users.

Using a namespace

It’s possible you might have other coupons or plans already in Stripe. In this case you’ll want to set the STRIPE_NAMESPACE configuration setting.

If this setting is used the all Stripe pricing plan IDs and coupon codes will need to be prefixed with the namespace like: <namespace>-<ID or code> this should include the hyphen the namespace.

This will prevent users from using coupons intended for other non-Alaveteli Pro subscription products.

Note that the namespace is not exposed to end users. For example, given a coupon FOO-FIRSTMONTHFREE, where FOO is the STRIPE_NAMESPACE, the coupon code the user should use is FIRSTMONTHFREE

While this setting is optional we recommend using this and setting it from the beginning. If set at a later date then your Stripe pricing plan IDs and coupon codes will need to be recreated with prefixed with the namespace.

Stripe email notifications

Stripe will automatically send out emails to customers in certain situations if configured to do so, you may want to consider:

Successful payments

In the email settings you can configure Stripe to email users when they are successfully charged. Alaveteli does not send these, so we recommend enabling this.

Failed payments

On the billing email settings the ‘Send emails when card payments fail’ setting should be disabled. These emails are sent directly from Alaveteli Professional.

Limitations

Don’t add subscription from the Stripe dashboard

Currently it is not possible to use the dashboard to manually create subscriptions. If this is done your Alaveteli installation will end up out of sync with Stripe and users could be charged without being granted access to the professional features.

Testing Pro Pricing

You may wish to test Pro Pricing before enabling the ENABLE_PRO_PRICING configuration setting. This can be done on a per user basis from the command console:

bash$ bin/rails console
irb(main):001:0> user = User.find_by(email: 'YOUR_EMAIL_ADDRESS')
irb(main):002:0> AlaveteliFeatures.backend.enable(:pro_pricing, user)

Translations

Enabling Pricing also enables a “legal” page and counterpart sidebar that you’ll need to translate in the same way as help pages. In this case you must locate the templates in lib/views/alaveteli_pro/pages in your theme.

Configuration settings

The following are all the configuration settings that you can change in config/general.yml. When you edit this file, remember it must be in the YAML syntax. It’s not complicated but — especially if you’re editing a list — be careful to get the indentation correct. If in doubt, look at the examples already in the file, and don’t use tabs.

ENABLE_PRO_PRICING
STRIPE_PUBLISHABLE_KEY
STRIPE_SECRET_KEY
STRIPE_NAMESPACE
STRIPE_WEBHOOK_SECRET
PRO_REFERRAL_COUPON
ISO_CURRENCY_CODE
STRIPE_TAX_RATE


All the Pro Pricing settings

ENABLE_PRO_PRICING
Setting this will enable the Pro Pricing feature for all users.

Example:

  • ENABLE_PRO_PRICING: true
STRIPE_PUBLISHABLE_KEY & STRIPE_SECRET_KEY
API keys for your Stripe account. These can be found in the Stripe.com developer dashboard.

Examples:

  • STRIPE_PUBLISHABLE_KEY: pk_test_6rCXFw20WPjhMArF2Y3JquI2
  • STRIPE_SECRET_KEY: sk_test_pLEJl474WdGWt5Pz8KCUZo3F
STRIPE_NAMESPACE

An optional Stripe.com namespace which allows plans & coupons to be separated from other resources within Stripe. If used the Stripe resources will need IDs like: '<namespace>-<id>'.

Must be uppercase.

Example:

  • STRIPE_NAMESPACE: ALAVETELI
STRIPE_WEBHOOK_SECRET
Webhook key for your Stripe account. These can be found in the Stripe.com developer dashboard.

Example:

  • WEBHOOK_SECRET: wh_test_UD6BDsARFZIYb8273dbdl
PRO_REFERRAL_COUPON

A Stripe coupon code – displayed to existing Pro users on their subscriptions page – that they can share with friends for their friends to receive a signup discount.

This should not include the STRIPE_NAMESPACE.

You must set a `humanized_terms` key in the Coupon Metadata to display the discount that will be applied when using the coupon (e.g. "50% off for 1 month").

Example:

  • PRO_REFERRAL_COUPON: PROREFERRAL
ISO_CURRENCY_CODE
ISO currency code of the currency Alaveteli Professional cost should be displayed in. Doesn't affect what currency the plans are setup in so this should match what is configured at Stripe.com.

Example:

  • ISO_CURRENCY_CODE: GBP
STRIPE_TAX_RATE
The rate of Tax / VAT to add to Pro subscriptions. Note that the Price per unit of your Stripe Product Plan must be created without tax. Alaveteli will automatically calculate the gross amount to charge.

Example:

  • STRIPE_TAX_RATE: "0.20"