I'm trying to integrated Chargify's hosted billing with my rails app and am running into some difficulties.
I'm following this tutorial: http://blog.formedfunction.com/post/4022209767/how-to-integrate-chargify-hosted-payment-pages-with-a
And since I'm a total noob, I'm running into a problem here:
def self.product_id(plan)
# your own logic to retrieve the Chargify product ID for
# the plan in question (hint: I store mine in the DB)
end
Basically this is just to connect the URLs to the proper Chargify hosted page... i.e. each plan has a 6 digit ID, and depending on which plan they click on the pricing page, they should be taken to chargify.com/#{self.product_id(plan)}
I'm sure there is a simple solution, I just can't wrap my head around it right now.
Thanks in advance.
I believe that Ryan stores his plans for Golf Trac in his database with a column like "chargify_product_id" that he either filled in manually (you can find the Product ID in the Chargify UI under the "Products" tab) or by querying the API. So the first step would be to create the notion of a product or plan in your own app, and keep your offerings in sync with your Chargify setup either manually or via the API. Note: this really could be as simple as a constant in your app, if you choose, i.e.
SMALL_PLAN=123456
MEDIUM_PLAN=123457
When a user selects a plan on your site, you would then "lookup" the Chargify Product ID so that you could send them to the proper hosted page, via his hosted_signup_page_for
method.