Created
January 5, 2012 16:08
-
-
Save jperrine/1565902 to your computer and use it in GitHub Desktop.
stripe callbacks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StripeCallbacksController < ApplicationController | |
def create | |
@user = User.find_by_stripe_customer_token(params[:customer]) | |
if ["recurring_payment_failed", "recurring_payment_succeeded", "subscription_final_payment_attempt_failed"].include? params[:event] | |
send(params[:event]) | |
end | |
respond_to do |format| | |
format.json { render :json => {}, :status => :ok } | |
end | |
end | |
private | |
def recurring_payment_failed | |
@user.last_payment_succeeded = false | |
@user.save(false) | |
end | |
def recurring_payment_succeeded | |
@user.last_payment_succeeded = true | |
@user.save(false) | |
end | |
def subscription_final_payment_attempt_failed | |
recurring_payment_failed | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment