react-native-cashfree-pg-sdk 2.1.8 → 2.1.9-dev.1

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 (31) hide show
  1. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  2. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  3. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  5. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  6. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  7. package/android/.gradle/checksums/checksums.lock +0 -0
  8. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  9. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  10. package/android/.idea/sonarlint/issuestore/4/4/44aaf172f11159c609e569cf1b49bcd49376a770 +10 -12
  11. package/android/.idea/sonarlint/issuestore/index.pb +1 -3
  12. package/android/.idea/sonarlint/securityhotspotstore/index.pb +1 -3
  13. package/android/build.gradle +3 -3
  14. package/ios/CashfreeEmitter.swift +1 -1
  15. package/ios/CashfreePgApi.m +3 -0
  16. package/ios/CashfreePgApi.swift +141 -0
  17. package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  18. package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  19. package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/xcuserdata/kishankumarmaurya.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  20. package/ios/CashfreePgApi.xcodeproj/xcuserdata/kishankumarmaurya.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +6 -0
  21. package/ios/CashfreePgApi.xcodeproj/xcuserdata/kishankumarmaurya.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  22. package/lib/commonjs/index.js +25 -7
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/module/index.js +25 -7
  25. package/lib/module/index.js.map +1 -1
  26. package/lib/typescript/src/index.d.ts +1 -0
  27. package/package.json +10 -3
  28. package/src/index.js +29 -8
  29. package/src/index.ts +29 -7
  30. package/android/.idea/sonarlint/issuestore/2/a/2afbb999f001938c88fa43fc2ef52abf0f8213e4 +0 -0
  31. package/android/.idea/sonarlint/securityhotspotstore/2/a/2afbb999f001938c88fa43fc2ef52abf0f8213e4 +0 -0
@@ -1,2 +1,2 @@
1
- #Wed Dec 27 14:18:28 IST 2023
2
- gradle.version=7.6
1
+ #Fri Feb 23 12:29:44 IST 2024
2
+ gradle.version=7.2
@@ -1,20 +1,18 @@
1
1
 
2
2
  e
3
- java:S1192f"HDefine a constant instead of duplicating this literal "orderID" 4 times.(Ѝ��8�����1
3
+ java:S1192f"HDefine a constant instead of duplicating this literal "orderID" 4 times.(Ѝ��8�����1
4
4
  n
5
- java:S1192e"LDefine a constant instead of duplicating this literal "environment" 3 times.(ݒ�������8�����1
5
+ java:S1192e"LDefine a constant instead of duplicating this literal "environment" 3 times.(ݒ�������8�����1
6
6
  u
7
- java:S1192g"SDefine a constant instead of duplicating this literal "payment_session_id" 3 times.(���������8�����1
7
+ java:S1192g"SDefine a constant instead of duplicating this literal "payment_session_id" 3 times.(���������8�����1
8
8
  v
9
- java:S1192<"TDefine a constant instead of duplicating this literal "CashfreePgApiModule" 4 times.(���������8�����1
9
+ java:S1192<"TDefine a constant instead of duplicating this literal "CashfreePgApiModule" 4 times.(���������8�����1
10
10
  m
11
- java:S1192E"QDefine a constant instead of duplicating this literal "activity is null" 5 times.(�ȮT8�����1
11
+ java:S1192E"QDefine a constant instead of duplicating this literal "activity is null" 5 times.(�ȮT8�����1
12
12
  �
13
- java:S1598"�This file "CashfreePgApiModule.java" should be located in "com/reactnativecashfreepgapi" directory, not in "/Users/kishankumarmaurya/Development/ReactNative/RN_PG_APP/react-native-cashfree-pg-sdk/android/src/main/java/com/reactnativecashfreepgsdk".(ٻ�������8�����1
14
- [
15
- java:S1874�"=Remove this use of "queryIntentActivities"; it is deprecated.(��Ő8�����1
16
- F java:S108�")Either remove or fill this block of code.(����8�����1
17
- K java:S108�")Either remove or fill this block of code.(Ƹۂ�����8�����1
18
- K java:S108�")Either remove or fill this block of code.(Ƹۂ�����8�����1
13
+ java:S1598"�This file "CashfreePgApiModule.java" should be located in "com/reactnativecashfreepgapi" directory, not in "/Users/kishankumarmaurya/Development/ReactNative/RN_PG_APP/react-native-cashfree-pg-sdk/android/src/main/java/com/reactnativecashfreepgsdk".(ٻ�������8�����1
14
+ F java:S108�")Either remove or fill this block of code.(����8�����1
15
+ K java:S108�")Either remove or fill this block of code.(Ƹۂ�����8�����1
16
+ K java:S108�")Either remove or fill this block of code.(Ƹۂ�����8�����1
19
17
  W
20
- java:S2864�"4Iterate over the "entrySet" instead of the "keySet".(�ֲ������8�����1
18
+ java:S2864�"4Iterate over the "entrySet" instead of the "keySet".(�ֲ������8�����1
@@ -8,6 +8,4 @@ Csrc/main/java/com/reactnativecashfreepgsdk/CashfreePgApiModule.java,4/4/44aaf1
8
8
  t
9
9
  Dsrc/main/java/com/reactnativecashfreepgsdk/CashfreePgApiPackage.java,3/e/3e1984987c20cd21984de8c97894175bd94b0037
10
10
  <
11
- build.gradle,f/0/f07866736216be0ee2aba49e392191aeae700a35
12
- A
13
- gradle.properties,2/a/2afbb999f001938c88fa43fc2ef52abf0f8213e4
11
+ build.gradle,f/0/f07866736216be0ee2aba49e392191aeae700a35
@@ -8,6 +8,4 @@ Csrc/main/java/com/reactnativecashfreepgsdk/CashfreePgApiModule.java,4/4/44aaf1
8
8
  t
9
9
  Dsrc/main/java/com/reactnativecashfreepgsdk/CashfreePgApiPackage.java,3/e/3e1984987c20cd21984de8c97894175bd94b0037
10
10
  <
11
- build.gradle,f/0/f07866736216be0ee2aba49e392191aeae700a35
12
- A
13
- gradle.properties,2/a/2afbb999f001938c88fa43fc2ef52abf0f8213e4
11
+ build.gradle,f/0/f07866736216be0ee2aba49e392191aeae700a35
@@ -19,10 +19,10 @@ def safeExtGet(prop, fallback) {
19
19
  }
20
20
 
21
21
  android {
22
- compileSdkVersion safeExtGet('CashfreePgApi_compileSdkVersion', 30)
22
+ compileSdkVersion 33
23
23
  defaultConfig {
24
- minSdkVersion safeExtGet('CashfreePgApi_minSdkVersion', 19)
25
- targetSdkVersion safeExtGet('CashfreePgApi_targetSdkVersion', 30)
24
+ minSdkVersion 21
25
+ targetSdkVersion 33
26
26
  versionCode 1
27
27
  versionName "1.0"
28
28
 
@@ -26,7 +26,7 @@ class CashfreeEmitter {
26
26
 
27
27
  /// All Events which must be support by React Native.
28
28
  lazy var allEvents: [String] = {
29
- var allEventNames: [String] = ["cfSuccess", "cfFailure", "cfEvent"]
29
+ var allEventNames: [String] = ["cfSuccess", "cfFailure", "cfEvent", "cfUpiApps"]
30
30
 
31
31
  // Append all events here
32
32
 
@@ -8,6 +8,9 @@ RCT_EXTERN_METHOD(doPayment:(NSString)paymentObject)
8
8
  RCT_EXTERN_METHOD(doUPIPayment:(NSString)paymentObject)
9
9
 
10
10
  RCT_EXTERN_METHOD(doWebPayment:(NSString)paymentObject)
11
+ RCT_EXTERN_METHOD(doCardPayment:(NSString)paymentObject)
12
+ RCT_EXTERN_METHOD(doElementUPIPayment:(NSString)paymentObject)
13
+ RCT_EXTERN_METHOD(getInstalledUpiApps)
11
14
 
12
15
  RCT_EXTERN_METHOD(setCallback)
13
16
 
@@ -57,6 +57,47 @@ class CashfreePgApi: NSObject {
57
57
  }
58
58
  }
59
59
 
60
+ @objc func doCardPayment(_ paymentObject: NSString) -> Void {
61
+ do {
62
+ if let cfCardPayment = try parseCardObject(paymentObject: "\(paymentObject)") {
63
+ if let vc = RCTPresentedViewController() {
64
+ try CFPaymentGatewayService.getInstance().doPayment(cfCardPayment, viewController: vc)
65
+ }
66
+ }
67
+ }
68
+ catch {
69
+ print (error)
70
+ }
71
+ }
72
+
73
+ @objc func getInstalledUpiApps(){
74
+ let upiApplications = CFUPIUtils().getInstalledUPIApplications()
75
+ var appsToSend: [NSDictionary] = []
76
+ for upi in upiApplications {
77
+ if (upi["id"] ?? "").contains("cred") {
78
+ continue
79
+ }
80
+ appsToSend.append([
81
+ "appPackage": upi["id"] ?? "",
82
+ "appName": upi["displayName"] ?? ""
83
+ ])
84
+ }
85
+ CashfreeEmitter.sharedInstance.dispatch(name: "cfUpiApps", body: stringify(json: appsToSend))
86
+ }
87
+
88
+ @objc func doElementUPIPayment(_ paymentObject: NSString) -> Void {
89
+ do {
90
+ if let cfUPIPayment = try parseUpiObject(paymentObject: "\(paymentObject)") {
91
+ if let vc = RCTPresentedViewController() {
92
+ try CFPaymentGatewayService.getInstance().doPayment(cfUPIPayment, viewController: vc)
93
+ }
94
+ }
95
+ }
96
+ catch {
97
+ print (error)
98
+ }
99
+ }
100
+
60
101
  @objc func setCallback() -> Void {
61
102
  CFPaymentGatewayService.getInstance().setCallback(self)
62
103
  }
@@ -69,6 +110,59 @@ class CashfreePgApi: NSObject {
69
110
  analyticsCallbackEnabled = false
70
111
  }
71
112
 
113
+ private func parseCardObject(paymentObject: String) throws -> CFCardPayment? {
114
+ let data = paymentObject.data(using: .utf8)!
115
+ if let output = try! JSONSerialization.jsonObject(with: data, options: .allowFragments) as? Dictionary<String, Any> {
116
+ do {
117
+ let finalSession = getSession(paymentObject: output)
118
+ if let cfCard = getCard(paymentObject: output){
119
+ let savePaymentMethod = isForSavePayment(paymentObject: output)
120
+ print(savePaymentMethod)
121
+
122
+ let cardPayment = try CFCardPayment.CFCardPaymentBuilder()
123
+ .setCard(cfCard)
124
+ .setSession(finalSession!)
125
+ .saveInstrument(savePaymentMethod)
126
+ .build()
127
+
128
+ let systemVersion = UIDevice.current.systemVersion
129
+
130
+ cardPayment.setPlatform("irnx-e-2.1.9-x-m-s-x-i-\(systemVersion.prefix(4))")
131
+
132
+ return cardPayment
133
+ }
134
+ return nil
135
+ } catch let e {
136
+ let error = e as! CashfreeError
137
+ print(error.localizedDescription)
138
+ }
139
+ }
140
+ return nil
141
+ }
142
+
143
+ private func parseUpiObject(paymentObject: String) throws -> CFUPIPayment? {
144
+ let data = paymentObject.data(using: .utf8)!
145
+ if let output = try! JSONSerialization.jsonObject(with: data, options: .allowFragments) as? Dictionary<String, Any> {
146
+ do {
147
+ let finalSession = getSession(paymentObject: output)
148
+ let cfUPI = getUpi(paymentObject: output)
149
+
150
+ let upiPayment = try CFUPIPayment.CFUPIPaymentBuilder()
151
+ .setSession(finalSession!)
152
+ .setUPI(cfUPI!)
153
+ .build()
154
+ let systemVersion = UIDevice.current.systemVersion
155
+ upiPayment.setPlatform("irnx-e-2.1.9-x-m-s-x-i-\(systemVersion.prefix(4))")
156
+
157
+ return upiPayment
158
+ } catch let e {
159
+ let error = e as! CashfreeError
160
+ print(error.localizedDescription)
161
+ }
162
+ }
163
+ return nil
164
+ }
165
+
72
166
  private func parseDropPayment(paymentObject: String) throws -> CFDropCheckoutPayment? {
73
167
  // print(paymentObject)
74
168
  let data = paymentObject.data(using: .utf8)!
@@ -163,6 +257,53 @@ class CashfreePgApi: NSObject {
163
257
  return nil
164
258
  }
165
259
 
260
+ private func getCard(paymentObject: Dictionary<String,Any>) -> CFCard? {
261
+ let card = paymentObject["card"] as? NSDictionary ?? [:]
262
+ do {
263
+ var cardObject: CFCard!
264
+ if card["instrumentId"] != nil && card["instrumentId"] as? String ?? "" != "" {
265
+ cardObject = try CFCard.CFCardBuilder()
266
+ .setCVV(card["cardCvv"] as? String ?? "")
267
+ .setInstrumentId(card["instrumentId"] as? String ?? "")
268
+ .build()
269
+ } else {
270
+ cardObject = try CFCard.CFCardBuilder()
271
+ .setCVV(card["cardCvv"] as? String ?? "")
272
+ .setCardNumber(card["cardNumber"] as? String ?? "")
273
+ .setCardExpiryYear(card["cardExpiryYY"] as? String ?? "")
274
+ .setCardExpiryMonth(card["cardExpiryMM"] as? String ?? "")
275
+ .setCardHolderName(card["cardHolderName"] as? String ?? "")
276
+ .build()
277
+ }
278
+ return cardObject
279
+ } catch let e {
280
+ let error = e as! CashfreeError
281
+ print(error.localizedDescription)
282
+ return nil
283
+ }
284
+ }
285
+
286
+ private func isForSavePayment(paymentObject: Dictionary<String,Any>) -> Bool {
287
+ let card = paymentObject["card"] as? NSDictionary ?? [:]
288
+ return card["saveCard"] as? Bool ?? false
289
+ }
290
+
291
+ private func getUpi(paymentObject: Dictionary<String,Any>) -> CFUPI?{
292
+ if let upi = paymentObject["upi"] as? Dictionary<String, String> {
293
+ do {
294
+ let cfUPI = try CFUPI.CFUPIBuilder()
295
+ .setChannel(upi["mode"] ?? "" == "COLLECT" ? .COLLECT : .INTENT)
296
+ .setUPIID(upi["id"] ?? "")
297
+ .build()
298
+ return cfUPI
299
+ } catch let e {
300
+ let err = e as! CashfreeError
301
+ print(err.localizedDescription)
302
+ }
303
+ }
304
+ return nil
305
+ }
306
+
166
307
  private func getComponents(paymentObject: Dictionary<String,Any>) -> CFPaymentComponent? {
167
308
  if let components = paymentObject["components"] as? Array<String> {
168
309
  do {
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Bucket
3
+ uuid = "4075B5AF-BE54-4DA4-B387-03B4668144C8"
4
+ type = "1"
5
+ version = "2.0">
6
+ </Bucket>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>CashfreePgApi.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
@@ -25,6 +25,7 @@ class CFPaymentGateway {
25
25
  _defineProperty(this, "successSubscription", null);
26
26
  _defineProperty(this, "failureSubscription", null);
27
27
  _defineProperty(this, "eventSubscription", null);
28
+ _defineProperty(this, "upiAppsSubscription", null);
28
29
  this.emitter = _reactNative.Platform.OS === 'ios' ? new _reactNative.NativeEventEmitter(_reactNative.NativeModules.CashfreeEventEmitter) : _reactNative.NativeAppEventEmitter;
29
30
  }
30
31
  doPayment(checkoutPayment) {
@@ -47,13 +48,26 @@ class CFPaymentGateway {
47
48
  }
48
49
  async getInstalledUpiApps() {
49
50
  return new Promise((resolve, reject) => {
50
- CashfreePgApi.getInstalledUpiApps(apps => {
51
- if (apps) {
52
- resolve(apps);
53
- } else {
54
- reject('No UPI apps found');
55
- }
56
- });
51
+ if (_reactNative.Platform.OS === 'ios') {
52
+ let fetchUpiList = apps => {
53
+ console.log(JSON.stringify(apps));
54
+ if (apps) {
55
+ resolve(apps);
56
+ } else {
57
+ reject('No UPI apps found');
58
+ }
59
+ };
60
+ this.upiAppsSubscription = this.emitter.addListener('cfUpiApps', fetchUpiList);
61
+ CashfreePgApi.getInstalledUpiApps();
62
+ } else {
63
+ CashfreePgApi.getInstalledUpiApps(apps => {
64
+ if (apps) {
65
+ resolve(apps);
66
+ } else {
67
+ reject('No UPI apps found');
68
+ }
69
+ });
70
+ }
57
71
  });
58
72
  }
59
73
  makePayment(cfPayment) {
@@ -111,6 +125,10 @@ class CFPaymentGateway {
111
125
  this.failureSubscription.remove();
112
126
  this.failureSubscription = null;
113
127
  }
128
+ if (this.upiAppsSubscription !== undefined && this.upiAppsSubscription !== null) {
129
+ this.upiAppsSubscription.remove();
130
+ this.upiAppsSubscription = null;
131
+ }
114
132
  }
115
133
  }
116
134
  class CFErrorResponse {
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_package","_cashfreePgApiContract","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","LINKING_ERROR","Platform","select","ios","default","CashfreePgApi","NativeModules","Proxy","get","Error","CFPaymentGateway","constructor","emitter","OS","NativeEventEmitter","CashfreeEventEmitter","NativeAppEventEmitter","doPayment","checkoutPayment","version","JSON","stringify","doUPIPayment","doWebPayment","cfSession","doCardPayment","cardPayment","makePayment","getInstalledUpiApps","Promise","resolve","reject","apps","cfPayment","paymentData","CFUPIPayment","doElementUPIPayment","CFCardPayment","console","log","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","addListener","removeEventSubscriber","remove","setCallback","cfCallback","successFunction","orderID","onVerify","failureFunction","error","response","CFErrorResponse","message","fromJSON","onError","successSubscription","failureSubscription","removeCallback","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","exports","CFPaymentGatewayService"],"sources":["index.ts"],"sourcesContent":["import {\n EmitterSubscription,\n EventEmitter,\n NativeAppEventEmitter,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\nimport { version } from '../package.json';\nimport { type CheckoutPayment, type CFSession, CFUPIPayment, CFCardPayment } from 'cashfree-pg-api-contract';\n\nconst LINKING_ERROR =\n `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: '- You have run \\'pod install\\'\\n', default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst CashfreePgApi = NativeModules.CashfreePgApi\n ? NativeModules.CashfreePgApi\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n },\n );\n\nclass CFPaymentGateway {\n private emitter: EventEmitter;\n private successSubscription: EmitterSubscription | null = null;\n private failureSubscription: EmitterSubscription | null = null;\n private eventSubscription: EmitterSubscription | null = null;\n\n constructor() {\n this.emitter =\n Platform.OS === 'ios'\n ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter)\n : NativeAppEventEmitter;\n }\n\n doPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));\n }\n\n doUPIPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));\n }\n\n doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(cfSession);\n }\n\n /**\n * @deprecated : Instead call makePayment\n */\n doCardPayment(cardPayment: CheckoutPayment) {\n this.makePayment(cardPayment);\n }\n\n async getInstalledUpiApps() {\n return new Promise((resolve, reject) => {\n CashfreePgApi.getInstalledUpiApps((apps: string) => {\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n });\n });\n }\n\n makePayment(cfPayment: CheckoutPayment) {\n cfPayment.version = version;\n const paymentData = JSON.stringify(cfPayment);\n if (cfPayment instanceof CFUPIPayment) {\n CashfreePgApi.doElementUPIPayment(paymentData);\n } else if (cfPayment instanceof CFCardPayment) {\n CashfreePgApi.doCardPayment(paymentData);\n } else {\n console.log('makePayment::==> Wrong payment object');\n }\n }\n\n setEventSubscriber(cfEventCallback: CFEventCallback) {\n let eventFunction = (event: string) => {\n console.log(JSON.stringify(event));\n let data = JSON.parse(event);\n cfEventCallback.onReceivedEvent(data.eventName, data.meta);\n };\n this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);\n CashfreePgApi.setEventSubscriber();\n }\n\n removeEventSubscriber() {\n if (\n this.eventSubscription !== undefined &&\n this.eventSubscription !== null\n ) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\n }\n\n setCallback(cfCallback: CFCallback) {\n // this.cfCallback = cfCallback;\n let successFunction = (orderID: string) => {\n console.log('response is : ' + JSON.stringify(orderID));\n cfCallback.onVerify(orderID);\n };\n let failureFunction = (error: string) => {\n console.log('reason: ' + JSON.stringify(error));\n const response = new CFErrorResponse();\n // @ts-ignore\n const message = JSON.parse(error);\n response.fromJSON(message.error);\n // @ts-ignore\n cfCallback.onError(response, message.orderID);\n };\n this.successSubscription = this.emitter.addListener(\n 'cfSuccess',\n successFunction,\n );\n this.failureSubscription = this.emitter.addListener(\n 'cfFailure',\n failureFunction,\n );\n CashfreePgApi.setCallback();\n }\n\n removeCallback() {\n if (\n this.successSubscription !== undefined &&\n this.successSubscription !== null\n ) {\n this.successSubscription.remove();\n this.successSubscription = null;\n }\n if (\n this.failureSubscription !== undefined &&\n this.failureSubscription !== null\n ) {\n this.failureSubscription.remove();\n this.failureSubscription = null;\n }\n }\n}\n\nexport interface CFCallback {\n onVerify(orderID: string): void;\n\n onError(error: CFErrorResponse, orderID: string): void;\n}\n\nexport interface CFEventCallback {\n onReceivedEvent(eventName: string, map: Map<string, string>): void;\n}\n\nexport class CFErrorResponse {\n private status: string = 'FAILED';\n private message: string = 'payment has failed';\n private code: string = 'payment_failed';\n private type: string = 'request_failed';\n\n fromJSON(errorString: string) {\n console.log('errorString :' + errorString);\n const object = JSON.parse(errorString);\n console.log('errorStringObject :' + object);\n this.status = object.status;\n this.message = object.message;\n this.code = object.code;\n this.type = object.type;\n }\n\n getStatus(): string {\n return this.status;\n }\n\n getMessage(): string {\n return this.message;\n }\n\n getCode(): string {\n return this.code;\n }\n\n getType(): string {\n return this.type;\n }\n}\n\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAQA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AAA6G,SAAAG,gBAAAC,GAAA,EAA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C;IAC3C,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;IAC3B,IAAI,CAACR,OAAO,GAAGO,MAAM,CAACP,OAAO;IAC7B,IAAI,CAACS,IAAI,GAAGF,MAAM,CAACE,IAAI;IACvB,IAAI,CAACC,IAAI,GAAGH,MAAM,CAACG,IAAI;EACzB;EAEAC,SAASA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACH,MAAM;EACpB;EAEAI,UAAUA,CAAA,EAAW;IACnB,OAAO,IAAI,CAACZ,OAAO;EACrB;EAEAa,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;EAEAK,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;AACF;AAACK,OAAA,CAAAhB,eAAA,GAAAA,eAAA;AAEM,MAAMiB,uBAAuB,GAAG,IAAIpE,gBAAgB,CAAC,CAAC;AAACmE,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
1
+ {"version":3,"names":["_reactNative","require","_package","_cashfreePgApiContract","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","LINKING_ERROR","Platform","select","ios","default","CashfreePgApi","NativeModules","Proxy","get","Error","CFPaymentGateway","constructor","emitter","OS","NativeEventEmitter","CashfreeEventEmitter","NativeAppEventEmitter","doPayment","checkoutPayment","version","JSON","stringify","doUPIPayment","doWebPayment","cfSession","doCardPayment","cardPayment","makePayment","getInstalledUpiApps","Promise","resolve","reject","fetchUpiList","apps","console","log","upiAppsSubscription","addListener","cfPayment","paymentData","CFUPIPayment","doElementUPIPayment","CFCardPayment","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","removeEventSubscriber","remove","setCallback","cfCallback","successFunction","orderID","onVerify","failureFunction","error","response","CFErrorResponse","message","fromJSON","onError","successSubscription","failureSubscription","removeCallback","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","exports","CFPaymentGatewayService"],"sources":["index.ts"],"sourcesContent":["import {\n EmitterSubscription,\n EventEmitter,\n NativeAppEventEmitter,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\nimport { version } from '../package.json';\nimport { type CheckoutPayment, type CFSession, CFUPIPayment, CFCardPayment } from 'cashfree-pg-api-contract';\n\nconst LINKING_ERROR =\n `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: '- You have run \\'pod install\\'\\n', default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst CashfreePgApi = NativeModules.CashfreePgApi\n ? NativeModules.CashfreePgApi\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n },\n );\n\nclass CFPaymentGateway {\n private emitter: EventEmitter;\n private successSubscription: EmitterSubscription | null = null;\n private failureSubscription: EmitterSubscription | null = null;\n private eventSubscription: EmitterSubscription | null = null;\n private upiAppsSubscription: EmitterSubscription | null = null;\n\n constructor() {\n this.emitter =\n Platform.OS === 'ios'\n ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter)\n : NativeAppEventEmitter;\n }\n\n doPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));\n }\n\n doUPIPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));\n }\n\n doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(cfSession);\n }\n\n /**\n * @deprecated : Instead call makePayment\n */\n doCardPayment(cardPayment: CheckoutPayment) {\n this.makePayment(cardPayment);\n }\n\n async getInstalledUpiApps() {\n return new Promise((resolve, reject) => {\n if(Platform.OS === 'ios'){\n let fetchUpiList = (apps: string) => {\n console.log(JSON.stringify(apps));\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n };\n this.upiAppsSubscription = this.emitter.addListener('cfUpiApps', fetchUpiList);\n CashfreePgApi.getInstalledUpiApps()\n }\n else {\n CashfreePgApi.getInstalledUpiApps((apps: string) => {\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n });\n }\n });\n }\n\n makePayment(cfPayment: CheckoutPayment) {\n cfPayment.version = version;\n const paymentData = JSON.stringify(cfPayment);\n if (cfPayment instanceof CFUPIPayment) {\n CashfreePgApi.doElementUPIPayment(paymentData);\n } else if (cfPayment instanceof CFCardPayment) {\n CashfreePgApi.doCardPayment(paymentData);\n } else {\n console.log('makePayment::==> Wrong payment object');\n }\n }\n\n setEventSubscriber(cfEventCallback: CFEventCallback) {\n let eventFunction = (event: string) => {\n console.log(JSON.stringify(event));\n let data = JSON.parse(event);\n cfEventCallback.onReceivedEvent(data.eventName, data.meta);\n };\n this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);\n CashfreePgApi.setEventSubscriber();\n }\n\n removeEventSubscriber() {\n if (\n this.eventSubscription !== undefined &&\n this.eventSubscription !== null\n ) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\n }\n\n setCallback(cfCallback: CFCallback) {\n // this.cfCallback = cfCallback;\n let successFunction = (orderID: string) => {\n console.log('response is : ' + JSON.stringify(orderID));\n cfCallback.onVerify(orderID);\n };\n let failureFunction = (error: string) => {\n console.log('reason: ' + JSON.stringify(error));\n const response = new CFErrorResponse();\n // @ts-ignore\n const message = JSON.parse(error);\n response.fromJSON(message.error);\n // @ts-ignore\n cfCallback.onError(response, message.orderID);\n };\n this.successSubscription = this.emitter.addListener(\n 'cfSuccess',\n successFunction,\n );\n this.failureSubscription = this.emitter.addListener(\n 'cfFailure',\n failureFunction,\n );\n CashfreePgApi.setCallback();\n }\n\n removeCallback() {\n if (\n this.successSubscription !== undefined &&\n this.successSubscription !== null\n ) {\n this.successSubscription.remove();\n this.successSubscription = null;\n }\n if (\n this.failureSubscription !== undefined &&\n this.failureSubscription !== null\n ) {\n this.failureSubscription.remove();\n this.failureSubscription = null;\n }\n if (\n this.upiAppsSubscription !== undefined &&\n this.upiAppsSubscription !== null\n ) {\n this.upiAppsSubscription.remove();\n this.upiAppsSubscription = null;\n }\n }\n}\n\nexport interface CFCallback {\n onVerify(orderID: string): void;\n\n onError(error: CFErrorResponse, orderID: string): void;\n}\n\nexport interface CFEventCallback {\n onReceivedEvent(eventName: string, map: Map<string, string>): void;\n}\n\nexport class CFErrorResponse {\n private status: string = 'FAILED';\n private message: string = 'payment has failed';\n private code: string = 'payment_failed';\n private type: string = 'request_failed';\n\n fromJSON(errorString: string) {\n console.log('errorString :' + errorString);\n const object = JSON.parse(errorString);\n console.log('errorStringObject :' + object);\n this.status = object.status;\n this.message = object.message;\n this.code = object.code;\n this.type = object.type;\n }\n\n getStatus(): string {\n return this.status;\n }\n\n getMessage(): string {\n return this.message;\n }\n\n getCode(): string {\n return this.code;\n }\n\n getType(): string {\n return this.type;\n }\n}\n\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAQA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AAA6G,SAAAG,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,S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eAAA,eACvB,gBAAgB;IAAAA,eAAA,eAChB,gBAAgB;EAAA;EAEvCwF,QAAQA,CAACK,WAAmB,EAAE;IAC5BpC,OAAO,CAACC,GAAG,CAAC,eAAe,GAAGmC,WAAW,CAAC;IAC1C,MAAMC,MAAM,GAAGnD,IAAI,CAAC4B,KAAK,CAACsB,WAAW,CAAC;IACtCpC,OAAO,CAACC,GAAG,CAAC,qBAAqB,GAAGoC,MAAM,CAAC;IAC3C,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;IAC3B,IAAI,CAACR,OAAO,GAAGO,MAAM,CAACP,OAAO;IAC7B,IAAI,CAACS,IAAI,GAAGF,MAAM,CAACE,IAAI;IACvB,IAAI,CAACC,IAAI,GAAGH,MAAM,CAACG,IAAI;EACzB;EAEAC,SAASA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACH,MAAM;EACpB;EAEAI,UAAUA,CAAA,EAAW;IACnB,OAAO,IAAI,CAACZ,OAAO;EACrB;EAEAa,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;EAEAK,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;AACF;AAACK,OAAA,CAAAhB,eAAA,GAAAA,eAAA;AAEM,MAAMiB,uBAAuB,GAAG,IAAItE,gBAAgB,CAAC,CAAC;AAACqE,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
@@ -19,6 +19,7 @@ class CFPaymentGateway {
19
19
  _defineProperty(this, "successSubscription", null);
20
20
  _defineProperty(this, "failureSubscription", null);
21
21
  _defineProperty(this, "eventSubscription", null);
22
+ _defineProperty(this, "upiAppsSubscription", null);
22
23
  this.emitter = Platform.OS === 'ios' ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter) : NativeAppEventEmitter;
23
24
  }
24
25
  doPayment(checkoutPayment) {
@@ -41,13 +42,26 @@ class CFPaymentGateway {
41
42
  }
42
43
  async getInstalledUpiApps() {
43
44
  return new Promise((resolve, reject) => {
44
- CashfreePgApi.getInstalledUpiApps(apps => {
45
- if (apps) {
46
- resolve(apps);
47
- } else {
48
- reject('No UPI apps found');
49
- }
50
- });
45
+ if (Platform.OS === 'ios') {
46
+ let fetchUpiList = apps => {
47
+ console.log(JSON.stringify(apps));
48
+ if (apps) {
49
+ resolve(apps);
50
+ } else {
51
+ reject('No UPI apps found');
52
+ }
53
+ };
54
+ this.upiAppsSubscription = this.emitter.addListener('cfUpiApps', fetchUpiList);
55
+ CashfreePgApi.getInstalledUpiApps();
56
+ } else {
57
+ CashfreePgApi.getInstalledUpiApps(apps => {
58
+ if (apps) {
59
+ resolve(apps);
60
+ } else {
61
+ reject('No UPI apps found');
62
+ }
63
+ });
64
+ }
51
65
  });
52
66
  }
53
67
  makePayment(cfPayment) {
@@ -105,6 +119,10 @@ class CFPaymentGateway {
105
119
  this.failureSubscription.remove();
106
120
  this.failureSubscription = null;
107
121
  }
122
+ if (this.upiAppsSubscription !== undefined && this.upiAppsSubscription !== null) {
123
+ this.upiAppsSubscription.remove();
124
+ this.upiAppsSubscription = null;
125
+ }
108
126
  }
109
127
  }
110
128
  export class CFErrorResponse {
@@ -1 +1 @@
1
- {"version":3,"names":["NativeAppEventEmitter","NativeEventEmitter","NativeModules","Platform","version","CFUPIPayment","CFCardPayment","LINKING_ERROR","select","ios","default","CashfreePgApi","Proxy","get","Error","CFPaymentGateway","constructor","_defineProperty","emitter","OS","CashfreeEventEmitter","doPayment","checkoutPayment","JSON","stringify","doUPIPayment","doWebPayment","cfSession","doCardPayment","cardPayment","makePayment","getInstalledUpiApps","Promise","resolve","reject","apps","cfPayment","paymentData","doElementUPIPayment","console","log","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","addListener","removeEventSubscriber","undefined","remove","setCallback","cfCallback","successFunction","orderID","onVerify","failureFunction","error","response","CFErrorResponse","message","fromJSON","onError","successSubscription","failureSubscription","removeCallback","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","CFPaymentGatewayService"],"sources":["index.ts"],"sourcesContent":["import {\n EmitterSubscription,\n EventEmitter,\n NativeAppEventEmitter,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\nimport { version } from '../package.json';\nimport { type CheckoutPayment, type CFSession, CFUPIPayment, CFCardPayment } from 'cashfree-pg-api-contract';\n\nconst LINKING_ERROR =\n `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: '- You have run \\'pod install\\'\\n', default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst CashfreePgApi = NativeModules.CashfreePgApi\n ? NativeModules.CashfreePgApi\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n },\n );\n\nclass CFPaymentGateway {\n private emitter: EventEmitter;\n private successSubscription: EmitterSubscription | null = null;\n private failureSubscription: EmitterSubscription | null = null;\n private eventSubscription: EmitterSubscription | null = null;\n\n constructor() {\n this.emitter =\n Platform.OS === 'ios'\n ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter)\n : NativeAppEventEmitter;\n }\n\n doPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));\n }\n\n doUPIPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));\n }\n\n doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(cfSession);\n }\n\n /**\n * @deprecated : Instead call makePayment\n */\n doCardPayment(cardPayment: CheckoutPayment) {\n this.makePayment(cardPayment);\n }\n\n async getInstalledUpiApps() {\n return new Promise((resolve, reject) => {\n CashfreePgApi.getInstalledUpiApps((apps: string) => {\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n });\n });\n }\n\n makePayment(cfPayment: CheckoutPayment) {\n cfPayment.version = version;\n const paymentData = JSON.stringify(cfPayment);\n if (cfPayment instanceof CFUPIPayment) {\n CashfreePgApi.doElementUPIPayment(paymentData);\n } else if (cfPayment instanceof CFCardPayment) {\n CashfreePgApi.doCardPayment(paymentData);\n } else {\n console.log('makePayment::==> Wrong payment object');\n }\n }\n\n setEventSubscriber(cfEventCallback: CFEventCallback) {\n let eventFunction = (event: string) => {\n console.log(JSON.stringify(event));\n let data = JSON.parse(event);\n cfEventCallback.onReceivedEvent(data.eventName, data.meta);\n };\n this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);\n CashfreePgApi.setEventSubscriber();\n }\n\n removeEventSubscriber() {\n if (\n this.eventSubscription !== undefined &&\n this.eventSubscription !== null\n ) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\n }\n\n setCallback(cfCallback: CFCallback) {\n // this.cfCallback = cfCallback;\n let successFunction = (orderID: string) => {\n console.log('response is : ' + JSON.stringify(orderID));\n cfCallback.onVerify(orderID);\n };\n let failureFunction = (error: string) => {\n console.log('reason: ' + JSON.stringify(error));\n const response = new CFErrorResponse();\n // @ts-ignore\n const message = JSON.parse(error);\n response.fromJSON(message.error);\n // @ts-ignore\n cfCallback.onError(response, message.orderID);\n };\n this.successSubscription = this.emitter.addListener(\n 'cfSuccess',\n successFunction,\n );\n this.failureSubscription = this.emitter.addListener(\n 'cfFailure',\n failureFunction,\n );\n CashfreePgApi.setCallback();\n }\n\n removeCallback() {\n if (\n this.successSubscription !== undefined &&\n this.successSubscription !== null\n ) {\n this.successSubscription.remove();\n this.successSubscription = null;\n }\n if (\n this.failureSubscription !== undefined &&\n this.failureSubscription !== null\n ) {\n this.failureSubscription.remove();\n this.failureSubscription = null;\n }\n }\n}\n\nexport interface CFCallback {\n onVerify(orderID: string): void;\n\n onError(error: CFErrorResponse, orderID: string): void;\n}\n\nexport interface CFEventCallback {\n onReceivedEvent(eventName: string, map: Map<string, string>): void;\n}\n\nexport class CFErrorResponse {\n private status: string = 'FAILED';\n private message: string = 'payment has failed';\n private code: string = 'payment_failed';\n private type: string = 'request_failed';\n\n fromJSON(errorString: string) {\n console.log('errorString :' + errorString);\n const object = JSON.parse(errorString);\n console.log('errorStringObject :' + object);\n this.status = object.status;\n this.message = object.message;\n this.code = object.code;\n this.type = object.type;\n }\n\n getStatus(): string {\n return this.status;\n }\n\n getMessage(): string {\n return this.message;\n }\n\n getCode(): string {\n return this.code;\n }\n\n getType(): string {\n return this.type;\n }\n}\n\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;AAAA,SAGEA,qBAAqB,EACrBC,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QACH,cAAc;AACrB,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAA+CC,YAAY,EAAEC,aAAa,QAAQ,0BAA0B;AAE5G,MAAMC,aAAa,GAChB,uFAAsF,GACvFJ,QAAQ,CAACK,MAAM,CAAC;EAAEC,GAAG,EAAE,kCAAkC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACzE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,aAAa,GAAGT,aAAa,CAACS,aAAa,GAC7CT,aAAa,CAACS,aAAa,GAC3B,IAAIC,KAAK,CACT,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEH,MAAMQ,gBAAgB,CAAC;EAMrBC,WAAWA,CAAA,EAAG;IAAAC,eAAA;IAAAA,eAAA,8BAJ4C,IAAI;IAAAA,eAAA,8BACJ,IAAI;IAAAA,eAAA,4BACN,IAAI;IAG1D,IAAI,CAACC,OAAO,GACVf,QAAQ,CAACgB,EAAE,KAAK,KAAK,GACjB,IAAIlB,kBAAkB,CAACC,aAAa,CAACkB,oBAAoB,CAAC,GAC1DpB,qBAAqB;EAC7B;EAEAqB,SAASA,CAACC,eAAgC,EAAE;IAC1CA,eAAe,CAAClB,OAAO,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;EAEAC,SAASA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACH,MAAM;EACpB;EAEAI,UAAUA,CAAA,EAAW;IACnB,OAAO,IAAI,CAACZ,OAAO;EACrB;EAEAa,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;EAEAK,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;AACF;AAEA,OAAO,MAAMK,uBAAuB,GAAG,IAAIhE,gBAAgB,CAAC,CAAC"}
1
+ {"version":3,"names":["NativeAppEventEmitter","NativeEventEmitter","NativeModules","Platform","version","CFUPIPayment","CFCardPayment","LINKING_ERROR","select","ios","default","CashfreePgApi","Proxy","get","Error","CFPaymentGateway","constructor","_defineProperty","emitter","OS","CashfreeEventEmitter","doPayment","checkoutPayment","JSON","stringify","doUPIPayment","doWebPayment","cfSession","doCardPayment","cardPayment","makePayment","getInstalledUpiApps","Promise","resolve","reject","fetchUpiList","apps","console","log","upiAppsSubscription","addListener","cfPayment","paymentData","doElementUPIPayment","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","removeEventSubscriber","undefined","remove","setCallback","cfCallback","successFunction","orderID","onVerify","failureFunction","error","response","CFErrorResponse","message","fromJSON","onError","successSubscription","failureSubscription","removeCallback","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","CFPaymentGatewayService"],"sources":["index.ts"],"sourcesContent":["import {\n EmitterSubscription,\n EventEmitter,\n NativeAppEventEmitter,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\nimport { version } from '../package.json';\nimport { type CheckoutPayment, type CFSession, CFUPIPayment, CFCardPayment } from 'cashfree-pg-api-contract';\n\nconst LINKING_ERROR =\n `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: '- You have run \\'pod install\\'\\n', default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst CashfreePgApi = NativeModules.CashfreePgApi\n ? NativeModules.CashfreePgApi\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n },\n );\n\nclass CFPaymentGateway {\n private emitter: EventEmitter;\n private successSubscription: EmitterSubscription | null = null;\n private failureSubscription: EmitterSubscription | null = null;\n private eventSubscription: EmitterSubscription | null = null;\n private upiAppsSubscription: EmitterSubscription | null = null;\n\n constructor() {\n this.emitter =\n Platform.OS === 'ios'\n ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter)\n : NativeAppEventEmitter;\n }\n\n doPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));\n }\n\n doUPIPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));\n }\n\n doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(cfSession);\n }\n\n /**\n * @deprecated : Instead call makePayment\n */\n doCardPayment(cardPayment: CheckoutPayment) {\n this.makePayment(cardPayment);\n }\n\n async getInstalledUpiApps() {\n return new Promise((resolve, reject) => {\n if(Platform.OS === 'ios'){\n let fetchUpiList = (apps: string) => {\n console.log(JSON.stringify(apps));\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n };\n this.upiAppsSubscription = this.emitter.addListener('cfUpiApps', fetchUpiList);\n CashfreePgApi.getInstalledUpiApps()\n }\n else {\n CashfreePgApi.getInstalledUpiApps((apps: string) => {\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n });\n }\n });\n }\n\n makePayment(cfPayment: CheckoutPayment) {\n cfPayment.version = version;\n const paymentData = JSON.stringify(cfPayment);\n if (cfPayment instanceof CFUPIPayment) {\n CashfreePgApi.doElementUPIPayment(paymentData);\n } else if (cfPayment instanceof CFCardPayment) {\n CashfreePgApi.doCardPayment(paymentData);\n } else {\n console.log('makePayment::==> Wrong payment object');\n }\n }\n\n setEventSubscriber(cfEventCallback: CFEventCallback) {\n let eventFunction = (event: string) => {\n console.log(JSON.stringify(event));\n let data = JSON.parse(event);\n cfEventCallback.onReceivedEvent(data.eventName, data.meta);\n };\n this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);\n CashfreePgApi.setEventSubscriber();\n }\n\n removeEventSubscriber() {\n if (\n this.eventSubscription !== undefined &&\n this.eventSubscription !== null\n ) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\n }\n\n setCallback(cfCallback: CFCallback) {\n // this.cfCallback = cfCallback;\n let successFunction = (orderID: string) => {\n console.log('response is : ' + JSON.stringify(orderID));\n cfCallback.onVerify(orderID);\n };\n let failureFunction = (error: string) => {\n console.log('reason: ' + JSON.stringify(error));\n const response = new CFErrorResponse();\n // @ts-ignore\n const message = JSON.parse(error);\n response.fromJSON(message.error);\n // @ts-ignore\n cfCallback.onError(response, message.orderID);\n };\n this.successSubscription = this.emitter.addListener(\n 'cfSuccess',\n successFunction,\n );\n this.failureSubscription = this.emitter.addListener(\n 'cfFailure',\n failureFunction,\n );\n CashfreePgApi.setCallback();\n }\n\n removeCallback() {\n if (\n this.successSubscription !== undefined &&\n this.successSubscription !== null\n ) {\n this.successSubscription.remove();\n this.successSubscription = null;\n }\n if (\n this.failureSubscription !== undefined &&\n this.failureSubscription !== null\n ) {\n this.failureSubscription.remove();\n this.failureSubscription = null;\n }\n if (\n this.upiAppsSubscription !== undefined &&\n this.upiAppsSubscription !== null\n ) {\n this.upiAppsSubscription.remove();\n this.upiAppsSubscription = null;\n }\n }\n}\n\nexport interface CFCallback {\n onVerify(orderID: string): void;\n\n onError(error: CFErrorResponse, orderID: string): void;\n}\n\nexport interface CFEventCallback {\n onReceivedEvent(eventName: string, map: Map<string, string>): void;\n}\n\nexport class CFErrorResponse {\n private status: string = 'FAILED';\n private message: string = 'payment has failed';\n private code: string = 'payment_failed';\n private type: string = 'request_failed';\n\n fromJSON(errorString: string) {\n console.log('errorString :' + errorString);\n const object = JSON.parse(errorString);\n console.log('errorStringObject :' + object);\n this.status = object.status;\n this.message = object.message;\n this.code = object.code;\n this.type = object.type;\n }\n\n getStatus(): string {\n return this.status;\n }\n\n getMessage(): string {\n return this.message;\n }\n\n getCode(): string {\n return this.code;\n }\n\n getType(): string {\n return this.type;\n }\n}\n\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;AAAA,SAGEA,qBAAqB,EACrBC,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QACH,cAAc;AACrB,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAA+CC,YAAY,EAAEC,aAAa,QAAQ,0BAA0B;AAE5G,MAAMC,aAAa,GAChB,uFAAsF,GACvFJ,QAAQ,CAACK,MAAM,CAAC;EAAEC,GAAG,EAAE,kCAAkC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACzE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,aAAa,GAAGT,aAAa,CAACS,aAAa,GAC7CT,aAAa,CAACS,aAAa,GAC3B,IAAIC,KAAK,CACT,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEH,MAAMQ,gBAAgB,CAAC;EAOrBC,WAAWA,CAAA,EAAG;IAAAC,eAAA;IAAAA,eAAA,8BAL4C,IAAI;IAAAA,eAAA,8BACJ,IAAI;IAAAA,eAAA,4BACN,IAAI;IAAAA,eAAA,8BACF,IAAI;IAG5D,IAAI,CAACC,OAAO,GACVf,QAAQ,CAACgB,EAAE,KAAK,KAAK,GACjB,IAAIlB,kBAAkB,CAACC,aAAa,CAACkB,oBAAoB,CAAC,GAC1DpB,qBAAqB;EAC7B;EAEAqB,SAASA,CAACC,eAAgC,EAAE;IAC1CA,eAAe,CAAClB,OAAO,GAAGA,OAAO;IACjCO,aAAa,CAACU,S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ACjC;EACF;AACF;AAYA,OAAO,MAAM0B,eAAe,CAAC;EAAAjD,YAAA;IAAAC,eAAA,iBACF,QAAQ;IAAAA,eAAA,kBACP,oBAAoB;IAAAA,eAAA,eACvB,gBAAgB;IAAAA,eAAA,eAChB,gBAAgB;EAAA;EAEvCkD,QAAQA,CAACK,WAAmB,EAAE;IAC5BnC,OAAO,CAACC,GAAG,CAAC,eAAe,GAAGkC,WAAW,CAAC;IAC1C,MAAMC,MAAM,GAAGlD,IAAI,CAAC0B,KAAK,CAACuB,WAAW,CAAC;IACtCnC,OAAO,CAACC,GAAG,CAAC,qBAAqB,GAAGmC,MAAM,CAAC;IAC3C,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;IAC3B,IAAI,CAACR,OAAO,GAAGO,MAAM,CAACP,OAAO;IAC7B,IAAI,CAACS,IAAI,GAAGF,MAAM,CAACE,IAAI;IACvB,IAAI,CAACC,IAAI,GAAGH,MAAM,CAACG,IAAI;EACzB;EAEAC,SAASA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACH,MAAM;EACpB;EAEAI,UAAUA,CAAA,EAAW;IACnB,OAAO,IAAI,CAACZ,OAAO;EACrB;EAEAa,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;EAEAK,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;AACF;AAEA,OAAO,MAAMK,uBAAuB,GAAG,IAAIlE,gBAAgB,CAAC,CAAC"}
@@ -4,6 +4,7 @@ declare class CFPaymentGateway {
4
4
  private successSubscription;
5
5
  private failureSubscription;
6
6
  private eventSubscription;
7
+ private upiAppsSubscription;
7
8
  constructor();
8
9
  doPayment(checkoutPayment: CheckoutPayment): void;
9
10
  doUPIPayment(checkoutPayment: CheckoutPayment): void;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "react-native-cashfree-pg-sdk",
3
- "version": "2.1.8",
3
+ "version": "2.1.9-dev.1",
4
4
  "description": "Cashfree PG Plugin for React Native",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
7
- "types": "lib/typescript/index.d.ts",
7
+ "types": "lib/typescript/src/index.d.ts",
8
8
  "react-native": "src/index",
9
9
  "source": "src/index",
10
10
  "files": [
@@ -34,7 +34,14 @@
34
34
  "keywords": [
35
35
  "react-native",
36
36
  "ios",
37
- "android"
37
+ "android",
38
+ "cashfree",
39
+ "react-native-android",
40
+ "react-native-ios",
41
+ "cashfree react-native sdk",
42
+ "react-native payment gateway",
43
+ "payment gateway",
44
+ "react-native-cashfree-pg-sdk"
38
45
  ],
39
46
  "repository": "https://github.com/cashfree/react-native-cashfree-pg-sdk",
40
47
  "author": "cashfree-payments <developers@cashfree.com> (https://www.cashfree.com/)",
package/src/index.js CHANGED
@@ -17,6 +17,7 @@ class CFPaymentGateway {
17
17
  successSubscription = null;
18
18
  failureSubscription = null;
19
19
  eventSubscription = null;
20
+ upiAppsSubscription = null;
20
21
  constructor() {
21
22
  this.emitter =
22
23
  Platform.OS === 'ios'
@@ -42,14 +43,29 @@ class CFPaymentGateway {
42
43
  }
43
44
  async getInstalledUpiApps() {
44
45
  return new Promise((resolve, reject) => {
45
- CashfreePgApi.getInstalledUpiApps((apps) => {
46
- if (apps) {
47
- resolve(apps);
48
- }
49
- else {
50
- reject('No UPI apps found');
51
- }
52
- });
46
+ if (Platform.OS === 'ios') {
47
+ let fetchUpiList = (apps) => {
48
+ console.log(JSON.stringify(apps));
49
+ if (apps) {
50
+ resolve(apps);
51
+ }
52
+ else {
53
+ reject('No UPI apps found');
54
+ }
55
+ };
56
+ this.upiAppsSubscription = this.emitter.addListener('cfUpiApps', fetchUpiList);
57
+ CashfreePgApi.getInstalledUpiApps();
58
+ }
59
+ else {
60
+ CashfreePgApi.getInstalledUpiApps((apps) => {
61
+ if (apps) {
62
+ resolve(apps);
63
+ }
64
+ else {
65
+ reject('No UPI apps found');
66
+ }
67
+ });
68
+ }
53
69
  });
54
70
  }
55
71
  makePayment(cfPayment) {
@@ -112,6 +128,11 @@ class CFPaymentGateway {
112
128
  this.failureSubscription.remove();
113
129
  this.failureSubscription = null;
114
130
  }
131
+ if (this.upiAppsSubscription !== undefined &&
132
+ this.upiAppsSubscription !== null) {
133
+ this.upiAppsSubscription.remove();
134
+ this.upiAppsSubscription = null;
135
+ }
115
136
  }
116
137
  }
117
138
  export class CFErrorResponse {
package/src/index.ts CHANGED
@@ -31,6 +31,7 @@ class CFPaymentGateway {
31
31
  private successSubscription: EmitterSubscription | null = null;
32
32
  private failureSubscription: EmitterSubscription | null = null;
33
33
  private eventSubscription: EmitterSubscription | null = null;
34
+ private upiAppsSubscription: EmitterSubscription | null = null;
34
35
 
35
36
  constructor() {
36
37
  this.emitter =
@@ -62,13 +63,27 @@ class CFPaymentGateway {
62
63
 
63
64
  async getInstalledUpiApps() {
64
65
  return new Promise((resolve, reject) => {
65
- CashfreePgApi.getInstalledUpiApps((apps: string) => {
66
- if (apps) {
67
- resolve(apps);
68
- } else {
69
- reject('No UPI apps found');
70
- }
71
- });
66
+ if(Platform.OS === 'ios'){
67
+ let fetchUpiList = (apps: string) => {
68
+ console.log(JSON.stringify(apps));
69
+ if (apps) {
70
+ resolve(apps);
71
+ } else {
72
+ reject('No UPI apps found');
73
+ }
74
+ };
75
+ this.upiAppsSubscription = this.emitter.addListener('cfUpiApps', fetchUpiList);
76
+ CashfreePgApi.getInstalledUpiApps()
77
+ }
78
+ else {
79
+ CashfreePgApi.getInstalledUpiApps((apps: string) => {
80
+ if (apps) {
81
+ resolve(apps);
82
+ } else {
83
+ reject('No UPI apps found');
84
+ }
85
+ });
86
+ }
72
87
  });
73
88
  }
74
89
 
@@ -146,6 +161,13 @@ class CFPaymentGateway {
146
161
  this.failureSubscription.remove();
147
162
  this.failureSubscription = null;
148
163
  }
164
+ if (
165
+ this.upiAppsSubscription !== undefined &&
166
+ this.upiAppsSubscription !== null
167
+ ) {
168
+ this.upiAppsSubscription.remove();
169
+ this.upiAppsSubscription = null;
170
+ }
149
171
  }
150
172
  }
151
173