PayMe

This gem is currently a work in progress, follows semver, and may change significantly until version 1.0

A gem for attaching a payment system to business login in Rails

TODO...

Details

TODO...

Testing

Ensure you have STRIPE_TEST_SECRET_KEY as an ENV variable. This progect uses dotenv so you can create a .env file. You can run the tests using rake test.

Installation

Add the gem to your Gemfile: gem 'pay_me'.

Run bundle install to install it.

Run rails g pay_me:install

Add the following to your routes

...
  pay_me_customerable_for :users
...

Add the following to your customer model controller

require 'pay_me/concerns/controllers/customerable'
...
class UsersController < BaseController
  include PayMe::Concerns::Controllers::Customerable
...

Add the following to your customer model

require 'pay_me/concerns/models/customerable'
...
class User < ActiveRecord::Base
  include PayMe::Concerns::Models::Customerable
...

The model will also need a receipt_email attribute and customer_id.

The installer will automatically add the following to your secrets.yml for development test and production. secrets.yml

development:
  ###
  # Other configs
  ###
  stripe_publishable_key: <%= ENV['STRIPE_PUBLISHABLE_KEY'] %>
  stripe_secret_key: <%= ENV['STRIPE_SECRET_KEY'] %>
  stripe_webhook_secret: <%= ENV['STRIPE_WEBHOOK_SECRET'] %>
  stripe_signing_secret: <%= ENV['STRIPE_SIGNING_SECRET'] %>

or using inheritance: secrets.yml

stripe: &stripe
  stripe_publishable_key: <%= ENV['STRIPE_PUBLISHABLE_KEY'] %>
  stripe_secret_key: <%= ENV['STRIPE_SECRET_KEY'] %>
  stripe_webhook_secret: <%= ENV['STRIPE_WEBHOOK_SECRET'] %>
  stripe_signing_secret: <%= ENV['STRIPE_SIGNING_SECRET'] %>

development:
  <<: *stripe
  ...

test:
  <<: *stripe
  ...

production:
  <<: *stripe
  ...

You will need to add the stripe keys to your ENV.

  • STRIPE_PUBLISHABLE_KEY is your stripe publishable key.
  • STRIPE_SECRET_KEY is your stripe secret key.
  • STRIPE_WEBHOOK_SECRET is a secret that is used for stripe as a password for basic authentication to the webhook. You can use rake secret to generate a suitable secret. This is also used when configuring the stripe webhook in stripe: https://stripe:[email protected]/pay_me-stripe_webhooks
  • STRIPE_SIGNING_SECRET is used by stripe to sign webhooks. It can be found in your stripe webhook settings.

PayMe adds to rake task for caching Stripe plans locally to reduce calls to stripe. They are:

  • pay_me:stripe:add_stripe_plans This will add missing Stripe plans, but not delete local ones that no longer exist on stripe.
  • pay_me:stripe:sync_stripe_plans This will add missing Stripe plans and delete local ones that don't exist on stripe.

You are now setup!

Stripe Configuration Checklist

  • [ ] Get API keys and add to ENV
  • [ ] Add webhook URL and webhook secret to ENV
  • [ ] Get webhook signing secret and add to ENV
  • [ ] Add plan(s) to Stripe. TODO...

Usage

Todo:

  • [ ] TODO...

License

Copyright (c) 2015, Pay Me is developed and maintained by Wildland