@paciolan/cybersource-sdk
Version:
CyberSource REST API Typescript SDK
340 lines (339 loc) • 30.2 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BillingAgreementsApi = exports.BillingAgreementsApiFactory = exports.BillingAgreementsApiFp = exports.BillingAgreementsApiAxiosParamCreator = void 0;
/* tslint:disable */
/* eslint-disable */
/**
* 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
* Do not edit the class manually.
*/
const axios_1 = __importDefault(require("axios"));
const AuthenticationHeader_1 = require("../authentication/core/AuthenticationHeader");
// Some imports not used depending on template conditions
// @ts-ignore
const base_1 = require("../base");
/**
* BillingAgreementsApi - axios parameter creator
* @export
*/
const BillingAgreementsApiAxiosParamCreator = function (configuration) {
return {
/**
* #### Standing Instruction: Standing Instruction with or without Token. #### Revoke Mandate: When you revoke a mandate, any pending direct debits linked to that mandate are canceled. No notifications are sent. When you revoke a mandate with no pending direct debits, the Bacs scheme or customer's bank notify you of any subsequent direct debit events. When you revoke a mandate, you cannot send a direct debit request using the mandate ID. Customer payments cannot be made against a revoked mandate. You can revoke a mandate when the customer: - Requests that you revoke the mandate. - Closes their account with you. Possible revoke mandate status values - - Revoked—the revoke mandate request was successfully processed. - Failed—the revoke mandate request was not accepted. #### Update Mandate: In most cases, the account details of an existing mandate cannot be updated in the Bacs schema, except by creating a new mandate. However, some very limited customer information, like name and address, can be updated to the mandate without needing to revoke it first #### Mandate Status: After the customer signs the mandate, request that the mandate status service verify the mandate status. Possible mandate status values: - Active—the mandate is successfully created. A direct debit can be sent for this mandate ID. - Pending—a pending mandate means the mandate is not yet signed. - Failed—the customer did not authenticate. - Expired—the deadline to create the mandate passed. - Revoked—the mandate is cancelled. #### Paypal Billing Agreement: A billing agreement is set up between PayPal and your customer. When you collect the details of a customer's billing agreement, you are able to bill that customer without requiring an authorization for each payment. You can bill the customer at the same time you process their PayPal Express checkout order, which simplifies your business processes.
* @summary Modify a Billing Agreement
* @param {BillingagreementsIdBody} body
* @param {string} id ID for de-registration or cancellation of Billing Agreement
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
billingAgreementsDeRegistration: (body, id, options = {}) => __awaiter(this, void 0, void 0, function* () {
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new base_1.RequiredError('body', 'Required parameter body was null or undefined when calling billingAgreementsDeRegistration.');
}
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new base_1.RequiredError('id', 'Required parameter id was null or undefined when calling billingAgreementsDeRegistration.');
}
const localVarPath = `/pts/v2/billing-agreements/{id}`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'PATCH' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
localVarHeaderParameter['Content-Type'] = 'application/json;charset=utf-8';
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
const authHeader = new AuthenticationHeader_1.AuthenticationHeader();
authHeader.setConfiguration(Object.assign(Object.assign({}, configuration), options));
localVarRequestOptions.headers = authHeader.callAuthenticationHeader(localVarRequestOptions.method, localVarPath, localVarRequestOptions.data, localVarRequestOptions.headers);
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
}),
/**
* Standing Instruction with or without Token.
* @summary Standing Instruction intimation
* @param {IdIntimationsBody} body
* @param {string} id ID for intimation of Billing Agreement
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
billingAgreementsIntimation: (body, id, options = {}) => __awaiter(this, void 0, void 0, function* () {
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new base_1.RequiredError('body', 'Required parameter body was null or undefined when calling billingAgreementsIntimation.');
}
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new base_1.RequiredError('id', 'Required parameter id was null or undefined when calling billingAgreementsIntimation.');
}
const localVarPath = `/pts/v2/billing-agreements/{id}/intimations`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
localVarHeaderParameter['Content-Type'] = 'application/json;charset=utf-8';
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
const authHeader = new AuthenticationHeader_1.AuthenticationHeader();
authHeader.setConfiguration(Object.assign(Object.assign({}, configuration), options));
localVarRequestOptions.headers = authHeader.callAuthenticationHeader(localVarRequestOptions.method, localVarPath, localVarRequestOptions.data, localVarRequestOptions.headers);
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
}),
/**
* #### Standing Instruction: Standing Instruction with or without Token. Transaction amount in case First payment is coming along with registration. Only 2 decimal places allowed #### Create Mandate: You can create a mandate through the direct debit mandate flow. Possible create mandate status values: - Pending—the create mandate request was successfully processed. - Failed—the create mandate request was not accepted. #### Import Mandate: In the Bacs scheme, a mandate is created with a status of active. Direct debit collections can be made against it immediately. You can import a mandate to the CyberSource database when: - You have existing customers with signed, active mandates - You manage mandates outside of CyberSource. When you import an existing mandate to the CyberSource database, provide a unique value for the mandate ID or the request results in an error. If an import mandate request is not accepted, the import mandate status value is failed.
* @summary Create a Billing Agreement
* @param {V2BillingagreementsBody} body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
billingAgreementsRegistration: (body, options = {}) => __awaiter(this, void 0, void 0, function* () {
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new base_1.RequiredError('body', 'Required parameter body was null or undefined when calling billingAgreementsRegistration.');
}
const localVarPath = `/pts/v2/billing-agreements`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
localVarHeaderParameter['Content-Type'] = 'application/json;charset=utf-8';
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
const authHeader = new AuthenticationHeader_1.AuthenticationHeader();
authHeader.setConfiguration(Object.assign(Object.assign({}, configuration), options));
localVarRequestOptions.headers = authHeader.callAuthenticationHeader(localVarRequestOptions.method, localVarPath, localVarRequestOptions.data, localVarRequestOptions.headers);
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
}),
};
};
exports.BillingAgreementsApiAxiosParamCreator = BillingAgreementsApiAxiosParamCreator;
/**
* BillingAgreementsApi - functional programming interface
* @export
*/
const BillingAgreementsApiFp = function (configuration) {
return {
/**
* #### Standing Instruction: Standing Instruction with or without Token. #### Revoke Mandate: When you revoke a mandate, any pending direct debits linked to that mandate are canceled. No notifications are sent. When you revoke a mandate with no pending direct debits, the Bacs scheme or customer's bank notify you of any subsequent direct debit events. When you revoke a mandate, you cannot send a direct debit request using the mandate ID. Customer payments cannot be made against a revoked mandate. You can revoke a mandate when the customer: - Requests that you revoke the mandate. - Closes their account with you. Possible revoke mandate status values - - Revoked—the revoke mandate request was successfully processed. - Failed—the revoke mandate request was not accepted. #### Update Mandate: In most cases, the account details of an existing mandate cannot be updated in the Bacs schema, except by creating a new mandate. However, some very limited customer information, like name and address, can be updated to the mandate without needing to revoke it first #### Mandate Status: After the customer signs the mandate, request that the mandate status service verify the mandate status. Possible mandate status values: - Active—the mandate is successfully created. A direct debit can be sent for this mandate ID. - Pending—a pending mandate means the mandate is not yet signed. - Failed—the customer did not authenticate. - Expired—the deadline to create the mandate passed. - Revoked—the mandate is cancelled. #### Paypal Billing Agreement: A billing agreement is set up between PayPal and your customer. When you collect the details of a customer's billing agreement, you are able to bill that customer without requiring an authorization for each payment. You can bill the customer at the same time you process their PayPal Express checkout order, which simplifies your business processes.
* @summary Modify a Billing Agreement
* @param {BillingagreementsIdBody} body
* @param {string} id ID for de-registration or cancellation of Billing Agreement
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
billingAgreementsDeRegistration(body, id, options) {
return __awaiter(this, void 0, void 0, function* () {
const localVarAxiosArgs = yield (0, exports.BillingAgreementsApiAxiosParamCreator)(configuration).billingAgreementsDeRegistration(body, id, options);
return (axios = axios_1.default, basePath = base_1.BASE_PATH) => {
const axiosRequestArgs = Object.assign(Object.assign({}, localVarAxiosArgs.options), { url: basePath + localVarAxiosArgs.url });
return axios.request(axiosRequestArgs);
};
});
},
/**
* Standing Instruction with or without Token.
* @summary Standing Instruction intimation
* @param {IdIntimationsBody} body
* @param {string} id ID for intimation of Billing Agreement
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
billingAgreementsIntimation(body, id, options) {
return __awaiter(this, void 0, void 0, function* () {
const localVarAxiosArgs = yield (0, exports.BillingAgreementsApiAxiosParamCreator)(configuration).billingAgreementsIntimation(body, id, options);
return (axios = axios_1.default, basePath = base_1.BASE_PATH) => {
const axiosRequestArgs = Object.assign(Object.assign({}, localVarAxiosArgs.options), { url: basePath + localVarAxiosArgs.url });
return axios.request(axiosRequestArgs);
};
});
},
/**
* #### Standing Instruction: Standing Instruction with or without Token. Transaction amount in case First payment is coming along with registration. Only 2 decimal places allowed #### Create Mandate: You can create a mandate through the direct debit mandate flow. Possible create mandate status values: - Pending—the create mandate request was successfully processed. - Failed—the create mandate request was not accepted. #### Import Mandate: In the Bacs scheme, a mandate is created with a status of active. Direct debit collections can be made against it immediately. You can import a mandate to the CyberSource database when: - You have existing customers with signed, active mandates - You manage mandates outside of CyberSource. When you import an existing mandate to the CyberSource database, provide a unique value for the mandate ID or the request results in an error. If an import mandate request is not accepted, the import mandate status value is failed.
* @summary Create a Billing Agreement
* @param {V2BillingagreementsBody} body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
billingAgreementsRegistration(body, options) {
return __awaiter(this, void 0, void 0, function* () {
const localVarAxiosArgs = yield (0, exports.BillingAgreementsApiAxiosParamCreator)(configuration).billingAgreementsRegistration(body, options);
return (axios = axios_1.default, basePath = base_1.BASE_PATH) => {
const axiosRequestArgs = Object.assign(Object.assign({}, localVarAxiosArgs.options), { url: basePath + localVarAxiosArgs.url });
return axios.request(axiosRequestArgs);
};
});
},
};
};
exports.BillingAgreementsApiFp = BillingAgreementsApiFp;
/**
* BillingAgreementsApi - factory interface
* @export
*/
const BillingAgreementsApiFactory = function (configuration, basePath, axios) {
return {
/**
* #### Standing Instruction: Standing Instruction with or without Token. #### Revoke Mandate: When you revoke a mandate, any pending direct debits linked to that mandate are canceled. No notifications are sent. When you revoke a mandate with no pending direct debits, the Bacs scheme or customer's bank notify you of any subsequent direct debit events. When you revoke a mandate, you cannot send a direct debit request using the mandate ID. Customer payments cannot be made against a revoked mandate. You can revoke a mandate when the customer: - Requests that you revoke the mandate. - Closes their account with you. Possible revoke mandate status values - - Revoked—the revoke mandate request was successfully processed. - Failed—the revoke mandate request was not accepted. #### Update Mandate: In most cases, the account details of an existing mandate cannot be updated in the Bacs schema, except by creating a new mandate. However, some very limited customer information, like name and address, can be updated to the mandate without needing to revoke it first #### Mandate Status: After the customer signs the mandate, request that the mandate status service verify the mandate status. Possible mandate status values: - Active—the mandate is successfully created. A direct debit can be sent for this mandate ID. - Pending—a pending mandate means the mandate is not yet signed. - Failed—the customer did not authenticate. - Expired—the deadline to create the mandate passed. - Revoked—the mandate is cancelled. #### Paypal Billing Agreement: A billing agreement is set up between PayPal and your customer. When you collect the details of a customer's billing agreement, you are able to bill that customer without requiring an authorization for each payment. You can bill the customer at the same time you process their PayPal Express checkout order, which simplifies your business processes.
* @summary Modify a Billing Agreement
* @param {BillingagreementsIdBody} body
* @param {string} id ID for de-registration or cancellation of Billing Agreement
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
billingAgreementsDeRegistration(body, id, options) {
return __awaiter(this, void 0, void 0, function* () {
return (0, exports.BillingAgreementsApiFp)(configuration).billingAgreementsDeRegistration(body, id, options).then((request) => request(axios, basePath));
});
},
/**
* Standing Instruction with or without Token.
* @summary Standing Instruction intimation
* @param {IdIntimationsBody} body
* @param {string} id ID for intimation of Billing Agreement
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
billingAgreementsIntimation(body, id, options) {
return __awaiter(this, void 0, void 0, function* () {
return (0, exports.BillingAgreementsApiFp)(configuration).billingAgreementsIntimation(body, id, options).then((request) => request(axios, basePath));
});
},
/**
* #### Standing Instruction: Standing Instruction with or without Token. Transaction amount in case First payment is coming along with registration. Only 2 decimal places allowed #### Create Mandate: You can create a mandate through the direct debit mandate flow. Possible create mandate status values: - Pending—the create mandate request was successfully processed. - Failed—the create mandate request was not accepted. #### Import Mandate: In the Bacs scheme, a mandate is created with a status of active. Direct debit collections can be made against it immediately. You can import a mandate to the CyberSource database when: - You have existing customers with signed, active mandates - You manage mandates outside of CyberSource. When you import an existing mandate to the CyberSource database, provide a unique value for the mandate ID or the request results in an error. If an import mandate request is not accepted, the import mandate status value is failed.
* @summary Create a Billing Agreement
* @param {V2BillingagreementsBody} body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
billingAgreementsRegistration(body, options) {
return __awaiter(this, void 0, void 0, function* () {
return (0, exports.BillingAgreementsApiFp)(configuration).billingAgreementsRegistration(body, options).then((request) => request(axios, basePath));
});
},
};
};
exports.BillingAgreementsApiFactory = BillingAgreementsApiFactory;
/**
* BillingAgreementsApi - object-oriented interface
* @export
* @class BillingAgreementsApi
* @extends {BaseAPI}
*/
class BillingAgreementsApi extends base_1.BaseAPI {
/**
* #### Standing Instruction: Standing Instruction with or without Token. #### Revoke Mandate: When you revoke a mandate, any pending direct debits linked to that mandate are canceled. No notifications are sent. When you revoke a mandate with no pending direct debits, the Bacs scheme or customer's bank notify you of any subsequent direct debit events. When you revoke a mandate, you cannot send a direct debit request using the mandate ID. Customer payments cannot be made against a revoked mandate. You can revoke a mandate when the customer: - Requests that you revoke the mandate. - Closes their account with you. Possible revoke mandate status values - - Revoked—the revoke mandate request was successfully processed. - Failed—the revoke mandate request was not accepted. #### Update Mandate: In most cases, the account details of an existing mandate cannot be updated in the Bacs schema, except by creating a new mandate. However, some very limited customer information, like name and address, can be updated to the mandate without needing to revoke it first #### Mandate Status: After the customer signs the mandate, request that the mandate status service verify the mandate status. Possible mandate status values: - Active—the mandate is successfully created. A direct debit can be sent for this mandate ID. - Pending—a pending mandate means the mandate is not yet signed. - Failed—the customer did not authenticate. - Expired—the deadline to create the mandate passed. - Revoked—the mandate is cancelled. #### Paypal Billing Agreement: A billing agreement is set up between PayPal and your customer. When you collect the details of a customer's billing agreement, you are able to bill that customer without requiring an authorization for each payment. You can bill the customer at the same time you process their PayPal Express checkout order, which simplifies your business processes.
* @summary Modify a Billing Agreement
* @param {BillingagreementsIdBody} body
* @param {string} id ID for de-registration or cancellation of Billing Agreement
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof BillingAgreementsApi
*/
billingAgreementsDeRegistration(body, id, options) {
return __awaiter(this, void 0, void 0, function* () {
return (0, exports.BillingAgreementsApiFp)(this.configuration).billingAgreementsDeRegistration(body, id, options).then((request) => request(this.axios, options.runEnvironment != null ? `https://${options.runEnvironment}` : this.basePath));
});
}
/**
* Standing Instruction with or without Token.
* @summary Standing Instruction intimation
* @param {IdIntimationsBody} body
* @param {string} id ID for intimation of Billing Agreement
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof BillingAgreementsApi
*/
billingAgreementsIntimation(body, id, options) {
return __awaiter(this, void 0, void 0, function* () {
return (0, exports.BillingAgreementsApiFp)(this.configuration).billingAgreementsIntimation(body, id, options).then((request) => request(this.axios, options.runEnvironment != null ? `https://${options.runEnvironment}` : this.basePath));
});
}
/**
* #### Standing Instruction: Standing Instruction with or without Token. Transaction amount in case First payment is coming along with registration. Only 2 decimal places allowed #### Create Mandate: You can create a mandate through the direct debit mandate flow. Possible create mandate status values: - Pending—the create mandate request was successfully processed. - Failed—the create mandate request was not accepted. #### Import Mandate: In the Bacs scheme, a mandate is created with a status of active. Direct debit collections can be made against it immediately. You can import a mandate to the CyberSource database when: - You have existing customers with signed, active mandates - You manage mandates outside of CyberSource. When you import an existing mandate to the CyberSource database, provide a unique value for the mandate ID or the request results in an error. If an import mandate request is not accepted, the import mandate status value is failed.
* @summary Create a Billing Agreement
* @param {V2BillingagreementsBody} body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof BillingAgreementsApi
*/
billingAgreementsRegistration(body, options) {
return __awaiter(this, void 0, void 0, function* () {
return (0, exports.BillingAgreementsApiFp)(this.configuration).billingAgreementsRegistration(body, options).then((request) => request(this.axios, options.runEnvironment != null ? `https://${options.runEnvironment}` : this.basePath));
});
}
}
exports.BillingAgreementsApi = BillingAgreementsApi;