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
Creates a prepayment for a subscription.
-
#deduct_service_credit(subscription_id, body: nil) ⇒ void
Deducts a service credit from the subscription in the specified amount.
-
#issue_service_credit(subscription_id, body: nil) ⇒ ServiceCredit
Adds a service credit to the subscription in the specified amount.
-
#list_prepayments(options = {}) ⇒ PrepaymentsResponse
Lists a subscription’s prepayments.
-
#list_service_credits(subscription_id, page: 1, per_page: 20, direction: nil) ⇒ ListServiceCreditsResponse
Lists a subscription’s service credits.
-
#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
Refunds a prepayment applied to a subscription, either fully or partially.
Methods inherited from BaseController
#initialize, #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
Creates a prepayment for a subscription. 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. Note that passing `amount_in_cents` is now allowed. ## 3D Secure (3DS) Authentication post-authentication flow When a payment requires 3DS Authentication to adhere to Strong Customer Authentication (SCA), the request enters a post-authentication flow where a 422 Unprocessable Entity status is returned with an action_link that will direct the customer through 3DS Authentication. See the [3D Secure Post-Authentication Flow](docs.maxio.com/hc/en-us/articles/44277749524365-3D-Secure-Po st-Authentication-Flow) article in the product documentation to learn how to manage the redirect flow. the subscription. description here
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 53 def create_prepayment(subscription_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/subscriptions/{subscription_id}/prepayments.json', Server::PRODUCTION) .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.
Deducts a service credit from the subscription in the specified amount. The credit amount being deducted must be equal to or less than the current credit balance. the subscription. description here
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 156 def deduct_service_credit(subscription_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/subscriptions/{subscription_id}/service_credit_deductions.json', Server::PRODUCTION) .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
Adds a service credit to the subscription in the specified amount. The credit is subsequently applied to the next generated invoice. the subscription. description here
124 125 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 124 def issue_service_credit(subscription_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/subscriptions/{subscription_id}/service_credits.json', Server::PRODUCTION) .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
Lists 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
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 94 def list_prepayments( = {}) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/subscriptions/{subscription_id}/prepayments.json', Server::PRODUCTION) .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 |
#list_service_credits(subscription_id, page: 1, per_page: 20, direction: nil) ⇒ ListServiceCreditsResponse
Lists a subscription’s service credits. 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`. in which results are returned. Use in query `direction=asc`.
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 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 195 def list_service_credits(subscription_id, page: 1, per_page: 20, direction: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/subscriptions/{subscription_id}/service_credits/list.json', Server::PRODUCTION) .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(direction, key: 'direction')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ListServiceCreditsResponse.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', ErrorListResponseException)) .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) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/subscriptions/{subscription_id}/account_balances.json', Server::PRODUCTION) .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
Refunds a prepayment applied to a subscription, either fully or partially. 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. description here
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/advanced_billing/controllers/subscription_invoice_account_controller.rb', line 236 def refund_prepayment(subscription_id, prepayment_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/subscriptions/{subscription_id}/prepayments/{prepayment_id}/refunds.json', Server::PRODUCTION) .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 |