cashfree-pg 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/base.d.ts ADDED
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Cashfree Payment Gateway APIs
3
+ * Cashfree\'s Payment Gateway APIs provide developers with a streamlined pathway to integrate advanced payment processing capabilities into their applications, platforms and websites.
4
+ *
5
+ * The version of the OpenAPI document: 2022-09-01
6
+ * Contact: developers@cashfree.com
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import type { Configuration } from './configuration';
13
+ import type { AxiosInstance, AxiosRequestConfig } from 'axios';
14
+ export declare const BASE_PATH: string;
15
+ /**
16
+ *
17
+ * @export
18
+ */
19
+ export declare const COLLECTION_FORMATS: {
20
+ csv: string;
21
+ ssv: string;
22
+ tsv: string;
23
+ pipes: string;
24
+ };
25
+ /**
26
+ *
27
+ * @export
28
+ * @interface RequestArgs
29
+ */
30
+ export interface RequestArgs {
31
+ url: string;
32
+ options: AxiosRequestConfig;
33
+ }
34
+ /**
35
+ *
36
+ * @export
37
+ * @class BaseAPI
38
+ */
39
+ export declare class BaseAPI {
40
+ protected basePath: string;
41
+ protected axios: AxiosInstance;
42
+ protected configuration: Configuration | undefined;
43
+ constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
44
+ }
45
+ /**
46
+ *
47
+ * @export
48
+ * @class RequiredError
49
+ * @extends {Error}
50
+ */
51
+ export declare class RequiredError extends Error {
52
+ field: string;
53
+ constructor(field: string, msg?: string);
54
+ }
package/dist/base.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Cashfree Payment Gateway APIs
6
+ * Cashfree\'s Payment Gateway APIs provide developers with a streamlined pathway to integrate advanced payment processing capabilities into their applications, platforms and websites.
7
+ *
8
+ * The version of the OpenAPI document: 2022-09-01
9
+ * Contact: developers@cashfree.com
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.RequiredError = exports.BaseAPI = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
17
+ const axios_1 = require("axios");
18
+ exports.BASE_PATH = "https://sandbox.cashfree.com/pg".replace(/\/+$/, "");
19
+ /**
20
+ *
21
+ * @export
22
+ */
23
+ exports.COLLECTION_FORMATS = {
24
+ csv: ",",
25
+ ssv: " ",
26
+ tsv: "\t",
27
+ pipes: "|",
28
+ };
29
+ /**
30
+ *
31
+ * @export
32
+ * @class BaseAPI
33
+ */
34
+ class BaseAPI {
35
+ constructor(configuration, basePath = exports.BASE_PATH, axios = axios_1.default) {
36
+ this.basePath = basePath;
37
+ this.axios = axios;
38
+ if (configuration) {
39
+ this.configuration = configuration;
40
+ this.basePath = configuration.basePath || this.basePath;
41
+ }
42
+ }
43
+ }
44
+ exports.BaseAPI = BaseAPI;
45
+ ;
46
+ /**
47
+ *
48
+ * @export
49
+ * @class RequiredError
50
+ * @extends {Error}
51
+ */
52
+ class RequiredError extends Error {
53
+ constructor(field, msg) {
54
+ super(msg);
55
+ this.field = field;
56
+ this.name = "RequiredError";
57
+ }
58
+ }
59
+ exports.RequiredError = RequiredError;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Cashfree Payment Gateway APIs
3
+ * Cashfree\'s Payment Gateway APIs provide developers with a streamlined pathway to integrate advanced payment processing capabilities into their applications, platforms and websites.
4
+ *
5
+ * The version of the OpenAPI document: 2022-09-01
6
+ * Contact: developers@cashfree.com
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import type { Configuration } from "./configuration";
13
+ import type { RequestArgs } from "./base";
14
+ import type { AxiosInstance, AxiosResponse } from 'axios';
15
+ /**
16
+ *
17
+ * @export
18
+ */
19
+ /**
20
+ *
21
+ * @throws {RequiredError}
22
+ * @export
23
+ */
24
+ export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
25
+ /**
26
+ *
27
+ * @export
28
+ */
29
+ export declare const setApiKeyToObject: (object: any, keyParamName: string) => Promise<void>;
30
+ /**
31
+ *
32
+ * @export
33
+ */
34
+ export declare const setBasicAuthToObject: (object: any, configuration?: Configuration) => void;
35
+ /**
36
+ *
37
+ * @export
38
+ */
39
+ export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
40
+ /**
41
+ *
42
+ * @export
43
+ */
44
+ export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise<void>;
45
+ /**
46
+ *
47
+ * @export
48
+ */
49
+ export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
50
+ /**
51
+ *
52
+ * @export
53
+ */
54
+ export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
55
+ /**
56
+ *
57
+ * @export
58
+ */
59
+ export declare const toPathString: (url: URL) => string;
60
+ /**
61
+ *
62
+ * @export
63
+ */
64
+ export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T, any>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
package/dist/common.js ADDED
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Cashfree Payment Gateway APIs
6
+ * Cashfree\'s Payment Gateway APIs provide developers with a streamlined pathway to integrate advanced payment processing capabilities into their applications, platforms and websites.
7
+ *
8
+ * The version of the OpenAPI document: 2022-09-01
9
+ * Contact: developers@cashfree.com
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
+ return new (P || (P = Promise))(function (resolve, reject) {
18
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22
+ });
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = void 0;
26
+ const base_1 = require("./base");
27
+ const api_1 = require("./api");
28
+ /**
29
+ *
30
+ * @export
31
+ */
32
+ /**
33
+ *
34
+ * @throws {RequiredError}
35
+ * @export
36
+ */
37
+ const assertParamExists = function (functionName, paramName, paramValue) {
38
+ if (paramValue === null || paramValue === undefined) {
39
+ throw new base_1.RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
40
+ }
41
+ };
42
+ exports.assertParamExists = assertParamExists;
43
+ /**
44
+ *
45
+ * @export
46
+ */
47
+ const setApiKeyToObject = function (object, keyParamName) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ if (keyParamName == "x-client-id") {
50
+ if (api_1.Cashfree.XClientId != null && api_1.Cashfree.XClientId != undefined) {
51
+ object[keyParamName] = api_1.Cashfree.XClientId;
52
+ }
53
+ }
54
+ if (keyParamName == "x-client-secret") {
55
+ if (api_1.Cashfree.XClientSecret != null && api_1.Cashfree.XClientSecret != undefined) {
56
+ object[keyParamName] = api_1.Cashfree.XClientSecret;
57
+ }
58
+ }
59
+ if (keyParamName == "x-partner-apikey") {
60
+ if (api_1.Cashfree.XPartnerKey != null && api_1.Cashfree.XPartnerKey != undefined) {
61
+ object[keyParamName] = api_1.Cashfree.XPartnerKey;
62
+ }
63
+ }
64
+ if (keyParamName == "x-partner-merchantid") {
65
+ if (api_1.Cashfree.XPartnerMerchantId != null && api_1.Cashfree.XPartnerMerchantId != undefined) {
66
+ object[keyParamName] = api_1.Cashfree.XPartnerMerchantId;
67
+ }
68
+ }
69
+ if (keyParamName == "x-client-signature") {
70
+ if (api_1.Cashfree.XClientSignature != null && api_1.Cashfree.XClientSignature != undefined) {
71
+ object[keyParamName] = api_1.Cashfree.XClientSignature;
72
+ }
73
+ }
74
+ });
75
+ };
76
+ exports.setApiKeyToObject = setApiKeyToObject;
77
+ /**
78
+ *
79
+ * @export
80
+ */
81
+ const setBasicAuthToObject = function (object, configuration) {
82
+ if (configuration && (configuration.username || configuration.password)) {
83
+ object["auth"] = { username: configuration.username, password: configuration.password };
84
+ }
85
+ };
86
+ exports.setBasicAuthToObject = setBasicAuthToObject;
87
+ /**
88
+ *
89
+ * @export
90
+ */
91
+ const setBearerAuthToObject = function (object, configuration) {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ if (configuration && configuration.accessToken) {
94
+ const accessToken = typeof configuration.accessToken === 'function'
95
+ ? yield configuration.accessToken()
96
+ : yield configuration.accessToken;
97
+ object["Authorization"] = "Bearer " + accessToken;
98
+ }
99
+ });
100
+ };
101
+ exports.setBearerAuthToObject = setBearerAuthToObject;
102
+ /**
103
+ *
104
+ * @export
105
+ */
106
+ const setOAuthToObject = function (object, name, scopes, configuration) {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ if (configuration && configuration.accessToken) {
109
+ const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
110
+ ? yield configuration.accessToken(name, scopes)
111
+ : yield configuration.accessToken;
112
+ object["Authorization"] = "Bearer " + localVarAccessTokenValue;
113
+ }
114
+ });
115
+ };
116
+ exports.setOAuthToObject = setOAuthToObject;
117
+ function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
118
+ if (parameter == null)
119
+ return;
120
+ if (typeof parameter === "object") {
121
+ if (Array.isArray(parameter)) {
122
+ parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
123
+ }
124
+ else {
125
+ Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`));
126
+ }
127
+ }
128
+ else {
129
+ if (urlSearchParams.has(key)) {
130
+ urlSearchParams.append(key, parameter);
131
+ }
132
+ else {
133
+ urlSearchParams.set(key, parameter);
134
+ }
135
+ }
136
+ }
137
+ /**
138
+ *
139
+ * @export
140
+ */
141
+ const setSearchParams = function (url, ...objects) {
142
+ const searchParams = new URLSearchParams(url.search);
143
+ setFlattenedQueryParams(searchParams, objects);
144
+ url.search = searchParams.toString();
145
+ };
146
+ exports.setSearchParams = setSearchParams;
147
+ /**
148
+ *
149
+ * @export
150
+ */
151
+ const serializeDataIfNeeded = function (value, requestOptions, configuration) {
152
+ const nonString = typeof value !== 'string';
153
+ const needsSerialization = nonString && configuration && configuration.isJsonMime
154
+ ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
155
+ : nonString;
156
+ return needsSerialization
157
+ ? JSON.stringify(value !== undefined ? value : {})
158
+ : (value || "");
159
+ };
160
+ exports.serializeDataIfNeeded = serializeDataIfNeeded;
161
+ /**
162
+ *
163
+ * @export
164
+ */
165
+ const toPathString = function (url) {
166
+ return url.pathname + url.search + url.hash;
167
+ };
168
+ exports.toPathString = toPathString;
169
+ /**
170
+ *
171
+ * @export
172
+ */
173
+ const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
174
+ return (axios = globalAxios, basePath = BASE_PATH) => {
175
+ const axiosRequestArgs = Object.assign(Object.assign({}, axiosArgs.options), { url: basePath + axiosArgs.url });
176
+ return axios.request(axiosRequestArgs);
177
+ };
178
+ };
179
+ exports.createRequestFunction = createRequestFunction;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Cashfree Payment Gateway APIs
3
+ * Cashfree\'s Payment Gateway APIs provide developers with a streamlined pathway to integrate advanced payment processing capabilities into their applications, platforms and websites.
4
+ *
5
+ * The version of the OpenAPI document: 2022-09-01
6
+ * Contact: developers@cashfree.com
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ /**
13
+ *
14
+ * @export
15
+ */
16
+ export declare enum CFEnvironment {
17
+ SANDBOX = 1,
18
+ PRODUCTION = 2
19
+ }
20
+ export interface ConfigurationParameters {
21
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
22
+ username?: string;
23
+ password?: string;
24
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
25
+ basePath?: string;
26
+ baseOptions?: any;
27
+ formDataCtor?: new () => any;
28
+ }
29
+ export declare class Configuration {
30
+ /**
31
+ * parameter for apiKey security
32
+ * @param name security name
33
+ * @memberof Configuration
34
+ */
35
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
36
+ /**
37
+ * parameter for basic security
38
+ *
39
+ * @type {string}
40
+ * @memberof Configuration
41
+ */
42
+ username?: string;
43
+ /**
44
+ * parameter for basic security
45
+ *
46
+ * @type {string}
47
+ * @memberof Configuration
48
+ */
49
+ password?: string;
50
+ /**
51
+ * parameter for oauth2 security
52
+ * @param name security name
53
+ * @param scopes oauth2 scope
54
+ * @memberof Configuration
55
+ */
56
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
57
+ /**
58
+ * override base path
59
+ *
60
+ * @type {string}
61
+ * @memberof Configuration
62
+ */
63
+ basePath?: string;
64
+ /**
65
+ * base options for axios calls
66
+ *
67
+ * @type {any}
68
+ * @memberof Configuration
69
+ */
70
+ baseOptions?: any;
71
+ /**
72
+ * The FormData constructor that will be used to create multipart form data
73
+ * requests. You can inject this here so that execution environments that
74
+ * do not support the FormData class can still run the generated client.
75
+ *
76
+ * @type {new () => FormData}
77
+ */
78
+ formDataCtor?: new () => any;
79
+ constructor(param?: ConfigurationParameters);
80
+ /**
81
+ * Check if the given MIME is a JSON MIME.
82
+ * JSON MIME examples:
83
+ * application/json
84
+ * application/json; charset=UTF8
85
+ * APPLICATION/JSON
86
+ * application/vnd.company+json
87
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
88
+ * @return True if the given MIME is JSON, false otherwise.
89
+ */
90
+ isJsonMime(mime: string): boolean;
91
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Cashfree Payment Gateway APIs
6
+ * Cashfree\'s Payment Gateway APIs provide developers with a streamlined pathway to integrate advanced payment processing capabilities into their applications, platforms and websites.
7
+ *
8
+ * The version of the OpenAPI document: 2022-09-01
9
+ * Contact: developers@cashfree.com
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Configuration = exports.CFEnvironment = void 0;
17
+ /**
18
+ *
19
+ * @export
20
+ */
21
+ var CFEnvironment;
22
+ (function (CFEnvironment) {
23
+ CFEnvironment[CFEnvironment["SANDBOX"] = 1] = "SANDBOX";
24
+ CFEnvironment[CFEnvironment["PRODUCTION"] = 2] = "PRODUCTION";
25
+ })(CFEnvironment = exports.CFEnvironment || (exports.CFEnvironment = {}));
26
+ class Configuration {
27
+ constructor(param = {}) {
28
+ this.apiKey = param.apiKey;
29
+ this.username = param.username;
30
+ this.password = param.password;
31
+ this.accessToken = param.accessToken;
32
+ this.basePath = param.basePath;
33
+ this.baseOptions = param.baseOptions;
34
+ this.formDataCtor = param.formDataCtor;
35
+ }
36
+ /**
37
+ * Check if the given MIME is a JSON MIME.
38
+ * JSON MIME examples:
39
+ * application/json
40
+ * application/json; charset=UTF8
41
+ * APPLICATION/JSON
42
+ * application/vnd.company+json
43
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
44
+ * @return True if the given MIME is JSON, false otherwise.
45
+ */
46
+ isJsonMime(mime) {
47
+ const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
48
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
49
+ }
50
+ }
51
+ exports.Configuration = Configuration;