Class: AdvancedBilling::SubscriptionInvoiceAccountController
- Inherits:
-
BaseController
- Object
- BaseController
- AdvancedBilling::SubscriptionInvoiceAccountController
- Defined in:
- lib/advanced_billing/controllers/subscription_invoice_account_controller.rb
Overview
SubscriptionInvoiceAccountController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_prepayment(subscription_id, body: nil) ⇒ CreatePrepaymentResponse
## Create Prepayment In order to specify a prepayment made against a subscription, specify the ‘amount, memo, details, method`.
-
#deduct_service_credit(subscription_id, body: nil) ⇒ void
Credit will be removed from the subscription in the amount specified in the request body.
-
#issue_service_credit(subscription_id, body: nil) ⇒ ServiceCredit
Credit will be added to the subscription in the amount specified in the request body.
-
#list_prepayments(options = {}) ⇒ PrepaymentsResponse
This request will list a subscription’s prepayments.
-
#read_account_balances(subscription_id) ⇒ AccountBalances
Returns the ‘balance_in_cents` of the Subscription’s Pending Discount, Service Credit, and Prepayment accounts, as well as the sum of the Subscription’s open, payable invoices.
-
#refund_prepayment(subscription_id, prepayment_id, body: nil) ⇒ PrepaymentResponse
This endpoint will refund, completely or partially, a particular prepayment applied to a subscription.
Methods inherited from BaseController
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from AdvancedBilling::BaseController
Instance Method Details
#create_prepayment(subscription_id, body: nil) ⇒ CreatePrepaymentResponse
## Create Prepayment In order to specify a prepayment made against a subscription, specify the ‘amount, memo, details, method`. When the `method` specified is `“credit_card_on_file”`, the prepayment amount will be collected using the default credit card payment profile and applied to the prepayment account balance. This is especially useful for manual replenishment of prepaid subscriptions. Please note that you **can’t** pass ‘amount_in_cents`. subscription
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 160 def create_prepayment(subscription_id, body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/subscriptions/{subscription_id}/prepayments.json', Server::DEFAULT) .template_param(new_parameter(subscription_id, key: 'subscription_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('BasicAuth'))) .response(new_response_handler .is_nullify404(true) .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CreatePrepaymentResponse.method(:from_hash))) .execute end |
#deduct_service_credit(subscription_id, body: nil) ⇒ void
This method returns an undefined value.
Credit will be removed from the subscription in the amount specified in the request body. The credit amount being deducted must be equal to or less than the current credit balance. subscription
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 126 def deduct_service_credit(subscription_id, body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/subscriptions/{subscription_id}/service_credit_deductions.json', Server::DEFAULT) .template_param(new_parameter(subscription_id, key: 'subscription_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('BasicAuth'))) .response(new_response_handler .is_nullify404(true) .is_response_void(true) .local_error('422', 'Unprocessable Entity (WebDAV)', ErrorListResponseException)) .execute end |
#issue_service_credit(subscription_id, body: nil) ⇒ ServiceCredit
Credit will be added to the subscription in the amount specified in the request body. The credit is subsequently applied to the next generated invoice. subscription
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 16 def issue_service_credit(subscription_id, body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/subscriptions/{subscription_id}/service_credits.json', Server::DEFAULT) .template_param(new_parameter(subscription_id, key: 'subscription_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('BasicAuth'))) .response(new_response_handler .is_nullify404(true) .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ServiceCredit.method(:from_hash))) .execute end |
#list_prepayments(options = {}) ⇒ PrepaymentsResponse
This request will list a subscription’s prepayments. subscription pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned. Use in query ‘page=1`. many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200. Use in query `per_page=200`. filter you would like to apply to your search. created_at - Time when prepayment was created. application_at - Time when prepayment was applied to invoice. Use in query `filter=created_at`. (format YYYY-MM-DD) with which to filter the date_field. Returns prepayments with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified. Use in query `filter=2011-12-15`. YYYY-MM-DD) with which to filter the date_field. Returns prepayments with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified. Use in query `filter=2011-12-15`.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 88 def list_prepayments( = {}) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/subscriptions/{subscription_id}/prepayments.json', Server::DEFAULT) .template_param(new_parameter(['subscription_id'], key: 'subscription_id') .is_required(true) .should_encode(true)) .query_param(new_parameter(['page'], key: 'page')) .query_param(new_parameter(['per_page'], key: 'per_page')) .query_param(new_parameter(['filter_date_field'], key: 'filter[date_field]')) .query_param(new_parameter(['filter_start_date'], key: 'filter[start_date]')) .query_param(new_parameter(['filter_end_date'], key: 'filter[end_date]')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth'))) .response(new_response_handler .is_nullify404(true) .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PrepaymentsResponse.method(:from_hash)) .local_error('401', 'Unauthorized', APIException) .local_error('403', 'Forbidden', APIException) .local_error('404', 'Not Found', APIException)) .execute end |
#read_account_balances(subscription_id) ⇒ AccountBalances
Returns the ‘balance_in_cents` of the Subscription’s Pending Discount, Service Credit, and Prepayment accounts, as well as the sum of the Subscription’s open, payable invoices. subscription
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 43 def read_account_balances(subscription_id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/subscriptions/{subscription_id}/account_balances.json', Server::DEFAULT) .template_param(new_parameter(subscription_id, key: 'subscription_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth'))) .response(new_response_handler .is_nullify404(true) .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(AccountBalances.method(:from_hash))) .execute end |
#refund_prepayment(subscription_id, prepayment_id, body: nil) ⇒ PrepaymentResponse
This endpoint will refund, completely or partially, a particular prepayment applied to a subscription. The ‘prepayment_id` will be the account transaction ID of the original payment. The prepayment must have some amount remaining in order to be refunded. The amount may be passed either as a decimal, with `amount`, or an integer in cents, with `amount_in_cents`. subscription
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 192 def refund_prepayment(subscription_id, prepayment_id, body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/subscriptions/{subscription_id}/prepayments/{prepayment_id}/refunds.json', Server::DEFAULT) .template_param(new_parameter(subscription_id, key: 'subscription_id') .is_required(true) .should_encode(true)) .template_param(new_parameter(prepayment_id, key: 'prepayment_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('BasicAuth'))) .response(new_response_handler .is_nullify404(true) .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PrepaymentResponse.method(:from_hash)) .local_error('400', 'Bad Request', RefundPrepaymentBaseErrorsResponseException) .local_error('404', 'Not Found', APIException) .local_error('422', 'Unprocessable Entity', RefundPrepaymentAggregatedErrorsResponseException)) .execute end |