cybersource-rest-client
Version:
Node.js SDK for the CyberSource REST API
120 lines (102 loc) • 6.46 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/GenerateUnifiedCheckoutCaptureContextRequest', '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/GenerateUnifiedCheckoutCaptureContextRequest'), require('../model/InlineResponse4001'));
} else {
// Browser globals (root is window)
if (!root.CyberSource) {
root.CyberSource = {};
}
root.CyberSource.UnifiedCheckoutCaptureContextApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.GenerateUnifiedCheckoutCaptureContextRequest, root.CyberSource.InlineResponse4001);
}
}(this, function(MLEUtility, ApiClient, GenerateUnifiedCheckoutCaptureContextRequest, InlineResponse4001) {
'use strict';
/**
* UnifiedCheckoutCaptureContext service.
* @module api/UnifiedCheckoutCaptureContextApi
* @version 0.0.1
*/
/**
* Constructs a new UnifiedCheckoutCaptureContextApi.
* @alias module:api/UnifiedCheckoutCaptureContextApi
* @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 generateUnifiedCheckoutCaptureContext operation.
* @callback module:api/UnifiedCheckoutCaptureContextApi~generateUnifiedCheckoutCaptureContextCallback
* @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 Unified Checkout Capture Context
* Unified Checkout is a powerful product within the Digital Acceptance Suite. Unified Checkout is designed to assist merchants with the adoption and inclusion of digital payments within their payment acceptance page. With Unified Checkout Integration you can add digital payment methods to create familiar, convenient and seamless payment experiences that are designed to reduce checkout friction and increase conversions. Click to Pay Drop-in UI is built on the Unified Checkout platform. For more information about Unified Checkout, see the [Unified Checkout Developer Guides Page](https://developer.cybersource.com/docs/cybs/en-us/unified-checkout/developer/all/rest/unified-checkout/uc-intro.html). For examples on how to integrate Unified Checkout within your webpage please see our [GitHub Unified Checkout Samples](https://github.com/CyberSource/cybersource-unified-checkout-sample-java). Generate Unified Checkout Capture Context Generate a one-time use capture context used for the invocation of Unified Checkout. The Request wil contain all of the parameters for how Unified Checkout will operate within a client webpage. The resulting payload will be a JWT signed object that can be used to initiate Unified Checkout or Click to Pay Drop-in UI within a web page
* @param {module:model/GenerateUnifiedCheckoutCaptureContextRequest} generateUnifiedCheckoutCaptureContextRequest
* @param {module:api/UnifiedCheckoutCaptureContextApi~generateUnifiedCheckoutCaptureContextCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link 'String'}
*/
this.generateUnifiedCheckoutCaptureContext = function(generateUnifiedCheckoutCaptureContextRequest, callback) {
var postBody = generateUnifiedCheckoutCaptureContextRequest;
// verify the required parameter 'generateUnifiedCheckoutCaptureContextRequest' is set
if (generateUnifiedCheckoutCaptureContextRequest === undefined || generateUnifiedCheckoutCaptureContextRequest === null) {
throw new Error("Missing the required parameter 'generateUnifiedCheckoutCaptureContextRequest' when calling generateUnifiedCheckoutCaptureContext");
}
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/GenerateUnifiedCheckoutCaptureContextRequest', 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.generateUnifiedCheckoutCaptureContext'
var isMLESupportedByCybsForApi = false;
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, isMLESupportedByCybsForApi, 'generateUnifiedCheckoutCaptureContext');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/up/v1/capture-contexts', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/up/v1/capture-contexts', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
};
return exports;
}));