react-native-cashfree-pg-sdk 2.4.0 → 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.
Files changed (53) hide show
  1. package/README.md +36 -16
  2. package/android/.project +6 -0
  3. package/android/build.gradle +6 -4
  4. package/android/src/main/java/com/reactnativecashfreepgsdk/CashfreePgApiModule.java +75 -27
  5. package/android/src/main/java/com/reactnativecashfreepgsdk/CashfreePgApiPackage.java +32 -18
  6. package/ios/CashfreeEmitter.swift +11 -11
  7. package/ios/CashfreePgApi.swift +36 -20
  8. package/ios/CashfreePgApiAdapter.h +15 -0
  9. package/ios/CashfreePgApiAdapter.mm +94 -0
  10. package/lib/commonjs/CFErrorResponse.js +43 -0
  11. package/lib/commonjs/CFErrorResponse.js.map +1 -0
  12. package/lib/commonjs/Card/CFCardComponent.js +12 -6
  13. package/lib/commonjs/Card/CFCardComponent.js.map +1 -1
  14. package/lib/commonjs/Card/CFSubsCardComponent.js +9 -6
  15. package/lib/commonjs/Card/CFSubsCardComponent.js.map +1 -1
  16. package/lib/commonjs/Card/index.js.map +1 -1
  17. package/lib/commonjs/NativeCashfreePgApi.js +9 -0
  18. package/lib/commonjs/NativeCashfreePgApi.js.map +1 -0
  19. package/lib/commonjs/PPIWallet/PPIWalletPayment.js +104 -0
  20. package/lib/commonjs/PPIWallet/PPIWalletPayment.js.map +1 -0
  21. package/lib/commonjs/index.js +37 -83
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/module/CFErrorResponse.js +36 -0
  24. package/lib/module/CFErrorResponse.js.map +1 -0
  25. package/lib/module/Card/CFCardComponent.js +12 -6
  26. package/lib/module/Card/CFCardComponent.js.map +1 -1
  27. package/lib/module/Card/CFSubsCardComponent.js +4 -2
  28. package/lib/module/Card/CFSubsCardComponent.js.map +1 -1
  29. package/lib/module/NativeCashfreePgApi.js +3 -0
  30. package/lib/module/NativeCashfreePgApi.js.map +1 -0
  31. package/lib/module/PPIWallet/PPIWalletPayment.js +98 -0
  32. package/lib/module/PPIWallet/PPIWalletPayment.js.map +1 -0
  33. package/lib/module/index.js +17 -68
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/typescript/src/CFErrorResponse.d.ts +16 -0
  36. package/lib/typescript/src/NativeCashfreePgApi.d.ts +21 -0
  37. package/lib/typescript/src/PPIWallet/PPIWalletPayment.d.ts +6 -0
  38. package/lib/typescript/src/index.d.ts +9 -15
  39. package/package.json +32 -10
  40. package/react-native-cashfree-pg-sdk.podspec +6 -3
  41. package/src/CFErrorResponse.ts +38 -0
  42. package/src/Card/CFCardComponent.tsx +4 -2
  43. package/src/Card/CFSubsCardComponent.tsx +4 -2
  44. package/src/NativeCashfreePgApi.ts +23 -0
  45. package/src/PPIWallet/PPIWalletPayment.ts +120 -0
  46. package/src/index.ts +17 -92
  47. package/ios/CashfreeEventEmitter.m +0 -16
  48. package/ios/CashfreeEventEmitter.swift +0 -28
  49. package/ios/CashfreePgApi.m +0 -26
  50. package/src/Card/CFCardComponent.js +0 -238
  51. package/src/Card/CFSubsCardComponent.js +0 -203
  52. package/src/Card/index.js +0 -2
  53. package/src/index.js +0 -191
@@ -0,0 +1,21 @@
1
+ import type { TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ doPayment(paymentData: string): void;
4
+ doUPIPayment(paymentData: string): void;
5
+ doWebPayment(paymentData: string): void;
6
+ doSubscriptionPayment(paymentData: string): void;
7
+ doCardPayment(paymentData: string): void;
8
+ doElementUPIPayment(paymentData: string): void;
9
+ doElementNBPayment(paymentData: string): void;
10
+ doSubsCardPayment(paymentData: string): void;
11
+ doSubsUPIPayment(paymentData: string): void;
12
+ doSubsNBPayment(paymentData: string): void;
13
+ getInstalledUpiApps(): Promise<string>;
14
+ setCallback(): void;
15
+ setEventSubscriber(): void;
16
+ removeEventSubscriber(): void;
17
+ addListener(eventName: string): void;
18
+ removeListeners(count: number): void;
19
+ }
20
+ declare const _default: Spec;
21
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { type CFPPIWalletPayment } from 'cashfree-pg-api-contract';
2
+ /**
3
+ * Creates a PPI wallet order session. Resolves with the API JSON as-is,
4
+ * rejects with CFErrorResponse. Request/response carry PII: never log them.
5
+ */
6
+ export declare function doPPIWalletPayment(payment: CFPPIWalletPayment): Promise<unknown>;
@@ -1,10 +1,10 @@
1
- import { type CheckoutPayment, type CFSession, type CFSubscriptionSession } from 'cashfree-pg-api-contract';
1
+ import { type CheckoutPayment, type CFSession, type CFSubscriptionSession, type CFPPIWalletPayment } from 'cashfree-pg-api-contract';
2
+ import { CFErrorResponse } from './CFErrorResponse';
2
3
  declare class CFPaymentGateway {
3
4
  private emitter;
4
5
  private successSubscription;
5
6
  private failureSubscription;
6
7
  private eventSubscription;
7
- private upiAppsSubscription;
8
8
  constructor();
9
9
  doPayment(checkoutPayment: CheckoutPayment): void;
10
10
  doUPIPayment(checkoutPayment: CheckoutPayment): void;
@@ -14,9 +14,14 @@ declare class CFPaymentGateway {
14
14
  * @deprecated : Instead call makePayment
15
15
  */
16
16
  doCardPayment(cardPayment: CheckoutPayment): void;
17
- getInstalledUpiApps(): Promise<unknown>;
17
+ getInstalledUpiApps(): Promise<string>;
18
18
  makePayment(cfPayment: CheckoutPayment): void;
19
19
  makeSubsPayment(cfPayment: CheckoutPayment): void;
20
+ /**
21
+ * Creates a PPI wallet order session via Cashfree's API.
22
+ * Resolves with the API response as-is; rejects with CFErrorResponse.
23
+ */
24
+ doPPIWalletPayment(payment: CFPPIWalletPayment): Promise<unknown>;
20
25
  setEventSubscriber(cfEventCallback: CFEventCallback): void;
21
26
  removeEventSubscriber(): void;
22
27
  setCallback(cfCallback: CFCallback): void;
@@ -29,18 +34,7 @@ export interface CFCallback {
29
34
  export interface CFEventCallback {
30
35
  onReceivedEvent(eventName: string, map: Map<string, string>): void;
31
36
  }
32
- export declare class CFErrorResponse {
33
- private status;
34
- private message;
35
- private code;
36
- private type;
37
- fromJSON(errorString: string): void;
38
- getStatus(): string;
39
- getMessage(): string;
40
- getCode(): string;
41
- getType(): string;
42
- }
37
+ export { CFErrorResponse };
43
38
  export declare const CFCard: any;
44
39
  export declare const CFSubsCard: any;
45
40
  export declare const CFPaymentGatewayService: CFPaymentGateway;
46
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-cashfree-pg-sdk",
3
- "version": "2.4.0",
3
+ "version": "3.0.0",
4
4
  "description": "Cashfree PG Plugin for React Native",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -14,7 +14,7 @@
14
14
  "ios",
15
15
  "cpp",
16
16
  "react-native-cashfree-pg-sdk.podspec",
17
- "!lib/typescript/example",
17
+ "!lib/typescript/sampleApps",
18
18
  "!android/build",
19
19
  "!android/.gradle",
20
20
  "!android/.idea",
@@ -34,9 +34,13 @@
34
34
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
35
35
  "prepare": "bob build",
36
36
  "release": "release-it",
37
- "example": "yarn --cwd example",
38
- "pods": "cd example && pod-install --quiet",
39
- "bootstrap": "yarn example && yarn && yarn pods"
37
+ "oldarch": "npm --prefix sampleApps/OldArchSample",
38
+ "newarch": "npm --prefix sampleApps/NewArchSample",
39
+ "expo": "npm --prefix sampleApps/ExpoSample",
40
+ "pods:oldarch": "cd sampleApps/OldArchSample && pod-install --quiet",
41
+ "pods:newarch": "cd sampleApps/NewArchSample && pod-install --quiet",
42
+ "pods:expo": "cd sampleApps/ExpoSample && pod-install --quiet",
43
+ "bootstrap": "yarn && npm --prefix sampleApps/OldArchSample install && npm --prefix sampleApps/NewArchSample install && npm --prefix sampleApps/ExpoSample install"
40
44
  },
41
45
  "keywords": [
42
46
  "react-native",
@@ -58,7 +62,16 @@
58
62
  },
59
63
  "homepage": "https://docs.cashfree.com/docs/react-native-integration",
60
64
  "publishConfig": {
61
- "registry": "https://registry.npmjs.org/"
65
+ "registry": "https://registry.npmjs.org/",
66
+ "tag": "turbo"
67
+ },
68
+ "codegenConfig": {
69
+ "name": "RNCashfreePgApiSpec",
70
+ "type": "modules",
71
+ "jsSrcsDir": "src",
72
+ "android": {
73
+ "javaPackageName": "com.reactnativecashfreepgsdk"
74
+ }
62
75
  },
63
76
  "devDependencies": {
64
77
  "@commitlint/config-conventional": "^11.0.0",
@@ -66,6 +79,7 @@
66
79
  "@react-native/babel-preset": "^0.73.18",
67
80
  "@release-it/conventional-changelog": "^2.0.0",
68
81
  "@types/jest": "^26.0.0",
82
+ "@types/node": "^18.0.0",
69
83
  "@types/react": "^18.2.0",
70
84
  "@types/react-native": "^0.73.0",
71
85
  "commitlint": "^11.0.0",
@@ -84,12 +98,19 @@
84
98
  },
85
99
  "peerDependencies": {
86
100
  "react": "*",
87
- "react-native": "*"
101
+ "react-native": ">=0.73.0"
88
102
  },
89
103
  "jest": {
90
104
  "preset": "react-native",
105
+ "testPathIgnorePatterns": [
106
+ "<rootDir>/sampleApps/",
107
+ "<rootDir>/lib/",
108
+ "<rootDir>/node_modules/"
109
+ ],
91
110
  "modulePathIgnorePatterns": [
92
- "<rootDir>/example/node_modules",
111
+ "<rootDir>/sampleApps/OldArchSample/node_modules",
112
+ "<rootDir>/sampleApps/NewArchSample/node_modules",
113
+ "<rootDir>/sampleApps/ExpoSample/node_modules",
93
114
  "<rootDir>/lib/"
94
115
  ]
95
116
  },
@@ -104,7 +125,8 @@
104
125
  "tagName": "v${version}"
105
126
  },
106
127
  "npm": {
107
- "publish": true
128
+ "publish": true,
129
+ "tag": "turbo"
108
130
  },
109
131
  "github": {
110
132
  "release": true
@@ -160,6 +182,6 @@
160
182
  ]
161
183
  },
