<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>opensoul.org - acts_as_billable :plugin, :through =&gt; :rails Changes</title>
  <id>tag:opensoul.org,2009:/2006/7/13/acts_as_billable-plugin-through-rails/changes</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://opensoul.org/2006/7/13/acts_as_billable-plugin-through-rails/changes.xml" rel="self" type="application/atom+xml"/>
  <link href="/2006/7/13/acts_as_billable-plugin-through-rails" rel="alternate" type="text/html"/>
  <updated>2006-12-01T05:58:35Z</updated>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>brandon</name>
    </author>
    <id>tag:opensoul.org,2006-12-01:190:2</id>
    <published>2006-07-13T22:59:00Z</published>
    <updated>2006-12-01T05:58:35Z</updated>
    <link href="http://opensoul.org/2006/7/13/acts_as_billable-plugin-through-rails" rel="alternate" type="text/html"/>
    <title>acts_as_billable :plugin, :through =&gt; :rails</title>
<content type="html">&lt;p&gt;At &lt;a href=&quot;http://collectiveidea.com&quot;&gt;Collective Idea&lt;/a&gt;, we&#8217;re developing &lt;a href=&quot;http://eventable.com&quot;&gt;several&lt;/a&gt; &lt;a href=&quot;http://7dots.com&quot;&gt;apps&lt;/a&gt; that take credit card payments. (We&#8217;ve previously &lt;a href=&quot;http://blog.7dots.com/articles/2006/05/24/credit-card-hell-merchant-accounts-payment-gateways-and-apis&quot; title=&quot;Credit Card Hell: Merchant Accounts, Payment Gateways and APIs&quot;&gt;blogged&lt;/a&gt; &lt;a href=&quot;http://blog.7dots.com/articles/2006/07/01/choosing-a-merchant-provider&quot; title=&quot;Chosing a Merchant Provider&quot;&gt;about&lt;/a&gt; sorting through this whole mine-field of credit card processing.) One of the ideas we came up with early on was using the magic of Ruby and Rails plugins to extract the billing and credit card processing logic into something that is reusable.&lt;/p&gt;

&lt;p&gt;We started with &lt;a href=&quot;http://home.leetsoft.com/am/&quot;&gt;ActiveMerchant&lt;/a&gt;, a handy little library developed for &lt;a href=&quot;http://shopify.com&quot;&gt;Shopify&lt;/a&gt; by JadedPixel.  ActiveMerchant is great for abstracting the credit card processing &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;, but you still need to figure out what to charge for, how much, how often, and be able to pull up a history of payments.&lt;/p&gt;

&lt;p&gt;Welcome to &lt;code&gt;acts_as_billable&lt;/code&gt;, a plugin we&#8217;re working on that we think will remove some of the complexity from online billing and payments.  To illustrate how it will work, here is an example.&lt;/p&gt;

&lt;pre&gt;
  class User &amp;amp;lt; ActiveRecord::Base
    belongs_to :plan
    acts_as_billable :plan, :frequency =&amp;amp;gt; :monthly
  end

  class Plan &amp;amp;lt; ActiveRecord::Base
    has_many :users
  end
&lt;/pre&gt;

