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