Class: GoCardlessPro::Resources::Subscription
- Inherits:
-
Object
- Object
- GoCardlessPro::Resources::Subscription
- Defined in:
- lib/gocardless_pro/resources/subscription.rb
Overview
Subscriptions create payments (https://developer.gocardless.com/api-reference/#core-endpoints-payments) according to a schedule.
Recurrence Rules
The following rules apply when specifying recurrence:
- If
day_of_monthandstart_dateare not providedstart_datewill be the mandate (https://developer.gocardless.com/api-reference/#core-endpoints-mandates)'snext_possible_charge_dateand the subscription will then recur based on theinterval&interval_unit - If
monthorday_of_monthare present the following validations apply:
| interval_unit | month |
| day_of_month |
|---|
:----------------------------------------- |
| yearly | optional (required if day_of_month provided) |
optional (invalid if month not provided) |
| monthly | invalid |
optional |
| weekly | invalid |
invalid |
Examples:
| interval_unit | interval | month | day_of_month | valid?
|
| :---------------- | :----------- | :-------- | :--------------- |
:------------------------------------------------- |
| yearly | 1 | january | -1 | valid
|
| monthly | 6 | | | valid
|
| monthly | 6 | | 12 | valid
|
| weekly | 2 | | | valid
|
| yearly | 1 | march | |
invalid - missing day_of_month |
| yearly | 1 | | 2 |
invalid - missing month |
| monthly | 6 | august | 12 |
invalid - month must be blank |
| weekly | 2 | october | 10 |
invalid - month and day_of_month must be blank |
Rolling dates
When a charge date falls on a non-business day, one of two things will happen:
- if the recurrence rule specified
-1as theday_of_month, the charge date will be rolled backwards to the previous business day (i.e., the last working day of the month). - otherwise the charge date will be rolled forwards to the next business day.
Defined Under Namespace
Classes: Links
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#app_fee ⇒ Object
readonly
Returns the value of attribute app_fee.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#day_of_month ⇒ Object
readonly
Returns the value of attribute day_of_month.
-
#earliest_charge_date_after_resume ⇒ Object
readonly
Returns the value of attribute earliest_charge_date_after_resume.
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#interval_unit ⇒ Object
readonly
Returns the value of attribute interval_unit.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#month ⇒ Object
readonly
Returns the value of attribute month.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent_plan_paused ⇒ Object
readonly
Returns the value of attribute parent_plan_paused.
-
#payment_reference ⇒ Object
readonly
Returns the value of attribute payment_reference.
-
#retry_if_possible ⇒ Object
readonly
Returns the value of attribute retry_if_possible.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#upcoming_payments ⇒ Object
readonly
Returns the value of attribute upcoming_payments.
Instance Method Summary collapse
- #api_response ⇒ Object
-
#initialize(object, response = nil) ⇒ Subscription
constructor
Initialize a subscription resource instance.
-
#links ⇒ Object
Return the links that the resource has.
-
#to_h ⇒ Object
Provides the subscription resource as a hash of all its readable attributes.
Constructor Details
#initialize(object, response = nil) ⇒ Subscription
Initialize a subscription resource instance
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 97 def initialize(object, response = nil) @object = object @amount = object['amount'] @app_fee = object['app_fee'] @count = object['count'] @created_at = object['created_at'] @currency = object['currency'] @day_of_month = object['day_of_month'] @earliest_charge_date_after_resume = object['earliest_charge_date_after_resume'] @end_date = object['end_date'] @id = object['id'] @interval = object['interval'] @interval_unit = object['interval_unit'] @links = object['links'] @metadata = object['metadata'] @month = object['month'] @name = object['name'] @parent_plan_paused = object['parent_plan_paused'] @payment_reference = object['payment_reference'] @retry_if_possible = object['retry_if_possible'] @start_date = object['start_date'] @status = object['status'] @upcoming_payments = object['upcoming_payments'] @response = response end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
74 75 76 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 74 def amount @amount end |
#app_fee ⇒ Object (readonly)
Returns the value of attribute app_fee.
75 76 77 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 75 def app_fee @app_fee end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
76 77 78 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 76 def count @count end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
77 78 79 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 77 def created_at @created_at end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
78 79 80 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 78 def currency @currency end |
#day_of_month ⇒ Object (readonly)
Returns the value of attribute day_of_month.
79 80 81 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 79 def day_of_month @day_of_month end |
#earliest_charge_date_after_resume ⇒ Object (readonly)
Returns the value of attribute earliest_charge_date_after_resume.
80 81 82 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 80 def earliest_charge_date_after_resume @earliest_charge_date_after_resume end |
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
81 82 83 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 81 def end_date @end_date end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
82 83 84 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 82 def id @id end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
83 84 85 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 83 def interval @interval end |
#interval_unit ⇒ Object (readonly)
Returns the value of attribute interval_unit.
84 85 86 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 84 def interval_unit @interval_unit end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
85 86 87 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 85 def @metadata end |
#month ⇒ Object (readonly)
Returns the value of attribute month.
86 87 88 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 86 def month @month end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
87 88 89 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 87 def name @name end |
#parent_plan_paused ⇒ Object (readonly)
Returns the value of attribute parent_plan_paused.
88 89 90 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 88 def parent_plan_paused @parent_plan_paused end |
#payment_reference ⇒ Object (readonly)
Returns the value of attribute payment_reference.
89 90 91 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 89 def payment_reference @payment_reference end |
#retry_if_possible ⇒ Object (readonly)
Returns the value of attribute retry_if_possible.
90 91 92 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 90 def retry_if_possible @retry_if_possible end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
91 92 93 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 91 def start_date @start_date end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
92 93 94 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 92 def status @status end |
#upcoming_payments ⇒ Object (readonly)
Returns the value of attribute upcoming_payments.
93 94 95 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 93 def upcoming_payments @upcoming_payments end |
Instance Method Details
#api_response ⇒ Object
124 125 126 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 124 def api_response ApiResponse.new(@response) end |
#links ⇒ Object
Return the links that the resource has
129 130 131 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 129 def links @subscription_links ||= Links.new(@links) end |
#to_h ⇒ Object
Provides the subscription resource as a hash of all its readable attributes
134 135 136 |
# File 'lib/gocardless_pro/resources/subscription.rb', line 134 def to_h @object end |