react-native-cashfree-pg-sdk 2.2.3 → 2.2.4-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.
@@ -66,7 +66,7 @@ dependencies {
66
66
  implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
67
67
  implementation 'androidx.gridlayout:gridlayout:1.0.0'
68
68
 
69
- implementation 'com.cashfree.pg:api:2.2.3'
69
+ implementation 'com.cashfree.pg:api:2.2.4'
70
70
 
71
71
  implementation "com.facebook.react:react-native:+" // From node_modules
72
72
  }
@@ -15,14 +15,18 @@ import com.cashfree.pg.cf_analytics.CFAnalyticsService;
15
15
  import com.cashfree.pg.cf_analytics.CFEventsSubscriber;
16
16
  import com.cashfree.pg.core.api.CFCorePaymentGatewayService;
17
17
  import com.cashfree.pg.core.api.CFSession;
18
+ import com.cashfree.pg.core.api.CFSubscriptionSession;
18
19
  import com.cashfree.pg.core.api.base.CFPayment;
19
20
  import com.cashfree.pg.core.api.callback.CFCheckoutResponseCallback;
21
+ import com.cashfree.pg.core.api.callback.CFSubscriptionResponseCallback;
20
22
  import com.cashfree.pg.core.api.card.CFCard;
21
23
  import com.cashfree.pg.core.api.card.CFCardPayment;
22
24
  import com.cashfree.pg.core.api.exception.CFException;
25
+ import com.cashfree.pg.core.api.subscription.CFSubscriptionPayment;
23
26
  import com.cashfree.pg.core.api.upi.CFUPI;
24
27
  import com.cashfree.pg.core.api.upi.CFUPIPayment;
25
28
  import com.cashfree.pg.core.api.utils.CFErrorResponse;
29
+ import com.cashfree.pg.core.api.utils.CFSubscriptionResponse;
26
30
  import com.cashfree.pg.core.api.webcheckout.CFWebCheckoutPayment;
27
31
  import com.cashfree.pg.ui.api.CFDropCheckoutPayment;
28
32
  import com.cashfree.pg.ui.api.upi.intent.CFUPIIntentCheckoutPayment;
@@ -42,7 +46,7 @@ import java.util.List;
42
46
  import java.util.Map;
43
47
 
44
48
  @ReactModule(name = CashfreePgApiModule.NAME)
45
- public class CashfreePgApiModule extends ReactContextBaseJavaModule implements CFCheckoutResponseCallback, CFEventsSubscriber {
49
+ public class CashfreePgApiModule extends ReactContextBaseJavaModule implements CFCheckoutResponseCallback, CFEventsSubscriber, CFSubscriptionResponseCallback {
46
50
  public static final String NAME = "CashfreePgApi";
47
51
 
48
52
  public CashfreePgApiModule(ReactApplicationContext reactContext) {
@@ -122,6 +126,37 @@ public class CashfreePgApiModule extends ReactContextBaseJavaModule implements C
122
126
  }
123
127
  }
124
128
 
129
+ @ReactMethod
130
+ public void doSubscriptionPayment(String sessionString) {
131
+ CFSubscriptionSession cfSubsSession = null;
132
+ try {
133
+ JSONObject jsonObject = new JSONObject(sessionString);
134
+ cfSubsSession = new CFSubscriptionSession.CFSubscriptionSessionBuilder()
135
+ .setEnvironment(CFSubscriptionSession.Environment.valueOf(jsonObject.getString("environment")))
136
+ .setSubscriptionId(jsonObject.getString("subscription_id"))
137
+ .setSubscriptionSessionID(jsonObject.getString("subscription_session_id"))
138
+ .build();
139
+ } catch (Exception exception) {
140
+ throw new IllegalStateException("Subscription Session is invalid");
141
+ }
142
+ try {
143
+ Activity activity = getCurrentActivity();
144
+ CFSubscriptionPayment cfSubscriptionPayment = new CFSubscriptionPayment.CFSubscriptionCheckoutBuilder()
145
+ .setSubscriptionSession(cfSubsSession)
146
+ .build();
147
+ cfSubscriptionPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
148
+ cfSubscriptionPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.SUBSCRIPTION);
149
+ if (activity != null) {
150
+ CFPaymentGatewayService.getInstance().setSubscriptionCheckoutCallback(this);
151
+ CFPaymentGatewayService.getInstance().doSubscriptionPayment(activity, cfSubscriptionPayment);
152
+ } else {
153
+ throw new IllegalStateException("activity is null");
154
+ }
155
+ } catch (Exception e) {
156
+ e.printStackTrace();
157
+ }
158
+ }
159
+
125
160
  @ReactMethod
