react-native-cashfree-pg-sdk 2.0.0-dev.3 → 2.0.0-dev.4
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/android/build.gradle +1 -1
- package/lib/commonjs/index.js +16 -14
- package/lib/commonjs/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +15 -11
package/android/build.gradle
CHANGED
|
@@ -68,7 +68,7 @@ dependencies {
|
|
|
68
68
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
|
69
69
|
implementation 'androidx.gridlayout:gridlayout:1.0.0'
|
|
70
70
|
|
|
71
|
-
implementation 'com.cashfree.pg:api:2.0.1
|
|
71
|
+
implementation 'com.cashfree.pg:api:2.0.1'
|
|
72
72
|
|
|
73
73
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
74
74
|
}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -41,22 +41,26 @@ class CFPaymentGateway {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
setEventSubscriber(cfEventCallback) {
|
|
44
|
-
|
|
45
|
-
let
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
45
|
+
let eventFunction = event => {
|
|
46
|
+
let data = JSON.parse(event);
|
|
47
|
+
cfEventCallback.onReceivedEvent(data.eventName, data.meta);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
|
|
51
|
+
CashfreePgApi.setEventSubscriber();
|
|
52
|
+
}
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
removeEventSubscriber() {
|
|
54
|
-
if (
|
|
55
|
-
this.eventSubscription.
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
57
|
+
if (this.eventSubscription !== undefined && this.eventSubscription !== null) {
|
|
58
|
+
this.eventSubscription.remove();
|
|
59
|
+
this.eventSubscription = null;
|
|
60
|
+
}
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
CashfreePgApi.removeEventSubscriber();
|
|
63
|
+
}
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
setCallback(cfCallback) {
|
|
@@ -137,6 +141,4 @@ class CFErrorResponse {
|
|
|
137
141
|
exports.CFErrorResponse = CFErrorResponse;
|
|
138
142
|
const CFPaymentGatewayService = new CFPaymentGateway();
|
|
139
143
|
exports.CFPaymentGatewayService = CFPaymentGatewayService;
|
|
140
|
-
//# sourceMappingURL=index.js.maptGatewayService = new CFPaymentGateway();
|
|
141
|
-
exports.CFPaymentGatewayService = CFPaymentGatewayService;
|
|
142
144
|
//# 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.
|
|
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 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;;AAQA;;;;AAGA,MAAMA,aAAa,GAChB,uFAAD,GACAC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,kCAAP;EAA2CC,OAAO,EAAE;AAApD,CAAhB,CADA,GAEA,sDAFA,GAGA,6C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;AAtFoB;;AAmGhB,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;;;AAiCtB,MAAMK,uBAAuB,GAAG,IAAIpD,gBAAJ,EAAhC"}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -27,20 +27,24 @@ class CFPaymentGateway {
|
|
|
27
27
|
CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));
|
|
28
28
|
}
|
|
29
29
|
setEventSubscriber(cfEventCallback) {
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
if (Platform.OS === 'android') {
|
|
31
|
+
let eventFunction = (event) => {
|
|
32
|
+
let data = JSON.parse(event);
|
|
33
|
+
cfEventCallback.onReceivedEvent(data.eventName, data.meta);
|
|
34
|
+
};
|
|
35
|
+
this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
|
|
36
|
+
CashfreePgApi.setEventSubscriber();
|
|
37
|
+
}
|
|
36
38
|
}
|
|
37
39
|
removeEventSubscriber() {
|
|
38
|
-
if (
|
|
39
|
-
this.eventSubscription !==
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
if (Platform.OS === 'android') {
|
|
41
|
+
if (this.eventSubscription !== undefined &&
|
|
42
|
+
this.eventSubscription !== null) {
|
|
43
|
+
this.eventSubscription.remove();
|
|
44
|
+
this.eventSubscription = null;
|
|
45
|
+
}
|
|
46
|
+
CashfreePgApi.removeEventSubscriber();
|
|
42
47
|
}
|
|
43
|
-
CashfreePgApi.removeEventSubscriber();
|
|
44
48
|
}
|
|
45
49
|
setCallback(cfCallback) {
|
|
46
50
|
// this.cfCallback = cfCallback;
|