Skip to content

Instantly share code, notes, and snippets.

@iftikhar0005
Created August 13, 2013 18:13
Show Gist options
  • Save iftikhar0005/d59554a7f4697056d74f to your computer and use it in GitHub Desktop.
Save iftikhar0005/d59554a7f4697056d74f to your computer and use it in GitHub Desktop.
Stripe-Connect help
class Checkout < ActiveRecord::Base
attr_accessible :create, :new
end
class CheckoutsController < ApplicationController
#This is the post request i am making...
def save_with_payment
if valid?
customer = Stripe::Customer.create(description: email, card: stripe_card_token)
self.stripe_customer_token = customer.id
save!
end
rescue Stripe::InvalidRequestError => e
logger.error "Stripe error while creating customer: #{e.message}"
errors.add :base, "There was a problem with your credit card."
false
end
def new
@checkout = Checkout.new
end
def create
@checkout = Checkout.new(params[:checkout])
if @checkout.save_with_payment
redirect_to @checkout, :notice => "Thank you for checkout!"
else
render :new
end
end
end
@isaacsanders
Copy link

The way this is written, I don't see what Stripe Connect is doing for you. This is more about Stripe's API, it seems.

@isaacsanders
Copy link

Strip Connect is a way to make your users into vendors. If you are creating a shopping cart, you need to have Stripe integration help, not Stripe Connect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment