-
Notifications
You must be signed in to change notification settings - Fork 22
Plan
lyang edited this page Mar 17, 2013
·
3 revisions
Plan is also a readonly model. You can only create/update plans in Braintree web UI.
[
:billing_day_of_month, :billing_frequency, :created_at, :currency_iso_code, :description, :id,
:merchant_id, :name, :number_of_billing_cycles, :price, :trial_duration, :trial_duration_unit,
:trial_period, :updated_at
]
plan = BraintreeRails::Plan.find('plan_id')
plan.add_ons # eager loaded collection
plan = BraintreeRails::Plan.find('plan_id')
plan.discounts # eager loaded collection
plan = BraintreeRails::Plan.find('plan_id')
plan.subscriptions # lazy loaded collection from Braintree::Subscription.search
# initialize a subscription ready to be created for the plan
subscription = plan.subscriptions.build(:credit_card => a_vaulted_card) # This only allows vaulted card
subscription.save!
# another way to initialize a subscription ready to be created for the plan
subscription = plan.subscriptions.build(:payment_method_token => vaulted_card.token) # This only allows vaulted card
subscription.save!
# create a subscription for this plan
subscription = plan.subscriptions.create(:credit_card => a_vaulted_card) # This only allows vaulted card
# find a subscription from the cached collection instead of firing API call
subscription = plan.subscriptions.find('subscription_id')
None
None
Returns an array of BraintreeRails::Plan
. Wraps Braintree::Plan.all
behind the scenes.
A convenient find method is added. It looks for the given id in Plan.all
.