cybersource-rest-client
Version:
Node.js SDK for the CyberSource REST API
210 lines (179 loc) • 10 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/InlineResponse200', 'model/InlineResponse400', 'model/InlineResponse403', 'model/InlineResponse410', 'model/InlineResponse424', 'model/InlineResponse500', 'model/PostPaymentCredentialsRequest'], 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/InlineResponse200'), require('../model/InlineResponse400'), require('../model/InlineResponse403'), require('../model/InlineResponse410'), require('../model/InlineResponse424'), require('../model/InlineResponse500'), require('../model/PostPaymentCredentialsRequest'));
} else {
// Browser globals (root is window)
if (!root.CyberSource) {
root.CyberSource = {};
}
root.CyberSource.TokenApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.InlineResponse200, root.CyberSource.InlineResponse400, root.CyberSource.InlineResponse403, root.CyberSource.InlineResponse410, root.CyberSource.InlineResponse424, root.CyberSource.InlineResponse500, root.CyberSource.PostPaymentCredentialsRequest);
}
}(this, function(MLEUtility, ApiClient, InlineResponse200, InlineResponse400, InlineResponse403, InlineResponse410, InlineResponse424, InlineResponse500, PostPaymentCredentialsRequest) {
'use strict';
/**
* Token service.
* @module api/TokenApi
* @version 0.0.1
*/
/**
* Constructs a new TokenApi.
* @alias module:api/TokenApi
* @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 getCardArtAsset operation.
* @callback module:api/TokenApi~getCardArtAssetCallback
* @param {String} error Error message, if any.
* @param {module:model/InlineResponse200} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Retrieve Card Art
* Retrieves Card Art for a specific Instrument Identifier. The Card Art is a visual representation of the cardholder's payment card. Card Art is only available if a Network Token is successfully provisioned.
* @param {String} instrumentIdentifierId The Id of an Instrument Identifier.
* @param {module:model/String} tokenProvider The token provider.
* @param {module:model/String} assetType The type of asset.
* @param {module:api/TokenApi~getCardArtAssetCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/InlineResponse200}
*/
this.getCardArtAsset = function(instrumentIdentifierId, tokenProvider, assetType, callback) {
var postBody = null;
if ('GET' == 'POST') {
postBody = '{}';
}
// verify the required parameter 'instrumentIdentifierId' is set
if (instrumentIdentifierId === undefined || instrumentIdentifierId === null) {
throw new Error("Missing the required parameter 'instrumentIdentifierId' when calling getCardArtAsset");
}
// verify the required parameter 'tokenProvider' is set
if (tokenProvider === undefined || tokenProvider === null) {
throw new Error("Missing the required parameter 'tokenProvider' when calling getCardArtAsset");
}
// verify the required parameter 'assetType' is set
if (assetType === undefined || assetType === null) {
throw new Error("Missing the required parameter 'assetType' when calling getCardArtAsset");
}
var pathParams = {
'instrumentIdentifierId': instrumentIdentifierId,
'tokenProvider': tokenProvider,
'assetType': assetType
};
var queryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json;charset=utf-8'];
var accepts = ['application/json;charset=utf-8'];
var returnType = InlineResponse200;
//check isMLE for an api method 'this.getCardArtAsset'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getCardArtAsset');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/tms/v2/tokens/{instrumentIdentifierId}/{tokenProvider}/assets/{assetType}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/tms/v2/tokens/{instrumentIdentifierId}/{tokenProvider}/assets/{assetType}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the postTokenPaymentCredentials operation.
* @callback module:api/TokenApi~postTokenPaymentCredentialsCallback
* @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 Payment Credentials for a TMS Token
* | | | | | --- | --- | --- | |**Token**<br>A Token can represent your tokenized Customer, Payment Instrument or Instrument Identifier information.| |**Payment Credentials**<br>Contains payment information such as the network token, generated cryptogram for Visa & MasterCard or dynamic CVV for Amex in a JSON Web Encryption (JWE) response.<br>Your system can use this API to retrieve the Payment Credentials for an existing Customer, Payment Instrument or Instrument Identifier.
* @param {String} tokenId The Id of a token representing a Customer, Payment Instrument or Instrument Identifier.
* @param {module:model/PostPaymentCredentialsRequest} postPaymentCredentialsRequest
* @param {Object} opts Optional parameters
* @param {String} opts.profileId The Id of a profile containing user specific TMS configuration.
* @param {module:api/TokenApi~postTokenPaymentCredentialsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link 'String'}
*/
this.postTokenPaymentCredentials = function(tokenId, postPaymentCredentialsRequest, opts, callback) {
opts = opts || {};
var postBody = postPaymentCredentialsRequest;
// verify the required parameter 'tokenId' is set
if (tokenId === undefined || tokenId === null) {
throw new Error("Missing the required parameter 'tokenId' when calling postTokenPaymentCredentials");
}
// verify the required parameter 'postPaymentCredentialsRequest' is set
if (postPaymentCredentialsRequest === undefined || postPaymentCredentialsRequest === null) {
throw new Error("Missing the required parameter 'postPaymentCredentialsRequest' when calling postTokenPaymentCredentials");
}
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/PostPaymentCredentialsRequest', this.apiClient.merchantConfig.runEnvironment, this.apiClient.merchantConfig.defaultDeveloperId);
var pathParams = {
'tokenId': tokenId
};
var queryParams = {
};
var headerParams = {
'profile-id': opts['profileId']
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json;charset=utf-8'];
var accepts = ['application/jose;charset=utf-8'];
var returnType = 'String';
//check isMLE for an api method 'this.postTokenPaymentCredentials'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'postTokenPaymentCredentials');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/tms/v2/tokens/{tokenId}/payment-credentials', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/tms/v2/tokens/{tokenId}/payment-credentials', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
};
return exports;
}));