UNPKG

cybersource-rest-client

Version:

Node.js SDK for the CyberSource REST API

580 lines (492 loc) 24.5 kB
/** * CyberSource Merged Spec * All CyberSource API specs merged together. These are available at https://developer.cybersource.com/api/reference/api-reference.html * * OpenAPI spec version: 0.0.1 * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * * Swagger Codegen version: 2.4.38 * * Do not edit the class manually. * */ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['Authentication/MLEUtility', 'ApiClient', 'model/ActivateDeactivatePlanResponse', 'model/CreatePlanRequest', 'model/CreatePlanResponse', 'model/DeletePlanResponse', 'model/GetAllPlansResponse', 'model/GetPlanCodeResponse', 'model/GetPlanResponse', 'model/InlineResponse4003', 'model/InlineResponse404', 'model/PtsV2PaymentsPost502Response', 'model/UpdatePlanRequest', 'model/UpdatePlanResponse'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. module.exports = factory(require('../authentication/util/MLEUtility'), require('../ApiClient'), require('../model/ActivateDeactivatePlanResponse'), require('../model/CreatePlanRequest'), require('../model/CreatePlanResponse'), require('../model/DeletePlanResponse'), require('../model/GetAllPlansResponse'), require('../model/GetPlanCodeResponse'), require('../model/GetPlanResponse'), require('../model/InlineResponse4003'), require('../model/InlineResponse404'), require('../model/PtsV2PaymentsPost502Response'), require('../model/UpdatePlanRequest'), require('../model/UpdatePlanResponse')); } else { // Browser globals (root is window) if (!root.CyberSource) { root.CyberSource = {}; } root.CyberSource.PlansApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.ActivateDeactivatePlanResponse, root.CyberSource.CreatePlanRequest, root.CyberSource.CreatePlanResponse, root.CyberSource.DeletePlanResponse, root.CyberSource.GetAllPlansResponse, root.CyberSource.GetPlanCodeResponse, root.CyberSource.GetPlanResponse, root.CyberSource.InlineResponse4003, root.CyberSource.InlineResponse404, root.CyberSource.PtsV2PaymentsPost502Response, root.CyberSource.UpdatePlanRequest, root.CyberSource.UpdatePlanResponse); } }(this, function(MLEUtility, ApiClient, ActivateDeactivatePlanResponse, CreatePlanRequest, CreatePlanResponse, DeletePlanResponse, GetAllPlansResponse, GetPlanCodeResponse, GetPlanResponse, InlineResponse4003, InlineResponse404, PtsV2PaymentsPost502Response, UpdatePlanRequest, UpdatePlanResponse) { 'use strict'; /** * Plans service. * @module api/PlansApi * @version 0.0.1 */ /** * Constructs a new PlansApi. * @alias module:api/PlansApi * @class * @param {module:ApiClient} apiClient Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ var exports = function(configObject, apiClient) { this.apiClient = apiClient || ApiClient.instance; this.apiClient.setConfiguration(configObject); /** * Callback function to receive the result of the activatePlan operation. * @callback module:api/PlansApi~activatePlanCallback * @param {String} error Error message, if any. * @param {module:model/ActivateDeactivatePlanResponse} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Activate a Plan * Activate a Plan * @param {String} id Plan Id * @param {module:api/PlansApi~activatePlanCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/ActivateDeactivatePlanResponse} */ this.activatePlan = function(id, callback) { var postBody = null; if ('POST' == 'POST') { postBody = '{}'; } // verify the required parameter 'id' is set if (id === undefined || id === null) { throw new Error("Missing the required parameter 'id' when calling activatePlan"); } var pathParams = { 'id': id }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json', 'application/hal+json', 'application/json;charset=utf-8', 'application/hal+json;charset=utf-8']; var returnType = ActivateDeactivatePlanResponse; //check isMLE for an api method 'this.activatePlan' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'activatePlan'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/rbs/v1/plans/{id}/activate', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/rbs/v1/plans/{id}/activate', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the createPlan operation. * @callback module:api/PlansApi~createPlanCallback * @param {String} error Error message, if any. * @param {module:model/CreatePlanResponse} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Create a Plan * 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](#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. * @param {module:model/CreatePlanRequest} createPlanRequest * @param {module:api/PlansApi~createPlanCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/CreatePlanResponse} */ this.createPlan = function(createPlanRequest, callback) { var postBody = createPlanRequest; // verify the required parameter 'createPlanRequest' is set if (createPlanRequest === undefined || createPlanRequest === null) { throw new Error("Missing the required parameter 'createPlanRequest' when calling createPlan"); } var SdkTracker = require('../utilities/tracking/SdkTracker'); var sdkTracker = new SdkTracker(); postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/CreatePlanRequest', this.apiClient.merchantConfig.runEnvironment, this.apiClient.merchantConfig.defaultDeveloperId); var pathParams = { }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json', 'application/hal+json', 'application/json;charset=utf-8', 'application/hal+json;charset=utf-8']; var returnType = CreatePlanResponse; //check isMLE for an api method 'this.createPlan' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'createPlan'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/rbs/v1/plans', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/rbs/v1/plans', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the deactivatePlan operation. * @callback module:api/PlansApi~deactivatePlanCallback * @param {String} error Error message, if any. * @param {module:model/ActivateDeactivatePlanResponse} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Deactivate a Plan * Deactivate a Plan * @param {String} id Plan Id * @param {module:api/PlansApi~deactivatePlanCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/ActivateDeactivatePlanResponse} */ this.deactivatePlan = function(id, callback) { var postBody = null; if ('POST' == 'POST') { postBody = '{}'; } // verify the required parameter 'id' is set if (id === undefined || id === null) { throw new Error("Missing the required parameter 'id' when calling deactivatePlan"); } var pathParams = { 'id': id }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json', 'application/hal+json', 'application/json;charset=utf-8', 'application/hal+json;charset=utf-8']; var returnType = ActivateDeactivatePlanResponse; //check isMLE for an api method 'this.deactivatePlan' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'deactivatePlan'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/rbs/v1/plans/{id}/deactivate', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/rbs/v1/plans/{id}/deactivate', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the deletePlan operation. * @callback module:api/PlansApi~deletePlanCallback * @param {String} error Error message, if any. * @param {module:model/DeletePlanResponse} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Delete a Plan * Delete a Plan is only allowed: - plan status is in `DRAFT` - plan status is in `ACTIVE`, and `INACTIVE` only allowed when no subscriptions attached to a plan in the lifetime of a plan * @param {String} id Plan Id * @param {module:api/PlansApi~deletePlanCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/DeletePlanResponse} */ this.deletePlan = function(id, callback) { var postBody = null; if ('DELETE' == 'POST') { postBody = '{}'; } // verify the required parameter 'id' is set if (id === undefined || id === null) { throw new Error("Missing the required parameter 'id' when calling deletePlan"); } var pathParams = { 'id': id }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json', 'application/hal+json', 'application/json;charset=utf-8', 'application/hal+json;charset=utf-8']; var returnType = DeletePlanResponse; //check isMLE for an api method 'this.deletePlan' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'deletePlan'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/rbs/v1/plans/{id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/rbs/v1/plans/{id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the getPlan operation. * @callback module:api/PlansApi~getPlanCallback * @param {String} error Error message, if any. * @param {module:model/GetPlanResponse} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Get a Plan * Retrieve a Plan details by Plan Id. * @param {String} id Plan Id * @param {module:api/PlansApi~getPlanCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/GetPlanResponse} */ this.getPlan = function(id, callback) { var postBody = null; if ('GET' == 'POST') { postBody = '{}'; } // verify the required parameter 'id' is set if (id === undefined || id === null) { throw new Error("Missing the required parameter 'id' when calling getPlan"); } var pathParams = { 'id': id }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json', 'application/hal+json', 'application/json;charset=utf-8', 'application/hal+json;charset=utf-8']; var returnType = GetPlanResponse; //check isMLE for an api method 'this.getPlan' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getPlan'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/rbs/v1/plans/{id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/rbs/v1/plans/{id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the getPlanCode operation. * @callback module:api/PlansApi~getPlanCodeCallback * @param {String} error Error message, if any. * @param {module:model/GetPlanCodeResponse} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Get a Plan Code * Get a Unique Plan Code * @param {module:api/PlansApi~getPlanCodeCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/GetPlanCodeResponse} */ this.getPlanCode = function(callback) { var postBody = null; if ('GET' == 'POST') { postBody = '{}'; } var pathParams = { }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json', 'application/hal+json', 'application/json;charset=utf-8', 'application/hal+json;charset=utf-8']; var returnType = GetPlanCodeResponse; //check isMLE for an api method 'this.getPlanCode' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getPlanCode'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/rbs/v1/plans/code', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/rbs/v1/plans/code', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the getPlans operation. * @callback module:api/PlansApi~getPlansCallback * @param {String} error Error message, if any. * @param {module:model/GetAllPlansResponse} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Get a List of Plans * Retrieve Plans by Plan Code & Plan Status. * @param {Object} opts Optional parameters * @param {Number} opts.offset Page offset number. * @param {Number} opts.limit Number of items to be returned. Default - `20`, Max - `100` * @param {String} opts.code Filter by Plan Code * @param {String} opts.status Filter by Plan Status * @param {String} opts.name Filter by Plan Name. (First sub string or full string) **[Not Recommended]** * @param {module:api/PlansApi~getPlansCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/GetAllPlansResponse} */ this.getPlans = function(opts, callback) { opts = opts || {}; var postBody = null; if ('GET' == 'POST') { postBody = '{}'; } var pathParams = { }; var queryParams = { 'offset': opts['offset'], 'limit': opts['limit'], 'code': opts['code'], 'status': opts['status'], 'name': opts['name'] }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json', 'application/hal+json', 'application/json;charset=utf-8', 'application/hal+json;charset=utf-8']; var returnType = GetAllPlansResponse; //check isMLE for an api method 'this.getPlans' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getPlans'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/rbs/v1/plans', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/rbs/v1/plans', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the updatePlan operation. * @callback module:api/PlansApi~updatePlanCallback * @param {String} error Error message, if any. * @param {module:model/UpdatePlanResponse} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Update a Plan * Update a Plan Plan in `DRAFT` status - All updates are allowed on Plan with `DRAFT` status Plan in `ACTIVE` status [Following fields are **Not Updatable**] - `planInformation.billingPeriod` - `planInformation.billingCycles` [Update is only allowed to **increase** billingCycles] - `orderInformation.amountDetails.currency` * @param {String} id Plan Id * @param {module:model/UpdatePlanRequest} updatePlanRequest * @param {module:api/PlansApi~updatePlanCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/UpdatePlanResponse} */ this.updatePlan = function(id, updatePlanRequest, callback) { var postBody = updatePlanRequest; // verify the required parameter 'id' is set if (id === undefined || id === null) { throw new Error("Missing the required parameter 'id' when calling updatePlan"); } // verify the required parameter 'updatePlanRequest' is set if (updatePlanRequest === undefined || updatePlanRequest === null) { throw new Error("Missing the required parameter 'updatePlanRequest' when calling updatePlan"); } var SdkTracker = require('../utilities/tracking/SdkTracker'); var sdkTracker = new SdkTracker(); postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/UpdatePlanRequest', this.apiClient.merchantConfig.runEnvironment, this.apiClient.merchantConfig.defaultDeveloperId); var pathParams = { 'id': id }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json', 'application/hal+json', 'application/json;charset=utf-8', 'application/hal+json;charset=utf-8']; var returnType = UpdatePlanResponse; //check isMLE for an api method 'this.updatePlan' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'updatePlan'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/rbs/v1/plans/{id}', 'PATCH', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/rbs/v1/plans/{id}', 'PATCH', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } }; return exports; }));