I go to subscriptions/new, put my CC info and I get this:
No background worker installed. No turbolinks. What's wrong?
Subscription_controller.rb
class SubscriptionsController < ApplicationController
# bring in the `render_payola_status` helper.
include Payola::StatusBehavior
def new
@plan = SubscriptionPlan.first
end
def create
# do any required setup here, including finding or creating the owner object
owner = current_user # this is just an example for Devise
# set your plan in the params hash
params[:plan] = SubscriptionPlan.find_by(id: 1)
params[:stripeEmail] = owner.email
# call Payola::CreateSubscription
subscription = Payola::CreateSubscription.call(params, owner)
# Render the status json that Payola's javascript expects
render_payola_status(subscription)
end
end
views/subscriptions/new.html.erb
<%= render 'payola/transactions/stripe_header' %>
<%= form_tag('/subscriptions',
class: 'payola-onestep-subscription-form',
'data-payola-base-path' => '/payola',
'data-payola-error-selector' => '.payola-error',
'data-payola-plan-type' => @plan.class,
'data-payola-plan-id' => @plan.id
) do |f| %>
<span class="payola-payment-error"></span>
Email:<br>
<input type="email" name="stripeEmail" data-payola="email"></input><br>
Card Number<br>
<input type="text" data-stripe="number"></input><br>
Exp Month<br>
<input type="text" data-stripe="exp_month"></input><br>
Exp Year<br>
<input type="text" data-stripe="exp_year"></input><br>
CVC<br>
<input type="text" data-stripe="cvc"></input><br>
<input type="submit"></input>
<div class="alert alert-warning payola-error" style="display: none"></div>
<% end %>
subscription Plan.rb (Model)
class SubscriptionPlan < ActiveRecord::Base
def redirect_path(subscription)
# you can return any path here, possibly referencing the given subscription
'http://google.com'
end
end
Payola.configure do |config|
config.secret_key = 'sk_test_blablalblalblal' config.publishable_key = 'pk_test_rCxOKWqL22MjvOvc4RsutK6o'
config.send_email_for :receipt
config.default_currency = 'eur' # Example subscription: # # config.subscribe 'payola.package.sale.finished' do |sale| # EmailSender.send_an_email(sale.email) # end # # In addition to any event that Stripe sends, you can subscribe # to the following special payola events: # # - payola..sale.finished # - payola..sale.refunded # - payola..sale.failed # # These events consume a Payola::Sale, not a Stripe::Event # # Example charge verifier: # # config.charge_verifier = lambda do |sale| # raise "Nope!" if sale.email.includes?('yahoo.com') # end
# Keep this subscription unless you want to disable refund handling config.subscribe 'charge.refunded' do |event| sale = Payola::Sale.find_by(stripe_id: event.data.object.id) sale.refund! end end
Payola.background_worker = lambda do |klass, *args| klass.call(*args) end