react-native-cashfree-pg-sdk 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -67,7 +67,7 @@ If you want to contribute please read the [Contributing](CONTRIBUTING.md) guidel
67
67
 
68
68
  ## License
69
69
  <pre>
70
- The Crowdin React Native SDK is licensed under the MIT License.
70
+ The Cashfree React Native SDK is licensed under the MIT License.
71
71
  See the LICENSE file distributed with this work for additional
72
72
  information regarding copyright ownership.
73
73
 
@@ -0,0 +1,3 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
@@ -16,6 +16,7 @@ import com.cashfree.pg.core.api.exception.CFException;
16
16
  import com.cashfree.pg.core.api.utils.CFErrorResponse;
17
17
  import com.cashfree.pg.core.api.webcheckout.CFWebCheckoutPayment;
18
18
  import com.cashfree.pg.ui.api.CFDropCheckoutPayment;
19
+ import com.cashfree.pg.ui.api.upi.intent.CFUPIIntentCheckoutPayment;
19
20
  import com.facebook.react.bridge.ReactApplicationContext;
20
21
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
21
22
  import com.facebook.react.bridge.ReactMethod;
@@ -30,129 +31,147 @@ import java.util.Map;
30
31
 
31
32
  @ReactModule(name = CashfreePgApiModule.NAME)
32
33
  public class CashfreePgApiModule extends ReactContextBaseJavaModule implements CFCheckoutResponseCallback, CFEventsSubscriber {
33
- public static final String NAME = "CashfreePgApi";
34
-
35
- public CashfreePgApiModule(ReactApplicationContext reactContext) {
36
- super(reactContext);
37
- }
38
-
39
- @Override
40
- @NonNull
41
- public String getName() {
42
- return NAME;
43
- }
44
-
45
- @ReactMethod
46
- public void doPayment(String cfPaymentString) {
47
- Log.d("CashfreePgApiModule", cfPaymentString);
48
- try {
49
- Activity activity = getCurrentActivity();
50
- CFDropCheckoutPayment cfDropCheckoutPayment = DropPaymentParser.getDropCheckoutPayment(cfPaymentString);
51
- cfDropCheckoutPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
52
- cfDropCheckoutPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.DROP);
53
- if (activity != null) {
54
- CFPaymentGatewayService.getInstance().doPayment(activity, cfDropCheckoutPayment);
55
- } else {
56
- throw new IllegalStateException("activity is null");
57
- }
58
- } catch (Exception e) {
59
- e.printStackTrace();
34
+ public static final String NAME = "CashfreePgApi";
35
+
36
+ public CashfreePgApiModule(ReactApplicationContext reactContext) {
37
+ super(reactContext);
60
38
  }
61
- }
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");
39
+
40
+ @Override
41
+ @NonNull
42
+ public String getName() {
43
+ return NAME;
76
44
  }
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();
45
+
46
+ @ReactMethod
47
+ public void doPayment(String cfPaymentString) {
48
+ Log.d("CashfreePgApiModule", cfPaymentString);
49
+ try {
50
+ Activity activity = getCurrentActivity();
51
+ CFDropCheckoutPayment cfDropCheckoutPayment = DropPaymentParser.getDropCheckoutPayment(cfPaymentString);
52
+ cfDropCheckoutPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
53
+ cfDropCheckoutPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.DROP);
54
+ if (activity != null) {
55
+ CFPaymentGatewayService.getInstance().doPayment(activity, cfDropCheckoutPayment);
56
+ } else {
57
+ throw new IllegalStateException("activity is null");
58
+ }
59
+ } catch (Exception e) {
60
+ e.printStackTrace();
61
+ }
91
62
  }
92
- }
93
63
 
94
- @ReactMethod
95
- public void setCallback() {
96
- try {
97
- CFPaymentGatewayService.getInstance().setCheckoutCallback(this);
98
- } catch (CFException cfException) {
64
+ @ReactMethod
65
+ public void doUPIPayment(String cfPaymentString) {
66
+ Log.d("CashfreePgApiModule", cfPaymentString);
67
+ try {
68
+ Activity activity = getCurrentActivity();
69
+ CFUPIIntentCheckoutPayment cfupiIntentCheckoutPayment = DropPaymentParser.getUPICheckoutPayment(cfPaymentString);
70
+ cfupiIntentCheckoutPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
71
+ cfupiIntentCheckoutPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.DROP);
72
+ if (activity != null) {
73
+ CFPaymentGatewayService.getInstance().doPayment(activity, cfupiIntentCheckoutPayment);
74
+ } else {
75
+ throw new IllegalStateException("activity is null");
76
+ }
77
+ } catch (Exception e) {
78
+ e.printStackTrace();
79
+ }
99
80
  }
100
- }
101
81
 
102
- @ReactMethod
103
- public void setEventSubscriber() {
104
- try {
105
- CFAnalyticsService.getInstance().setSubscriber(this);
106
- } catch (Exception ignored) {
82
+ @ReactMethod
83
+ public void doWebPayment(String sessionString) {
84
+ Log.d("CashfreePgApiModule Web", sessionString);
85
+ CFSession cfSession = null;
86
+ try {
87
+ JSONObject jsonObject = new JSONObject(sessionString);
88
+ cfSession = new CFSession.CFSessionBuilder()
89
+ .setEnvironment(CFSession.Environment.valueOf(jsonObject.getString("environment")))
90
+ .setOrderId(jsonObject.getString("orderID"))
91
+ .setPaymentSessionID(jsonObject.getString("payment_session_id"))
92
+ .build();
93
+ } catch (Exception exception) {
94
+ throw new IllegalStateException("Session is invalid");
95
+ }
96
+ try {
97
+ Activity activity = getCurrentActivity();
98
+ CFWebCheckoutPayment cfWebCheckoutPayment = new CFWebCheckoutPayment.CFWebCheckoutPaymentBuilder()
99
+ .setSession(cfSession)
100
+ .build();
101
+ cfWebCheckoutPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
102
+ cfWebCheckoutPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.WEB_CHECKOUT);
103
+ if (activity != null) {
104
+ CFPaymentGatewayService.getInstance().doPayment(activity, cfWebCheckoutPayment);
105
+ } else {
106
+ throw new IllegalStateException("activity is null");
107
+ }
108
+ } catch (Exception e) {
109
+ e.printStackTrace();
110
+ }
107
111
  }
108
- }
109
112
 
