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`. the subscription
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 43 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 .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CreatePrepaymentResponse.method(:from_hash)) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', APIException)) .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. the subscription
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 145 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_response_void(true) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', APIException)) .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. the subscription
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 114 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 .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ServiceCredit.method(:from_hash)) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', APIException)) .execute end |
#list_prepayments(options = {}) ⇒ PrepaymentsResponse
This request will list a subscription’s prepayments. the 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`. for List Prepayments operations
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 84 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'], key: 'filter')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth')) .array_serialization_format(ArraySerializationFormat::CSV)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PrepaymentsResponse.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', 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. the subscription
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 15 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 .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`. the subscription
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 178 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 .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PrepaymentResponse.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException) .local_error_template('400', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', RefundPrepaymentBaseErrorsResponseException) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', APIException)) .execute end |