cybersource-rest-client
Version:
Node.js SDK for the CyberSource REST API
120 lines (102 loc) • 5.86 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/GenerateCaptureContextRequest', 'model/InlineResponseDefault'], 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/GenerateCaptureContextRequest'), require('../model/InlineResponseDefault'));
} else {
// Browser globals (root is window)
if (!root.CyberSource) {
root.CyberSource = {};
}
root.CyberSource.MicroformIntegrationApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.GenerateCaptureContextRequest, root.CyberSource.InlineResponseDefault);
}
}(this, function(MLEUtility, ApiClient, GenerateCaptureContextRequest, InlineResponseDefault) {
'use strict';
/**
* MicroformIntegration service.
* @module api/MicroformIntegrationApi
* @version 0.0.1
*/
/**
* Constructs a new MicroformIntegrationApi.
* @alias module:api/MicroformIntegrationApi
* @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 generateCaptureContext operation.
* @callback module:api/MicroformIntegrationApi~generateCaptureContextCallback
* @param {String} error Error message, if any.
* @param {'String'} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Generate Capture Context
* This API is used to generate the Capture Context data structure for the Microform Integration. Microform is a browser-based acceptance solution that allows a seller to capture payment information is a secure manner from their website. For more information about Flex Microform transactions, see the [Flex Developer Guides Page](https://developer.cybersource.com/api/developer-guides/dita-flex/SAFlexibleToken.html). For examples on how to integrate Flex Microform within your webpage please see our [GitHub Flex Samples](https://github.com/CyberSource?q=flex&type=&language=) This API is a server-to-server API to generate the capture context that can be used to initiate instance of microform on a acceptance page. The capture context is a digitally signed JWT that provides authentication, one-time keys, and the target origin to the Microform Integration application. The availability of API features for a merchant may 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/GenerateCaptureContextRequest} generateCaptureContextRequest
* @param {module:api/MicroformIntegrationApi~generateCaptureContextCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link 'String'}
*/
this.generateCaptureContext = function(generateCaptureContextRequest, callback) {
var postBody = generateCaptureContextRequest;
// verify the required parameter 'generateCaptureContextRequest' is set
if (generateCaptureContextRequest === undefined || generateCaptureContextRequest === null) {
throw new Error("Missing the required parameter 'generateCaptureContextRequest' when calling generateCaptureContext");
}
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/GenerateCaptureContextRequest', 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.generateCaptureContext'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'generateCaptureContext');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/microform/v2/sessions', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/microform/v2/sessions', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
};
return exports;
}));