110
- @ReactMethod
111
- public void removeEventSubscriber() {
112
- try {
113
- CFAnalyticsService.getInstance().removeSubscriber();
114
- } catch (Exception ignored) {
113
+ @ReactMethod
114
+ public void setCallback() {
115
+ try {
116
+ CFPaymentGatewayService.getInstance().setCheckoutCallback(this);
117
+ } catch (CFException cfException) {
118
+ }
115
119
  }
116
- }
117
-
118
- @Override
119
- public void onPaymentVerify(String orderID) {
120
- this.getReactApplicationContext()
121
- .getJSModule(RCTNativeAppEventEmitter.class)
122
- .emit("cfSuccess", orderID);
123
- }
124
-
125
- @Override
126
- public void onPaymentFailure(CFErrorResponse cfErrorResponse, String orderID) {
127
- JSONObject jsonObject = new JSONObject();
128
- try {
129
- jsonObject.put("error", cfErrorResponse.toJSON().toString());
130
- jsonObject.put("orderID", orderID);
131
- } catch (JSONException e) {
132
- e.printStackTrace();
120
+
121
+ @ReactMethod
122
+ public void setEventSubscriber() {
123
+ try {
124
+ CFAnalyticsService.getInstance().setSubscriber(this);
125
+ } catch (Exception ignored) {
126
+ }
133
127
  }
134
- this.getReactApplicationContext()
135
- .getJSModule(RCTNativeAppEventEmitter.class)
136
- .emit("cfFailure", jsonObject.toString());
137
- }
138
-
139
- @Override
140
- public void receivedEvent(String s, @Nullable Map<String, String> map) {
141
- JSONObject jsonObject = new JSONObject();
142
- JSONObject jsonMeta = new JSONObject();
143
- try {
144
- if (map != null) {
145
- for (String key : map.keySet()) {
146
- jsonMeta.put(key, map.get(key));
128
+
129
+ @ReactMethod
130
+ public void removeEventSubscriber() {
131
+ try {
132
+ CFAnalyticsService.getInstance().removeSubscriber();
133
+ } catch (Exception ignored) {
134
+ }
135
+ }
136
+
137
+ @Override
138
+ public void onPaymentVerify(String orderID) {
139
+ this.getReactApplicationContext()
140
+ .getJSModule(RCTNativeAppEventEmitter.class)
141
+ .emit("cfSuccess", orderID);
142
+ }
143
+
144
+ @Override
145
+ public void onPaymentFailure(CFErrorResponse cfErrorResponse, String orderID) {
146
+ JSONObject jsonObject = new JSONObject();
147
+ try {
148
+ jsonObject.put("error", cfErrorResponse.toJSON().toString());
149
+ jsonObject.put("orderID", orderID);
150
+ } catch (JSONException e) {
151
+ e.printStackTrace();
152
+ }
153
+ this.getReactApplicationContext()
154
+ .getJSModule(RCTNativeAppEventEmitter.class)
155
+ .emit("cfFailure", jsonObject.toString());
156
+ }
157
+
158
+ @Override
159
+ public void receivedEvent(String s, @Nullable Map<String, String> map) {
160
+ JSONObject jsonObject = new JSONObject();
161
+ JSONObject jsonMeta = new JSONObject();
162
+ try {
163
+ if (map != null) {
164
+ for (String key : map.keySet()) {
165
+ jsonMeta.put(key, map.get(key));
166
+ }
167
+ }
168
+ jsonObject.put("eventName", s);
169
+ jsonObject.put("meta", jsonMeta);
170
+ } catch (JSONException e) {
171
+ e.printStackTrace();
147
172
  }
148
- }
149
- jsonObject.put("eventName", s);
150
- jsonObject.put("meta", jsonMeta);
151
- } catch (JSONException e) {
152
- e.printStackTrace();
173
+ this.getReactApplicationContext()
174
+ .getJSModule(RCTNativeAppEventEmitter.class)
175
+ .emit("cfEvent", jsonObject.toString());
153
176
  }
154
- this.getReactApplicationContext()
155
- .getJSModule(RCTNativeAppEventEmitter.class)
156
- .emit("cfEvent", jsonObject.toString());
157
- }
158
177
  }
package/ios/.DS_Store ADDED
Binary file
@@ -5,6 +5,8 @@
5
5
 
6
6
  RCT_EXTERN_METHOD(doPayment:(NSString)paymentObject)
7
7
 
8
+ RCT_EXTERN_METHOD(doUPIPayment:(NSString)paymentObject)
9
+
8
10
  RCT_EXTERN_METHOD(doWebPayment:(NSString)paymentObject)
9
11
 
10
12
  RCT_EXTERN_METHOD(setCallback)
@@ -28,6 +28,19 @@ class CashfreePgApi: NSObject {
28
28
  }
29
29
  }
30
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
+
31
44
  @objc func doWebPayment(_ paymentObject: NSString) -> Void {
32
45
  do {
33
46
  if let sessionObj = try parseWebPayment(paymentObject: "\(paymentObject)") {
@@ -83,6 +96,33 @@ class CashfreePgApi: NSObject {
83
96
  return nil
84
97
  }
85
98
 
99
+ private func parseUPIPayment(paymentObject: String) throws -> CFDropCheckoutPayment? {
100
+ // print(paymentObject)
101
+ let data = paymentObject.data(using: .utf8)!
102
+ if let output = try! JSONSerialization.jsonObject(with: data, options: .allowFragments) as? Dictionary<String, Any> {
103
+ do {
104
+ let session = getSession(paymentObject: output)
105
+ let paymentComponents = try CFPaymentComponent.CFPaymentComponentBuilder()
106
+ .enableComponents(["upi"])
107
+ .build()
108
+ let theme = getTheme(paymentObject: output)
109
+
110
+ let nativePayment = try CFDropCheckoutPayment.CFDropCheckoutPaymentBuilder()
111
+ .setSession(session!)
112
+ .setTheme(theme!)
113
+ .setComponent(paymentComponents)
114
+ .build()
115
+ return nativePayment
116
+
117
+ } catch let e {
118
+ let error = e as! CashfreeError
119
+ print(error.localizedDescription)
120
+ // Handle errors here
121
+ }
122
+ }
123
+ return nil
124
+ }
125
+
86
126
  private func parseWebPayment(paymentObject: String) throws -> CFSession? {
87
127
  // print(paymentObject)
88
128
  let data = paymentObject.data(using: .utf8)!
@@ -30,6 +30,10 @@ class CFPaymentGateway {
30
30
  checkoutPayment.version = _package.version;
31
31
  CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));
32
32
  }
33
+ doUPIPayment(checkoutPayment) {
34
+ checkoutPayment.version = _package.version;
35
+ CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));
36
+ }
33
37
  doWebPayment(cfSession) {
34
38
  CashfreePgApi.doWebPayment(cfSession);
35
39
  }
@@ -1 +1 @@
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","console","log","data","parse","onReceivedEvent","eventName","meta","eventSubscription","addListener","removeEventSubscriber","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","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, CFSession } from 'cashfree-pg-api-contract';\n\nconst LINKING_ERROR =\n `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst CashfreePgApi = NativeModules.CashfreePgApi\n ? NativeModules.CashfreePgApi\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nclass CFPaymentGateway {\n private emitter: EventEmitter;\n private successSubscription: EmitterSubscription | null = null;\n private failureSubscription: EmitterSubscription | null = null;\n private eventSubscription: EmitterSubscription | null = null;\n\n constructor() {\n this.emitter =\n Platform.OS === 'ios'\n ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter)\n : NativeAppEventEmitter;\n }\n\n doPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));\n }\n\n doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(cfSession);\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 }\n}\n\nexport interface CFCallback {\n onVerify(orderID: string): void;\n\n onError(error: CFErrorResponse, orderID: string): void;\n}\n\nexport interface CFEventCallback {\n onReceivedEvent(eventName: string, map: Map<string, string>): void;\n}\n\nexport class CFErrorResponse {\n private status: string = 'FAILED';\n private message: string = 'payment has failed';\n private code: string = 'payment_failed';\n private type: string = 'request_failed';\n\n fromJSON(errorString: string) {\n console.log('errorString :' + errorString);\n const object = JSON.parse(errorString);\n console.log('errorStringObject :' + object);\n this.status = object.status;\n this.message = object.message;\n this.code = object.code;\n this.type = object.type;\n }\n\n getStatus(): string {\n return this.status;\n }\n\n getMessage(): string {\n return this.message;\n }\n\n getCode(): string {\n return this.code;\n }\n\n getType(): string {\n return this.type;\n }\n}\n\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAQA,IAAAC,QAAA,GAAAD,OAAA;AAA0C,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GA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AO,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,uBAAuB,GAAG,IAAItD,gBAAgB,EAAE;AAACqD,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
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","doUPIPayment","doWebPayment","cfSession","setEventSubscriber","cfEventCallback","eventFunction","event","console","log","data","parse","onReceivedEvent","eventName","meta","eventSubscription","addListener","removeEventSubscriber","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","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 doUPIPayment(checkoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));\n }\n doWebPayment(cfSession) {\n CashfreePgApi.doWebPayment(cfSession);\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 }\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,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAA0C,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAA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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,IAAIvD,gBAAgB,EAAE;AAACsD,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
@@ -24,6 +24,10 @@ class CFPaymentGateway {
24
24
  checkoutPayment.version = version;
25
25
  CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));
26
26
  }
27
+ doUPIPayment(checkoutPayment) {
28
+ checkoutPayment.version = version;
29
+ CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));
30
+ }
27
31
  doWebPayment(cfSession) {
28
32
  CashfreePgApi.doWebPayment(cfSession);
29
33
  }
@@ -1 +1 @@
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","console","log","data","parse","onReceivedEvent","eventName","meta","eventSubscription","addListener","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","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, CFSession } from 'cashfree-pg-api-contract';\n\nconst LINKING_ERROR =\n `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst CashfreePgApi = NativeModules.CashfreePgApi\n ? NativeModules.CashfreePgApi\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nclass CFPaymentGateway {\n private emitter: EventEmitter;\n private successSubscription: EmitterSubscription | null = null;\n private failureSubscription: EmitterSubscription | null = null;\n private eventSubscription: EmitterSubscription | null = null;\n\n constructor() {\n this.emitter =\n Platform.OS === 'ios'\n ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter)\n : NativeAppEventEmitter;\n }\n\n doPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));\n }\n\n doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(cfSession);\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 }\n}\n\nexport interface CFCallback {\n onVerify(orderID: string): void;\n\n onError(error: CFErrorResponse, orderID: string): void;\n}\n\nexport interface CFEventCallback {\n onReceivedEvent(eventName: string, map: Map<string, string>): void;\n}\n\nexport class CFErrorResponse {\n private status: string = 'FAILED';\n private message: string = 'payment has failed';\n private code: string = 'payment_failed';\n private type: string = 'request_failed';\n\n fromJSON(errorString: string) {\n console.log('errorString :' + errorString);\n const object = JSON.parse(errorString);\n console.log('errorStringObject :' + object);\n this.status = object.status;\n this.message = object.message;\n this.code = object.code;\n this.type = object.type;\n }\n\n getStatus(): string {\n return this.status;\n }\n\n getMessage(): string {\n return this.message;\n }\n\n getCode(): string {\n return this.code;\n }\n\n getType(): string {\n return this.type;\n }\n}\n\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;AAAA,SAGEA,qBAAqB,EACrBC,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QACH,cAAc;AACrB,SAASC,OAAO,QAAQ,iBAAiB;AAGzC,MAAMC,aAAa,GAChB,uFAAsF,GACvFF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,aAAa,GAAGP,aAAa,CAACO,aAAa,GAC7CP,aAAa,CAACO,aAAa,GAC3B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAA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mBAAmB,GAAG,IAAI;IACjC;EACF;AACF;AAYA,OAAO,MAAML,eAAe,CAAC;EAAAnC,YAAA;IAAAC,eAAA,iBACF,QAAQ;IAAAA,eAAA,kBACP,oBAAoB;IAAAA,eAAA,eACvB,gBAAgB;IAAAA,eAAA,eAChB,gBAAgB;EAAA;EAEvCoC,QAAQA,CAACK,WAAmB,EAAE;IAC5B3B,OAAO,CAACC,GAAG,CAAC,eAAe,GAAG0B,WAAW,CAAC;IAC1C,MAAMC,MAAM,GAAGpC,IAAI,CAACW,KAAK,CAACwB,WAAW,CAAC;IACtC3B,OAAO,CAACC,GAAG,CAAC,qBAAqB,GAAG2B,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;AAEA,OAAO,MAAMK,uBAAuB,GAAG,IAAIpD,gBAAgB,EAAE"}
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","doUPIPayment","doWebPayment","cfSession","setEventSubscriber","cfEventCallback","eventFunction","event","console","log","data","parse","onReceivedEvent","eventName","meta","eventSubscription","addListener","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","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 doUPIPayment(checkoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));\n }\n doWebPayment(cfSession) {\n CashfreePgApi.doWebPayment(cfSession);\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 }\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,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,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,KAA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IACA,IAAI,IAAI,CAACC,mBAAmB,KAAKf,SAAS,IACtC,IAAI,CAACe,mBAAmB,KAAK,IAAI,EAAE;MACnC,IAAI,CAACA,mBAAmB,CAACd,MAAM,EAAE;MACjC,IAAI,CAACc,mBAAmB,GAAG,IAAI;IACnC;EACJ;AACJ;AACA,OAAO,MAAML,eAAe,CAAC;EAAApC,YAAA;IAAAC,eAAA,iBAChB,QAAQ;IAAAA,eAAA,kBACP,oBAAoB;IAAAA,eAAA,eACvB,gBAAgB;IAAAA,eAAA,eAChB,gBAAgB;EAAA;EACvBqC,QAAQA,CAACK,WAAW,EAAE;IAClB3B,OAAO,CAACC,GAAG,CAAC,eAAe,GAAG0B,WAAW,CAAC;IAC1C,MAAMC,MAAM,GAAGrC,IAAI,CAACY,KAAK,CAACwB,WAAW,CAAC;IACtC3B,OAAO,CAACC,GAAG,CAAC,qBAAqB,GAAG2B,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,IAAIrD,gBAAgB,EAAE"}
@@ -6,6 +6,7 @@ declare class CFPaymentGateway {
6
6
  private eventSubscription;
7
7
  constructor();
8
8
  doPayment(checkoutPayment: CheckoutPayment): void;
9
+ doUPIPayment(checkoutPayment: CheckoutPayment): void;
9
10
  doWebPayment(cfSession: CFSession): void;
10
11
  setEventSubscriber(cfEventCallback: CFEventCallback): void;
11
12
  removeEventSubscriber(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-cashfree-pg-sdk",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "Cashfree PG Plugin for React Native",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -145,6 +145,6 @@
145
145
  ]
146
146
  },
147
147
  "dependencies": {
148
- "cashfree-pg-api-contract": "2.0.2"
148
+ "cashfree-pg-api-contract": "2.0.3-dev.0"
149
149
  }
150
150
  }
package/src/index.js CHANGED
@@ -26,6 +26,10 @@ class CFPaymentGateway {
26
26
  checkoutPayment.version = version;
27
27
  CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));
28
28
  }
29
+ doUPIPayment(checkoutPayment) {
30
+ checkoutPayment.version = version;
31
+ CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));
32
+ }
29
33
  doWebPayment(cfSession) {
30
34
  CashfreePgApi.doWebPayment(cfSession);
31
35
  }
package/src/index.ts CHANGED
@@ -44,6 +44,11 @@ class CFPaymentGateway {
44
44
  CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));
45
45
  }
46
46
 
47
+ doUPIPayment(checkoutPayment: CheckoutPayment) {
48
+ checkoutPayment.version = version;
49
+ CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));
50
+ }
51
+
47
52
  doWebPayment(cfSession: CFSession) {
48
53
  CashfreePgApi.doWebPayment(cfSession);
49
54
  }