162
184
  "dependencies": {
163
- "cashfree-pg-api-contract": "2.1.1"
185
+ "cashfree-pg-api-contract": "2.2.0"
164
186
  }
165
187
  }
@@ -10,11 +10,14 @@ Pod::Spec.new do |s|
10
10
  s.license = package["license"]
11
11
  s.authors = package["author"]
12
12
 
13
- s.platforms = { :ios => "10.0" }
13
+ s.platforms = { :ios => "13.0" }
14
14
  s.source = { :git => "https://www.cashfree.com/.git", :tag => "#{s.version}" }
15
15
 
16
16
  s.source_files = "ios/**/*.{h,m,mm,swift}"
17
17
 
18
- s.dependency "React-Core"
19
- s.dependency "CashfreePG", "2.4.0"
18
+ s.frameworks = "WebKit"
19
+
20
+ s.dependency "CashfreePG", "2.5.2"
21
+
22
+ install_modules_dependencies(s)
20
23
  end
@@ -0,0 +1,38 @@
1
+ export class CFErrorResponse {
2
+ private status: string = 'FAILED';
3
+ private message: string = 'payment has failed';
4
+ private code: string = 'payment_failed';
5
+ private type: string = 'request_failed';
6
+
7
+ constructor(fields?: { message?: string; code?: string; type?: string }) {
8
+ if (fields?.message !== undefined) this.message = fields.message;
9
+ if (fields?.code !== undefined) this.code = fields.code;
10
+ if (fields?.type !== undefined) this.type = fields.type;
11
+ }
12
+
13
+ fromJSON(errorString: string) {
14
+ console.log('errorString :' + errorString);
15
+ const object = JSON.parse(errorString);
16
+ console.log('errorStringObject :' + object);
17
+ this.status = object.status;
18
+ this.message = object.message;
19
+ this.code = object.code;
20
+ this.type = object.type;
21
+ }
22
+
23
+ getStatus(): string {
24
+ return this.status;
25
+ }
26
+
27
+ getMessage(): string {
28
+ return this.message;
29
+ }
30
+
31
+ getCode(): string {
32
+ return this.code;
33
+ }
34
+
35
+ getType(): string {
36
+ return this.type;
37
+ }
38
+ }
@@ -244,7 +244,8 @@ const CardInput: any = forwardRef<CardPaymentHandle, CardInputProps>(
244
244
  const cardPayment = new CFCardPayment(sessionRef.current, cardInfo);
245
245
  CFPaymentGatewayService.makePayment(cardPayment);
246
246
  } catch (e: any) {
247
- console.log(e.message);
247
+ console.error('[CFCard] payment call failed:', e?.message ?? e);
248
+ throw e;
248
249
  }