126
161
  public void doCardPayment(String data) {
127
162
  CFSession cfSession = null;
@@ -277,7 +312,9 @@ public class CashfreePgApiModule extends ReactContextBaseJavaModule implements C
277
312
  JSONObject jsonObject = new JSONObject();
278
313
  try {
279
314
  jsonObject.put("error", cfErrorResponse.toJSON().toString());
280
- jsonObject.put("orderID", orderID);
315
+ if(orderID !=null && !orderID.isEmpty()) {
316
+ jsonObject.put("orderID", orderID);
317
+ }
281
318
  } catch (JSONException e) {
282
319
  e.printStackTrace();
283
320
  }
@@ -305,4 +342,14 @@ public class CashfreePgApiModule extends ReactContextBaseJavaModule implements C
305
342
  .getJSModule(RCTNativeAppEventEmitter.class)
306
343
  .emit("cfEvent", jsonObject.toString());
307
344
  }
345
+
346
+ @Override
347
+ public void onSubscriptionVerify(CFSubscriptionResponse cfSubscriptionResponse) {
348
+ onPaymentVerify(cfSubscriptionResponse.getSubscriptionId());
349
+ }
350
+
351
+ @Override
352
+ public void onSubscriptionFailure(CFErrorResponse cfErrorResponse) {
353
+ onPaymentFailure(cfErrorResponse, "");
354
+ }
308
355
  }
@@ -8,6 +8,7 @@ RCT_EXTERN_METHOD(doPayment:(NSString)paymentObject)
8
8
  RCT_EXTERN_METHOD(doUPIPayment:(NSString)paymentObject)
9
9
 
10
10
  RCT_EXTERN_METHOD(doWebPayment:(NSString)paymentObject)
11
+ RCT_EXTERN_METHOD(doSubscriptionPayment:(NSString)paymentObject)
11
12
  RCT_EXTERN_METHOD(doCardPayment:(NSString)paymentObject)
12
13
  RCT_EXTERN_METHOD(doElementUPIPayment:(NSString)paymentObject)
13
14
  RCT_EXTERN_METHOD(getInstalledUpiApps)
