react-native-cashfree-pg-sdk 2.0.0-dev.2 → 2.0.0-dev.3

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.
@@ -137,4 +137,6 @@ class CFErrorResponse {
137
137
  exports.CFErrorResponse = CFErrorResponse;
138
138
  const CFPaymentGatewayService = new CFPaymentGateway();
139
139
  exports.CFPaymentGatewayService = CFPaymentGatewayService;
140
+ //# sourceMappingURL=index.js.maptGatewayService = new CFPaymentGateway();
141
+ exports.CFPaymentGatewayService = CFPaymentGatewayService;
140
142
  //# sourceMappingURL=index.js.map
@@ -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","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 } 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 setEventSubscriber(cfEventCallback: CFEventCallback) {\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 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}\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;;;;;AAAA;;AAQA;;;;AAGA,MAAMA,aAAa,GAChB,uFAAD,GACAC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,kCAAP;EAA2CC,OAAO,EAAE;AAApD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,aAAa,GAAGC,0BAAA,CAAcD,aAAd,GAClBC,0BAAA,CAAcD,aADI,GAElB,IAAIE,KAAJ,CACA,EADA,EAEA;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUT,aAAV,CAAN;EACD;;AAHH,CAFA,CAFJ;;AAWA,MAAMU,gBAAN,CAAuB;EAMrBC,WAAW,GAAG;IAAA;;IAAA,6CAJ4C,IAI5C;;IAAA,6CAH4C,IAG5C;;IAAA,2CAF0C,IAE1C;;IACZ,KAAKC,OAAL,GACEX,qBAAA,CAASY,EAAT,KAAgB,KAAhB,GACI,IAAIC,+BAAJ,CAAuBR,0BAAA,CAAcS,oBAArC,CADJ,GAEIC,kCAHN;EAID;;EAEDC,SAAS,CAACC,eAAD,EAAmC;IAC1CA,eAAe,CAACC,OAAhB,GAA0BA,gBAA1B;IACAd,aAAa,CAACY,SAAd,CAAwBG,I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OAAO,KAAKJ,IAAZ;EACD;;AA9B0B;;;AAgCtB,MAAMK,uBAAuB,GAAG,IAAIpD,gBAAJ,EAAhC"}
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","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.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 setEventSubscriber(cfEventCallback) {\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 removeEventSubscriber() {\n if (this.eventSubscription !== undefined &&\n this.eventSubscription !== null) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\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;;AACA;;;;AACA,MAAMA,aAAa,GAAI,uFAAD,GAClBC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,kCAAP;EAA2CC,OAAO,EAAE;AAApD,CAAhB,CADkB,GAElB,sDAFkB,GAGlB,6CAHJ;AAIA,MAAMC,aAAa,GAAGC,0BAAA,CAAcD,aAAd,GAChB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O,CAACC,GAAR,CAAY,kBAAkBY,WAA9B;IACA,MAAMC,MAAM,GAAGlC,IAAI,CAACO,KAAL,CAAW0B,WAAX,CAAf;IACAb,OAAO,CAACC,GAAR,CAAY,wBAAwBa,MAApC;IACA,KAAKC,MAAL,GAAcD,MAAM,CAACC,MAArB;IACA,KAAKR,OAAL,GAAeO,MAAM,CAACP,OAAtB;IACA,KAAKS,IAAL,GAAYF,MAAM,CAACE,IAAnB;IACA,KAAKC,IAAL,GAAYH,MAAM,CAACG,IAAnB;EACH;;EACDC,SAAS,GAAG;IACR,OAAO,KAAKH,MAAZ;EACH;;EACDI,UAAU,GAAG;IACT,OAAO,KAAKZ,OAAZ;EACH;;EACDa,OAAO,GAAG;IACN,OAAO,KAAKJ,IAAZ;EACH;;EACDK,OAAO,GAAG;IACN,OAAO,KAAKJ,IAAZ;EACH;;AAzBwB;;;AA2BtB,MAAMK,uBAAuB,GAAG,IAAIpD,gBAAJ,EAAhC"}
@@ -32,22 +32,26 @@ class CFPaymentGateway {
32
32
  }
33
33
 
34
34
  setEventSubscriber(cfEventCallback) {
35
- let eventFunction = event => {
36
- let data = JSON.parse(event);
37
- cfEventCallback.onReceivedEvent(data.eventName, data.meta);
38
- };
39
-
40
- this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
41
- CashfreePgApi.setEventSubscriber();
35
+ if (Platform.OS === 'android') {
36
+ let eventFunction = event => {
37
+ let data = JSON.parse(event);
38
+ cfEventCallback.onReceivedEvent(data.eventName, data.meta);
39
+ };
40
+
41
+ this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
42
+ CashfreePgApi.setEventSubscriber();
43
+ }
42
44
  }
43
45
 
44
46
  removeEventSubscriber() {
45
- if (this.eventSubscription !== undefined && this.eventSubscription !== null) {
46
- this.eventSubscription.remove();
47
- this.eventSubscription = null;
48
- }
47
+ if (Platform.OS === 'android') {
48
+ if (this.eventSubscription !== undefined && this.eventSubscription !== null) {
49
+ this.eventSubscription.remove();
50
+ this.eventSubscription = null;
51
+ }
49
52
 
50
- CashfreePgApi.removeEventSubscriber();
53
+ CashfreePgApi.removeEventSubscriber();
54
+ }
51
55
  }
52
56
 
53
57
  setCallback(cfCallback) {
@@ -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","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 } 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 setEventSubscriber(cfEventCallback: CFEventCallback) {\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 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}\nexport const 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,kCAAP;EAA2CC,OAAO,EAAE;AAApD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,aAAa,GAAGP,aAAa,CAACO,aAAd,GAClBP,aAAa,CAACO,aADI,GAElB,IAAIC,KAAJ,CACA,EADA,EAEA;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUP,aAAV,CAAN;EACD;;AAHH,CAFA,CAFJ;;AAWA,MAAMQ,gBAAN,CAAuB;EAMrBC,WAAW,GAAG;IAAA;;IAAA,6CAJ4C,IAI5C;;IAAA,6CAH4C,IAG5C;;IAAA,2CAF0C,IAE1C;;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,kBAAkB,CAACC,eAAD,EAAmC;IACnD,IAAIC,aAAa,GAAIC,KAAD,IAAmB;MACrC,IAAIC,IAAI,GAAGN,IAAI,CAACO,KAAL,CAAWF,KAAX,C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2B,WAAd;EACD;;EAEDgB,cAAc,GAAG;IACf,IACE,KAAKF,mBAAL,KAA6BhB,SAA7B,IACA,KAAKgB,mBAAL,KAA6B,IAF/B,EAGE;MACA,KAAKA,mBAAL,CAAyBf,MAAzB;MACA,KAAKe,mBAAL,GAA2B,IAA3B;IACD;;IACD,IACE,KAAKC,mBAAL,KAA6BjB,SAA7B,IACA,KAAKiB,mBAAL,KAA6B,IAF/B,EAGE;MACA,KAAKA,mBAAL,CAAyBhB,MAAzB;MACA,KAAKgB,mBAAL,GAA2B,IAA3B;IACD;EACF;;AAlFoB;;AA+FvB,OAAO,MAAML,eAAN,CAAsB;EAAA;IAAA,gCACF,QADE;;IAAA,iCAED,oBAFC;;IAAA,8BAGJ,gBAHI;;IAAA,8BAIJ,gBAJI;EAAA;;EAM3BE,QAAQ,CAACK,WAAD,EAAsB;IAC5Bb,OAAO,CAACC,GAAR,CAAY,kBAAkBY,WAA9B;IACA,MAAMC,MAAM,GAAGlC,IAAI,CAACO,KAAL,CAAW0B,WAAX,CAAf;IACAb,OAAO,CAACC,GAAR,CAAY,wBAAwBa,MAApC;IACA,KAAKC,MAAL,GAAcD,MAAM,CAACC,MAArB;IACA,KAAKR,OAAL,GAAeO,MAAM,CAACP,OAAtB;IACA,KAAKS,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,KAAKZ,OAAZ;EACD;;EAEDa,OAAO,GAAW;IAChB,OAAO,KAAKJ,IAAZ;EACD;;EAEDK,OAAO,GAAW;IAChB,OAAO,KAAKJ,IAAZ;EACD;;AA9B0B;AAgC7B,OAAO,MAAMK,uBAAuB,GAAG,IAAIjD,gBAAJ,EAAhC"}
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","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 } 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 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;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  "description": "Cashfree PG Plugin for React Native",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
package/src/index.ts CHANGED
@@ -45,26 +45,30 @@ class CFPaymentGateway {
45
45
  }
46
46
 
47
47
  setEventSubscriber(cfEventCallback: CFEventCallback) {
48
- let eventFunction = (event: string) => {
49
- let data = JSON.parse(event);
50
- cfEventCallback.onReceivedEvent(data.eventName, data.meta);
51
- };
52
- this.eventSubscription = this.emitter.addListener(
53
- 'cfEvent',
54
- eventFunction,
55
- );
56
- CashfreePgApi.setEventSubscriber();
48
+ if (Platform.OS === 'android') {
49
+ let eventFunction = (event: string) => {
50
+ let data = JSON.parse(event);
51
+ cfEventCallback.onReceivedEvent(data.eventName, data.meta);
52
+ };
53
+ this.eventSubscription = this.emitter.addListener(
54
+ 'cfEvent',
55
+ eventFunction,
56
+ );
57
+ CashfreePgApi.setEventSubscriber();
58
+ }
57
59
  }
58
60
 
59
61
  removeEventSubscriber() {
60
- if (
61
- this.eventSubscription !== undefined &&
62
- this.eventSubscription !== null
63
- ) {
64
- this.eventSubscription.remove();
65
- this.eventSubscription = null;
62
+ if (Platform.OS === 'android') {
63
+ if (
64
+ this.eventSubscription !== undefined &&
65
+ this.eventSubscription !== null
66
+ ) {
67
+ this.eventSubscription.remove();
68
+ this.eventSubscription = null;
69
+ }
70
+ CashfreePgApi.removeEventSubscriber();
66
71
  }
67
- CashfreePgApi.removeEventSubscriber();
68
72
  }
69
73
 
70
74
  setCallback(cfCallback: CFCallback) {
@@ -153,4 +157,5 @@ export class CFErrorResponse {
153
157
  return this.type;
154
158
  }
155
159
  }
160
+
156
161
  export const CFPaymentGatewayService = new CFPaymentGateway();