peterkeen/payola — pull request #40 by jagthedrummer (2014-11-13 01:50:10+00:00)
Title: Subscription coupons

This is not ready to merge yet, but I wanted to get some feedback on the approach. This introduces a `Payola::StripeCoupon` concern that can be included in `ActiveModel`s. It handles creating the coupon at Stripe before the model is saved. This approach makes it easy for an app to build out their own logic for coupons, but it does have some drawbacks.

* We need to register coupon classes, currently this is in `Payola.saveables`
* When a coupon is redeemed we have to iterate over the classes in `Payola.saveables` calling `find` to look for a coupon.

This is assuming that we do want to actually look up the coupon before passing it to Stripe. We could conceivably not model Stripe coupons at all and just tell people to set them up in the Stripe interface, and then provide some instructions on how to pass in codes in a way that Payola will understand (params[:cc] for instance). Then Payola could just pass that code directly to Stripe.

If we do want to actually model the coupons, then another alternative would be to have a `Payola::StripeCoupon` model (instead of concern) that works much like the current approach, but without the need for `Payola.saveables`. If we took the approach we could conceivably allow easy extension by developers by allowing for a `type` attribute so that they could use single table inheritance.

What do you think?