@@ -6,6 +6,7 @@ import CashfreePG
6
6
  class CashfreePgApi: NSObject {
7
7
 
8
8
  var analyticsCallbackEnabled: Bool = false
9
+ private let versionNumber = "2.2.4"
9
10
 
10
11
  override init() {
11
12
  super.init()
@@ -41,6 +42,24 @@ class CashfreePgApi: NSObject {
41
42
  }
42
43
  }
43
44
 
45
+ @objc func doSubscriptionPayment(_ paymentObject: NSString) -> Void {
46
+ do {
47
+ if let subscriptionSessionObj = try parseSubscriptionSession(paymentObject: "\(paymentObject)") {
48
+ let subscriptionWebCheckoutPayment = try! CFSubscriptionPayment.CFSubscriptionPaymentBuilder()
49
+ .setSession(subscriptionSessionObj)
50
+ .build()
51
+ let systemVersion = UIDevice.current.systemVersion
52
+ subscriptionWebCheckoutPayment.setPlatform("irnx-sbc-\(versionNumber)-x-m-s-x-i-\(systemVersion.prefix(4))")
53
+ if let vc = RCTPresentedViewController() {
54
+ try CFPaymentGatewayService.getInstance().startSubscription(subscriptionWebCheckoutPayment, viewController: vc)
55
+ }
56
+ }
57
+ }
58
+ catch {
59
+ print (error)
60
+ }
61
+ }
62
+
44
63
  @objc func doWebPayment(_ paymentObject: NSString) -> Void {
45
64
  do {
46
65
  if let sessionObj = try parseWebPayment(paymentObject: "\(paymentObject)") {
@@ -127,7 +146,7 @@ class CashfreePgApi: NSObject {
127
146
 
128
147
  let systemVersion = UIDevice.current.systemVersion
129
148
 
130
- cardPayment.setPlatform("irnx-e-2.2.1-x-m-s-x-i-\(systemVersion.prefix(4))")
149
+ cardPayment.setPlatform("irnx-e-\(versionNumber)-x-m-s-x-i-\(systemVersion.prefix(4))")
131
150
 
132
151
  return cardPayment
133
152
  }
@@ -152,7 +171,7 @@ class CashfreePgApi: NSObject {
152
171
  .setUPI(cfUPI!)
153
172
  .build()
154
173
  let systemVersion = UIDevice.current.systemVersion
155
- upiPayment.setPlatform("irnx-e-2.2.1-x-m-s-x-i-\(systemVersion.prefix(4))")
174
+ upiPayment.setPlatform("irnx-e-\(versionNumber)-x-m-s-x-i-\(systemVersion.prefix(4))")
156
175
 
157
176
  return upiPayment
158
177
  } catch let e {
@@ -235,6 +254,42 @@ class CashfreePgApi: NSObject {
235
254
  }
236
255
 
237
256
 
257
+ private func parseSubscriptionSession(paymentObject: String) throws -> CFSubscriptionSession? {
258
+ let data = paymentObject.data(using: .utf8)!
259
+ do {
260
+ if let output = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? Dictionary<String, Any> {
261
+ let paymentObj = ["session":output]
262
+ let session = getSubscriptionSession(paymentObject: paymentObj)
263
+ return session
264
+ }
265
+ } catch let e {
266
+ let error = e as! CashfreeError
267
+ print(error.localizedDescription)
268
+ }
269
+ return nil
270
+ }
271
+
272
+ private func getSubscriptionSession(paymentObject: Dictionary<String,Any>) -> CFSubscriptionSession? {
273
+ if let sessionDict = paymentObject["session"] as? Dictionary<String, String> {
274
+ do {
275
+ let subscriptionBuilder = CFSubscriptionSession.CFSubscriptionSessionBuilder()
276
+ .setSubscriptionId(sessionDict["subscription_id"] ?? "")
277
+ .setSubscriptionSessionId(sessionDict["subscription_session_id"] ?? "")
278
+ if (sessionDict["environment"] == "SANDBOX") {
279
+ subscriptionBuilder.setEnvironment(CFENVIRONMENT.SANDBOX)
280
+ } else {
281
+ subscriptionBuilder.setEnvironment(CFENVIRONMENT.PRODUCTION)
282
+ }
283
+ let subscriptionSession = try subscriptionBuilder.build()
284
+ return subscriptionSession
285
+ } catch let e {
286
+ let error = e as! CashfreeError
287
+ print(error.localizedDescription)
288
+ }
289
+ }
290
+ return nil
291
+ }
292
+
238
293
  private func getSession(paymentObject: Dictionary<String,Any>) -> CFSession? {
239
294
  if let sessionDict = paymentObject["session"] as? Dictionary<String, String> {
240
295
  do {
@@ -13,7 +13,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
13
13
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
14
14
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
15
  const LINKING_ERROR = `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
16
- ios: '- You have run \'pod install\'\n',
16
+ ios: "- You have run 'pod install'\n",
17
17
  default: ''
18
18
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
19
19
  const CashfreePgApi = _reactNative.NativeModules.CashfreePgApi ? _reactNative.NativeModules.CashfreePgApi : new Proxy({}, {
@@ -41,6 +41,9 @@ class CFPaymentGateway {
41
41
  doWebPayment(cfSession) {
42
42
  CashfreePgApi.doWebPayment(JSON.stringify(cfSession));
43
43
  }
44
+ doSubscriptionPayment(cfSession) {
45
+ CashfreePgApi.doSubscriptionPayment(JSON.stringify(cfSession));
46
+ }
44
47
 
45
48
  /**
46
49
  * @deprecated : Instead call makePayment
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_package","_cashfreePgApiContract","_CFCardComponent","_interopRequireDefault","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","LINKING_ERROR","Platform","select","ios","CashfreePgApi","NativeModules","Proxy","get","Error","CFPaymentGateway","constructor","emitter","OS","NativeEventEmitter","CashfreeEventEmitter","NativeAppEventEmitter","doPayment","checkoutPayment","version","JSON","stringify","doUPIPayment","doWebPayment","cfSession","doCardPayment","cardPayment","makePayment","getInstalledUpiApps","Promise","resolve","reject","fetchUpiList","apps","console","log","upiAppsSubscription","addListener","cfPayment","paymentData","CFUPIPayment","doElementUPIPayment","CFCardPayment","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","removeEventSubscriber","undefined","remove","setCallback","cfCallback","successFunction","orderID","onVerify","failureFunction","error","response","CFErrorResponse","message","fromJSON","onError","successSubscription","failureSubscription","removeCallback","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","exports","CFCard","CFCardComponent","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, type CFSession, CFUPIPayment, CFCardPayment } from 'cashfree-pg-api-contract';\nimport CFCardComponent from './Card/CFCardComponent';\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 private upiAppsSubscription: 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 doUPIPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));\n }\n\n doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(JSON.stringify(cfSession));\n }\n\n /**\n * @deprecated : Instead call makePayment\n */\n doCardPayment(cardPayment: CheckoutPayment) {\n this.makePayment(cardPayment);\n }\n\n async getInstalledUpiApps() {\n return new Promise((resolve, reject) => {\n if(Platform.OS === 'ios'){\n let fetchUpiList = (apps: string) => {\n console.log(JSON.stringify(apps));\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n };\n this.upiAppsSubscription = this.emitter.addListener('cfUpiApps', fetchUpiList);\n CashfreePgApi.getInstalledUpiApps()\n }\n else {\n CashfreePgApi.getInstalledUpiApps((apps: string) => {\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n });\n }\n });\n }\n\n makePayment(cfPayment: CheckoutPayment) {\n cfPayment.version = version;\n const paymentData = JSON.stringify(cfPayment);\n if (cfPayment instanceof CFUPIPayment) {\n CashfreePgApi.doElementUPIPayment(paymentData);\n } else if (cfPayment instanceof CFCardPayment) {\n CashfreePgApi.doCardPayment(paymentData);\n } else {\n console.log('makePayment::==> Wrong payment object');\n }\n }\n\n setEventSubscriber(cfEventCallback: CFEventCallback) {\n let eventFunction = (event: string) => {\n console.log(JSON.stringify(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 (\n this.eventSubscription !== undefined &&\n this.eventSubscription !== null\n ) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\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 if (\n this.upiAppsSubscription !== undefined &&\n this.upiAppsSubscription !== null\n ) {\n this.upiAppsSubscription.remove();\n this.upiAppsSubscription = 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 CFCard = CFCardComponent\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAQA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAqD,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;A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ACP,oBAAoB;IAAAA,eAAA,eACvB,gBAAgB;IAAAA,eAAA,eAChB,gBAAgB;EAAA;EAEvCmF,QAAQA,CAACK,WAAmB,EAAE;IAC5BrC,OAAO,CAACC,GAAG,CAAC,eAAe,GAAGoC,WAAW,CAAC;IAC1C,MAAMC,MAAM,GAAGpD,IAAI,CAAC4B,KAAK,CAACuB,WAAW,CAAC;IACtCrC,OAAO,CAACC,GAAG,CAAC,qBAAqB,GAAGqC,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;EACzB;EAEAC,SAASA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACH,MAAM;EACpB;EAEAI,UAAUA,CAAA,EAAW;IACnB,OAAO,IAAI,CAACZ,OAAO;EACrB;EAEAa,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;EAEAK,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;AACF;AAACK,OAAA,CAAAhB,eAAA,GAAAA,eAAA;AAEM,MAAMiB,MAAM,GAAAD,OAAA,CAAAC,MAAA,GAAGC,wBAAe;AAC9B,MAAMC,uBAAuB,GAAAH,OAAA,CAAAG,uBAAA,GAAG,IAAIzE,gBAAgB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_package","_cashfreePgApiContract","_CFCardComponent","_interopRequireDefault","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","LINKING_ERROR","Platform","select","ios","CashfreePgApi","NativeModules","Proxy","get","Error","CFPaymentGateway","constructor","emitter","OS","NativeEventEmitter","CashfreeEventEmitter","NativeAppEventEmitter","doPayment","checkoutPayment","version","JSON","stringify","doUPIPayment","doWebPayment","cfSession","doSubscriptionPayment","doCardPayment","cardPayment","makePayment","getInstalledUpiApps","Promise","resolve","reject","fetchUpiList","apps","console","log","upiAppsSubscription","addListener","cfPayment","paymentData","CFUPIPayment","doElementUPIPayment","CFCardPayment","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","removeEventSubscriber","undefined","remove","setCallback","cfCallback","successFunction","orderID","onVerify","failureFunction","error","response","CFErrorResponse","message","fromJSON","onError","successSubscription","failureSubscription","removeCallback","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","exports","CFCard","CFCardComponent","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 {\n type CheckoutPayment,\n type CFSession,\n type CFSubscriptionSession,\n CFUPIPayment,\n CFCardPayment,\n} from 'cashfree-pg-api-contract';\nimport CFCardComponent from './Card/CFCardComponent';\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 private upiAppsSubscription: 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 doUPIPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));\n }\n\n doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(JSON.stringify(cfSession));\n }\n\n doSubscriptionPayment(cfSession: CFSubscriptionSession) {\n CashfreePgApi.doSubscriptionPayment(JSON.stringify(cfSession));\n }\n\n /**\n * @deprecated : Instead call makePayment\n */\n doCardPayment(cardPayment: CheckoutPayment) {\n this.makePayment(cardPayment);\n }\n\n async getInstalledUpiApps() {\n return new Promise((resolve, reject) => {\n if (Platform.OS === 'ios') {\n let fetchUpiList = (apps: string) => {\n console.log(JSON.stringify(apps));\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n };\n this.upiAppsSubscription = this.emitter.addListener(\n 'cfUpiApps',\n fetchUpiList\n );\n CashfreePgApi.getInstalledUpiApps();\n } else {\n CashfreePgApi.getInstalledUpiApps((apps: string) => {\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n });\n }\n });\n }\n\n makePayment(cfPayment: CheckoutPayment) {\n cfPayment.version = version;\n const paymentData = JSON.stringify(cfPayment);\n if (cfPayment instanceof CFUPIPayment) {\n CashfreePgApi.doElementUPIPayment(paymentData);\n } else if (cfPayment instanceof CFCardPayment) {\n CashfreePgApi.doCardPayment(paymentData);\n } else {\n console.log('makePayment::==> Wrong payment object');\n }\n }\n\n setEventSubscriber(cfEventCallback: CFEventCallback) {\n let eventFunction = (event: string) => {\n console.log(JSON.stringify(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 (\n this.eventSubscription !== undefined &&\n this.eventSubscription !== null\n ) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\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 if (\n this.upiAppsSubscription !== undefined &&\n this.upiAppsSubscription !== null\n ) {\n this.upiAppsSubscription.remove();\n this.upiAppsSubscription = 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 CFCard = CFCard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OAAO;IAC7B,IAAI,CAACS,IAAI,GAAGF,MAAM,CAACE,IAAI;IACvB,IAAI,CAACC,IAAI,GAAGH,MAAM,CAACG,IAAI;EACzB;EAEAC,SAASA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACH,MAAM;EACpB;EAEAI,UAAUA,CAAA,EAAW;IACnB,OAAO,IAAI,CAACZ,OAAO;EACrB;EAEAa,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;EAEAK,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;AACF;AAACK,OAAA,CAAAhB,eAAA,GAAAA,eAAA;AAEM,MAAMiB,MAAM,GAAAD,OAAA,CAAAC,MAAA,GAAGC,wBAAe;AAC9B,MAAMC,uBAAuB,GAAAH,OAAA,CAAAG,uBAAA,GAAG,IAAI1E,gBAAgB,CAAC,CAAC","ignoreList":[]}
@@ -6,7 +6,7 @@ import { version } from '../package.json';
6
6
  import { CFUPIPayment, CFCardPayment } from 'cashfree-pg-api-contract';
7
7
  import CFCardComponent from './Card/CFCardComponent';
8
8
  const LINKING_ERROR = `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
9
- ios: '- You have run \'pod install\'\n',
9
+ ios: "- You have run 'pod install'\n",
10
10
  default: ''
11
11
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
12
12
  const CashfreePgApi = NativeModules.CashfreePgApi ? NativeModules.CashfreePgApi : new Proxy({}, {
@@ -34,6 +34,10 @@ class CFPaymentGateway {
34
34
  doWebPayment(cfSession) {
35
35
  CashfreePgApi.doWebPayment(JSON.stringify(cfSession));
36
36
  }
37
+ doSubscriptionPayment(cfSession) {
38
+ CashfreePgApi.doSubscriptionPayment(JSON.stringify(cfSession));
39
+ }
40
+
37
41
  /**
38
42
  * @deprecated : Instead call makePayment
39
43
  */
@@ -156,4 +160,4 @@ export class CFErrorResponse {
156
160
  }
157
161
  export const CFCard = CFCardComponent;
158
162
  export const CFPaymentGatewayService = new CFPaymentGateway();
159
- //# sourceMappingURL=index.js.mapp
163
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeAppEventEmitter","NativeEventEmitter","NativeModules","Platform","version","CFUPIPayment","CFCardPayment","CFCardComponent","LINKING_ERROR","select","ios","default","CashfreePgApi","Proxy","get","Error","CFPaymentGateway","constructor","_defineProperty","emitter","OS","CashfreeEventEmitter","doPayment","checkoutPayment","JSON","stringify","doUPIPayment","doWebPayment","cfSession","doCardPayment","cardPayment","makePayment","getInstalledUpiApps","Promise","resolve","reject","fetchUpiList","apps","console","log","upiAppsSubscription","addListener","cfPayment","paymentData","doElementUPIPayment","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","removeEventSubscriber","undefined","remove","setCallback","cfCallback","successFunction","orderID","onVerify","failureFunction","error","response","CFErrorResponse","message","fromJSON","onError","successSubscription","failureSubscription","removeCallback","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","CFCard","CFPaymentGatewayService"],"sources":["index.js"],"sourcesContent":["import { NativeAppEventEmitter, NativeEventEmitter, NativeModules, Platform, } from 'react-native';\nimport { version } from '../package.json';\nimport { CFUPIPayment, CFCardPayment } from 'cashfree-pg-api-contract';\nimport CFCardComponent from './Card/CFCardComponent';\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 upiAppsSubscription = 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 doUPIPayment(checkoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));\n }\n doWebPayment(cfSession) {\n CashfreePgApi.doWebPayment(JSON.stringify(cfSession));\n }\n /**\n * @deprecated : Instead call makePayment\n */\n doCardPayment(cardPayment) {\n this.makePayment(cardPayment);\n }\n async getInstalledUpiApps() {\n return new Promise((resolve, reject) => {\n if (Platform.OS === 'ios') {\n let fetchUpiList = (apps) => {\n console.log(JSON.stringify(apps));\n if (apps) {\n resolve(apps);\n }\n else {\n reject('No UPI apps found');\n }\n };\n this.upiAppsSubscription = this.emitter.addListener('cfUpiApps', fetchUpiList);\n CashfreePgApi.getInstalledUpiApps();\n }\n else {\n CashfreePgApi.getInstalledUpiApps((apps) => {\n if (apps) {\n resolve(apps);\n }\n else {\n reject('No UPI apps found');\n }\n });\n }\n });\n }\n makePayment(cfPayment) {\n cfPayment.version = version;\n const paymentData = JSON.stringify(cfPayment);\n if (cfPayment instanceof CFUPIPayment) {\n CashfreePgApi.doElementUPIPayment(paymentData);\n }\n else if (cfPayment instanceof CFCardPayment) {\n CashfreePgApi.doCardPayment(paymentData);\n }\n else {\n console.log('makePayment::==> Wrong payment object');\n }\n }\n setEventSubscriber(cfEventCallback) {\n let eventFunction = (event) => {\n console.log(JSON.stringify(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 removeEventSubscriber() {\n if (this.eventSubscription !== undefined &&\n this.eventSubscription !== null) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\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 if (this.upiAppsSubscription !== undefined &&\n this.upiAppsSubscription !== null) {\n this.upiAppsSubscription.remove();\n this.upiAppsSubscription = 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 CFCard = CFCardComponent;\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;AAAA,SAASA,qBAAqB,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAS,cAAc;AAClG,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,YAAY,EAAEC,aAAa,QAAQ,0BAA0B;AACtE,OAAOC,eAAe,MAAM,wBAAwB;AACpD,MAAMC,aAAa,GAAG,uFAAuF,GACzGL,QAAQ,CAACM,MAAM,CAAC;EAAEC,GAAG,EAAE,kCAAkC;EAAEC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AGF,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,MAAM,GAAG3E,eAAe;AACrC,OAAO,MAAM4E,uBAAuB,GAAG,IAAInE,gBAAgB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["NativeAppEventEmitter","NativeEventEmitter","NativeModules","Platform","version","CFUPIPayment","CFCardPayment","CFCardComponent","LINKING_ERROR","select","ios","default","CashfreePgApi","Proxy","get","Error","CFPaymentGateway","constructor","_defineProperty","emitter","OS","CashfreeEventEmitter","doPayment","checkoutPayment","JSON","stringify","doUPIPayment","doWebPayment","cfSession","doSubscriptionPayment","doCardPayment","cardPayment","makePayment","getInstalledUpiApps","Promise","resolve","reject","fetchUpiList","apps","console","log","upiAppsSubscription","addListener","cfPayment","paymentData","doElementUPIPayment","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","removeEventSubscriber","undefined","remove","setCallback","cfCallback","successFunction","orderID","onVerify","failureFunction","error","response","CFErrorResponse","message","fromJSON","onError","successSubscription","failureSubscription","removeCallback","errorString","object","status","code","type","getStatus","getMessage","getCode","getType","CFCard","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 {\n type CheckoutPayment,\n type CFSession,\n type CFSubscriptionSession,\n CFUPIPayment,\n CFCardPayment,\n} from 'cashfree-pg-api-contract';\nimport CFCardComponent from './Card/CFCardComponent';\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 private upiAppsSubscription: 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 doUPIPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));\n }\n\n doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(JSON.stringify(cfSession));\n }\n\n doSubscriptionPayment(cfSession: CFSubscriptionSession) {\n CashfreePgApi.doSubscriptionPayment(JSON.stringify(cfSession));\n }\n\n /**\n * @deprecated : Instead call makePayment\n */\n doCardPayment(cardPayment: CheckoutPayment) {\n this.makePayment(cardPayment);\n }\n\n async getInstalledUpiApps() {\n return new Promise((resolve, reject) => {\n if (Platform.OS === 'ios') {\n let fetchUpiList = (apps: string) => {\n console.log(JSON.stringify(apps));\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n };\n this.upiAppsSubscription = this.emitter.addListener(\n 'cfUpiApps',\n fetchUpiList\n );\n CashfreePgApi.getInstalledUpiApps();\n } else {\n CashfreePgApi.getInstalledUpiApps((apps: string) => {\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n });\n }\n });\n }\n\n makePayment(cfPayment: CheckoutPayment) {\n cfPayment.version = version;\n const paymentData = JSON.stringify(cfPayment);\n if (cfPayment instanceof CFUPIPayment) {\n CashfreePgApi.doElementUPIPayment(paymentData);\n } else if (cfPayment instanceof CFCardPayment) {\n CashfreePgApi.doCardPayment(paymentData);\n } else {\n console.log('makePayment::==> Wrong payment object');\n }\n }\n\n setEventSubscriber(cfEventCallback: CFEventCallback) {\n let eventFunction = (event: string) => {\n console.log(JSON.stringify(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 (\n this.eventSubscription !== undefined &&\n this.eventSubscription !== null\n ) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\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 if (\n this.upiAppsSubscription !== undefined &&\n this.upiAppsSubscription !== null\n ) {\n this.upiAppsSubscription.remove();\n this.upiAppsSubscription = 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 CFCard = CFCardComponent;\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;AAAA,SAGEA,qBAAqB,EACrBC,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QACH,cAAc;AACrB,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAIEC,YAAY,EACZC,aAAa,QACR,0BAA0B;AACjC,OAAOC,eAAe,MAAM,wBAAwB;AAEpD,MAAMC,aAAa,GACjB,uFAAuF,GACvFL,QAAQ,CAACM,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,aAAa,GAAGV,aAAa,CAACU,aAAa,GAC7CV,aAAa,CAACU,aAAa,GAC3B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,MAAMQ,gBAAgB,CAAC;EAOrBC,WAAWA,CAAA,EAAG;IAAAC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AO;EACrB;EAEAa,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;EAEAK,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;AACF;AAEA,OAAO,MAAMK,MAAM,GAAG5E,eAAe;AACrC,OAAO,MAAM6E,uBAAuB,GAAG,IAAIpE,gBAAgB,CAAC,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { type CheckoutPayment, type CFSession } from 'cashfree-pg-api-contract';
1
+ import { type CheckoutPayment, type CFSession, type CFSubscriptionSession } from 'cashfree-pg-api-contract';
2
2
  declare class CFPaymentGateway {
3
3
  private emitter;
4
4
  private successSubscription;
@@ -9,6 +9,7 @@ declare class CFPaymentGateway {
9
9
  doPayment(checkoutPayment: CheckoutPayment): void;
10
10
  doUPIPayment(checkoutPayment: CheckoutPayment): void;
11
11
  doWebPayment(cfSession: CFSession): void;
12
+ doSubscriptionPayment(cfSession: CFSubscriptionSession): void;
12
13
  /**
13
14
  * @deprecated : Instead call makePayment
14
15
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-cashfree-pg-sdk",
3
- "version": "2.2.3",
3
+ "version": "2.2.4-dev.0",
4
4
  "description": "Cashfree PG Plugin for React Native",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -152,6 +152,6 @@
152
152
  ]
153
153
  },
154
154
  "dependencies": {
155
- "cashfree-pg-api-contract": "^2.0.7"
155
+ "cashfree-pg-api-contract": "^2.0.8"
156
156
  }
157
157
  }
package/src/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { NativeAppEventEmitter, NativeEventEmitter, NativeModules, Platform, } from 'react-native';
2
2
  import { version } from '../package.json';
3
- import { CFUPIPayment, CFCardPayment } from 'cashfree-pg-api-contract';
3
+ import { CFUPIPayment, CFCardPayment, } from 'cashfree-pg-api-contract';
4
4
  import CFCardComponent from './Card/CFCardComponent';
5
5
  const LINKING_ERROR = `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` +
6
- Platform.select({ ios: '- You have run \'pod install\'\n', default: '' }) +
6
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
7
7
  '- You rebuilt the app after installing the package\n' +
8
8
  '- You are not using Expo managed workflow\n';
9
9
  const CashfreePgApi = NativeModules.CashfreePgApi
@@ -36,6 +36,9 @@ class CFPaymentGateway {
36
36
  doWebPayment(cfSession) {
37
37
  CashfreePgApi.doWebPayment(JSON.stringify(cfSession));
38
38
  }
39
+ doSubscriptionPayment(cfSession) {
40
+ CashfreePgApi.doSubscriptionPayment(JSON.stringify(cfSession));
41
+ }
39
42
  /**
40
43
  * @deprecated : Instead call makePayment
41
44
  */
package/src/index.ts CHANGED
@@ -7,25 +7,31 @@ import {
7
7
  Platform,
8
8
  } from 'react-native';
9
9
  import { version } from '../package.json';
10
- import { type CheckoutPayment, type CFSession, CFUPIPayment, CFCardPayment } from 'cashfree-pg-api-contract';
10
+ import {
11
+ type CheckoutPayment,
12
+ type CFSession,
13
+ type CFSubscriptionSession,
14
+ CFUPIPayment,
15
+ CFCardPayment,
16
+ } from 'cashfree-pg-api-contract';
11
17
  import CFCardComponent from './Card/CFCardComponent';
12
18
 
13
19
  const LINKING_ERROR =
14
20
  `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` +
15
- Platform.select({ ios: '- You have run \'pod install\'\n', default: '' }) +
21
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
16
22
  '- You rebuilt the app after installing the package\n' +
17
23
  '- You are not using Expo managed workflow\n';
18
24
 
19
25
  const CashfreePgApi = NativeModules.CashfreePgApi
20
26
  ? NativeModules.CashfreePgApi
21
27
  : new Proxy(
22
- {},
23
- {
24
- get() {
25
- throw new Error(LINKING_ERROR);
26
- },
27
- },
28
- );
28
+ {},
29
+ {
30
+ get() {
31
+ throw new Error(LINKING_ERROR);
32
+ },
33
+ }
34
+ );
29
35
 
30
36
  class CFPaymentGateway {
31
37
  private emitter: EventEmitter;
@@ -55,6 +61,10 @@ class CFPaymentGateway {
55
61
  CashfreePgApi.doWebPayment(JSON.stringify(cfSession));
56
62
  }
57
63
 
64
+ doSubscriptionPayment(cfSession: CFSubscriptionSession) {
65
+ CashfreePgApi.doSubscriptionPayment(JSON.stringify(cfSession));
66
+ }
67
+
58
68
  /**
59
69
  * @deprecated : Instead call makePayment
60
70
  */
@@ -64,7 +74,7 @@ class CFPaymentGateway {
64
74
 
65
75
  async getInstalledUpiApps() {
66
76
  return new Promise((resolve, reject) => {
67
- if(Platform.OS === 'ios'){
77
+ if (Platform.OS === 'ios') {
68
78
  let fetchUpiList = (apps: string) => {
69
79
  console.log(JSON.stringify(apps));
70
80
  if (apps) {
@@ -73,10 +83,12 @@ class CFPaymentGateway {
73
83
  reject('No UPI apps found');
74
84
  }
75
85
  };
76
- this.upiAppsSubscription = this.emitter.addListener('cfUpiApps', fetchUpiList);
77
- CashfreePgApi.getInstalledUpiApps()
78
- }
79
- else {
86
+ this.upiAppsSubscription = this.emitter.addListener(
87
+ 'cfUpiApps',
88
+ fetchUpiList
89
+ );
90
+ CashfreePgApi.getInstalledUpiApps();
91
+ } else {
80
92
  CashfreePgApi.getInstalledUpiApps((apps: string) => {
81
93
  if (apps) {
82
94
  resolve(apps);
@@ -138,11 +150,11 @@ class CFPaymentGateway {
138
150
  };
139
151
  this.successSubscription = this.emitter.addListener(
140
152
  'cfSuccess',
141
- successFunction,
153
+ successFunction
142
154
  );
143
155
  this.failureSubscription = this.emitter.addListener(
144
156
  'cfFailure',
145
- failureFunction,
157
+ failureFunction
146
158
  );
147
159
  CashfreePgApi.setCallback();
148
160
  }
@@ -215,5 +227,5 @@ export class CFErrorResponse {
215
227
  }
216
228
  }
217
229
 
218
- export const CFCard = CFCardComponent
230
+ export const CFCard = CFCardComponent;
219
231
  export const CFPaymentGatewayService = new CFPaymentGateway();