249
250
  };
250
251
 
@@ -256,7 +257,8 @@ const CardInput: any = forwardRef<CardPaymentHandle, CardInputProps>(
256
257
  sessionRef.current = session;
257
258
  doPayment(cardInfo);
258
259
  } catch (e: any) {
259
- console.log(e.message);
260
+ console.error('[CFCard] payment call failed:', e?.message ?? e);
261
+ throw e;
260
262
  }
261
263
  };
262
264
 
@@ -215,7 +215,8 @@ const SubsCardInput: any = forwardRef<
215
215
  const cardPayment = new CFSubsCardPayment(sessionRef.current, cardInfo);
216
216
  CFPaymentGatewayService.makeSubsPayment(cardPayment);
217
217
  } catch (e: any) {
218
- console.log(e.message);
218
+ console.error('[CFSubsCard] payment call failed:', e?.message ?? e);
219
+ throw e;
219
220
  }
220
221
  };
221
222
 
@@ -227,7 +228,8 @@ const SubsCardInput: any = forwardRef<
227
228
  sessionRef.current = session;
228
229
  doSubscriptionPayment(cardInfo);
229
230
  } catch (e: any) {
230
- console.log(e.message);
231
+ console.error('[CFSubsCard] payment call failed:', e?.message ?? e);
232
+ throw e;
231
233
  }
232
234
  };
233
235
 
@@ -0,0 +1,23 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ doPayment(paymentData: string): void;
6
+ doUPIPayment(paymentData: string): void;
7
+ doWebPayment(paymentData: string): void;
8
+ doSubscriptionPayment(paymentData: string): void;
9
+ doCardPayment(paymentData: string): void;
10
+ doElementUPIPayment(paymentData: string): void;
11
+ doElementNBPayment(paymentData: string): void;
12
+ doSubsCardPayment(paymentData: string): void;
13
+ doSubsUPIPayment(paymentData: string): void;
14
+ doSubsNBPayment(paymentData: string): void;
15
+ getInstalledUpiApps(): Promise<string>;
16
+ setCallback(): void;
17
+ setEventSubscriber(): void;
18
+ removeEventSubscriber(): void;
19
+ addListener(eventName: string): void;
20
+ removeListeners(count: number): void;
21
+ }
22
+
23
+ export default TurboModuleRegistry.getEnforcing<Spec>('CashfreePgApi');
@@ -0,0 +1,120 @@
1
+ import {
2
+ CFEnvironment,
3
+ CFPPIWallet,
4
+ type CFPPIWalletPayment,
5
+ type CFSession,
6
+ } from 'cashfree-pg-api-contract';
7
+ import { CFErrorResponse } from '../CFErrorResponse';
8
+
9
+ const ROUTE = '/pg/orders/sessions';
10
+ const BASE_URLS: Record<string, string> = {
11
+ [CFEnvironment.SANDBOX]: 'https://sandbox.cashfree.com',
12
+ [CFEnvironment.PRODUCTION]: 'https://api.cashfree.com',
13
+ };
14
+
15
+ const failure = (message: string, code: string, type: string = code) =>
16
+ new CFErrorResponse({ message, code, type });
17
+
18
+ const validationError = (message: string) =>
19
+ failure(message, 'validation_error');
20
+
21
+ const stringField = (body: unknown, key: string): string | undefined => {
22
+ if (body !== null && typeof body === 'object') {
23
+ const value = (body as Record<string, unknown>)[key];
24
+ if (typeof value === 'string' && value !== '') {
25
+ return value;
26
+ }
27
+ }
28
+ return undefined;
29
+ };
30
+
31
+ const parseJson = (text: string): unknown => {
32
+ try {
33
+ return JSON.parse(text);
34
+ } catch {
35
+ return undefined;
36
+ }
37
+ };
38
+
39
+ // Validation is repeated here (on top of the contract constructors) because
40
+ // JS callers can mutate or hand-build these objects.
41
+ function buildRequest(payment: CFPPIWalletPayment) {
42
+ if (
43
+ payment == null ||
44
+ typeof payment.getSession !== 'function' ||
45
+ typeof payment.getWallet !== 'function'
46
+ ) {
47
+ throw validationError('payment cannot be empty.');
48
+ }
49
+ const session: CFSession = payment.getSession();
50
+ if (
51
+ session == null ||
52
+ typeof session.payment_session_id !== 'string' ||
53
+ session.payment_session_id.trim() === ''
54
+ ) {
55
+ throw validationError('payment_session_id cannot be empty.');
56
+ }
57
+ const baseUrl = BASE_URLS[session.environment];
58
+ if (baseUrl === undefined) {
59
+ throw validationError('environment is invalid.');
60
+ }
61
+ let wallet: CFPPIWallet;
62
+ try {
63
+ wallet = new CFPPIWallet(payment.getWallet());
64
+ } catch (error) {
65
+ throw validationError((error as Error).message);
66
+ }
67
+ return {
68
+ url: baseUrl + ROUTE,
69
+ body: JSON.stringify({
70
+ payment_session_id: session.payment_session_id,
71
+ payment_method: {
72
+ app: {
73
+ provider: wallet.provider,
74
+ channel: wallet.channel,
75
+ phone: wallet.phone,
76
+ wallet_id: wallet.walletId,
77
+ user_id: wallet.userId,
78
+ cf_sub_wallet_id: wallet.cfSubWalletId,
79
+ },
80
+ },
81
+ }),
82
+ };
83
+ }
84
+
85
+ /**
86
+ * Creates a PPI wallet order session. Resolves with the API JSON as-is,
87
+ * rejects with CFErrorResponse. Request/response carry PII: never log them.
88
+ */
89
+ export async function doPPIWalletPayment(
90
+ payment: CFPPIWalletPayment
91
+ ): Promise<unknown> {
92
+ const { url, body: requestBody } = buildRequest(payment);
93
+
94
+ let response: Response;
95
+ let text: string;
96
+ try {
97
+ response = await fetch(url, {
98
+ method: 'POST',
99
+ headers: { 'Content-Type': 'application/json' },
100
+ body: requestBody,
101
+ });
102
+ text = await response.text();
103
+ } catch (error) {
104
+ throw failure(
105
+ (error as Error)?.message || 'Network request failed',
106
+ 'network_error'
107
+ );
108
+ }
109
+
110
+ const responseBody = parseJson(text);
111
+ if (response.ok && responseBody !== undefined) {
112
+ return responseBody;
113
+ }
114
+ throw failure(
115
+ stringField(responseBody, 'message') ??
116
+ 'Something went wrong. Please try again.',
117
+ stringField(responseBody, 'code') ?? 'request_failed',
118
+ stringField(responseBody, 'type') ?? 'api_error'
119
+ );
120
+ }
package/src/index.ts CHANGED
@@ -1,10 +1,8 @@
1
1
  import {
2
2
  EmitterSubscription,
3
- NativeAppEventEmitter,
4
3
  NativeEventEmitter,
5
- NativeModules,
6
- Platform,
7
4
  } from 'react-native';
5
+ import CashfreePgApi from './NativeCashfreePgApi';
8
6
  import { version } from '../package.json';
9
7
  import {
10
8
  type CheckoutPayment,
@@ -16,39 +14,21 @@ import {
16
14
  CFSubsUPIPayment,
17
15
  CFSubsCardPayment,
18
16
  CFSubsNBPayment,
17
+ type CFPPIWalletPayment,
19
18
  } from 'cashfree-pg-api-contract';
20
19
  import CFCardComponent from './Card/CFCardComponent';
21
20
  import CFSubsCardComponent from './Card/CFSubsCardComponent';
22
-
23
- const LINKING_ERROR =
24
- `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` +
25
- Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
26
- '- You rebuilt the app after installing the package\n' +
27
- '- You are not using Expo managed workflow\n';
28
-
29
- const CashfreePgApi = NativeModules.CashfreePgApi
30
- ? NativeModules.CashfreePgApi
31
- : new Proxy(
32
- {},
33
- {
34
- get() {
35
- throw new Error(LINKING_ERROR);
36
- },
37
- }
38
- );
21
+ import { CFErrorResponse } from './CFErrorResponse';
22
+ import { doPPIWalletPayment } from './PPIWallet/PPIWalletPayment';
39
23
 
40
24
  class CFPaymentGateway {
41
- private emitter: NativeEventEmitter | typeof NativeAppEventEmitter;
25
+ private emitter: NativeEventEmitter;
42
26
  private successSubscription: EmitterSubscription | null = null;
43
27
  private failureSubscription: EmitterSubscription | null = null;
44
28
  private eventSubscription: EmitterSubscription | null = null;
45
- private upiAppsSubscription: EmitterSubscription | null = null;
46
29
 
47
30
  constructor() {
48
- this.emitter =
49
- Platform.OS === 'ios'
50
- ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter)
51
- : NativeAppEventEmitter;
31
+ this.emitter = new NativeEventEmitter(CashfreePgApi as any);
52
32
  }
53
33
 
54
34
  doPayment(checkoutPayment: CheckoutPayment) {
@@ -76,32 +56,8 @@ class CFPaymentGateway {
76
56
  this.makePayment(cardPayment);
77
57
  }
78
58
 
79
- async getInstalledUpiApps() {
80
- return new Promise((resolve, reject) => {
81
- if (Platform.OS === 'ios') {
82
- let fetchUpiList = (apps: string) => {
83
- console.log(JSON.stringify(apps));
84
- if (apps) {
85
- resolve(apps);
86
- } else {
87
- reject('No UPI apps found');
88
- }
89
- };
90
- this.upiAppsSubscription = this.emitter.addListener(
91
- 'cfUpiApps',
92
- fetchUpiList
93
- );
94
- CashfreePgApi.getInstalledUpiApps();
95
- } else {
96
- CashfreePgApi.getInstalledUpiApps((apps: string) => {
97
- if (apps) {
98
- resolve(apps);
99
- } else {
100
- reject('No UPI apps found');
101
- }
102
- });
103
- }
104
- });
59
+ async getInstalledUpiApps(): Promise<string> {
60
+ return CashfreePgApi.getInstalledUpiApps();
105
61
  }
106
62
 
107
63
  makePayment(cfPayment: CheckoutPayment) {
@@ -132,6 +88,14 @@ class CFPaymentGateway {
132
88
  }
133
89
  }
134
90
 
91
+ /**
92
+ * Creates a PPI wallet order session via Cashfree's API.
93
+ * Resolves with the API response as-is; rejects with CFErrorResponse.
94
+ */
95
+ doPPIWalletPayment(payment: CFPPIWalletPayment): Promise<unknown> {
96
+ return doPPIWalletPayment(payment);
97
+ }
98
+
135
99
  setEventSubscriber(cfEventCallback: CFEventCallback) {
136
100
  let eventFunction = (event: string) => {
137
101
  console.log(JSON.stringify(event));
@@ -194,13 +158,6 @@ class CFPaymentGateway {
194
158
  this.failureSubscription.remove();
195
159
  this.failureSubscription = null;
196
160
  }
197
- if (
198
- this.upiAppsSubscription !== undefined &&
199
- this.upiAppsSubscription !== null
200
- ) {
201
- this.upiAppsSubscription.remove();
202
- this.upiAppsSubscription = null;
203
- }
204
161
  }
205
162
  }
206
163
 
@@ -214,39 +171,7 @@ export interface CFEventCallback {
214
171
  onReceivedEvent(eventName: string, map: Map<string, string>): void;
215
172
  }
216
173
 
217
- export class CFErrorResponse {
218
- private status: string = 'FAILED';
219
- private message: string = 'payment has failed';
220
- private code: string = 'payment_failed';
221
- private type: string = 'request_failed';
222
-
223
- fromJSON(errorString: string) {
224
- console.log('errorString :' + errorString);
225
- const object = JSON.parse(errorString);
226
- console.log('errorStringObject :' + object);
227
- this.status = object.status;
228
- this.message = object.message;
229
- this.code = object.code;
230
- this.type = object.type;
231
- }
232
-
233
- getStatus(): string {
234
- return this.status;
235
- }
236
-
237
- getMessage(): string {
238
- return this.message;
239
- }
240
-
241
- getCode(): string {
242
- return this.code;
243
- }
244
-
245
- getType(): string {
246
- return this.type;
247
- }
248
- }
249
-
174
+ export { CFErrorResponse };
250
175
  export const CFCard = CFCardComponent;
251
176
  export const CFSubsCard = CFSubsCardComponent;
252
177
  export const CFPaymentGatewayService = new CFPaymentGateway();
@@ -1,16 +0,0 @@
1
- //
2
- // CashfreeEventEmitter.m
3
- // DoubleConversion
4
- //
5
- // Created by Aabhas Jindal on 13/06/22.
6
- //
7
-
8
- #import <Foundation/Foundation.h>
9
- #import <React/RCTBridgeModule.h>
10
- #import <React/RCTEventEmitter.h>
11
-
12
- @interface RCT_EXTERN_MODULE(CashfreeEventEmitter, RCTEventEmitter)
13
-
14
- RCT_EXTERN_METHOD(supportedEvents)
15
-
16
- @end
@@ -1,28 +0,0 @@
1
- //
2
- // CashfreeEventEmitter.swift
3
- // DoubleConversion
4
- //
5
- // Created by Aabhas Jindal on 13/06/22.
6
- //
7
-
8
- import Foundation
9
-
10
- @objc(CashfreeEventEmitter)
11
- open class CashfreeEventEmitter: RCTEventEmitter {
12
-
13
- override init() {
14
- super.init()
15
- CashfreeEmitter.sharedInstance.registerEventEmitter(eventEmitter: self)
16
- }
17
-
18
- /// Base overide for RCTEventEmitter.
19
- ///
20
- /// - Returns: all supported events
21
- @objc open override func supportedEvents() -> [String] {
22
- return CashfreeEmitter.sharedInstance.allEvents
23
- }
24
-
25
- @objc public override static func requiresMainQueueSetup() -> Bool {
26
- return false
27
- }
28
- }
@@ -1,26 +0,0 @@
1
- #import <React/RCTBridgeModule.h>
2
- #import <React/RCTUtils.h>
3
-
4
- @interface RCT_EXTERN_MODULE(CashfreePgApi, NSObject)
5
-
6
- RCT_EXTERN_METHOD(doPayment:(NSString)paymentObject)
7
-
8
- RCT_EXTERN_METHOD(doUPIPayment:(NSString)paymentObject)
9
-
10
- RCT_EXTERN_METHOD(doWebPayment:(NSString)paymentObject)
11
- RCT_EXTERN_METHOD(doSubscriptionPayment:(NSString)paymentObject)
12
- RCT_EXTERN_METHOD(doCardPayment:(NSString)paymentObject)
13
- RCT_EXTERN_METHOD(doElementNBPayment:(NSString)paymentObject)
14
- RCT_EXTERN_METHOD(doElementUPIPayment:(NSString)paymentObject)
15
- RCT_EXTERN_METHOD(doSubsCardPayment:(NSString)paymentObject)
16
- RCT_EXTERN_METHOD(doSubsUPIPayment:(NSString)paymentObject)
17
- RCT_EXTERN_METHOD(doSubsNBPayment:(NSString)paymentObject)
18
- RCT_EXTERN_METHOD(getInstalledUpiApps)
19
-
20
- RCT_EXTERN_METHOD(setCallback)
21
-
22
- RCT_EXTERN_METHOD(setEventSubscriber)
23
-
24
- RCT_EXTERN_METHOD(removeEventSubscriber)
25
-
26
- @end