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 )
For more detailed documentation on Subscriptions, see www.braintreepaymentsolutions.com/gateway/subscription-api
| [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 |
Finds the subscription with the given id. Raises a Braintree::NotFoundError if the subscription cannot be found.
Allows searching on subscriptions. There are two types of fields that are searchable: text and multiple value fields. Searchable text fields are:
Searchable multiple value fields are:
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