Class: CyberSourceMergedSpec::PlansController
- Inherits:
-
BaseController
- Object
- BaseController
- CyberSourceMergedSpec::PlansController
- Defined in:
- lib/cyber_source_merged_spec/controllers/plans_controller.rb
Overview
PlansController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#activate_plan(id) ⇒ ApiResponse
Activate a Plan.
-
#create_plan(create_plan_request) ⇒ ApiResponse
The recurring billing service enables you to manage payment plans and subscriptions for recurring payment schedules.
-
#deactivate_plan(id) ⇒ ApiResponse
Deactivate a Plan.
-
#delete_plan(id) ⇒ ApiResponse
Delete a Plan is only allowed: - plan status is in
DRAFT- plan status is inACTIVE, andINACTIVEonly allowed when no subscriptions attached to a plan in the lifetime of a plan. -
#get_plan(id) ⇒ ApiResponse
Retrieve a Plan details by Plan Id.
-
#get_plan_code ⇒ ApiResponse
Get a Unique Plan Code.
-
#get_plans(offset: nil, limit: nil, code: nil, status: nil, name: nil) ⇒ ApiResponse
Retrieve Plans by Plan Code & Plan Status.
-
#update_plan(id, update_plan_request) ⇒ ApiResponse
Update a Plan Plan in
DRAFTstatus - All updates are allowed on Plan withDRAFTstatus Plan inACTIVEstatus [Following fields are Not Updatable] -planInformation.billingPeriod-planInformation.billingCycles[Update is only allowed to increase billingCycles] -orderInformation.amountDetails.currencytype description here.
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 CyberSourceMergedSpec::BaseController
Instance Method Details
#activate_plan(id) ⇒ ApiResponse
Activate a Plan
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 |
# File 'lib/cyber_source_merged_spec/controllers/plans_controller.rb', line 192 def activate_plan(id) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/rbs/v1/plans/{id}/activate', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ActivateDeactivatePlanResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', ActivatePlanException) .local_error('404', 'Not found.', ActivatePlanException2Exception) .local_error('502', 'Unexpected system error or system timeout.', ActivatePlanException3Exception)) .execute end |
#create_plan(create_plan_request) ⇒ ApiResponse
The recurring billing service enables you to manage payment plans and subscriptions for recurring payment schedules. It securely stores your customer's payment information and personal data within secure Visa data centers, reducing storage risks and PCI DSS scope through the use of Token Management (TMS). The three key elements of Cybersource Recurring Billing are: - Token: stores customer billing, shipping, and payment details. - Plan: stores the billing schedule. - Subscription: combines the token and plan, and defines the subscription start date, name, and description. The APIs in this section demonstrate the management of the Plans and Subscriptions. For Tokens please refer to Token Management The availability of API features for a merchant can depend on the portfolio configuration and may need to be enabled at the portfolio level before they can be added to merchant accounts. type description here
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cyber_source_merged_spec/controllers/plans_controller.rb', line 28 def create_plan(create_plan_request) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/rbs/v1/plans', Server::DEFAULT) .body_param(new_parameter(create_plan_request) .is_required(true)) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CreatePlanResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', CreatePlanException) .local_error('502', 'Unexpected system error or system timeout.', CreatePlanException2Exception)) .execute end |
#deactivate_plan(id) ⇒ ApiResponse
Deactivate a Plan
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/cyber_source_merged_spec/controllers/plans_controller.rb', line 221 def deactivate_plan(id) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/rbs/v1/plans/{id}/deactivate', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ActivateDeactivatePlanResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', DeactivatePlanException) .local_error('404', 'Not found.', DeactivatePlanException2Exception) .local_error('502', 'Unexpected system error or system timeout.', DeactivatePlanException3Exception)) .execute end |
#delete_plan(id) ⇒ ApiResponse
Delete a Plan is only allowed:
- plan status is in
DRAFT - plan status is in
ACTIVE, andINACTIVEonly allowed when no subscriptions attached to a plan in the lifetime of a plan
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/cyber_source_merged_spec/controllers/plans_controller.rb', line 163 def delete_plan(id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/rbs/v1/plans/{id}', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(DeletePlanResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', DeletePlanException) .local_error('404', 'Not found.', DeletePlanException2Exception) .local_error('502', 'Unexpected system error or system timeout.', DeletePlanException3Exception)) .execute end |
#get_plan(id) ⇒ ApiResponse
Retrieve a Plan details by Plan Id.
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 |
# File 'lib/cyber_source_merged_spec/controllers/plans_controller.rb', line 92 def get_plan(id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/rbs/v1/plans/{id}', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetPlanResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', GetPlanException) .local_error('404', 'Not found.', GetPlanException2Exception) .local_error('502', 'Unexpected system error or system timeout.', GetPlanException3Exception)) .execute end |
#get_plan_code ⇒ ApiResponse
Get a Unique Plan Code
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/cyber_source_merged_spec/controllers/plans_controller.rb', line 249 def get_plan_code @api_call .request(new_request_builder(HttpMethodEnum::GET, '/rbs/v1/plans/code', Server::DEFAULT) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetPlanCodeResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', GetPlanCodeException) .local_error('502', 'Unexpected system error or system timeout.', GetPlanCodeException2Exception)) .execute end |
#get_plans(offset: nil, limit: nil, code: nil, status: nil, name: nil) ⇒ ApiResponse
Retrieve Plans by Plan Code & Plan Status.
Default - 20, Max - 100
string or full string) [Not Recommended]
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/cyber_source_merged_spec/controllers/plans_controller.rb', line 60 def get_plans(offset: nil, limit: nil, code: nil, status: nil, name: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/rbs/v1/plans', Server::DEFAULT) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .query_param(new_parameter(offset, key: 'offset')) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(code, key: 'code')) .query_param(new_parameter(status, key: 'status')) .query_param(new_parameter(name, key: 'name')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetAllPlansResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', GetPlansException) .local_error('502', 'Unexpected system error or system timeout.', GetPlansException2Exception)) .execute end |
#update_plan(id, update_plan_request) ⇒ ApiResponse
Update a Plan
Plan in DRAFT status
- All updates are allowed on Plan with
DRAFTstatus Plan inACTIVEstatus [Following fields are Not Updatable] planInformation.billingPeriodplanInformation.billingCycles[Update is only allowed to increase billingCycles]orderInformation.amountDetails.currencytype description here
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/cyber_source_merged_spec/controllers/plans_controller.rb', line 130 def update_plan(id, update_plan_request) @api_call .request(new_request_builder(HttpMethodEnum::PATCH, '/rbs/v1/plans/{id}', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .should_encode(true)) .body_param(new_parameter(update_plan_request) .is_required(true)) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(UpdatePlanResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', UpdatePlanException) .local_error('502', 'Unexpected system error or system timeout.', UpdatePlanException2Exception)) .execute end |