views:

34

answers:

0

I'm developing a simple event management/ticketing application for LAN parties. I have a need obviously to have the user buy tickets for events.

Currently, a User visits an Event page and selects a Ticket. After the user pays for the Ticket, a Registration is created and the User is permitted to further interact with other Users and the Event.

What I'm having difficulties with is the checkout/payment process. I'd like to make it a little more robust, allowing for promotional codes and discounts and whatnot, but I'm limited on time I can spend developing these extra features (new-ish to Rails, not to e-commerce).

Rather than reinvent the wheel with my own custom shopping cart logic, I'd prefer to use something already existing, open source, and of a license compatible with the Affero GPL.

Ideally, I'd like to do something like this:

require 'magic_cart'
#...
cart = MagicCart.new
cart.add_item( Registration.new({:ticket_id => 2, :number => 1, :user_id => current_user}) )

A Registration would be a subclass of the cart's LineItem class, probably, and a Ticket would be a subclass of Product.

Eventually, we'd do something like

cart.add_promo_code PromoCode.find(params[:promocode_id]

and it would be smart enough to know that a promo code can only be applied when certain items are in the cart, etc. Then, when checking out:

redirect_to cart.payment_gateway_url 

That's when the user would be directed to the URL they need to pay at (PayPal for now) and eventually come back to my app to finish the registration, verify the payment, and start doing things registered users can do:

if cart.payment.verified?
  cart.registrations.each do |reg|
    reg.valid = true
    reg.save!
  end
  redirect_to event_registration_successful_url
end

I'd rather not have to build out the cart infrastructure myself, as it's time consuming and I've got ~30 hours tops to make this happen. Thus my desire to bolt-on something else if it exists.

If you're interested in the code, take a look at it on GitHub. It's still very immature and could use the eyes of more experienced Rubyists.

I'm already using ActiveMerchant for the payment gateway stuff, or at least I've started to use it.

I've investigated using Spree or Shopify as a store, and then using an API to handle pushing tickets as a product and redirecting the user to the store to complete the transaction. However, using those would seemingly necessitate more setup and dependencies than my meager needs.