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 +31 -7
- package/lib/module/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,23 +5,47 @@
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npm install react-native-cashfree-pg-
|
|
8
|
+
npm install react-native-cashfree-pg-sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
import {
|
|
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
|
-
|
|
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
|
package/lib/module/index.js.map
CHANGED
|
@@ -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.
|
|
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":";;AA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