cybersource-rest-client
Version:
Node.js SDK for the CyberSource REST API
120 lines (102 loc) • 5.45 kB
JavaScript
/**
* 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/GenerateFlexAPICaptureContextRequest', 'model/InlineResponse4001'], 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/GenerateFlexAPICaptureContextRequest'), require('../model/InlineResponse4001'));
} else {
// Browser globals (root is window)
if (!root.CyberSource) {
root.CyberSource = {};
}
root.CyberSource.FlexAPIApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.GenerateFlexAPICaptureContextRequest, root.CyberSource.InlineResponse4001);
}
}(this, function(MLEUtility, ApiClient, GenerateFlexAPICaptureContextRequest, InlineResponse4001) {
'use strict';
/**
* FlexAPI service.
* @module api/FlexAPIApi
* @version 0.0.1
*/
/**
* Constructs a new FlexAPIApi.
* @alias module:api/FlexAPIApi
* @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 generateFlexAPICaptureContext operation.
* @callback module:api/FlexAPIApi~generateFlexAPICaptureContextCallback
* @param {String} error Error message, if any.
* @param {'String'} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Establish a Payment Session with a Capture Context
* To establish a payment session, include the API fields you plan to use in that session in the body of the request. The system then returns a JSON Web Token (JWT) that includes the capture context. To determine which fields to include in your capture context, identify the personal information that you wish to isolate from the payment session. **Capture Context Fields**<br> When making a session request, any fields that you request to be added to the capture context are required by default. However, you can choose to make a field optional by setting the required parameter to false.
* @param {module:model/GenerateFlexAPICaptureContextRequest} generateFlexAPICaptureContextRequest
* @param {module:api/FlexAPIApi~generateFlexAPICaptureContextCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link 'String'}
*/
this.generateFlexAPICaptureContext = function(generateFlexAPICaptureContextRequest, callback) {
var postBody = generateFlexAPICaptureContextRequest;
// verify the required parameter 'generateFlexAPICaptureContextRequest' is set
if (generateFlexAPICaptureContextRequest === undefined || generateFlexAPICaptureContextRequest === null) {
throw new Error("Missing the required parameter 'generateFlexAPICaptureContextRequest' when calling generateFlexAPICaptureContext");
}
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/GenerateFlexAPICaptureContextRequest', 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/jwt'];
var returnType = 'String';
//check isMLE for an api method 'this.generateFlexAPICaptureContext'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'generateFlexAPICaptureContext');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/flex/v2/sessions', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/flex/v2/sessions', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
};
return exports;
}));