Skip to content

Instantly share code, notes, and snippets.

@Harrisonl
Created August 13, 2015 02:41
Show Gist options
  • Save Harrisonl/e7bfa3056adf36ebfc23 to your computer and use it in GitHub Desktop.
Save Harrisonl/e7bfa3056adf36ebfc23 to your computer and use it in GitHub Desktop.
def pay_by_card
# Get the credit card details submitted by the form
token = params[:stripeToken]
charge = charge_customer(@project, token)
if charge.successful?
create_payment(@project)
@project.update_attributes(paid: true)
@project.create_conversation_for_project
ProjectsMailer.inform_admin.deliver_later
session.delete(:signing_up_payment)
flash[:notice] = " Request Successfully added."
redirect_to dashboard_path
else
@payment = Payment.new
flash[:notice] = "An error occurred: #{charge.error_message}"
render :new_signup if session[:signing_up_payment] == true
render :new if session[:signing_up_payment] == nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment