react-native-cashfree-pg-sdk 2.0.6 → 2.0.7-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.
@@ -26,10 +26,10 @@ 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"]
29
+ var allEventNames: [String] = ["cfSuccess", "cfFailure", "cfEvent"]
30
30
 
31
31
  // Append all events here
32
-
32
+
33
33
  return allEventNames
34
34
  }()
35
35
 
@@ -9,4 +9,8 @@ RCT_EXTERN_METHOD(doWebPayment:(NSString)paymentObject)
9
9
 
10
10
  RCT_EXTERN_METHOD(setCallback)
11
11
 
12
+ RCT_EXTERN_METHOD(setEventSubscriber)
13
+
14
+ RCT_EXTERN_METHOD(removeEventSubscriber)
15
+
12
16
  @end
@@ -5,6 +5,8 @@ import CashfreePG
5
5
  @objc(CashfreePgApi)
6
6
  class CashfreePgApi: NSObject {
7
7
 
8
+ var analyticsCallbackEnabled: Bool = false
9
+
8
10
  override init() {
9
11
  super.init()
10
12
  }
@@ -46,6 +48,14 @@ class CashfreePgApi: NSObject {
46
48
  CFPaymentGatewayService.getInstance().setCallback(self)
47
49
  }
48
50
 
51
+ @objc func setEventSubscriber() -> Void {
52
+ analyticsCallbackEnabled = true
53
+ }
54
+
55
+ @objc func removeEventSubscriber() -> Void {
56
+ analyticsCallbackEnabled = false
57
+ }
58
+
49
59
  private func parseDropPayment(paymentObject: String) throws -> CFDropCheckoutPayment? {
50
60
  // print(paymentObject)
51
61
  let data = paymentObject.data(using: .utf8)!
@@ -207,4 +217,13 @@ extension CashfreePgApi: CFResponseDelegate {
207
217
  print(order_id)
208
218
  CashfreeEmitter.sharedInstance.dispatch(name: "cfSuccess", body: order_id)
209
219
  }
220
+
221
+ func receivedEvent(event_name: String, meta_data: Dictionary<String, Any>) {
222
+ if (analyticsCallbackEnabled) {
223
+ print(event_name)
224
+ let data: [String: Any] = ["eventName": event_name
225
+ , "meta": meta_data]
226
+ CashfreeEmitter.sharedInstance.dispatch(name: "cfEvent", body: stringify(json: data))
227
+ }
228
+ }
210
229
  }
@@ -10,7 +10,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
10
10
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
11
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
12
  const LINKING_ERROR = `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
13
- ios: '- You have run \'pod install\'\n',
13
+ ios: "- You have run 'pod install'\n",
14
14
  default: ''
15
15
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
16
16
  const CashfreePgApi = _reactNative.NativeModules.CashfreePgApi ? _reactNative.NativeModules.CashfreePgApi : new Proxy({}, {
@@ -34,23 +34,20 @@ class CFPaymentGateway {
34
34
  CashfreePgApi.doWebPayment(cfSession);
35
35
  }
36
36
  setEventSubscriber(cfEventCallback) {
37
- if (_reactNative.Platform.OS === 'android') {
38
- let eventFunction = event => {
39
- let data = JSON.parse(event);
40
- cfEventCallback.onReceivedEvent(data.eventName, data.meta);
41
- };
42
- this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
43
- CashfreePgApi.setEventSubscriber();
44
- }
37
+ let eventFunction = event => {
38
+ console.log(JSON.stringify(event));
39
+ let data = JSON.parse(event);
40
+ cfEventCallback.onReceivedEvent(data.eventName, data.meta);
41
+ };
42
+ this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
43
+ CashfreePgApi.setEventSubscriber();
45
44
  }
46
45
  removeEventSubscriber() {
47
- if (_reactNative.Platform.OS === 'android') {
48
- if (this.eventSubscription !== undefined && this.eventSubscription !== null) {
49
- this.eventSubscription.remove();
50
- this.eventSubscription = null;
51
- }
52
- CashfreePgApi.removeEventSubscriber();
46
+ if (this.eventSubscription !== undefined && this.eventSubscription !== null) {
47
+ this.eventSubscription.remove();
48
+ this.eventSubscription = null;
53
49
  }
50
+ CashfreePgApi.removeEventSubscriber();
54
51
  }
55
52
  setCallback(cfCallback) {
56
53
  // this.cfCallback = cfCallback;
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_package","_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","doWebPayment","cfSession","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","addListener","removeEventSubscriber","remove","setCallback","cfCallback","successFunction","orderID","console","log","onVerify","failureFunction","error","response","CFErrorResponse","message","fromJSON","onError","successSubscription","failureSubscription","removeCallback","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","exports","CFPaymentGatewayService"],"sources":["index.js"],"sourcesContent":["import { NativeAppEventEmitter, NativeEventEmitter, NativeModules, Platform, } from 'react-native';\nimport { version } from '../package.json';\nconst LINKING_ERROR = `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';\nconst CashfreePgApi = NativeModules.CashfreePgApi\n ? NativeModules.CashfreePgApi\n : new Proxy({}, {\n get() {\n throw new Error(LINKING_ERROR);\n },\n });\nclass CFPaymentGateway {\n emitter;\n successSubscription = null;\n failureSubscription = null;\n eventSubscription = null;\n constructor() {\n this.emitter =\n Platform.OS === 'ios'\n ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter)\n : NativeAppEventEmitter;\n }\n doPayment(checkoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));\n }\n doWebPayment(cfSession) {\n CashfreePgApi.doWebPayment(cfSession);\n }\n setEventSubscriber(cfEventCallback) {\n if (Platform.OS === 'android') {\n let eventFunction = (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 (Platform.OS === 'android') {\n if (this.eventSubscription !== undefined &&\n this.eventSubscription !== null) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\n }\n }\n setCallback(cfCallback) {\n // this.cfCallback = cfCallback;\n let successFunction = (orderID) => {\n console.log('response is : ' + JSON.stringify(orderID));\n cfCallback.onVerify(orderID);\n };\n let failureFunction = (error) => {\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('cfSuccess', successFunction);\n this.failureSubscription = this.emitter.addListener('cfFailure', failureFunction);\n CashfreePgApi.setCallback();\n }\n removeCallback() {\n if (this.successSubscription !== undefined &&\n this.successSubscription !== null) {\n this.successSubscription.remove();\n this.successSubscription = null;\n }\n if (this.failureSubscription !== undefined &&\n this.failureSubscription !== null) {\n this.failureSubscription.remove();\n this.failureSubscription = null;\n }\n }\n}\nexport class CFErrorResponse {\n status = 'FAILED';\n message = 'payment has failed';\n code = 'payment_failed';\n type = 'request_failed';\n fromJSON(errorString) {\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 getStatus() {\n return this.status;\n }\n getMessage() {\n return this.message;\n }\n getCode() {\n return this.code;\n }\n getType() {\n return this.type;\n }\n}\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAA0C,SAAAE,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,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,SAAA,4DAAAP,IAAA,gBAAAF,MAAA,GAAAU,MAAA,EAAAT,KAAA;AAC1C,MAAMU,aAAa,GAAI,uFAAsF,GACzGC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,kCAAkC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACzE,sDAAsD,GACtD,6CAA6C;AACjD,MAAMC,aAAa,GAAGC,0BAAa,CAACD,aAAa,G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AAG,IAAI;IACnC;IACA,IAAI,IAAI,CAACC,mBAAmB,KAAKzD,SAAS,IACtC,IAAI,CAACyD,mBAAmB,KAAK,IAAI,EAAE;MACnC,IAAI,CAACA,mBAAmB,CAAChB,MAAM,EAAE;MACjC,IAAI,CAACgB,mBAAmB,GAAG,IAAI;IACnC;EACJ;AACJ;AACO,MAAML,eAAe,CAAC;EAAApC,YAAA;IAAAlC,eAAA,iBAChB,QAAQ;IAAAA,eAAA,kBACP,oBAAoB;IAAAA,eAAA,eACvB,gBAAgB;IAAAA,eAAA,eAChB,gBAAgB;EAAA;EACvBwE,QAAQA,CAACK,WAAW,EAAE;IAClBb,OAAO,CAACC,GAAG,CAAC,eAAe,GAAGY,WAAW,CAAC;IAC1C,MAAMC,MAAM,GAAGnC,IAAI,CAACS,KAAK,CAACyB,WAAW,CAAC;IACtCb,OAAO,CAACC,GAAG,CAAC,qBAAqB,GAAGa,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;EAC3B;EACAC,SAASA,CAAA,EAAG;IACR,OAAO,IAAI,CAACH,MAAM;EACtB;EACAI,UAAUA,CAAA,EAAG;IACT,OAAO,IAAI,CAACZ,OAAO;EACvB;EACAa,OAAOA,CAAA,EAAG;IACN,OAAO,IAAI,CAACJ,IAAI;EACpB;EACAK,OAAOA,CAAA,EAAG;IACN,OAAO,IAAI,CAACJ,IAAI;EACpB;AACJ;AAACK,OAAA,CAAAhB,eAAA,GAAAA,eAAA;AACM,MAAMiB,uBAAuB,GAAG,IAAItD,gBAAgB,EAAE;AAACqD,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
1
+ {"version":3,"names":["_reactNative","require","_package","_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","doWebPayment","cfSession","setEventSubscriber","cfEventCallback","eventFunction","event","console","log","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, CFSession } 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 doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(cfSession);\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;AAA0C,SAAAE,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,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,SAAA,4DAAAP,IAAA,gBAAAF,MAAA,GAAAU,MAAA,EAAAT,KAAA;AAG1C,MAAMU,aAAa,GAChB,uFAAsF,GACvFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,aAAa,GAA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,IACE,IAAI,CAACC,mBAAmB,KAAKzD,SAAS,IACtC,IAAI,CAACyD,mBAAmB,KAAK,IAAI,EACjC;MACA,IAAI,CAACA,mBAAmB,CAACd,MAAM,EAAE;MACjC,IAAI,CAACc,mBAAmB,GAAG,IAAI;IACjC;EACF;AACF;AAYO,MAAML,eAAe,CAAC;EAAApC,YAAA;IAAAlC,eAAA,iBACF,QAAQ;IAAAA,eAAA,kBACP,oBAAoB;IAAAA,eAAA,eACvB,gBAAgB;IAAAA,eAAA,eAChB,gBAAgB;EAAA;EAEvCwE,QAAQA,CAACK,WAAmB,EAAE;IAC5B1B,OAAO,CAACC,GAAG,CAAC,eAAe,GAAGyB,WAAW,CAAC;IAC1C,MAAMC,MAAM,GAAGnC,IAAI,CAACW,KAAK,CAACuB,WAAW,CAAC;IACtC1B,OAAO,CAACC,GAAG,CAAC,qBAAqB,GAAG0B,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,IAAItD,gBAAgB,EAAE;AAACqD,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
@@ -4,7 +4,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
4
4
  import { NativeAppEventEmitter, NativeEventEmitter, NativeModules, Platform } from 'react-native';
5
5
  import { version } from '../package.json';
6
6
  const LINKING_ERROR = `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
7
- ios: '- You have run \'pod install\'\n',
7
+ ios: "- You have run 'pod install'\n",
8
8
  default: ''
9
9
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
10
10
  const CashfreePgApi = NativeModules.CashfreePgApi ? NativeModules.CashfreePgApi : new Proxy({}, {
@@ -28,23 +28,20 @@ class CFPaymentGateway {
28
28
  CashfreePgApi.doWebPayment(cfSession);
29
29
  }
30
30
  setEventSubscriber(cfEventCallback) {
31
- if (Platform.OS === 'android') {
32
- let eventFunction = event => {
33
- let data = JSON.parse(event);
34
- cfEventCallback.onReceivedEvent(data.eventName, data.meta);
35
- };
36
- this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
37
- CashfreePgApi.setEventSubscriber();
38
- }
31
+ let eventFunction = event => {
32
+ console.log(JSON.stringify(event));
33
+ let data = JSON.parse(event);
34
+ cfEventCallback.onReceivedEvent(data.eventName, data.meta);
35
+ };
36
+ this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
37
+ CashfreePgApi.setEventSubscriber();
39
38
  }
40
39
  removeEventSubscriber() {
41
- if (Platform.OS === 'android') {
42
- if (this.eventSubscription !== undefined && this.eventSubscription !== null) {
43
- this.eventSubscription.remove();
44
- this.eventSubscription = null;
45
- }
46
- CashfreePgApi.removeEventSubscriber();
40
+ if (this.eventSubscription !== undefined && this.eventSubscription !== null) {
41
+ this.eventSubscription.remove();
42
+ this.eventSubscription = null;
47
43
  }
44
+ CashfreePgApi.removeEventSubscriber();
48
45
  }
49
46
  setCallback(cfCallback) {
50
47
  // this.cfCallback = cfCallback;
@@ -1 +1 @@
1
- {"version":3,"names":["NativeAppEventEmitter","NativeEventEmitter","NativeModules","Platform","version","LINKING_ERROR","select","ios","default","CashfreePgApi","Proxy","get","Error","CFPaymentGateway","constructor","_defineProperty","emitter","OS","CashfreeEventEmitter","doPayment","checkoutPayment","JSON","stringify","doWebPayment","cfSession","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","addListener","removeEventSubscriber","undefined","remove","setCallback","cfCallback","successFunction","orderID","console","log","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, CFSession } 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 doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(cfSession);\n }\n\n setEventSubscriber(cfEventCallback: CFEventCallback) {\n if (Platform.OS === 'android') {\n let eventFunction = (event: string) => {\n let data = JSON.parse(event);\n cfEventCallback.onReceivedEvent(data.eventName, data.meta);\n };\n this.eventSubscription = this.emitter.addListener(\n 'cfEvent',\n eventFunction,\n );\n CashfreePgApi.setEventSubscriber();\n }\n }\n\n removeEventSubscriber() {\n if (Platform.OS === 'android') {\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\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;AAGzC,MAAMC,aAAa,GAChB,uFAAsF,GACvFF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,kCAAkC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACzE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,aAAa,GAAGP,aAAa,CAACO,aAAa,GAC7CP,aAAa,CAACO,aAAa,GAC3B,IAAIC,KAAK,CACT,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CAAC,CACF;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,GACVb,QAAQ,CAACc,EAAE,KAAK,KAAK,GACjB,IAAIhB,kBAAkB,CAACC,aAAa,CAACgB,oBAAoB,CAAC,GAC1DlB,qBAAqB;EAC7B;EAEAmB,SAASA,CAACC,eAAgC,EAAE;IAC1CA,eAAe,CAAChB,OAAO,GAAGA,OAAO;IACjCK,aAAa,CAACU,SAAS,CAACE,IAAI,CAACC,SAAS,CAACF,eAAe,CAAC,CAAC;EAC1D;EAEAG,YAAYA,CAACC,SAAoB,EAAE;IACjCf,aAAa,CAACc,YAAY,CAACC,SAAS,CAAC;EACvC;EAEAC,kBAAkBA,CAACC,eAAgC,EAAE;IACnD,IAAIvB,QAAQ,CAACc,EAAE,KAAK,SAAS,EAAE;MAC7B,IAAIU,a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EAC,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,IAAIpD,gBAAgB,EAAE"}
1
+ {"version":3,"names":["NativeAppEventEmitter","NativeEventEmitter","NativeModules","Platform","version","LINKING_ERROR","select","ios","default","CashfreePgApi","Proxy","get","Error","CFPaymentGateway","constructor","_defineProperty","emitter","OS","CashfreeEventEmitter","doPayment","checkoutPayment","JSON","stringify","doWebPayment","cfSession","setEventSubscriber","cfEventCallback","eventFunction","event","console","log","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, CFSession } 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 doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(cfSession);\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;AAGzC,MAAMC,aAAa,GAChB,uFAAsF,GACvFF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,aAAa,GAAGP,aAAa,CAACO,aAAa,GAC7CP,aAAa,CAACO,aAAa,GAC3B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CAAC,CACF;AAEL,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,GACVb,QAAQ,CAACc,EAAE,KAAK,KAAK,GACjB,IAAIhB,kBAAkB,CAACC,aAAa,CAACgB,oBAAoB,C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MAAM,GAAGpC,IAAI,CAACW,KAAK,CAACwB,WAAW,CAAC;IACtC3B,OAAO,CAACC,GAAG,CAAC,qBAAqB,GAAG2B,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,IAAIpD,gBAAgB,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-cashfree-pg-sdk",
3
- "version": "2.0.6",
3
+ "version": "2.0.7-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",
@@ -145,6 +145,6 @@
145
145
  ]
146
146
  },
147
147
  "dependencies": {
148
- "cashfree-pg-api-contract": "2.0.0"
148
+ "cashfree-pg-api-contract": "2.0.1"
149
149
  }
150
150
  }
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
16
16
  s.source_files = "ios/**/*.{h,m,mm,swift}"
17
17
 
18
18
  s.dependency "React-Core"
19
- s.dependency "CashfreePG", "~> 2.0.4"
19
+ s.dependency "CashfreePG", "~> 2.0.5"
20
20
  end
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { NativeAppEventEmitter, NativeEventEmitter, NativeModules, Platform, } from 'react-native';
2
2
  import { version } from '../package.json';
3
3
  const LINKING_ERROR = `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` +
4
- Platform.select({ ios: '- You have run \'pod install\'\n', default: '' }) +
4
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
5
5
  '- You rebuilt the app after installing the package\n' +
6
6
  '- You are not using Expo managed workflow\n';
7
7
  const CashfreePgApi = NativeModules.CashfreePgApi
@@ -30,24 +30,21 @@ class CFPaymentGateway {
30
30
  CashfreePgApi.doWebPayment(cfSession);
31
31
  }
32
32
  setEventSubscriber(cfEventCallback) {
33
- if (Platform.OS === 'android') {
34
- let eventFunction = (event) => {
35
- let data = JSON.parse(event);
36
- cfEventCallback.onReceivedEvent(data.eventName, data.meta);
37
- };
38
- this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
39
- CashfreePgApi.setEventSubscriber();
40
- }
33
+ let eventFunction = (event) => {
34
+ console.log(JSON.stringify(event));
35
+ let data = JSON.parse(event);
36
+ cfEventCallback.onReceivedEvent(data.eventName, data.meta);
37
+ };
38
+ this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
39
+ CashfreePgApi.setEventSubscriber();
41
40
  }
42
41
  removeEventSubscriber() {
43
- if (Platform.OS === 'android') {
44
- if (this.eventSubscription !== undefined &&
45
- this.eventSubscription !== null) {
46
- this.eventSubscription.remove();
47
- this.eventSubscription = null;
48
- }
49
- CashfreePgApi.removeEventSubscriber();
42
+ if (this.eventSubscription !== undefined &&
43
+ this.eventSubscription !== null) {
44
+ this.eventSubscription.remove();
45
+ this.eventSubscription = null;
50
46
  }
47
+ CashfreePgApi.removeEventSubscriber();
51
48
  }
52
49
  setCallback(cfCallback) {
53
50
  // this.cfCallback = cfCallback;
package/src/index.ts CHANGED
@@ -11,20 +11,20 @@ import type { CheckoutPayment, CFSession } from 'cashfree-pg-api-contract';
11
11
 
12
12
  const LINKING_ERROR =
13
13
  `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` +
14
- Platform.select({ ios: '- You have run \'pod install\'\n', default: '' }) +
14
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
15
15
  '- You rebuilt the app after installing the package\n' +
16
16
  '- You are not using Expo managed workflow\n';
17
17
 
18
18
  const CashfreePgApi = NativeModules.CashfreePgApi
19
19
  ? NativeModules.CashfreePgApi
20
20
  : new Proxy(
21
- {},
22
- {
23
- get() {
24
- throw new Error(LINKING_ERROR);
25
- },
26
- },
27
- );
21
+ {},
22
+ {
23
+ get() {
24
+ throw new Error(LINKING_ERROR);
25
+ },
26
+ }
27
+ );
28
28
 
29
29
  class CFPaymentGateway {
30
30
  private emitter: EventEmitter;
@@ -49,30 +49,24 @@ class CFPaymentGateway {
49
49
  }
50
50
 
51
51
  setEventSubscriber(cfEventCallback: CFEventCallback) {
52
- if (Platform.OS === 'android') {
53
- let eventFunction = (event: string) => {
54
- let data = JSON.parse(event);
55
- cfEventCallback.onReceivedEvent(data.eventName, data.meta);
56
- };
57
- this.eventSubscription = this.emitter.addListener(
58
- 'cfEvent',
59
- eventFunction,
60
- );
61
- CashfreePgApi.setEventSubscriber();
62
- }
52
+ let eventFunction = (event: string) => {
53
+ console.log(JSON.stringify(event));
54
+ let data = JSON.parse(event);
55
+ cfEventCallback.onReceivedEvent(data.eventName, data.meta);
56
+ };
57
+ this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
58
+ CashfreePgApi.setEventSubscriber();
63
59
  }
64
60
 
65
61
  removeEventSubscriber() {
66
- if (Platform.OS === 'android') {
67
- if (
68
- this.eventSubscription !== undefined &&
69
- this.eventSubscription !== null
70
- ) {
71
- this.eventSubscription.remove();
72
- this.eventSubscription = null;
73
- }
74
- CashfreePgApi.removeEventSubscriber();
62
+ if (
63
+ this.eventSubscription !== undefined &&
64
+ this.eventSubscription !== null
65
+ ) {
66
+ this.eventSubscription.remove();
67
+ this.eventSubscription = null;
75
68
  }
69
+ CashfreePgApi.removeEventSubscriber();
76
70
  }
77
71
 
78
72
  setCallback(cfCallback: CFCallback) {
@@ -92,11 +86,11 @@ class CFPaymentGateway {
92
86
  };
93
87
  this.successSubscription = this.emitter.addListener(
94
88
  'cfSuccess',
95
- successFunction,
89
+ successFunction
96
90
  );
97
91
  this.failureSubscription = this.emitter.addListener(
98
92
  'cfFailure',
99
- failureFunction,
93
+ failureFunction
100
94
  );
101
95
  CashfreePgApi.setCallback();
102
96
  }