react-native-cashfree-pg-sdk 2.0.3 → 2.0.5-dev.0
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/src/main/java/com/reactnativecashfreepgsdk/CashfreePgApiModule.java +33 -0
- package/ios/CashfreePgApi.m +2 -0
- package/ios/CashfreePgApi.swift +41 -7
- package/lib/commonjs/index.js +10 -37
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +10 -33
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -1
- package/package.json +1 -1
- package/react-native-cashfree-pg-sdk.podspec +1 -1
- package/src/index.js +3 -0
- package/src/index.ts +5 -1
- package/android/.idea/.gitignore +0 -3
- package/ios/.DS_Store +0 -0
|
@@ -9,10 +9,12 @@ import androidx.annotation.Nullable;
|
|
|
9
9
|
import com.cashfree.pg.api.CFPaymentGatewayService;
|
|
10
10
|
import com.cashfree.pg.cf_analytics.CFAnalyticsService;
|
|
11
11
|
import com.cashfree.pg.cf_analytics.CFEventsSubscriber;
|
|
12
|
+
import com.cashfree.pg.core.api.CFSession;
|
|
12
13
|
import com.cashfree.pg.core.api.base.CFPayment;
|
|
13
14
|
import com.cashfree.pg.core.api.callback.CFCheckoutResponseCallback;
|
|
14
15
|
import com.cashfree.pg.core.api.exception.CFException;
|
|
15
16
|
import com.cashfree.pg.core.api.utils.CFErrorResponse;
|
|
17
|
+
import com.cashfree.pg.core.api.webcheckout.CFWebCheckoutPayment;
|
|
16
18
|
import com.cashfree.pg.ui.api.CFDropCheckoutPayment;
|
|
17
19
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
18
20
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
@@ -58,6 +60,37 @@ public class CashfreePgApiModule extends ReactContextBaseJavaModule implements C
|
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
|
|
63
|
+
@ReactMethod
|
|
64
|
+
public void doWebPayment(String sessionString) {
|
|
65
|
+
Log.d("CashfreePgApiModule Web", sessionString);
|
|
66
|
+
CFSession cfSession = null;
|
|
67
|
+
try {
|
|
68
|
+
JSONObject jsonObject = new JSONObject(sessionString);
|
|
69
|
+
cfSession = new CFSession.CFSessionBuilder()
|
|
70
|
+
.setEnvironment(CFSession.Environment.valueOf(jsonObject.getString("environment")))
|
|
71
|
+
.setOrderId(jsonObject.getString("orderID"))
|
|
72
|
+
.setPaymentSessionID(jsonObject.getString("payment_session_id"))
|
|
73
|
+
.build();
|
|
74
|
+
} catch (Exception exception) {
|
|
75
|
+
throw new IllegalStateException("Session is invalid");
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
Activity activity = getCurrentActivity();
|
|
79
|
+
CFWebCheckoutPayment cfWebCheckoutPayment = new CFWebCheckoutPayment.CFWebCheckoutPaymentBuilder()
|
|
80
|
+
.setSession(cfSession)
|
|
81
|
+
.build();
|
|
82
|
+
cfWebCheckoutPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
|
|
83
|
+
cfWebCheckoutPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.WEB_CHECKOUT);
|
|
84
|
+
if (activity != null) {
|
|
85
|
+
CFPaymentGatewayService.getInstance().doPayment(activity, cfWebCheckoutPayment);
|
|
86
|
+
} else {
|
|
87
|
+
throw new IllegalStateException("activity is null");
|
|
88
|
+
}
|
|
89
|
+
} catch (Exception e) {
|
|
90
|
+
e.printStackTrace();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
61
94
|
@ReactMethod
|
|
62
95
|
public void setCallback() {
|
|
63
96
|
try {
|
package/ios/CashfreePgApi.m
CHANGED
package/ios/CashfreePgApi.swift
CHANGED
|
@@ -26,6 +26,22 @@ class CashfreePgApi: NSObject {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
@objc func doWebPayment(_ paymentObject: NSString) -> Void {
|
|
30
|
+
do {
|
|
31
|
+
if let sessionObj = try parseWebPayment(paymentObject: "\(paymentObject)") {
|
|
32
|
+
let cfPaymentObject = try! CFWebCheckoutPayment.CFWebCheckoutPaymentBuilder()
|
|
33
|
+
.setSession(sessionObj)
|
|
34
|
+
.build()
|
|
35
|
+
if let vc = RCTPresentedViewController() {
|
|
36
|
+
try CFPaymentGatewayService.getInstance().doPayment(cfPaymentObject, viewController: vc)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
print (error)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
29
45
|
@objc func setCallback() -> Void {
|
|
30
46
|
CFPaymentGatewayService.getInstance().setCallback(self)
|
|
31
47
|
}
|
|
@@ -44,8 +60,8 @@ class CashfreePgApi: NSObject {
|
|
|
44
60
|
.setTheme(theme!)
|
|
45
61
|
.setComponent(component!)
|
|
46
62
|
.build()
|
|
47
|
-
// let systemVersion = UIDevice.current.systemVersion
|
|
48
|
-
// nativePayment.setPlatform("irnx-d-" + (((output["version"]) as? String) ?? "") + "-3.3.9-m-s-x-i-\(systemVersion.prefix(4))")
|
|
63
|
+
// let systemVersion = UIDevice.current.systemVersion
|
|
64
|
+
// nativePayment.setPlatform("irnx-d-" + (((output["version"]) as? String) ?? "") + "-3.3.9-m-s-x-i-\(systemVersion.prefix(4))")
|
|
49
65
|
return nativePayment
|
|
50
66
|
|
|
51
67
|
} catch let e {
|
|
@@ -57,6 +73,24 @@ class CashfreePgApi: NSObject {
|
|
|
57
73
|
return nil
|
|
58
74
|
}
|
|
59
75
|
|
|
76
|
+
private func parseWebPayment(paymentObject: String) throws -> CFSession? {
|
|
77
|
+
// print(paymentObject)
|
|
78
|
+
let data = paymentObject.data(using: .utf8)!
|
|
79
|
+
do {
|
|
80
|
+
if let output = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? Dictionary<String, Any> {
|
|
81
|
+
let paymentObj = ["session":output]
|
|
82
|
+
let session = getSession(paymentObject: paymentObj)
|
|
83
|
+
return session
|
|
84
|
+
}
|
|
85
|
+
} catch let e {
|
|
86
|
+
let error = e as! CashfreeError
|
|
87
|
+
print(error.localizedDescription)
|
|
88
|
+
// Handle errors here
|
|
89
|
+
}
|
|
90
|
+
return nil
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
60
94
|
private func getSession(paymentObject: Dictionary<String,Any>) -> CFSession? {
|
|
61
95
|
if let sessionDict = paymentObject["session"] as? Dictionary<String, String> {
|
|
62
96
|
do {
|
|
@@ -146,12 +180,12 @@ class CashfreePgApi: NSObject {
|
|
|
146
180
|
func stringify(json: Any) -> String {
|
|
147
181
|
var options: JSONSerialization.WritingOptions = []
|
|
148
182
|
do {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
183
|
+
let data = try JSONSerialization.data(withJSONObject: json, options: options)
|
|
184
|
+
if let string = String(data: data, encoding: String.Encoding.utf8) {
|
|
185
|
+
return string
|
|
186
|
+
}
|
|
153
187
|
} catch {
|
|
154
|
-
|
|
188
|
+
print(error)
|
|
155
189
|
}
|
|
156
190
|
|
|
157
191
|
return ""
|
package/lib/commonjs/index.js
CHANGED
|
@@ -4,13 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CFPaymentGatewayService = exports.CFErrorResponse = void 0;
|
|
7
|
-
|
|
8
7
|
var _reactNative = require("react-native");
|
|
9
|
-
|
|
10
8
|
var _package = require("../package.json");
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
12
|
const LINKING_ERROR = `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
15
13
|
ios: '- You have run \'pod install\'\n',
|
|
16
14
|
default: ''
|
|
@@ -19,97 +17,78 @@ const CashfreePgApi = _reactNative.NativeModules.CashfreePgApi ? _reactNative.Na
|
|
|
19
17
|
get() {
|
|
20
18
|
throw new Error(LINKING_ERROR);
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
});
|
|
24
|
-
|
|
25
21
|
class CFPaymentGateway {
|
|
26
22
|
constructor() {
|
|
27
23
|
_defineProperty(this, "emitter", void 0);
|
|
28
|
-
|
|
29
24
|
_defineProperty(this, "successSubscription", null);
|
|
30
|
-
|
|
31
25
|
_defineProperty(this, "failureSubscription", null);
|
|
32
|
-
|
|
33
26
|
_defineProperty(this, "eventSubscription", null);
|
|
34
|
-
|
|
35
27
|
this.emitter = _reactNative.Platform.OS === 'ios' ? new _reactNative.NativeEventEmitter(_reactNative.NativeModules.CashfreeEventEmitter) : _reactNative.NativeAppEventEmitter;
|
|
36
28
|
}
|
|
37
|
-
|
|
38
29
|
doPayment(checkoutPayment) {
|
|
39
30
|
checkoutPayment.version = _package.version;
|
|
40
31
|
CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));
|
|
41
32
|
}
|
|
42
|
-
|
|
33
|
+
doWebPayment(cfSession) {
|
|
34
|
+
CashfreePgApi.doWebPayment(cfSession);
|
|
35
|
+
}
|
|
43
36
|
setEventSubscriber(cfEventCallback) {
|
|
44
37
|
if (_reactNative.Platform.OS === 'android') {
|
|
45
38
|
let eventFunction = event => {
|
|
46
39
|
let data = JSON.parse(event);
|
|
47
40
|
cfEventCallback.onReceivedEvent(data.eventName, data.meta);
|
|
48
41
|
};
|
|
49
|
-
|
|
50
42
|
this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
|
|
51
43
|
CashfreePgApi.setEventSubscriber();
|
|
52
44
|
}
|
|
53
45
|
}
|
|
54
|
-
|
|
55
46
|
removeEventSubscriber() {
|
|
56
47
|
if (_reactNative.Platform.OS === 'android') {
|
|
57
48
|
if (this.eventSubscription !== undefined && this.eventSubscription !== null) {
|
|
58
49
|
this.eventSubscription.remove();
|
|
59
50
|
this.eventSubscription = null;
|
|
60
51
|
}
|
|
61
|
-
|
|
62
52
|
CashfreePgApi.removeEventSubscriber();
|
|
63
53
|
}
|
|
64
54
|
}
|
|
65
|
-
|
|
66
55
|
setCallback(cfCallback) {
|
|
67
56
|
// this.cfCallback = cfCallback;
|
|
68
57
|
let successFunction = orderID => {
|
|
69
58
|
console.log('response is : ' + JSON.stringify(orderID));
|
|
70
59
|
cfCallback.onVerify(orderID);
|
|
71
60
|
};
|
|
72
|
-
|
|
73
61
|
let failureFunction = error => {
|
|
74
62
|
console.log('reason: ' + JSON.stringify(error));
|
|
75
|
-
const response = new CFErrorResponse();
|
|
76
|
-
|
|
63
|
+
const response = new CFErrorResponse();
|
|
64
|
+
// @ts-ignore
|
|
77
65
|
const message = JSON.parse(error);
|
|
78
|
-
response.fromJSON(message.error);
|
|
79
|
-
|
|
66
|
+
response.fromJSON(message.error);
|
|
67
|
+
// @ts-ignore
|
|
80
68
|
cfCallback.onError(response, message.orderID);
|
|
81
69
|
};
|
|
82
|
-
|
|
83
70
|
this.successSubscription = this.emitter.addListener('cfSuccess', successFunction);
|
|
84
71
|
this.failureSubscription = this.emitter.addListener('cfFailure', failureFunction);
|
|
85
72
|
CashfreePgApi.setCallback();
|
|
86
73
|
}
|
|
87
|
-
|
|
88
74
|
removeCallback() {
|
|
89
75
|
if (this.successSubscription !== undefined && this.successSubscription !== null) {
|
|
90
76
|
this.successSubscription.remove();
|
|
91
77
|
this.successSubscription = null;
|
|
92
78
|
}
|
|
93
|
-
|
|
94
79
|
if (this.failureSubscription !== undefined && this.failureSubscription !== null) {
|
|
95
80
|
this.failureSubscription.remove();
|
|
96
81
|
this.failureSubscription = null;
|
|
97
82
|
}
|
|
98
83
|
}
|
|
99
|
-
|
|
100
84
|
}
|
|
101
|
-
|
|
102
85
|
class CFErrorResponse {
|
|
103
86
|
constructor() {
|
|
104
87
|
_defineProperty(this, "status", 'FAILED');
|
|
105
|
-
|
|
106
88
|
_defineProperty(this, "message", 'payment has failed');
|
|
107
|
-
|
|
108
89
|
_defineProperty(this, "code", 'payment_failed');
|
|
109
|
-
|
|
110
90
|
_defineProperty(this, "type", 'request_failed');
|
|
111
91
|
}
|
|
112
|
-
|
|
113
92
|
fromJSON(errorString) {
|
|
114
93
|
console.log('errorString :' + errorString);
|
|
115
94
|
const object = JSON.parse(errorString);
|
|
@@ -119,25 +98,19 @@ class CFErrorResponse {
|
|
|
119
98
|
this.code = object.code;
|
|
120
99
|
this.type = object.type;
|
|
121
100
|
}
|
|
122
|
-
|
|
123
101
|
getStatus() {
|
|
124
102
|
return this.status;
|
|
125
103
|
}
|
|
126
|
-
|
|
127
104
|
getMessage() {
|
|
128
105
|
return this.message;
|
|
129
106
|
}
|
|
130
|
-
|
|
131
107
|
getCode() {
|
|
132
108
|
return this.code;
|
|
133
109
|
}
|
|
134
|
-
|
|
135
110
|
getType() {
|
|
136
111
|
return this.type;
|
|
137
112
|
}
|
|
138
|
-
|
|
139
113
|
}
|
|
140
|
-
|
|
141
114
|
exports.CFErrorResponse = CFErrorResponse;
|
|
142
115
|
const CFPaymentGatewayService = new CFPaymentGateway();
|
|
143
116
|
exports.CFPaymentGatewayService = CFPaymentGatewayService;
|
|
@@ -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","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_package","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","LINKING_ERROR","Platform","select","ios","default","CashfreePgApi","NativeModules","Proxy","get","Error","CFPaymentGateway","constructor","emitter","OS","NativeEventEmitter","CashfreeEventEmitter","NativeAppEventEmitter","doPayment","checkoutPayment","version","JSON","stringify","doWebPayment","cfSession","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","addListener","removeEventSubscriber","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","exports","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 doWebPayment(cfSession) {\n CashfreePgApi.doWebPayment(cfSession);\n }\n setEventSubscriber(cfEventCallback) {\n if (Platform.OS === 'android') {\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 }\n removeEventSubscriber() {\n if (Platform.OS === 'android') {\n if (this.eventSubscription !== undefined &&\n this.eventSubscription !== null) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\n }\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,IAAAA,YAAA,GAA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C,YAAA;IAAAlC,eAAA,iBAChB,QAAQ;IAAAA,eAAA,kBACP,oBAAoB;IAAAA,eAAA,eACvB,gBAAgB;IAAAA,eAAA,eAChB,gBAAgB;EAAA;EACvBwE,QAAQA,CAACK,WAAW,EAAE;IAClBb,OAAO,CAACC,GAAG,CAAC,eAAe,GAAGY,WAAW,CAAC;IAC1C,MAAMC,MAAM,GAAGnC,IAAI,CAACS,KAAK,CAACyB,WAAW,CAAC;IACtCb,OAAO,CAACC,GAAG,CAAC,qBAAqB,GAAGa,MAAM,CAAC;IAC3C,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;IAC3B,IAAI,CAACR,OAAO,GAAGO,MAAM,CAACP,OAAO;IAC7B,IAAI,CAACS,IAAI,GAAGF,MAAM,CAACE,IAAI;IACvB,IAAI,CAACC,IAAI,GAAGH,MAAM,CAACG,IAAI;EAC3B;EACAC,SAASA,CAAA,EAAG;IACR,OAAO,IAAI,CAACH,MAAM;EACtB;EACAI,UAAUA,CAAA,EAAG;IACT,OAAO,IAAI,CAACZ,OAAO;EACvB;EACAa,OAAOA,CAAA,EAAG;IACN,OAAO,IAAI,CAACJ,IAAI;EACpB;EACAK,OAAOA,CAAA,EAAG;IACN,OAAO,IAAI,CAACJ,IAAI;EACpB;AACJ;AAACK,OAAA,CAAAhB,eAAA,GAAAA,eAAA;AACM,MAAMiB,uBAAuB,GAAG,IAAItD,gBAAgB,EAAE;AAACqD,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
3
4
|
import { NativeAppEventEmitter, NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
4
5
|
import { version } from '../package.json';
|
|
5
6
|
const LINKING_ERROR = `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
@@ -10,97 +11,78 @@ const CashfreePgApi = NativeModules.CashfreePgApi ? NativeModules.CashfreePgApi
|
|
|
10
11
|
get() {
|
|
11
12
|
throw new Error(LINKING_ERROR);
|
|
12
13
|
}
|
|
13
|
-
|
|
14
14
|
});
|
|
15
|
-
|
|
16
15
|
class CFPaymentGateway {
|
|
17
16
|
constructor() {
|
|
18
17
|
_defineProperty(this, "emitter", void 0);
|
|
19
|
-
|
|
20
18
|
_defineProperty(this, "successSubscription", null);
|
|
21
|
-
|
|
22
19
|
_defineProperty(this, "failureSubscription", null);
|
|
23
|
-
|
|
24
20
|
_defineProperty(this, "eventSubscription", null);
|
|
25
|
-
|
|
26
21
|
this.emitter = Platform.OS === 'ios' ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter) : NativeAppEventEmitter;
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
doPayment(checkoutPayment) {
|
|
30
24
|
checkoutPayment.version = version;
|
|
31
25
|
CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));
|
|
32
26
|
}
|
|
33
|
-
|
|
27
|
+
doWebPayment(cfSession) {
|
|
28
|
+
CashfreePgApi.doWebPayment(cfSession);
|
|
29
|
+
}
|
|
34
30
|
setEventSubscriber(cfEventCallback) {
|
|
35
31
|
if (Platform.OS === 'android') {
|
|
36
32
|
let eventFunction = event => {
|
|
37
33
|
let data = JSON.parse(event);
|
|
38
34
|
cfEventCallback.onReceivedEvent(data.eventName, data.meta);
|
|
39
35
|
};
|
|
40
|
-
|
|
41
36
|
this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);
|
|
42
37
|
CashfreePgApi.setEventSubscriber();
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
|
-
|
|
46
40
|
removeEventSubscriber() {
|
|
47
41
|
if (Platform.OS === 'android') {
|
|
48
42
|
if (this.eventSubscription !== undefined && this.eventSubscription !== null) {
|
|
49
43
|
this.eventSubscription.remove();
|
|
50
44
|
this.eventSubscription = null;
|
|
51
45
|
}
|
|
52
|
-
|
|
53
46
|
CashfreePgApi.removeEventSubscriber();
|
|
54
47
|
}
|
|
55
48
|
}
|
|
56
|
-
|
|
57
49
|
setCallback(cfCallback) {
|
|
58
50
|
// this.cfCallback = cfCallback;
|
|
59
51
|
let successFunction = orderID => {
|
|
60
52
|
console.log('response is : ' + JSON.stringify(orderID));
|
|
61
53
|
cfCallback.onVerify(orderID);
|
|
62
54
|
};
|
|
63
|
-
|
|
64
55
|
let failureFunction = error => {
|
|
65
56
|
console.log('reason: ' + JSON.stringify(error));
|
|
66
|
-
const response = new CFErrorResponse();
|
|
67
|
-
|
|
57
|
+
const response = new CFErrorResponse();
|
|
58
|
+
// @ts-ignore
|
|
68
59
|
const message = JSON.parse(error);
|
|
69
|
-
response.fromJSON(message.error);
|
|
70
|
-
|
|
60
|
+
response.fromJSON(message.error);
|
|
61
|
+
// @ts-ignore
|
|
71
62
|
cfCallback.onError(response, message.orderID);
|
|
72
63
|
};
|
|
73
|
-
|
|
74
64
|
this.successSubscription = this.emitter.addListener('cfSuccess', successFunction);
|
|
75
65
|
this.failureSubscription = this.emitter.addListener('cfFailure', failureFunction);
|
|
76
66
|
CashfreePgApi.setCallback();
|
|
77
67
|
}
|
|
78
|
-
|
|
79
68
|
removeCallback() {
|
|
80
69
|
if (this.successSubscription !== undefined && this.successSubscription !== null) {
|
|
81
70
|
this.successSubscription.remove();
|
|
82
71
|
this.successSubscription = null;
|
|
83
72
|
}
|
|
84
|
-
|
|
85
73
|
if (this.failureSubscription !== undefined && this.failureSubscription !== null) {
|
|
86
74
|
this.failureSubscription.remove();
|
|
87
75
|
this.failureSubscription = null;
|
|
88
76
|
}
|
|
89
77
|
}
|
|
90
|
-
|
|
91
78
|
}
|
|
92
|
-
|
|
93
79
|
export class CFErrorResponse {
|
|
94
80
|
constructor() {
|
|
95
81
|
_defineProperty(this, "status", 'FAILED');
|
|
96
|
-
|
|
97
82
|
_defineProperty(this, "message", 'payment has failed');
|
|
98
|
-
|
|
99
83
|
_defineProperty(this, "code", 'payment_failed');
|
|
100
|
-
|
|
101
84
|
_defineProperty(this, "type", 'request_failed');
|
|
102
85
|
}
|
|
103
|
-
|
|
104
86
|
fromJSON(errorString) {
|
|
105
87
|
console.log('errorString :' + errorString);
|
|
106
88
|
const object = JSON.parse(errorString);
|
|
@@ -110,23 +92,18 @@ export class CFErrorResponse {
|
|
|
110
92
|
this.code = object.code;
|
|
111
93
|
this.type = object.type;
|
|
112
94
|
}
|
|
113
|
-
|
|
114
95
|
getStatus() {
|
|
115
96
|
return this.status;
|
|
116
97
|
}
|
|
117
|
-
|
|
118
98
|
getMessage() {
|
|
119
99
|
return this.message;
|
|
120
100
|
}
|
|
121
|
-
|
|
122
101
|
getCode() {
|
|
123
102
|
return this.code;
|
|
124
103
|
}
|
|
125
|
-
|
|
126
104
|
getType() {
|
|
127
105
|
return this.type;
|
|
128
106
|
}
|
|
129
|
-
|
|
130
107
|
}
|
|
131
108
|
export const CFPaymentGatewayService = new CFPaymentGateway();
|
|
132
109
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -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.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 if (Platform.OS === 'android') {\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 }\n removeEventSubscriber() {\n if (Platform.OS === 'android') {\n if (this.eventSubscription !== undefined &&\n this.eventSubscription !== null) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\n }\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":"
|
|
1
|
+
{"version":3,"names":["NativeAppEventEmitter","NativeEventEmitter","NativeModules","Platform","version","LINKING_ERROR","select","ios","default","CashfreePgApi","Proxy","get","Error","CFPaymentGateway","constructor","_defineProperty","emitter","OS","CashfreeEventEmitter","doPayment","checkoutPayment","JSON","stringify","doWebPayment","cfSession","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 doWebPayment(cfSession) {\n CashfreePgApi.doWebPayment(cfSession);\n }\n setEventSubscriber(cfEventCallback) {\n if (Platform.OS === 'android') {\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 }\n removeEventSubscriber() {\n if (Platform.OS === 'android') {\n if (this.eventSubscription !== undefined &&\n this.eventSubscription !== null) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\n }\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,SAASA,qBAAqB,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAS,cAAc;AAClG,SAASC,OAAO,QAAQ,iBAAiB;AACzC,MAAMC,aAAa,GAAI,uFAAsF,GACzGF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,kCAAkC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACzE,sDAAsD,GACtD,6CAA6C;AACjD,MAAMC,aAAa,GAAGP,aAAa,CAACO,aAAa,GAC3CP,aAAa,CAACO,aAAa,GAC3B,IAAIC,KAAK,CAAC,CAAC,CAAC,EAAE;EACZC,GAAGA,CAAA,EAAG;IACF,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAClC;AACJ,CAAC,CAAC;AACN,MAAMQ,gBAAgB,CAAC;EAKnBC,WAAWA,CAAA,EAAG;IAAAC,eAAA;IAAAA,eAAA,8BAHQ,IAAI;IAAAA,eAAA,8BACJ,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IAAAA,eAAA,kBACP,oBAAoB;IAAAA,eAAA,eACvB,gBAAgB;IAAAA,eAAA,eAChB,gBAAgB;EAAA;EACvBoC,QAAQA,CAACK,WAAW,EAAE;IAClBb,OAAO,CAACC,GAAG,CAAC,eAAe,GAAGY,WAAW,CAAC;IAC1C,MAAMC,MAAM,GAAGpC,IAAI,CAACS,KAAK,CAAC0B,WAAW,CAAC;IACtCb,OAAO,CAACC,GAAG,CAAC,qBAAqB,GAAGa,MAAM,CAAC;IAC3C,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;IAC3B,IAAI,CAACR,OAAO,GAAGO,MAAM,CAACP,OAAO;IAC7B,IAAI,CAACS,IAAI,GAAGF,MAAM,CAACE,IAAI;IACvB,IAAI,CAACC,IAAI,GAAGH,MAAM,CAACG,IAAI;EAC3B;EACAC,SAASA,CAAA,EAAG;IACR,OAAO,IAAI,CAACH,MAAM;EACtB;EACAI,UAAUA,CAAA,EAAG;IACT,OAAO,IAAI,CAACZ,OAAO;EACvB;EACAa,OAAOA,CAAA,EAAG;IACN,OAAO,IAAI,CAACJ,IAAI;EACpB;EACAK,OAAOA,CAAA,EAAG;IACN,OAAO,IAAI,CAACJ,IAAI;EACpB;AACJ;AACA,OAAO,MAAMK,uBAAuB,GAAG,IAAIpD,gBAAgB,EAAE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CheckoutPayment } from 'cashfree-pg-api-contract';
|
|
1
|
+
import type { CheckoutPayment, CFSession } from 'cashfree-pg-api-contract';
|
|
2
2
|
declare class CFPaymentGateway {
|
|
3
3
|
private emitter;
|
|
4
4
|
private successSubscription;
|
|
@@ -6,6 +6,7 @@ declare class CFPaymentGateway {
|
|
|
6
6
|
private eventSubscription;
|
|
7
7
|
constructor();
|
|
8
8
|
doPayment(checkoutPayment: CheckoutPayment): void;
|
|
9
|
+
doWebPayment(cfSession: CFSession): void;
|
|
9
10
|
setEventSubscriber(cfEventCallback: CFEventCallback): void;
|
|
10
11
|
removeEventSubscriber(): void;
|
|
11
12
|
setCallback(cfCallback: CFCallback): void;
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -26,6 +26,9 @@ class CFPaymentGateway {
|
|
|
26
26
|
checkoutPayment.version = version;
|
|
27
27
|
CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));
|
|
28
28
|
}
|
|
29
|
+
doWebPayment(cfSession) {
|
|
30
|
+
CashfreePgApi.doWebPayment(cfSession);
|
|
31
|
+
}
|
|
29
32
|
setEventSubscriber(cfEventCallback) {
|
|
30
33
|
if (Platform.OS === 'android') {
|
|
31
34
|
let eventFunction = (event) => {
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Platform,
|
|
8
8
|
} from 'react-native';
|
|
9
9
|
import { version } from '../package.json';
|
|
10
|
-
import type { CheckoutPayment } from 'cashfree-pg-api-contract';
|
|
10
|
+
import type { CheckoutPayment, CFSession } from 'cashfree-pg-api-contract';
|
|
11
11
|
|
|
12
12
|
const LINKING_ERROR =
|
|
13
13
|
`The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` +
|
|
@@ -44,6 +44,10 @@ class CFPaymentGateway {
|
|
|
44
44
|
CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
doWebPayment(cfSession: CFSession) {
|
|
48
|
+
CashfreePgApi.doWebPayment(cfSession);
|
|
49
|
+
}
|
|
50
|
+
|
|
47
51
|
setEventSubscriber(cfEventCallback: CFEventCallback) {
|
|
48
52
|
if (Platform.OS === 'android') {
|
|
49
53
|
let eventFunction = (event: string) => {
|
package/android/.idea/.gitignore
DELETED
package/ios/.DS_Store
DELETED
|
Binary file
|