Module: ChargebeeRails::Customer
- Defined in:
- lib/chargebee_rails/customer.rb
Instance Method Summary collapse
-
#as_chargebee_customer ⇒ Object
Retrieve the chargebee customer of the subscription owner - i.e subscription owner as chargebee customer * Returns : - the chargebee customer * Raises : -
ChargeBee::InvalidRequestError
-> If subscription owner is invalid. -
#invoices ⇒ Object
List all invoices for the subscription owner (customer).
-
#subscribe(options = {}) ⇒ Object
Subscribe customer to a new subscription in chargebee.
-
#subscribe_via_hosted_page(hosted_page) ⇒ Object
Subscribe customer to a new subscription in chargebee via chargebee’s hosted page.
-
#update_subscription(options = {}) ⇒ Object
Update the customer’s subscription * Args : -
options
-> the options hash allowed for subscription update in chargebee For more details on the options hash, refer the input parameters for apidocs.chargebee.com/docs/api/subscriptions?lang=ruby#update_a_subscription * Returns : - the updated subscription * Raises : -ChargeBee::InvalidRequestError
-> If subscription or options is invalid. -
#update_subscription_via_hosted_page(hosted_page) ⇒ Object
Subscribe customer to a new subscription in chargebee via chargebee’s hosted page.
Instance Method Details
#as_chargebee_customer ⇒ Object
Retrieve the chargebee customer of the subscription owner - i.e subscription owner as chargebee customer
-
Returns :
-
the chargebee customer
-
-
Raises :
-
ChargeBee::InvalidRequestError
-> If subscription owner is invalid
-
70 71 72 |
# File 'lib/chargebee_rails/customer.rb', line 70 def as_chargebee_customer ChargeBee::Customer.retrieve(chargebee_id).customer end |
#invoices ⇒ Object
List all invoices for the subscription owner (customer).
-
Returns :
-
the list of invoices for the customer in chargebee
-
-
Raises :
-
ChargeBee::InvalidRequestError
-> If customer is invalid
-
80 81 82 |
# File 'lib/chargebee_rails/customer.rb', line 80 def invoices ChargeBee::Invoice.invoices_for_customer(chargebee_id).map(&:invoice) end |
#subscribe(options = {}) ⇒ Object
Subscribe customer to a new subscription in chargebee.
-
Args :
-
options
-> the options hash allowed for subscription update in chargebee
-
For more details on the options hash, refer the input parameters for apidocs.chargebee.com/docs/api/subscriptions?lang=ruby#create_a_subscription
-
Returns :
-
the subscription
-
-
Raises :
-
ChargeBee::InvalidRequestError
-> If subscription options is invalid
-
14 15 16 |
# File 'lib/chargebee_rails/customer.rb', line 14 def subscribe(={}) SubscriptionBuilder.new(self, ).create end |
#subscribe_via_hosted_page(hosted_page) ⇒ Object
Subscribe customer to a new subscription in chargebee via chargebee’s hosted page.
-
Args :
-
hosted_page
-> thehosted_page
returned by chargebee
-
The subscription for the customer is created from the hosted_page
returned by chargebee. This hosted_page
object contains the details about the subscription in chargebee for the customer. For more on hosted_page
apidocs.chargebee.com/docs/api/hosted_pages?lang=ruby#checkout_new_subscription
-
Returns :
-
the subscription
-
-
Raises :
-
ChargeBee::InvalidRequestError
-> Ifhosted_page
is invalid
-
30 31 32 |
# File 'lib/chargebee_rails/customer.rb', line 30 def subscribe_via_hosted_page(hosted_page) HostedPageSubscriptionManager.new(self, hosted_page).create end |
#update_subscription(options = {}) ⇒ Object
Update the customer’s subscription
-
Args :
-
options
-> the options hash allowed for subscription update in chargebee
-
For more details on the options hash, refer the input parameters for apidocs.chargebee.com/docs/api/subscriptions?lang=ruby#update_a_subscription
-
Returns :
-
the updated subscription
-
-
Raises :
-
ChargeBee::InvalidRequestError
-> If subscription or options is invalid
-
59 60 61 |
# File 'lib/chargebee_rails/customer.rb', line 59 def update_subscription(={}) SubscriptionBuilder.new(self, ).update end |
#update_subscription_via_hosted_page(hosted_page) ⇒ Object
Subscribe customer to a new subscription in chargebee via chargebee’s hosted page.
-
Args :
-
hosted_page
-> thehosted_page
returned by chargebee
-
The subscription for the customer is updated from the hosted_page
returned by chargebee. This hosted_page
object contains the details about the updated subscription in chargebee for the customer.
-
Returns :
-
the subscription
-
-
Raises :
-
ChargeBee::InvalidRequestError
-> Ifhosted_page
is invalid
-
45 46 47 |
# File 'lib/chargebee_rails/customer.rb', line 45 def update_subscription_via_hosted_page(hosted_page) HostedPageSubscriptionManager.new(self, hosted_page).update end |