react-native-cashfree-pg-sdk 0.1.0 → 0.1.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.
package/README.md CHANGED
@@ -5,23 +5,47 @@
5
5
  ## Installation
6
6
 
7
7
  ```sh
8
- npm install react-native-cashfree-pg-api
8
+ npm install react-native-cashfree-pg-sdk
9
9
  ```
10
10
 
11
11
  ## Usage
12
12
 
13
13
  ```js
14
- import { multiply } from "react-native-cashfree-pg-api";
14
+ import {
15
+ CFCallback,
16
+ CFErrorResponse,
17
+ CFPaymentGatewayService,
18
+ } from 'react-native-cashfree-pg-api';
19
+ import {
20
+ CFDropCheckoutPayment,
21
+ CFEnvironment,
22
+ CFSession,
23
+ CFThemeBuilder,
24
+ } from 'cashfree-pg-api-contract';
15
25
 
16
26
  // ...
17
27
 
18
- const result = await multiply(3, 7);
28
+ try {
29
+ const session = new CFSession(
30
+ 'EKnOtw8HtEo26tlmUg6P',
31
+ 'order_1246922AeJyW66DV9SAC7LJL5UJGfmZuW',
32
+ CFEnvironment.SANDBOX
33
+ );
34
+ const theme = new CFThemeBuilder()
35
+ .setNavigationBarBackgroundColor('#E64A19')
36
+ .setNavigationBarTextColor('#FFFFFF')
37
+ .setButtonBackgroundColor('#FFC107')
38
+ .setButtonTextColor('#FFFFFF')
39
+ .setPrimaryTextColor('#212121')
40
+ .setSecondaryTextColor('#757575')
41
+ .build();
42
+ const dropPayment = new CFDropCheckoutPayment(session, null, theme);
43
+ CFPaymentGatewayService.doPayment(dropPayment);
44
+ } catch (e: any) {
45
+ console.log(e.message);
46
+ }
19
47
  ```
20
48
 
21
- ## Contributing
22
-
23
- See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
24
-
25
49
  ## License
26
50
 
27
51
  MIT
@@ -1 +1 @@
1
- {"version":3,"names":["NativeAppEventEmitter","NativeEventEmitter","NativeModules","Platform","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 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\n// noinspection JSVoidFunctionReturnValueUsed,TypeScriptValidateJSTypes\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 return 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;AAUA,MAAMC,aAAa,GAChB,uFAAD,GACAD,QAAQ,CAACE,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,aAAa,GAAGN,aAAa,CAACM,aAAd,GAClBN,aAAa,CAACM,aADI,GAElB,IAAIC,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUP,aAAV,CAAN;EACD;;AAHH,CAFF,CAFJ,C,CAWA;;AACA,MAAMQ,gBAA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6B,IAF/B,EAGE;MACA,KAAKtB,OAAL,CAAa2B,kBAAb,CAAgC,KAAKL,mBAArC;MACA,KAAKA,mBAAL,GAA2B,IAA3B;IACD;;IACD,IACE,KAAKE,mBAAL,KAA6BE,SAA7B,IACA,KAAKF,mBAAL,KAA6B,IAF/B,EAGE;MACA,KAAKxB,OAAL,CAAa2B,kBAAb,CAAgC,KAAKH,mBAArC;MACA,KAAKA,mBAAL,GAA2B,IAA3B;IACD;EACF;;AAzDoB;;AAkEvB,OAAO,MAAMP,eAAN,CAAsB;EAAA;IAAA,gCACF,QADE;;IAAA,iCAED,oBAFC;;IAAA,8BAGJ,gBAHI;;IAAA,8BAIJ,gBAJI;EAAA;;EAM3BG,QAAQ,CAACQ,WAAD,EAAsB;IAC5BjB,OAAO,CAACC,GAAR,CAAY,kBAAkBgB,WAA9B;IACA,MAAMC,MAAM,GAAGxB,IAAI,CAACc,KAAL,CAAWS,WAAX,CAAf;IACAjB,OAAO,CAACC,GAAR,CAAY,wBAAwBiB,MAApC;IACA,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","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.js"],"sourcesContent":["import { NativeAppEventEmitter, NativeEventEmitter, NativeModules, Platform, } from 'react-native';\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 });\n// noinspection JSVoidFunctionReturnValueUsed,TypeScriptValidateJSTypes\nclass CFPaymentGateway {\n emitter;\n successSubscription = null;\n failureSubscription = null;\n constructor() {\n this.emitter =\n Platform.OS === 'ios'\n ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter)\n : NativeAppEventEmitter;\n }\n doPayment(checkoutPayment) {\n return CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));\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.emitter.removeSubscription(this.successSubscription);\n this.successSubscription = null;\n }\n if (this.failureSubscription !== undefined &&\n this.failureSubscription !== null) {\n this.emitter.removeSubscription(this.failureSubscription);\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 var CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;AAAA,SAASA,qBAAT,EAAgCC,kBAAhC,EAAoDC,aAApD,EAAmEC,QAAnE,QAAoF,cAApF;AACA,MAAMC,aAAa,GAAI,uFAAD,GAClBD,QAAQ,CAACE,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADkB,GAElB,sDAFkB,GAGlB,6CAHJ;AAIA,MAAMC,aAAa,GAAGN,aAAa,CAACM,aAAd,GAChBN,aAAa,CAACM,aADE,GAEhB,IAAIC,KAAJ,CAAU,EAAV,EAAc;EACZC,GAAG,GAAG;IACF,MAAM,IAAIC,KAAJ,CAAUP,aAAV,CAAN;EACH;;AAHW,CAAd,CAFN,C,CAOA;;AACA,MAAMQ,gBAAN,CAAuB;EAInBC,WAAW,GAAG;IAAA;;IAAA,6CAFQ,IAER;;IAAA,6CADQ,IACR;;IACV,KAAKC,OAAL,GACIX,QAAQ,CAACY,EAAT,KAAgB,KAAhB,GACM,IAAId,kBAAJ,CAAuBC,aAAa,CAACc,oBAArC,CADN,GAEMhB,qBAHV;EAIH;;EACDiB,SAAS,CAACC,eAAD,EAAkB;IACvB,OAAOV,aAAa,CAACS,SAAd,CAAwBE,IAAI,CAACC,SAAL,CAAeF,eAAf,CAAxB,CAAP;EACH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B;EAAA;IAAA,gCAChB,QADgB;;IAAA,iCAEf,oBAFe;;IAAA,8BAGlB,gBAHkB;;IAAA,8BAIlB,gBAJkB;EAAA;;EAKzBG,QAAQ,CAACQ,WAAD,EAAc;IAClBjB,OAAO,CAACC,GAAR,CAAY,kBAAkBgB,WAA9B;IACA,MAAMC,MAAM,GAAGxB,IAAI,CAACc,KAAL,CAAWS,WAAX,CAAf;IACAjB,OAAO,CAACC,GAAR,CAAY,wBAAwBiB,MAApC;IACA,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;EACH;;EACDC,SAAS,GAAG;IACR,OAAO,KAAKH,MAAZ;EACH;;EACDI,UAAU,GAAG;IACT,OAAO,KAAKhB,OAAZ;EACH;;EACDiB,OAAO,GAAG;IACN,OAAO,KAAKJ,IAAZ;EACH;;EACDK,OAAO,GAAG;IACN,OAAO,KAAKJ,IAAZ;EACH;;AAzBwB;AA2B7B,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": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "..",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",