cybersource-rest-client
Version:
Node.js SDK for the CyberSource REST API
250 lines (210 loc) • 12.6 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/CheckPayerAuthEnrollmentRequest', 'model/PayerAuthSetupRequest', 'model/PtsV2PaymentsPost502Response', 'model/RiskV1AuthenticationResultsPost201Response', 'model/RiskV1AuthenticationSetupsPost201Response', 'model/RiskV1AuthenticationsPost201Response', 'model/RiskV1AuthenticationsPost400Response', 'model/RiskV1AuthenticationsPost400Response1', 'model/ValidateRequest'], 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/CheckPayerAuthEnrollmentRequest'), require('../model/PayerAuthSetupRequest'), require('../model/PtsV2PaymentsPost502Response'), require('../model/RiskV1AuthenticationResultsPost201Response'), require('../model/RiskV1AuthenticationSetupsPost201Response'), require('../model/RiskV1AuthenticationsPost201Response'), require('../model/RiskV1AuthenticationsPost400Response'), require('../model/RiskV1AuthenticationsPost400Response1'), require('../model/ValidateRequest'));
} else {
// Browser globals (root is window)
if (!root.CyberSource) {
root.CyberSource = {};
}
root.CyberSource.PayerAuthenticationApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.CheckPayerAuthEnrollmentRequest, root.CyberSource.PayerAuthSetupRequest, root.CyberSource.PtsV2PaymentsPost502Response, root.CyberSource.RiskV1AuthenticationResultsPost201Response, root.CyberSource.RiskV1AuthenticationSetupsPost201Response, root.CyberSource.RiskV1AuthenticationsPost201Response, root.CyberSource.RiskV1AuthenticationsPost400Response, root.CyberSource.RiskV1AuthenticationsPost400Response1, root.CyberSource.ValidateRequest);
}
}(this, function(MLEUtility, ApiClient, CheckPayerAuthEnrollmentRequest, PayerAuthSetupRequest, PtsV2PaymentsPost502Response, RiskV1AuthenticationResultsPost201Response, RiskV1AuthenticationSetupsPost201Response, RiskV1AuthenticationsPost201Response, RiskV1AuthenticationsPost400Response, RiskV1AuthenticationsPost400Response1, ValidateRequest) {
'use strict';
/**
* PayerAuthentication service.
* @module api/PayerAuthenticationApi
* @version 0.0.1
*/
/**
* Constructs a new PayerAuthenticationApi.
* @alias module:api/PayerAuthenticationApi
* @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 checkPayerAuthEnrollment operation.
* @callback module:api/PayerAuthenticationApi~checkPayerAuthEnrollmentCallback
* @param {String} error Error message, if any.
* @param {module:model/RiskV1AuthenticationsPost201Response} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Check Payer Auth Enrollment
* This call verifies that the card is enrolled in a card authentication program.
* @param {module:model/CheckPayerAuthEnrollmentRequest} checkPayerAuthEnrollmentRequest
* @param {module:api/PayerAuthenticationApi~checkPayerAuthEnrollmentCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/RiskV1AuthenticationsPost201Response}
*/
this.checkPayerAuthEnrollment = function(checkPayerAuthEnrollmentRequest, callback) {
var postBody = checkPayerAuthEnrollmentRequest;
// verify the required parameter 'checkPayerAuthEnrollmentRequest' is set
if (checkPayerAuthEnrollmentRequest === undefined || checkPayerAuthEnrollmentRequest === null) {
throw new Error("Missing the required parameter 'checkPayerAuthEnrollmentRequest' when calling checkPayerAuthEnrollment");
}
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/CheckPayerAuthEnrollmentRequest', 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/hal+json;charset=utf-8'];
var returnType = RiskV1AuthenticationsPost201Response;
//check isMLE for an api method 'this.checkPayerAuthEnrollment'
var inboundMLEStatus = 'optional';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'checkPayerAuthEnrollment');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/risk/v1/authentications', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/risk/v1/authentications', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the payerAuthSetup operation.
* @callback module:api/PayerAuthenticationApi~payerAuthSetupCallback
* @param {String} error Error message, if any.
* @param {module:model/RiskV1AuthenticationSetupsPost201Response} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Setup Payer Auth
* A new service for Merchants to get reference_id for Digital Wallets to use in place of BIN number in Cardinal. Set up file while authenticating with Cardinal. This service should be called by Merchant when payment instrument chosen or changes. This service has to be called before enrollment check. 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/PayerAuthSetupRequest} payerAuthSetupRequest
* @param {module:api/PayerAuthenticationApi~payerAuthSetupCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/RiskV1AuthenticationSetupsPost201Response}
*/
this.payerAuthSetup = function(payerAuthSetupRequest, callback) {
var postBody = payerAuthSetupRequest;
// verify the required parameter 'payerAuthSetupRequest' is set
if (payerAuthSetupRequest === undefined || payerAuthSetupRequest === null) {
throw new Error("Missing the required parameter 'payerAuthSetupRequest' when calling payerAuthSetup");
}
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/PayerAuthSetupRequest', 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/hal+json;charset=utf-8'];
var returnType = RiskV1AuthenticationSetupsPost201Response;
//check isMLE for an api method 'this.payerAuthSetup'
var inboundMLEStatus = 'optional';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'payerAuthSetup');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/risk/v1/authentication-setups', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/risk/v1/authentication-setups', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the validateAuthenticationResults operation.
* @callback module:api/PayerAuthenticationApi~validateAuthenticationResultsCallback
* @param {String} error Error message, if any.
* @param {module:model/RiskV1AuthenticationResultsPost201Response} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Validate Authentication Results
* This call retrieves and validates the authentication results from issuer and allows the merchant to proceed with processing the payment.
* @param {module:model/ValidateRequest} validateRequest
* @param {module:api/PayerAuthenticationApi~validateAuthenticationResultsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/RiskV1AuthenticationResultsPost201Response}
*/
this.validateAuthenticationResults = function(validateRequest, callback) {
var postBody = validateRequest;
// verify the required parameter 'validateRequest' is set
if (validateRequest === undefined || validateRequest === null) {
throw new Error("Missing the required parameter 'validateRequest' when calling validateAuthenticationResults");
}
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/ValidateRequest', 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/hal+json;charset=utf-8'];
var returnType = RiskV1AuthenticationResultsPost201Response;
//check isMLE for an api method 'this.validateAuthenticationResults'
var inboundMLEStatus = 'optional';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'validateAuthenticationResults');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/risk/v1/authentication-results', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/risk/v1/authentication-results', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
};
return exports;
}));