Class: Braintree::Subscription


Creating a Subscription

At minimum, a plan_id and payment_method_token are required. Any other values not provided will be defaulted to the plan‘s values:

 Braintree::Subscription.create(
   :payment_method_token => "my_token",
   :plan_id => "my_plan"
 )

Full example:

 Braintree::Subscription.create(
   :id => "my_id",
   :payment_method_token => "my_token",
   :plan_id => "my_plan",
   :price => "1.00",
   :trial_period => true,
   :trial_duration => "2",
   :trial_duration_unit => Subscription::TrialDurationUnit::Day
 )

More Information

For more detailed documentation on Subscriptions, see www.braintreepaymentsolutions.com/gateway/subscription-api


Attributes
[R] billing_period_end_date
[R] billing_period_start_date
[R] failure_count
[R] first_billing_date
[R] id
[R] merchant_account_id
[R] next_billing_date
[R] payment_method_token
[R] plan_id
[R] price
[R] status
[R] transactions
[R] trial_duration
[R] trial_duration_unit
[R] trial_period

Public Class Methods
_fetch_subscriptions(search, ids)
cancel(subscription_id)
create(attributes)
find(id)

Finds the subscription with the given id. Raises a Braintree::NotFoundError if the subscription cannot be found.

retry_charge(subscription_id, amount=nil)
search(&block)

Allows searching on subscriptions. There are two types of fields that are searchable: text and multiple value fields. Searchable text fields are:

  • plan_id
  • days_past_due

Searchable multiple value fields are:

  • status

For text fields, you can search using the following operators: is, is_not, starts_with, ends_with and contains. For mutiple value fields, you can search using the in operator. An example:

 Subscription.search do |s|
   s.plan_id.starts_with "abc"
   s.days_past_due.is "30"
   s.status.in [Subscription::Status::PastDue]
 end
update(subscription_id, attributes)

Public Instance Methods
==(other)

True if other has the same id.


© Copyright 2009 Braintree Payment Solutions. All Rights Reserved.