react-native-cashfree-pg-sdk 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # react-native-cashfree-pg-api
1
+ # react-native-cashfree-pg-sdk
2
2
  The Cashfree React Native SDK allows you to integrate Cashfree Payment Gateway into your application and start collecting payments from your customers. The React Native SDK has been designed to minimise the complexity of handling and integrating payments in your React Native project.
3
3
 
4
4
  Click [here](https://docs.cashfree.com/docs/react-native-integration) for more Documentation.
@@ -69,7 +69,7 @@ dependencies {
69
69
  implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
70
70
  implementation 'androidx.gridlayout:gridlayout:1.0.0'
71
71
 
72
- implementation 'com.cashfree.pg:api:1.0.10'
72
+ implementation 'com.cashfree.pg:api:1.0.11'
73
73
 
74
74
  implementation "com.facebook.react:react-native:+" // From node_modules
75
75
  }
@@ -9,16 +9,20 @@ import Foundation
9
9
 
10
10
  @objc(CashfreeEventEmitter)
11
11
  open class CashfreeEventEmitter: RCTEventEmitter {
12
-
12
+
13
13
  override init() {
14
14
  super.init()
15
15
  CashfreeEmitter.sharedInstance.registerEventEmitter(eventEmitter: self)
16
16
  }
17
-
17
+
18
18
  /// Base overide for RCTEventEmitter.
19
19
  ///
20
20
  /// - Returns: all supported events
21
21
  @objc open override func supportedEvents() -> [String] {
22
22
  return CashfreeEmitter.sharedInstance.allEvents
23
23
  }
24
+
25
+ @objc public override static func requiresMainQueueSetup() -> Bool {
26
+ return false
27
+ }
24
28
  }
@@ -5,6 +5,14 @@ import CashfreePG
5
5
  @objc(CashfreePgApi)
6
6
  class CashfreePgApi: NSObject {
7
7
 
8
+ override init() {
9
+ super.init()
10
+ }
11
+
12
+ @objc static func requiresMainQueueSetup() -> Bool {
13
+ return false
14
+ }
15
+
8
16
  @objc func doPayment(_ paymentObject: NSString) -> Void {
9
17
  do {
10
18
  let dropObject = try! parseDropPayment(paymentObject: "\(paymentObject)")
@@ -62,12 +62,12 @@ class CFPaymentGateway {
62
62
 
63
63
  removeCallback() {
64
64
  if (this.successSubscription !== undefined && this.successSubscription !== null) {
65
- this.emitter.removeSubscription(this.successSubscription);
65
+ this.successSubscription.remove();
66
66
  this.successSubscription = null;
67
67
  }
68
68
 
69
69
  if (this.failureSubscription !== undefined && this.failureSubscription !== null) {
70
- this.emitter.removeSubscription(this.failureSubscription);
70
+ this.failureSubscription.remove();
71
71
  this.failureSubscription = null;
72
72
  }
73
73
  }
@@ -1 +1 @@
1
- {"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","CashfreePgApi","NativeModules","Proxy","get","Error","CFPaymentGateway","constructor","emitter","OS","NativeEventEmitter","CashfreeEventEmitter","NativeAppEventEmitter","doPayment","checkoutPayment","version","JSON","stringify","setCallback","cfCallback","successFunction","orderID","console","log","onVerify","failureFunction","error","response","CFErrorResponse","message","parse","fromJSON","onError","successSubscription","addListener","failureSubscription","removeCallback","undefined","removeSubscription","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","CFPaymentGatewayService"],"sources":["index.tsx"],"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 } 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\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 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.emitter.removeSubscription(this.successSubscription);\n this.successSubscription = null;\n }\n if (\n this.failureSubscription !== undefined &&\n this.failureSubscription !== null\n ) {\n this.emitter.removeSubscription(this.failureSubscription);\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 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 var CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;;;;;AAAA;;AAQA;;;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SAAS,GAAW;IAClB,OAAO,KAAKH,MAAZ;EACD;;EAEDI,UAAU,GAAW;IACnB,OAAO,KAAKhB,OAAZ;EACD;;EAEDiB,OAAO,GAAW;IAChB,OAAO,KAAKJ,IAAZ;EACD;;EAEDK,OAAO,GAAW;IAChB,OAAO,KAAKJ,IAAZ;EACD;;AA9B0B;;;AAiCtB,IAAIK,uBAAuB,GAAG,IAAI1C,gBAAJ,EAA9B"}
1
+ {"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","CashfreePgApi","NativeModules","Proxy","get","Error","CFPaymentGateway","constructor","emitter","OS","NativeEventEmitter","CashfreeEventEmitter","NativeAppEventEmitter","doPayment","checkoutPayment","version","JSON","stringify","setCallback","cfCallback","successFunction","orderID","console","log","onVerify","failureFunction","error","response","CFErrorResponse","message","parse","fromJSON","onError","successSubscription","addListener","failureSubscription","removeCallback","undefined","remove","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","CFPaymentGatewayService"],"sources":["index.tsx"],"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 } 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\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 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 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 var CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;;;;;AAAA;;AAQA;;;;AAGA,MAAMA,aAAa,GAChB,uFAAD,GACAC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC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;EACD;;EAEDK,OAAO,GAAW;IAChB,OAAO,KAAKJ,IAAZ;EACD;;AA9B0B;;;AAiCtB,IAAIK,uBAAuB,GAAG,IAAI1C,gBAAJ,EAA9B"}
@@ -53,12 +53,12 @@ class CFPaymentGateway {
53
53
 
54
54
  removeCallback() {
55
55
  if (this.successSubscription !== undefined && this.successSubscription !== null) {
56
- this.emitter.removeSubscription(this.successSubscription);
56
+ this.successSubscription.remove();
57
57
  this.successSubscription = null;
58
58
  }
59
59
 
60
60
  if (this.failureSubscription !== undefined && this.failureSubscription !== null) {
61
- this.emitter.removeSubscription(this.failureSubscription);
61
+ this.failureSubscription.remove();
62
62
  this.failureSubscription = null;
63
63
  }
64
64
  }
@@ -1 +1 @@
1
- {"version":3,"names":["NativeAppEventEmitter","NativeEventEmitter","NativeModules","Platform","version","LINKING_ERROR","select","ios","default","CashfreePgApi","Proxy","get","Error","CFPaymentGateway","constructor","emitter","OS","CashfreeEventEmitter","doPayment","checkoutPayment","JSON","stringify","setCallback","cfCallback","successFunction","orderID","console","log","onVerify","failureFunction","error","response","CFErrorResponse","message","parse","fromJSON","onError","successSubscription","addListener","failureSubscription","removeCallback","undefined","removeSubscription","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","CFPaymentGatewayService"],"sources":["index.tsx"],"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 } 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\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 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.emitter.removeSubscription(this.successSubscription);\n this.successSubscription = null;\n }\n if (\n this.failureSubscription !== undefined &&\n this.failureSubscription !== null\n ) {\n this.emitter.removeSubscription(this.failureSubscription);\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 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 var CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;AAAA,SAGEA,qBAHF,EAIEC,kBAJF,EAKEC,aALF,EAMEC,QANF,QAOO,cAPP;AAQA,SAASC,OAAT,QAAwB,iBAAxB;AAGA,MAAMC,aAAa,GAChB,uFAAD,GACAF,QAAQ,CAACG,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,aAAa,GAAGP,aAAa,CAACO,aAAd,GAClBP,aAAa,CAACO,aADI,GAElB,IAAIC,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUP,aAAV,CAAN;EACD;;AAHH,CAFF,CAFJ;;AAWA,MAAMQ,gBAAN,CAAuB;EAKrBC,WAAW,GAAG;IAAA;;IAAA,6CAH4C,IAG5C;;IAAA,6CAF4C,IAE5C;;IACZ,KAAKC,OAAL,GACEZ,QAAQ,CAACa,EAAT,KAAgB,KAAhB,GACI,IAAIf,kBAAJ,CAAuBC,aAAa,CAACe,oBAArC,CADJ,GAEIjB,qBAHN;EAID;;EAEDkB,SAAS,CAACC,eAAD,EAAmC;IAC1CA,eAAe,CAACf,OAAhB,GAA0BA,OAA1B;IACAK,aAAa,CAACS,SAAd,CAAwBE,IAAI,CAACC,SAAL,CAAeF,eAAf,CAAxB;EACD;;EAEDG,WAAW,CAACC,UAAD,EAAyB;IAClC;IACA,IAAIC,eAAe,GAAIC,OAAD,IAAqB;MACzCC,OAAO,CAACC,GAAR,CAAY,mBAAmBP,IAAI,CAACC,SAAL,CAAeI,OAAf,CAA/B;MACAF,UAAU,CAACK,QAAX,CAAoBH,OAApB;IACD,CAHD;;IAIA,IAAII,eAAe,GAAIC,KAAD,IAAmB;MACvCJ,OAAO,CAACC,GAAR,CAAY,aAAaP,IAAI,CA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ACA,KAAKC,MAAL,GAAcD,MAAM,CAACC,MAArB;IACA,KAAKZ,OAAL,GAAeW,MAAM,CAACX,OAAtB;IACA,KAAKa,IAAL,GAAYF,MAAM,CAACE,IAAnB;IACA,KAAKC,IAAL,GAAYH,MAAM,CAACG,IAAnB;EACD;;EAEDC,SAAS,GAAW;IAClB,OAAO,KAAKH,MAAZ;EACD;;EAEDI,UAAU,GAAW;IACnB,OAAO,KAAKhB,OAAZ;EACD;;EAEDiB,OAAO,GAAW;IAChB,OAAO,KAAKJ,IAAZ;EACD;;EAEDK,OAAO,GAAW;IAChB,OAAO,KAAKJ,IAAZ;EACD;;AA9B0B;AAiC7B,OAAO,IAAIK,uBAAuB,GAAG,IAAIvC,gBAAJ,EAA9B"}
1
+ {"version":3,"names":["NativeAppEventEmitter","NativeEventEmitter","NativeModules","Platform","version","LINKING_ERROR","select","ios","default","CashfreePgApi","Proxy","get","Error","CFPaymentGateway","constructor","emitter","OS","CashfreeEventEmitter","doPayment","checkoutPayment","JSON","stringify","setCallback","cfCallback","successFunction","orderID","console","log","onVerify","failureFunction","error","response","CFErrorResponse","message","parse","fromJSON","onError","successSubscription","addListener","failureSubscription","removeCallback","undefined","remove","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","CFPaymentGatewayService"],"sources":["index.tsx"],"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 } 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\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 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 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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,GAAeW,MAAM,CAACX,OAAtB;IACA,KAAKa,IAAL,GAAYF,MAAM,CAACE,IAAnB;IACA,KAAKC,IAAL,GAAYH,MAAM,CAACG,IAAnB;EACD;;EAEDC,SAAS,GAAW;IAClB,OAAO,KAAKH,MAAZ;EACD;;EAEDI,UAAU,GAAW;IACnB,OAAO,KAAKhB,OAAZ;EACD;;EAEDiB,OAAO,GAAW;IAChB,OAAO,KAAKJ,IAAZ;EACD;;EAEDK,OAAO,GAAW;IAChB,OAAO,KAAKJ,IAAZ;EACD;;AA9B0B;AAiC7B,OAAO,IAAIK,uBAAuB,GAAG,IAAIvC,gBAAJ,EAA9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-cashfree-pg-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Cashfree PG Plugin for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -145,6 +145,6 @@
145
145
  ]
146
146
  },
147
147
  "dependencies": {
148
- "cashfree-pg-api-contract": "^0.0.5"
148
+ "cashfree-pg-api-contract": "^1.0.0"
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", "~> 1.1"
19
+ s.dependency "CashfreePG", "~> 1.1.2"
20
20
  end
package/src/index.js CHANGED
@@ -47,12 +47,12 @@ class CFPaymentGateway {
47
47
  removeCallback() {
48
48
  if (this.successSubscription !== undefined &&
49
49
  this.successSubscription !== null) {
50
- this.emitter.removeSubscription(this.successSubscription);
50
+ this.successSubscription.remove();
51
51
  this.successSubscription = null;
52
52
  }
53
53
  if (this.failureSubscription !== undefined &&
54
54
  this.failureSubscription !== null) {
55
- this.emitter.removeSubscription(this.failureSubscription);
55
+ this.failureSubscription.remove();
56
56
  this.failureSubscription = null;
57
57
  }
58
58
  }
package/src/index.tsx CHANGED
@@ -74,14 +74,14 @@ class CFPaymentGateway {
74
74
  this.successSubscription !== undefined &&
75
75
  this.successSubscription !== null
76
76
  ) {
77
- this.emitter.removeSubscription(this.successSubscription);
77
+ this.successSubscription.remove();
78
78
  this.successSubscription = null;
79
79
  }
80
80
  if (
81
81
  this.failureSubscription !== undefined &&
82
82
  this.failureSubscription !== null
83
83
  ) {
84
- this.emitter.removeSubscription(this.failureSubscription);
84
+ this.failureSubscription.remove();
85
85
  this.failureSubscription = null;
86
86
  }
87
87
  }