@cashfreepayments/react-native-cashfree-cn-sdk 1.0.0-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/LICENSE +21 -0
- package/README.md +79 -0
- package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/7.2/gc.properties +0 -0
- package/android/.gradle/7.5/checksums/checksums.lock +0 -0
- package/android/.gradle/7.5/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.5/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.5/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.5/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.5/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.5/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.5/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.5/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.5/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/7.5/gc.properties +0 -0
- package/android/.gradle/8.5/checksums/checksums.lock +0 -0
- package/android/.gradle/8.5/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.5/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.5/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.5/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.5/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/config.properties +2 -0
- package/android/.gradle/nb-cache/trust/5D9F4D2F872AE83553369BAEF9EF62F30CBE0A19F76FE265082C658DB033E1DA +1 -0
- package/android/.gradle/nb-cache/trust/811DB8418F399FDF2AFA5CB6893343C7013E03D6360FA7A8FBFC8B0C8A38EE77 +1 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +18 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +9 -0
- package/android/.idea/other.xml +549 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +77 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/local.properties +8 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/reactnativecashfreecnsdk/CashfreePgApiModule.java +319 -0
- package/android/src/main/java/com/reactnativecashfreecnsdk/CashfreePgApiPackage.java +28 -0
- package/ios/CashfreeEmitter.swift +36 -0
- package/ios/CashfreeEventEmitter.m +16 -0
- package/ios/CashfreeEventEmitter.swift +28 -0
- package/ios/CashfreePgApi-Bridging-Header.h +5 -0
- package/ios/CashfreePgApi.m +21 -0
- package/ios/CashfreePgApi.swift +410 -0
- package/ios/CashfreePgApi.xcodeproj/project.pbxproj +293 -0
- package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/xcuserdata/nikhil.kushwah.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/CashfreePgApi.xcodeproj/xcuserdata/nikhil.kushwah.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/commonjs/Card/CFCardComponent.js +287 -0
- package/lib/commonjs/Card/CFCardComponent.js.map +1 -0
- package/lib/commonjs/Card/index.js +14 -0
- package/lib/commonjs/Card/index.js.map +1 -0
- package/lib/commonjs/index.js +168 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/Card/CFCardComponent.js +279 -0
- package/lib/module/Card/CFCardComponent.js.map +1 -0
- package/lib/module/Card/index.js +2 -0
- package/lib/module/Card/index.js.map +1 -0
- package/lib/module/index.js +159 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/src/Card/CFCardComponent.d.ts +12 -0
- package/lib/typescript/src/Card/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts +43 -0
- package/package.json +157 -0
- package/react-native-cashfree-cn-sdk.podspec +20 -0
- package/src/Card/CFCardComponent.js +238 -0
- package/src/Card/CFCardComponent.tsx +323 -0
- package/src/Card/index.js +1 -0
- package/src/Card/index.ts +1 -0
- package/src/index.js +167 -0
- package/src/index.ts +219 -0
@@ -0,0 +1,410 @@
|
|
1
|
+
import CashfreePGCoreSDK
|
2
|
+
import CashfreePGUISDK
|
3
|
+
import CashfreePG
|
4
|
+
|
5
|
+
@objc(CashfreePgApi)
|
6
|
+
class CashfreePgApi: NSObject {
|
7
|
+
|
8
|
+
var analyticsCallbackEnabled: Bool = false
|
9
|
+
|
10
|
+
override init() {
|
11
|
+
super.init()
|
12
|
+
}
|
13
|
+
|
14
|
+
@objc static func requiresMainQueueSetup() -> Bool {
|
15
|
+
return false
|
16
|
+
}
|
17
|
+
|
18
|
+
@objc func doPayment(_ paymentObject: NSString) -> Void {
|
19
|
+
do {
|
20
|
+
let dropObject = try! parseDropPayment(paymentObject: "\(paymentObject)")
|
21
|
+
if (dropObject != nil) {
|
22
|
+
let vc = RCTPresentedViewController()
|
23
|
+
try CFPaymentGatewayService.getInstance().doPayment(dropObject!, viewController: vc!)
|
24
|
+
}
|
25
|
+
}
|
26
|
+
catch {
|
27
|
+
print (error)
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
@objc func doUPIPayment(_ paymentObject: NSString) -> Void {
|
32
|
+
do {
|
33
|
+
let upiObject = try! parseUPIPayment(paymentObject: "\(paymentObject)")
|
34
|
+
if (upiObject != nil) {
|
35
|
+
let vc = RCTPresentedViewController()
|
36
|
+
try CFPaymentGatewayService.getInstance().doPayment(upiObject!, viewController: vc!)
|
37
|
+
}
|
38
|
+
}
|
39
|
+
catch {
|
40
|
+
print (error)
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
@objc func doWebPayment(_ paymentObject: NSString,_ baseUrl: NSString) -> Void {
|
45
|
+
do {
|
46
|
+
if let sessionObj = try parseWebPayment(paymentObject: "\(paymentObject)") {
|
47
|
+
let cfPaymentObject = try! CFWebCheckoutPayment.CFWebCheckoutPaymentBuilder()
|
48
|
+
.setSession(sessionObj)
|
49
|
+
.build()
|
50
|
+
if let vc = RCTPresentedViewController() {
|
51
|
+
try CFPaymentGatewayService.getInstance().doPayment(cfPaymentObject, viewController: vc)
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
catch {
|
56
|
+
print (error)
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
@objc func doCardPayment(_ paymentObject: NSString) -> Void {
|
61
|
+
do {
|
62
|
+
if let cfCardPayment = try parseCardObject(paymentObject: "\(paymentObject)") {
|
63
|
+
if let vc = RCTPresentedViewController() {
|
64
|
+
try CFPaymentGatewayService.getInstance().doPayment(cfCardPayment, viewController: vc)
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
catch {
|
69
|
+
print (error)
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
@objc func getInstalledUpiApps(){
|
74
|
+
let upiApplications = CFUPIUtils().getInstalledUPIApplications()
|
75
|
+
var appsToSend: [NSDictionary] = []
|
76
|
+
for upi in upiApplications {
|
77
|
+
if (upi["id"] ?? "").contains("cred") {
|
78
|
+
continue
|
79
|
+
}
|
80
|
+
appsToSend.append([
|
81
|
+
"appPackage": upi["id"] ?? "",
|
82
|
+
"appName": upi["displayName"] ?? ""
|
83
|
+
])
|
84
|
+
}
|
85
|
+
CashfreeEmitter.sharedInstance.dispatch(name: "cfUpiApps", body: stringify(json: appsToSend))
|
86
|
+
}
|
87
|
+
|
88
|
+
@objc func doElementUPIPayment(_ paymentObject: NSString) -> Void {
|
89
|
+
do {
|
90
|
+
if let cfUPIPayment = try parseUpiObject(paymentObject: "\(paymentObject)") {
|
91
|
+
if let vc = RCTPresentedViewController() {
|
92
|
+
try CFPaymentGatewayService.getInstance().doPayment(cfUPIPayment, viewController: vc)
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
catch {
|
97
|
+
print (error)
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
@objc func setCallback() -> Void {
|
102
|
+
CFPaymentGatewayService.getInstance().setCallback(self)
|
103
|
+
}
|
104
|
+
|
105
|
+
@objc func setEventSubscriber() -> Void {
|
106
|
+
analyticsCallbackEnabled = true
|
107
|
+
}
|
108
|
+
|
109
|
+
@objc func removeEventSubscriber() -> Void {
|
110
|
+
analyticsCallbackEnabled = false
|
111
|
+
}
|
112
|
+
|
113
|
+
private func parseCardObject(paymentObject: String) throws -> CFCardPayment? {
|
114
|
+
let data = paymentObject.data(using: .utf8)!
|
115
|
+
if let output = try! JSONSerialization.jsonObject(with: data, options: .allowFragments) as? Dictionary<String, Any> {
|
116
|
+
do {
|
117
|
+
let finalSession = getSession(paymentObject: output)
|
118
|
+
if let cfCard = getCard(paymentObject: output){
|
119
|
+
let savePaymentMethod = isForSavePayment(paymentObject: output)
|
120
|
+
print(savePaymentMethod)
|
121
|
+
|
122
|
+
let cardPayment = try CFCardPayment.CFCardPaymentBuilder()
|
123
|
+
.setCard(cfCard)
|
124
|
+
.setSession(finalSession!)
|
125
|
+
.saveInstrument(savePaymentMethod)
|
126
|
+
.build()
|
127
|
+
|
128
|
+
let systemVersion = UIDevice.current.systemVersion
|
129
|
+
|
130
|
+
cardPayment.setPlatform("irnx-e-2.1.9-x-m-s-x-i-\(systemVersion.prefix(4))")
|
131
|
+
|
132
|
+
return cardPayment
|
133
|
+
}
|
134
|
+
return nil
|
135
|
+
} catch let e {
|
136
|
+
let error = e as! CashfreeError
|
137
|
+
print(error.localizedDescription)
|
138
|
+
}
|
139
|
+
}
|
140
|
+
return nil
|
141
|
+
}
|
142
|
+
|
143
|
+
private func parseUpiObject(paymentObject: String) throws -> CFUPIPayment? {
|
144
|
+
let data = paymentObject.data(using: .utf8)!
|
145
|
+
if let output = try! JSONSerialization.jsonObject(with: data, options: .allowFragments) as? Dictionary<String, Any> {
|
146
|
+
do {
|
147
|
+
let finalSession = getSession(paymentObject: output)
|
148
|
+
let cfUPI = getUpi(paymentObject: output)
|
149
|
+
|
150
|
+
let upiPayment = try CFUPIPayment.CFUPIPaymentBuilder()
|
151
|
+
.setSession(finalSession!)
|
152
|
+
.setUPI(cfUPI!)
|
153
|
+
.build()
|
154
|
+
let systemVersion = UIDevice.current.systemVersion
|
155
|
+
upiPayment.setPlatform("irnx-e-2.1.9-x-m-s-x-i-\(systemVersion.prefix(4))")
|
156
|
+
|
157
|
+
return upiPayment
|
158
|
+
} catch let e {
|
159
|
+
let error = e as! CashfreeError
|
160
|
+
print(error.localizedDescription)
|
161
|
+
}
|
162
|
+
}
|
163
|
+
return nil
|
164
|
+
}
|
165
|
+
|
166
|
+
private func parseDropPayment(paymentObject: String) throws -> CFDropCheckoutPayment? {
|
167
|
+
// print(paymentObject)
|
168
|
+
let data = paymentObject.data(using: .utf8)!
|
169
|
+
if let output = try! JSONSerialization.jsonObject(with: data, options: .allowFragments) as? Dictionary<String, Any> {
|
170
|
+
do {
|
171
|
+
let session = getSession(paymentObject: output)
|
172
|
+
let component = getComponents(paymentObject: output)
|
173
|
+
let theme = getTheme(paymentObject: output)
|
174
|
+
|
175
|
+
let nativePayment = try CFDropCheckoutPayment.CFDropCheckoutPaymentBuilder()
|
176
|
+
.setSession(session!)
|
177
|
+
.setTheme(theme!)
|
178
|
+
.setComponent(component!)
|
179
|
+
.build()
|
180
|
+
// let systemVersion = UIDevice.current.systemVersion
|
181
|
+
// nativePayment.setPlatform("irnx-d-" + (((output["version"]) as? String) ?? "") + "-3.3.9-m-s-x-i-\(systemVersion.prefix(4))")
|
182
|
+
return nativePayment
|
183
|
+
|
184
|
+
} catch let e {
|
185
|
+
let error = e as! CashfreeError
|
186
|
+
print(error.localizedDescription)
|
187
|
+
// Handle errors here
|
188
|
+
}
|
189
|
+
}
|
190
|
+
return nil
|
191
|
+
}
|
192
|
+
|
193
|
+
private func parseUPIPayment(paymentObject: String) throws -> CFDropCheckoutPayment? {
|
194
|
+
// print(paymentObject)
|
195
|
+
let data = paymentObject.data(using: .utf8)!
|
196
|
+
if let output = try! JSONSerialization.jsonObject(with: data, options: .allowFragments) as? Dictionary<String, Any> {
|
197
|
+
do {
|
198
|
+
let session = getSession(paymentObject: output)
|
199
|
+
let paymentComponents = try CFPaymentComponent.CFPaymentComponentBuilder()
|
200
|
+
.enableComponents(["upi"])
|
201
|
+
.build()
|
202
|
+
let theme = getTheme(paymentObject: output)
|
203
|
+
|
204
|
+
let nativePayment = try CFDropCheckoutPayment.CFDropCheckoutPaymentBuilder()
|
205
|
+
.setSession(session!)
|
206
|
+
.setTheme(theme!)
|
207
|
+
.setComponent(paymentComponents)
|
208
|
+
.build()
|
209
|
+
return nativePayment
|
210
|
+
|
211
|
+
} catch let e {
|
212
|
+
let error = e as! CashfreeError
|
213
|
+
print(error.localizedDescription)
|
214
|
+
// Handle errors here
|
215
|
+
}
|
216
|
+
}
|
217
|
+
return nil
|
218
|
+
}
|
219
|
+
|
220
|
+
private func parseWebPayment(paymentObject: String) throws -> CFSession? {
|
221
|
+
// print(paymentObject)
|
222
|
+
let data = paymentObject.data(using: .utf8)!
|
223
|
+
do {
|
224
|
+
if let output = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? Dictionary<String, Any> {
|
225
|
+
let paymentObj = ["session":output]
|
226
|
+
let session = getSession(paymentObject: paymentObj)
|
227
|
+
return session
|
228
|
+
}
|
229
|
+
} catch let e {
|
230
|
+
let error = e as! CashfreeError
|
231
|
+
print(error.localizedDescription)
|
232
|
+
// Handle errors here
|
233
|
+
}
|
234
|
+
return nil
|
235
|
+
}
|
236
|
+
|
237
|
+
|
238
|
+
private func getSession(paymentObject: Dictionary<String,Any>) -> CFSession? {
|
239
|
+
if let sessionDict = paymentObject["session"] as? Dictionary<String, String> {
|
240
|
+
do {
|
241
|
+
let builder = CFSession.CFSessionBuilder()
|
242
|
+
.setOrderID(sessionDict["orderID"] ?? "")
|
243
|
+
.setPaymentSessionId(sessionDict["payment_session_id"] ?? "")
|
244
|
+
if (sessionDict["environment"] == "SANDBOX") {
|
245
|
+
builder.setEnvironment(CFENVIRONMENT.SANDBOX)
|
246
|
+
} else {
|
247
|
+
builder.setEnvironment(CFENVIRONMENT.PRODUCTION)
|
248
|
+
}
|
249
|
+
let session = try builder.build()
|
250
|
+
return session
|
251
|
+
} catch let e {
|
252
|
+
let error = e as! CashfreeError
|
253
|
+
print(error.localizedDescription)
|
254
|
+
// Handle errors here
|
255
|
+
}
|
256
|
+
}
|
257
|
+
return nil
|
258
|
+
}
|
259
|
+
|
260
|
+
private func getCard(paymentObject: Dictionary<String,Any>) -> CFCard? {
|
261
|
+
let card = paymentObject["card"] as? NSDictionary ?? [:]
|
262
|
+
do {
|
263
|
+
var cardObject: CFCard!
|
264
|
+
if card["instrumentId"] != nil && card["instrumentId"] as? String ?? "" != "" {
|
265
|
+
cardObject = try CFCard.CFCardBuilder()
|
266
|
+
.setCVV(card["cardCvv"] as? String ?? "")
|
267
|
+
.setInstrumentId(card["instrumentId"] as? String ?? "")
|
268
|
+
.build()
|
269
|
+
} else {
|
270
|
+
cardObject = try CFCard.CFCardBuilder()
|
271
|
+
.setCVV(card["cardCvv"] as? String ?? "")
|
272
|
+
.setCardNumber(card["cardNumber"] as? String ?? "")
|
273
|
+
.setCardExpiryYear(card["cardExpiryYY"] as? String ?? "")
|
274
|
+
.setCardExpiryMonth(card["cardExpiryMM"] as? String ?? "")
|
275
|
+
.setCardHolderName(card["cardHolderName"] as? String ?? "")
|
276
|
+
.build()
|
277
|
+
}
|
278
|
+
return cardObject
|
279
|
+
} catch let e {
|
280
|
+
let error = e as! CashfreeError
|
281
|
+
print(error.localizedDescription)
|
282
|
+
return nil
|
283
|
+
}
|
284
|
+
}
|
285
|
+
|
286
|
+
private func isForSavePayment(paymentObject: Dictionary<String,Any>) -> Bool {
|
287
|
+
let card = paymentObject["card"] as? NSDictionary ?? [:]
|
288
|
+
return card["saveCard"] as? Bool ?? false
|
289
|
+
}
|
290
|
+
|
291
|
+
private func getUpi(paymentObject: Dictionary<String,Any>) -> CFUPI?{
|
292
|
+
if let upi = paymentObject["upi"] as? Dictionary<String, String> {
|
293
|
+
do {
|
294
|
+
let cfUPI = try CFUPI.CFUPIBuilder()
|
295
|
+
.setChannel(upi["mode"] ?? "" == "COLLECT" ? .COLLECT : .INTENT)
|
296
|
+
.setUPIID(upi["id"] ?? "")
|
297
|
+
.build()
|
298
|
+
return cfUPI
|
299
|
+
} catch let e {
|
300
|
+
let err = e as! CashfreeError
|
301
|
+
print(err.localizedDescription)
|
302
|
+
}
|
303
|
+
}
|
304
|
+
return nil
|
305
|
+
}
|
306
|
+
|
307
|
+
private func getComponents(paymentObject: Dictionary<String,Any>) -> CFPaymentComponent? {
|
308
|
+
if let components = paymentObject["components"] as? Array<String> {
|
309
|
+
do {
|
310
|
+
var array = ["order-details"]
|
311
|
+
components.forEach { item in
|
312
|
+
let component = getItemName(item: item)
|
313
|
+
if (component != nil) {
|
314
|
+
array.append(component!)
|
315
|
+
}
|
316
|
+
}
|
317
|
+
let paymentComponents = try CFPaymentComponent.CFPaymentComponentBuilder()
|
318
|
+
.enableComponents(array)
|
319
|
+
.build()
|
320
|
+
return paymentComponents
|
321
|
+
} catch let e {
|
322
|
+
let error = e as! CashfreeError
|
323
|
+
print(error.localizedDescription)
|
324
|
+
// Handle errors here
|
325
|
+
}
|
326
|
+
}
|
327
|
+
return nil
|
328
|
+
}
|
329
|
+
|
330
|
+
private func getItemName(item: String) -> String? {
|
331
|
+
switch item {
|
332
|
+
case "CARD" :
|
333
|
+
return "card"
|
334
|
+
case "UPI" :
|
335
|
+
return "upi"
|
336
|
+
case "NB" :
|
337
|
+
return "netbanking"
|
338
|
+
case "WALLET" :
|
339
|
+
return "wallet"
|
340
|
+
case "EMI" :
|
341
|
+
return "emi"
|
342
|
+
case "PAY_LATER" :
|
343
|
+
return "paylater"
|
344
|
+
default :
|
345
|
+
return nil
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
private func getTheme(paymentObject: Dictionary<String,Any>) -> CFTheme? {
|
350
|
+
if let theme = paymentObject["theme"] as? Dictionary<String, String> {
|
351
|
+
do {
|
352
|
+
return try CFTheme.CFThemeBuilder()
|
353
|
+
.setNavigationBarBackgroundColor(theme["navigationBarBackgroundColor"]!)
|
354
|
+
.setNavigationBarTextColor(theme["navigationBarTextColor"]!)
|
355
|
+
.setButtonBackgroundColor(theme["buttonBackgroundColor"]!)
|
356
|
+
.setButtonTextColor(theme["buttonTextColor"]!)
|
357
|
+
.setPrimaryTextColor(theme["primaryTextColor"]!)
|
358
|
+
.setSecondaryTextColor(theme["secondaryTextColor"]!)
|
359
|
+
.build()
|
360
|
+
} catch let e {
|
361
|
+
let error = e as! CashfreeError
|
362
|
+
print(error.localizedDescription)
|
363
|
+
// Handle errors here
|
364
|
+
}
|
365
|
+
// return CFTheme.CFThemeBuilder().build()
|
366
|
+
// .setNavigationBarBackgroundColor(theme["navigationBarBackgroundColor"] ?? "")
|
367
|
+
}
|
368
|
+
return nil
|
369
|
+
}
|
370
|
+
|
371
|
+
func stringify(json: Any) -> String {
|
372
|
+
var options: JSONSerialization.WritingOptions = []
|
373
|
+
do {
|
374
|
+
let data = try JSONSerialization.data(withJSONObject: json, options: options)
|
375
|
+
if let string = String(data: data, encoding: String.Encoding.utf8) {
|
376
|
+
return string
|
377
|
+
}
|
378
|
+
} catch {
|
379
|
+
print(error)
|
380
|
+
}
|
381
|
+
|
382
|
+
return ""
|
383
|
+
}
|
384
|
+
}
|
385
|
+
|
386
|
+
extension CashfreePgApi: CFResponseDelegate {
|
387
|
+
func onError(_ error: CFErrorResponse, order_id: String) {
|
388
|
+
print(error.message)
|
389
|
+
let data : [String: String] = ["status": error.status ?? ""
|
390
|
+
, "message": error.message ?? ""
|
391
|
+
, "code": error.code ?? ""
|
392
|
+
, "type": error.type ?? ""]
|
393
|
+
var body:[String: String] = ["error": stringify(json: data), "orderID": order_id]
|
394
|
+
CashfreeEmitter.sharedInstance.dispatch(name: "cfFailure", body: stringify(json: body))
|
395
|
+
}
|
396
|
+
|
397
|
+
func verifyPayment(order_id: String) {
|
398
|
+
print(order_id)
|
399
|
+
CashfreeEmitter.sharedInstance.dispatch(name: "cfSuccess", body: order_id)
|
400
|
+
}
|
401
|
+
|
402
|
+
func receivedEvent(event_name: String, meta_data: Dictionary<String, Any>) {
|
403
|
+
if (analyticsCallbackEnabled) {
|
404
|
+
print(event_name)
|
405
|
+
let data: [String: Any] = ["eventName": event_name
|
406
|
+
, "meta": meta_data]
|
407
|
+
CashfreeEmitter.sharedInstance.dispatch(name: "cfEvent", body: stringify(json: data))
|
408
|
+
}
|
409
|
+
}
|
410
|
+
}
|
@@ -0,0 +1,293 @@
|
|
1
|
+
// !$*UTF8*$!
|
2
|
+
{
|
3
|
+
archiveVersion = 1;
|
4
|
+
classes = {
|
5
|
+
};
|
6
|
+
objectVersion = 46;
|
7
|
+
objects = {
|
8
|
+
|
9
|
+
/* Begin PBXBuildFile section */
|
10
|
+
|
11
|
+
5E555C0D2413F4C50049A1A2 /* CashfreePgApi.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* CashfreePgApi.m */; };
|
12
|
+
F4FF95D7245B92E800C19C63 /* CashfreePgApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* CashfreePgApi.swift */; };
|
13
|
+
|
14
|
+
/* End PBXBuildFile section */
|
15
|
+
|
16
|
+
/* Begin PBXCopyFilesBuildPhase section */
|
17
|
+
58B511D91A9E6C8500147676 /* CopyFiles */ = {
|
18
|
+
isa = PBXCopyFilesBuildPhase;
|
19
|
+
buildActionMask = 2147483647;
|
20
|
+
dstPath = "include/$(PRODUCT_NAME)";
|
21
|
+
dstSubfolderSpec = 16;
|
22
|
+
files = (
|
23
|
+
);
|
24
|
+
runOnlyForDeploymentPostprocessing = 0;
|
25
|
+
};
|
26
|
+
/* End PBXCopyFilesBuildPhase section */
|
27
|
+
|
28
|
+
/* Begin PBXFileReference section */
|
29
|
+
134814201AA4EA6300B7C361 /* libCashfreePgApi.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCashfreePgApi.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
30
|
+
|
31
|
+
B3E7B5891CC2AC0600A0062D /* CashfreePgApi.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CashfreePgApi.m; sourceTree = "<group>"; };
|
32
|
+
F4FF95D5245B92E700C19C63 /* CashfreePgApi-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CashfreePgApi-Bridging-Header.h"; sourceTree = "<group>"; };
|
33
|
+
F4FF95D6245B92E800C19C63 /* CashfreePgApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CashfreePgApi.swift; sourceTree = "<group>"; };
|
34
|
+
|
35
|
+
/* End PBXFileReference section */
|
36
|
+
|
37
|
+
/* Begin PBXFrameworksBuildPhase section */
|
38
|
+
58B511D81A9E6C8500147676 /* Frameworks */ = {
|
39
|
+
isa = PBXFrameworksBuildPhase;
|
40
|
+
buildActionMask = 2147483647;
|
41
|
+
files = (
|
42
|
+
);
|
43
|
+
runOnlyForDeploymentPostprocessing = 0;
|
44
|
+
};
|
45
|
+
/* End PBXFrameworksBuildPhase section */
|
46
|
+
|
47
|
+
/* Begin PBXGroup section */
|
48
|
+
134814211AA4EA7D00B7C361 /* Products */ = {
|
49
|
+
isa = PBXGroup;
|
50
|
+
children = (
|
51
|
+
134814201AA4EA6300B7C361 /* libCashfreePgApi.a */,
|
52
|
+
);
|
53
|
+
name = Products;
|
54
|
+
sourceTree = "<group>";
|
55
|
+
};
|
56
|
+
58B511D21A9E6C8500147676 = {
|
57
|
+
isa = PBXGroup;
|
58
|
+
children = (
|
59
|
+
|
60
|
+
F4FF95D6245B92E800C19C63 /* CashfreePgApi.swift */,
|
61
|
+
B3E7B5891CC2AC0600A0062D /* CashfreePgApi.m */,
|
62
|
+
F4FF95D5245B92E700C19C63 /* CashfreePgApi-Bridging-Header.h */,
|
63
|
+
|
64
|
+
134814211AA4EA7D00B7C361 /* Products */,
|
65
|
+
);
|
66
|
+
sourceTree = "<group>";
|
67
|
+
};
|
68
|
+
/* End PBXGroup section */
|
69
|
+
|
70
|
+
/* Begin PBXNativeTarget section */
|
71
|
+
58B511DA1A9E6C8500147676 /* CashfreePgApi */ = {
|
72
|
+
isa = PBXNativeTarget;
|
73
|
+
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "CashfreePgApi" */;
|
74
|
+
buildPhases = (
|
75
|
+
58B511D71A9E6C8500147676 /* Sources */,
|
76
|
+
58B511D81A9E6C8500147676 /* Frameworks */,
|
77
|
+
58B511D91A9E6C8500147676 /* CopyFiles */,
|
78
|
+
);
|
79
|
+
buildRules = (
|
80
|
+
);
|
81
|
+
dependencies = (
|
82
|
+
);
|
83
|
+
name = CashfreePgApi;
|
84
|
+
productName = RCTDataManager;
|
85
|
+
productReference = 134814201AA4EA6300B7C361 /* libCashfreePgApi.a */;
|
86
|
+
productType = "com.apple.product-type.library.static";
|
87
|
+
};
|
88
|
+
/* End PBXNativeTarget section */
|
89
|
+
|
90
|
+
/* Begin PBXProject section */
|
91
|
+
58B511D31A9E6C8500147676 /* Project object */ = {
|
92
|
+
isa = PBXProject;
|
93
|
+
attributes = {
|
94
|
+
LastUpgradeCheck = 0920;
|
95
|
+
ORGANIZATIONNAME = Facebook;
|
96
|
+
TargetAttributes = {
|
97
|
+
58B511DA1A9E6C8500147676 = {
|
98
|
+
CreatedOnToolsVersion = 6.1.1;
|
99
|
+
};
|
100
|
+
};
|
101
|
+
};
|
102
|
+
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "CashfreePgApi" */;
|
103
|
+
compatibilityVersion = "Xcode 3.2";
|
104
|
+
developmentRegion = English;
|
105
|
+
hasScannedForEncodings = 0;
|
106
|
+
knownRegions = (
|
107
|
+
English,
|
108
|
+
en,
|
109
|
+
);
|
110
|
+
mainGroup = 58B511D21A9E6C8500147676;
|
111
|
+
productRefGroup = 58B511D21A9E6C8500147676;
|
112
|
+
projectDirPath = "";
|
113
|
+
projectRoot = "";
|
114
|
+
targets = (
|
115
|
+
58B511DA1A9E6C8500147676 /* CashfreePgApi */,
|
116
|
+
);
|
117
|
+
};
|
118
|
+
/* End PBXProject section */
|
119
|
+
|
120
|
+
/* Begin PBXSourcesBuildPhase section */
|
121
|
+
58B511D71A9E6C8500147676 /* Sources */ = {
|
122
|
+
isa = PBXSourcesBuildPhase;
|
123
|
+
buildActionMask = 2147483647;
|
124
|
+
files = (
|
125
|
+
|
126
|
+
F4FF95D7245B92E800C19C63 /* CashfreePgApi.swift in Sources */,
|
127
|
+
B3E7B58A1CC2AC0600A0062D /* CashfreePgApi.m in Sources */,
|
128
|
+
|
129
|
+
);
|
130
|
+
runOnlyForDeploymentPostprocessing = 0;
|
131
|
+
};
|
132
|
+
/* End PBXSourcesBuildPhase section */
|
133
|
+
|
134
|
+
/* Begin XCBuildConfiguration section */
|
135
|
+
58B511ED1A9E6C8500147676 /* Debug */ = {
|
136
|
+
isa = XCBuildConfiguration;
|
137
|
+
buildSettings = {
|
138
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
139
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
140
|
+
CLANG_CXX_LIBRARY = "libc++";
|
141
|
+
CLANG_ENABLE_MODULES = YES;
|
142
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
143
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
144
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
145
|
+
CLANG_WARN_COMMA = YES;
|
146
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
147
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
148
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
149
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
150
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
151
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
152
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
153
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
154
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
155
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
156
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
157
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
158
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
159
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
160
|
+
COPY_PHASE_STRIP = NO;
|
161
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
162
|
+
ENABLE_TESTABILITY = YES;
|
163
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
164
|
+
GCC_DYNAMIC_NO_PIC = NO;
|
165
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
166
|
+
GCC_OPTIMIZATION_LEVEL = 0;
|
167
|
+
GCC_PREPROCESSOR_DEFINITIONS = (
|
168
|
+
"DEBUG=1",
|
169
|
+
"$(inherited)",
|
170
|
+
);
|
171
|
+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
172
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
173
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
174
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
175
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
176
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
177
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
178
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
179
|
+
MTL_ENABLE_DEBUG_INFO = YES;
|
180
|
+
ONLY_ACTIVE_ARCH = YES;
|
181
|
+
SDKROOT = iphoneos;
|
182
|
+
};
|
183
|
+
name = Debug;
|
184
|
+
};
|
185
|
+
58B511EE1A9E6C8500147676 /* Release */ = {
|
186
|
+
isa = XCBuildConfiguration;
|
187
|
+
buildSettings = {
|
188
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
189
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
190
|
+
CLANG_CXX_LIBRARY = "libc++";
|
191
|
+
CLANG_ENABLE_MODULES = YES;
|
192
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
193
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
194
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
195
|
+
CLANG_WARN_COMMA = YES;
|
196
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
197
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
198
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
199
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
200
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
201
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
202
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
203
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
204
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
205
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
206
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
207
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
208
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
209
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
210
|
+
COPY_PHASE_STRIP = YES;
|
211
|
+
ENABLE_NS_ASSERTIONS = NO;
|
212
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
213
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
214
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
215
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
216
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
217
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
218
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
219
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
220
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
221
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
222
|
+
MTL_ENABLE_DEBUG_INFO = NO;
|
223
|
+
SDKROOT = iphoneos;
|
224
|
+
VALIDATE_PRODUCT = YES;
|
225
|
+
};
|
226
|
+
name = Release;
|
227
|
+
};
|
228
|
+
58B511F01A9E6C8500147676 /* Debug */ = {
|
229
|
+
isa = XCBuildConfiguration;
|
230
|
+
buildSettings = {
|
231
|
+
HEADER_SEARCH_PATHS = (
|
232
|
+
"$(inherited)",
|
233
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
234
|
+
"$(SRCROOT)/../../../React/**",
|
235
|
+
"$(SRCROOT)/../../react-native/React/**",
|
236
|
+
);
|
237
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
238
|
+
OTHER_LDFLAGS = "-ObjC";
|
239
|
+
PRODUCT_NAME = CashfreePgApi;
|
240
|
+
SKIP_INSTALL = YES;
|
241
|
+
|
242
|
+
SWIFT_OBJC_BRIDGING_HEADER = "CashfreePgApi-Bridging-Header.h";
|
243
|
+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
244
|
+
SWIFT_VERSION = 5.0;
|
245
|
+
|
246
|
+
};
|
247
|
+
name = Debug;
|
248
|
+
};
|
249
|
+
58B511F11A9E6C8500147676 /* Release */ = {
|
250
|
+
isa = XCBuildConfiguration;
|
251
|
+
buildSettings = {
|
252
|
+
HEADER_SEARCH_PATHS = (
|
253
|
+
"$(inherited)",
|
254
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
255
|
+
"$(SRCROOT)/../../../React/**",
|
256
|
+
"$(SRCROOT)/../../react-native/React/**",
|
257
|
+
);
|
258
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
259
|
+
OTHER_LDFLAGS = "-ObjC";
|
260
|
+
PRODUCT_NAME = CashfreePgApi;
|
261
|
+
SKIP_INSTALL = YES;
|
262
|
+
|
263
|
+
SWIFT_OBJC_BRIDGING_HEADER = "CashfreePgApi-Bridging-Header.h";
|
264
|
+
SWIFT_VERSION = 5.0;
|
265
|
+
|
266
|
+
};
|
267
|
+
name = Release;
|
268
|
+
};
|
269
|
+
/* End XCBuildConfiguration section */
|
270
|
+
|
271
|
+
/* Begin XCConfigurationList section */
|
272
|
+
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "CashfreePgApi" */ = {
|
273
|
+
isa = XCConfigurationList;
|
274
|
+
buildConfigurations = (
|
275
|
+
58B511ED1A9E6C8500147676 /* Debug */,
|
276
|
+
58B511EE1A9E6C8500147676 /* Release */,
|
277
|
+
);
|
278
|
+
defaultConfigurationIsVisible = 0;
|
279
|
+
defaultConfigurationName = Release;
|
280
|
+
};
|
281
|
+
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "CashfreePgApi" */ = {
|
282
|
+
isa = XCConfigurationList;
|
283
|
+
buildConfigurations = (
|
284
|
+
58B511F01A9E6C8500147676 /* Debug */,
|
285
|
+
58B511F11A9E6C8500147676 /* Release */,
|
286
|
+
);
|
287
|
+
defaultConfigurationIsVisible = 0;
|
288
|
+
defaultConfigurationName = Release;
|
289
|
+
};
|
290
|
+
/* End XCConfigurationList section */
|
291
|
+
};
|
292
|
+
rootObject = 58B511D31A9E6C8500147676 /* Project object */;
|
293
|
+
}
|