&lt;p&gt;When a user signs up for your super-duper-new-app, they can choose a plan. That plan determines what features they get, and how much they pay to use your app.  So, the user should be billed (well charged, but chargable just doesn&#8217;t sound as nice) each month for the plan.&lt;/p&gt;

&lt;p&gt;Another example:&lt;/p&gt;

&lt;pre&gt;
  class User &amp;amp;lt; ActiveRecord::Base
    has_many :registrations
    acts_as_billable :event, :through =&amp;amp;gt; :registrations
  end

  class Registration &amp;amp;lt; ActiveRecord::Base
    belongs_to :user
    belongs_to :event
  end

  class Event &amp;amp;lt; ActiveRecord::Base
    has_many :registrations
  end
&lt;/pre&gt;

&lt;p&gt;A user can register for events, which requires a payment.  Users should then be billed for each event that they register for.&lt;/p&gt;

&lt;p&gt;So what does &lt;code&gt;acts_as_billable&lt;/code&gt; really do? Several things:&lt;/p&gt;

&lt;ol&gt;
    &lt;li&gt;It adds temporary fields for the credit card information and kicks off the processing through ActiveMerchant when a record is saved.  So when an event is created, if the event costs money, it makes the &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; calls to process the credit card, returning errors if it fails.&lt;/li&gt;
    &lt;li&gt;It adds validations for the credit card information, and validates that the credit card processed successfully.&lt;/li&gt;
    &lt;li&gt;It adds polymorphic associations from the billable class (&lt;code&gt;User&lt;/code&gt; in this case) to &lt;code&gt;Exchange&lt;/code&gt; (transactions) and &lt;code&gt;Invoice&lt;/code&gt;. This gives you access to a record of all the user&#8217;s payments.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We&#8217;re pretty excited about what this plugin can do so far, and how easy it will make it for us to do more apps that require online payments.  We intend to release this plugin as open source when we get it to a usable state.  I&#8217;m sure there&#8217;s a lot we could do with it that we haven&#8217;t thought of, so we&#8217;d love some feedback.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>brandon</name>
    </author>
    <id>tag:opensoul.org,2006-10-23:122:1</id>
    <published>2006-07-13T22:59:34Z</published>
    <updated>2006-10-23T03:43:58Z</updated>
    <link href="http://opensoul.org/2006/7/13/acts_as_billable-plugin-through-rails" rel="alternate" type="text/html"/>
    <title>acts_as_billable :plugin, :through =&gt; :rails</title>
<content type="html">&lt;p&gt;At &lt;a href=&quot;http://collectiveidea.com&quot;&gt;Collective Idea&lt;/a&gt;, we&#8217;re developing &lt;a href=&quot;http://eventable.com&quot;&gt;several&lt;/a&gt; &lt;a href=&quot;http://7dots.com&quot;&gt;apps&lt;/a&gt; that take credit card payments. (We&#8217;ve previously &lt;a href=&quot;http://blog.7dots.com/articles/2006/05/24/credit-card-hell-merchant-accounts-payment-gateways-and-apis&quot; title=&quot;Credit Card Hell: Merchant Accounts, Payment Gateways and APIs&quot;&gt;blogged&lt;/a&gt; &lt;a href=&quot;http://blog.7dots.com/articles/2006/07/01/choosing-a-merchant-provider&quot; title=&quot;Chosing a Merchant Provider&quot;&gt;about&lt;/a&gt; sorting through this whole mine-field of credit card processing.) One of the ideas we came up with early on was using the magic of Ruby and Rails plugins to extract the billing and credit card processing logic into something that is reusable.&lt;/p&gt;

&lt;p&gt;We started with &lt;a href=&quot;http://home.leetsoft.com/am/&quot;&gt;ActiveMerchant&lt;/a&gt;, a handy little library developed for &lt;a href=&quot;http://shopify.com&quot;&gt;Shopify&lt;/a&gt; by JadedPixel.  ActiveMerchant is great for abstracting the credit card processing &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;, but you still need to figure out what to charge for, how much, how often, and be able to pull up a history of payments.&lt;/p&gt;

&lt;p&gt;Welcome to &lt;code&gt;acts_as_billable&lt;/code&gt;, a plugin we&#8217;re working on that we think will remove some of the complexity from online billing and payments.  To illustrate how it will work, here is an example.&lt;/p&gt;

&lt;pre&gt;
  class User &amp;amp;lt; ActiveRecord::Base
    belongs_to :plan
    acts_as_billable :plan, :frequency =&amp;amp;gt; :monthly
  end

  class Plan &amp;amp;lt; ActiveRecord::Base
    has_many :users
  end
&lt;/pre&gt;

&lt;p&gt;When a user signs up for your super-duper-new-app, they can choose a plan. That plan determines what features they get, and how much they pay to use your app.  So, the user should be billed (well charged, but chargable just doesn&#8217;t sound as nice) each month for the plan.&lt;/p&gt;

&lt;p&gt;Another example:&lt;/p&gt;

&lt;pre&gt;
  class User &amp;amp;lt; ActiveRecord::Base
    has_many :registrations
    acts_as_billable :event, :through =&amp;amp;gt; :registrations
  end

  class Registration &amp;amp;lt; ActiveRecord::Base
    belongs_to :user
    belongs_to :event
  end

  class Event &amp;amp;lt; ActiveRecord::Base
    has_many :registrations
  end
&lt;/pre&gt;

&lt;p&gt;A user can register for events, which requires a payment.  Users should then be billed for each event that they register for.&lt;/p&gt;

&lt;p&gt;So what does &lt;code&gt;acts_as_billable&lt;/code&gt; really do? Several things:&lt;/p&gt;

&lt;ol&gt;
    &lt;li&gt;It adds temporary fields for the credit card information and kicks off the processing through ActiveMerchant when a record is saved.  So when an event is created, if the event costs money, it makes the &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; calls to process the credit card, returning errors if it fails.&lt;/li&gt;
    &lt;li&gt;It adds validations for the credit card information, and validates that the credit card processed successfully.&lt;/li&gt;
    &lt;li&gt;It adds polymorphic associations from the billable class (&lt;code&gt;User&lt;/code&gt; in this case) to &lt;code&gt;Exchange&lt;/code&gt; (transactions) and &lt;code&gt;Invoice&lt;/code&gt;. This gives you access to a record of all the user&#8217;s payments.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We&#8217;re pretty excited about what this plugin can do so far, and how easy it will make it for us to do more apps that require online payments.  We intend to release this plugin as open source when we get it to a usable state.  I&#8217;m sure there&#8217;s a lot we could do with it that we haven&#8217;t thought of, so we&#8217;d love some feedback.&lt;/p&gt;</content>  </entry>
</feed>
