react-native-cashfree-pg-sdk 2.2.6 → 2.3.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.
Files changed (91) hide show
  1. package/README.md +2 -1
  2. package/android/.project +34 -0
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/com/reactnativecashfreepgsdk/CashfreePgApiModule.java +317 -195
  5. package/ios/CashfreePgApi.m +3 -0
  6. package/ios/CashfreePgApi.swift +117 -1
  7. package/lib/commonjs/Card/CFCardComponent.js +1 -2
  8. package/lib/commonjs/Card/CFCardComponent.js.map +1 -1
  9. package/lib/commonjs/Card/index.js.map +1 -1
  10. package/lib/commonjs/index.js +13 -1
  11. package/lib/commonjs/index.js.map +1 -1
  12. package/lib/module/Card/CFCardComponent.js +4 -8
  13. package/lib/module/Card/CFCardComponent.js.map +1 -1
  14. package/lib/module/Card/index.js.map +1 -1
  15. package/lib/module/index.js +14 -1
  16. package/lib/module/index.js.map +1 -1
  17. package/lib/typescript/src/index.d.ts +1 -0
  18. package/package.json +9 -2
  19. package/react-native-cashfree-pg-sdk.podspec +1 -1
  20. package/src/index.js +17 -1
  21. package/src/index.ts +17 -0
  22. package/android/.gradle/8.10.2/checksums/checksums.lock +0 -0
  23. package/android/.gradle/8.10.2/checksums/md5-checksums.bin +0 -0
  24. package/android/.gradle/8.10.2/checksums/sha1-checksums.bin +0 -0
  25. package/android/.gradle/8.10.2/dependencies-accessors/gc.properties +0 -0
  26. package/android/.gradle/8.10.2/executionHistory/executionHistory.lock +0 -0
  27. package/android/.gradle/8.10.2/fileChanges/last-build.bin +0 -0
  28. package/android/.gradle/8.10.2/fileHashes/fileHashes.bin +0 -0
  29. package/android/.gradle/8.10.2/fileHashes/fileHashes.lock +0 -0
  30. package/android/.gradle/8.10.2/fileHashes/resourceHashesCache.bin +0 -0
  31. package/android/.gradle/8.10.2/gc.properties +0 -0
  32. package/android/.gradle/8.12/checksums/checksums.lock +0 -0
  33. package/android/.gradle/8.12/checksums/md5-checksums.bin +0 -0
  34. package/android/.gradle/8.12/checksums/sha1-checksums.bin +0 -0
  35. package/android/.gradle/8.12/fileChanges/last-build.bin +0 -0
  36. package/android/.gradle/8.12/fileHashes/fileHashes.bin +0 -0
  37. package/android/.gradle/8.12/fileHashes/fileHashes.lock +0 -0
  38. package/android/.gradle/8.12/gc.properties +0 -0
  39. package/android/.gradle/8.7/checksums/checksums.lock +0 -0
  40. package/android/.gradle/8.7/checksums/md5-checksums.bin +0 -0
  41. package/android/.gradle/8.7/checksums/sha1-checksums.bin +0 -0
  42. package/android/.gradle/8.7/dependencies-accessors/gc.properties +0 -0
  43. package/android/.gradle/8.7/executionHistory/executionHistory.bin +0 -0
  44. package/android/.gradle/8.7/executionHistory/executionHistory.lock +0 -0
  45. package/android/.gradle/8.7/fileChanges/last-build.bin +0 -0
  46. package/android/.gradle/8.7/fileHashes/fileHashes.bin +0 -0
  47. package/android/.gradle/8.7/fileHashes/fileHashes.lock +0 -0
  48. package/android/.gradle/8.7/fileHashes/resourceHashesCache.bin +0 -0
  49. package/android/.gradle/8.7/gc.properties +0 -0
  50. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  51. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  52. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  53. package/android/.gradle/checksums/checksums.lock +0 -0
  54. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  55. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  56. package/android/.gradle/config.properties +0 -2
  57. package/android/.gradle/configuration-cache/gc.properties +0 -0
  58. package/android/.gradle/file-system.probe +0 -0
  59. package/android/.gradle/vcs-1/gc.properties +0 -0
  60. package/android/.idea/caches/deviceStreaming.xml +0 -1414
  61. package/android/.idea/compiler.xml +0 -6
  62. package/android/.idea/copilot.data.migration.ask2agent.xml +0 -6
  63. package/android/.idea/gradle.xml +0 -19
  64. package/android/.idea/jarRepositories.xml +0 -50
  65. package/android/.idea/kotlinc.xml +0 -6
  66. package/android/.idea/migrations.xml +0 -10
  67. package/android/.idea/misc.xml +0 -9
  68. package/android/.idea/modules/android.androidTest.iml +0 -6
  69. package/android/.idea/modules/android.main.iml +0 -6
  70. package/android/.idea/modules/android.unitTest.iml +0 -6
  71. package/android/.idea/other.xml +0 -736
  72. package/android/.idea/runConfigurations.xml +0 -17
  73. package/android/.idea/sonarlint/issuestore/0/6/066a3db98a4a279fde40d6ddf92c417b5c93198b +0 -0
  74. package/android/.idea/sonarlint/issuestore/3/e/3e1984987c20cd21984de8c97894175bd94b0037 +0 -3
  75. package/android/.idea/sonarlint/issuestore/4/4/44aaf172f11159c609e569cf1b49bcd49376a770 +0 -4
  76. package/android/.idea/sonarlint/issuestore/f/0/f07866736216be0ee2aba49e392191aeae700a35 +0 -0
  77. package/android/.idea/sonarlint/issuestore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
  78. package/android/.idea/sonarlint/issuestore/index.pb +0 -11
  79. package/android/.idea/sonarlint/securityhotspotstore/0/6/066a3db98a4a279fde40d6ddf92c417b5c93198b +0 -0
  80. package/android/.idea/sonarlint/securityhotspotstore/3/e/3e1984987c20cd21984de8c97894175bd94b0037 +0 -0
  81. package/android/.idea/sonarlint/securityhotspotstore/4/4/44aaf172f11159c609e569cf1b49bcd49376a770 +0 -0
  82. package/android/.idea/sonarlint/securityhotspotstore/f/0/f07866736216be0ee2aba49e392191aeae700a35 +0 -0
  83. package/android/.idea/sonarlint/securityhotspotstore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
  84. package/android/.idea/sonarlint/securityhotspotstore/index.pb +0 -11
  85. package/android/.idea/sonarlint.xml +0 -6
  86. package/android/.idea/vcs.xml +0 -6
  87. package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  88. package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  89. package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/xcuserdata/kishankumarmaurya.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  90. package/ios/CashfreePgApi.xcodeproj/xcuserdata/kishankumarmaurya.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
  91. package/ios/CashfreePgApi.xcodeproj/xcuserdata/kishankumarmaurya.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # react-native-cashfree-pg-sdk
2
2
 
3
- ![GitHub](https://img.shields.io/github/license/cashfree/react-native-cashfree-pg-sdk) ![Discord](https://img.shields.io/discord/931125665669972018?label=discord) ![GitHub last commit (branch)](https://img.shields.io/github/last-commit/cashfree/react-native-cashfree-pg-sdk/master) ![GitHub release (with filter)](https://img.shields.io/github/v/release/cashfree/react-native-cashfree-pg-sdk?label=latest) ![npm](https://img.shields.io/npm/v/react-native-cashfree-pg-sdk) ![GitHub forks](https://img.shields.io/github/forks/cashfree/react-native-cashfree-pg-sdk) ![GitHub Repo stars](https://img.shields.io/github/stars/cashfree/react-native-cashfree-pg-sdk)
3
+ ![GitHub](https://img.shields.io/github/license/cashfree/react-native-cashfree-pg-sdk) ![npm](https://img.shields.io/npm/v/react-native-cashfree-pg-sdk) ![downloads](https://img.shields.io/npm/dm/react-native-cashfree-pg-sdk.svg?style=flat) ![Discord](https://img.shields.io/discord/931125665669972018?label=discord) ![GitHub last commit (branch)](https://img.shields.io/github/last-commit/cashfree/react-native-cashfree-pg-sdk/master) [![install size](https://packagephobia.com/badge?p=react-native-cashfree-pg-sdk@2.2.7)](https://packagephobia.com/result?p=react-native-cashfree-pg-sdk@2.2.7)
4
4
 
5
+ [![NPM](https://nodei.co/npm/react-native-cashfree-pg-sdk.svg?data=n,v,u,d)](https://nodei.co/npm/react-native-cashfree-pg-sdk/)
5
6
 
6
7
  The Cashfree React Native SDK allows you to integrate Cashfree Payment Gateway into your application and start collecting payments from your customers. The React Native SDK has been designed to minimise the complexity of handling and integrating payments in your React Native project.
7
8
 
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>react-native-cashfree-pg-sdk</name>
4
+ <comment>Project react-native-cashfree-pg-sdk created by Buildship.</comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.jdt.core.javabuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ <buildCommand>
14
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15
+ <arguments>
16
+ </arguments>
17
+ </buildCommand>
18
+ </buildSpec>
19
+ <natures>
20
+ <nature>org.eclipse.jdt.core.javanature</nature>
21
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22
+ </natures>
23
+ <filteredResources>
24
+ <filter>
25
+ <id>1756708886674</id>
26
+ <name></name>
27
+ <type>30</type>
28
+ <matcher>
29
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
30
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31
+ </matcher>
32
+ </filter>
33
+ </filteredResources>
34
+ </projectDescription>
@@ -58,6 +58,6 @@ dependencies {
58
58
  implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
59
59
  implementation 'androidx.gridlayout:gridlayout:1.0.0'
60
60
 
61
- implementation 'com.cashfree.pg:api:2.2.9'
61
+ implementation 'com.cashfree.pg:api:2.3.0'
62
62
  implementation "com.facebook.react:react-native:+" // From node_modules
63
63
  }
@@ -22,7 +22,14 @@ import com.cashfree.pg.core.api.callback.CFSubscriptionResponseCallback;
22
22
  import com.cashfree.pg.core.api.card.CFCard;
23
23
  import com.cashfree.pg.core.api.card.CFCardPayment;
24
24
  import com.cashfree.pg.core.api.exception.CFException;
25
+ import com.cashfree.pg.core.api.subscription.CFSubsPayment;
25
26
  import com.cashfree.pg.core.api.subscription.CFSubscriptionPayment;
27
+ import com.cashfree.pg.core.api.subscription.card.CFSubsCard;
28
+ import com.cashfree.pg.core.api.subscription.card.CFSubsCardPayment;
29
+ import com.cashfree.pg.core.api.subscription.enach.CFSubsNetBanking;
30
+ import com.cashfree.pg.core.api.subscription.enach.CFSubsNetBankingPayment;
31
+ import com.cashfree.pg.core.api.subscription.upi.CFSubsUpi;
32
+ import com.cashfree.pg.core.api.subscription.upi.CFSubsUpiPayment;
26
33
  import com.cashfree.pg.core.api.upi.CFUPI;
27
34
  import com.cashfree.pg.core.api.upi.CFUPIPayment;
28
35
  import com.cashfree.pg.core.api.utils.CFErrorResponse;
@@ -47,84 +54,84 @@ import java.util.Map;
47
54
 
48
55
  @ReactModule(name = CashfreePgApiModule.NAME)
49
56
  public class CashfreePgApiModule extends ReactContextBaseJavaModule implements CFCheckoutResponseCallback, CFEventsSubscriber, CFSubscriptionResponseCallback {
50
- public static final String NAME = "CashfreePgApi";
57
+ public static final String NAME = "CashfreePgApi";
51
58
 
52
- public CashfreePgApiModule(ReactApplicationContext reactContext) {
53
- super(reactContext);
54
- }
59
+ public CashfreePgApiModule(ReactApplicationContext reactContext) {
60
+ super(reactContext);
61
+ }
55
62
 
56
- @Override
57
- @NonNull
58
- public String getName() {
59
- return NAME;
60
- }
63
+ @Override
64
+ @NonNull
65
+ public String getName() {
66
+ return NAME;
67
+ }
61
68
 
62
- @ReactMethod
63
- public void doPayment(String cfPaymentString) {
64
- Log.d("CashfreePgApiModule", cfPaymentString);
65
- try {
66
- Activity activity = getCurrentActivity();
67
- CFDropCheckoutPayment cfDropCheckoutPayment = DropPaymentParser.getDropCheckoutPayment(cfPaymentString);
68
- cfDropCheckoutPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
69
- cfDropCheckoutPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.DROP);
70
- if (activity != null) {
71
- CFPaymentGatewayService.getInstance().doPayment(activity, cfDropCheckoutPayment);
72
- } else {
73
- throw new IllegalStateException("activity is null");
74
- }
75
- } catch (Exception e) {
76
- e.printStackTrace();
77
- }
69
+ @ReactMethod
70
+ public void doPayment(String cfPaymentString) {
71
+ Log.d("CashfreePgApiModule", cfPaymentString);
72
+ try {
73
+ Activity activity = getCurrentActivity();
74
+ CFDropCheckoutPayment cfDropCheckoutPayment = DropPaymentParser.getDropCheckoutPayment(cfPaymentString);
75
+ cfDropCheckoutPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
76
+ cfDropCheckoutPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.DROP);
77
+ if (activity != null) {
78
+ CFPaymentGatewayService.getInstance().doPayment(activity, cfDropCheckoutPayment);
79
+ } else {
80
+ throw new IllegalStateException("activity is null");
81
+ }
82
+ } catch (Exception e) {
83
+ e.printStackTrace();
78
84
  }
85
+ }
79
86
 
80
- @ReactMethod
81
- public void doUPIPayment(String cfPaymentString) {
82
- Log.d("CashfreePgApiModule", cfPaymentString);
83
- try {
84
- Activity activity = getCurrentActivity();
85
- CFUPIIntentCheckoutPayment cfupiIntentCheckoutPayment = DropPaymentParser.getUPICheckoutPayment(cfPaymentString);
86
- cfupiIntentCheckoutPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
87
- cfupiIntentCheckoutPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.INTENT);
88
- if (activity != null) {
89
- CFPaymentGatewayService.getInstance().doPayment(activity, cfupiIntentCheckoutPayment);
90
- } else {
91
- throw new IllegalStateException("activity is null");
92
- }
93
- } catch (Exception e) {
94
- e.printStackTrace();
95
- }
87
+ @ReactMethod
88
+ public void doUPIPayment(String cfPaymentString) {
89
+ Log.d("CashfreePgApiModule", cfPaymentString);
90
+ try {
91
+ Activity activity = getCurrentActivity();
92
+ CFUPIIntentCheckoutPayment cfupiIntentCheckoutPayment = DropPaymentParser.getUPICheckoutPayment(cfPaymentString);
93
+ cfupiIntentCheckoutPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
94
+ cfupiIntentCheckoutPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.INTENT);
95
+ if (activity != null) {
96
+ CFPaymentGatewayService.getInstance().doPayment(activity, cfupiIntentCheckoutPayment);
97
+ } else {
98
+ throw new IllegalStateException("activity is null");
99
+ }
100
+ } catch (Exception e) {
101
+ e.printStackTrace();
96
102
  }
103
+ }
97
104
 
98
- @ReactMethod
99
- public void doWebPayment(String sessionString) {
100
- Log.d("CashfreePgApiModule Web", sessionString);
101
- CFSession cfSession = null;
102
- try {
103
- JSONObject jsonObject = new JSONObject(sessionString);
104
- cfSession = new CFSession.CFSessionBuilder()
105
- .setEnvironment(CFSession.Environment.valueOf(jsonObject.getString("environment")))
106
- .setOrderId(jsonObject.getString("orderID"))
107
- .setPaymentSessionID(jsonObject.getString("payment_session_id"))
108
- .build();
109
- } catch (Exception exception) {
110
- throw new IllegalStateException("Session is invalid");
111
- }
112
- try {
113
- Activity activity = getCurrentActivity();
114
- CFWebCheckoutPayment cfWebCheckoutPayment = new CFWebCheckoutPayment.CFWebCheckoutPaymentBuilder()
115
- .setSession(cfSession)
116
- .build();
117
- cfWebCheckoutPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
118
- cfWebCheckoutPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.WEB_CHECKOUT);
119
- if (activity != null) {
120
- CFPaymentGatewayService.getInstance().doPayment(activity, cfWebCheckoutPayment);
121
- } else {
122
- throw new IllegalStateException("activity is null");
123
- }
124
- } catch (Exception e) {
125
- e.printStackTrace();
126
- }
105
+ @ReactMethod
106
+ public void doWebPayment(String sessionString) {
107
+ Log.d("CashfreePgApiModule Web", sessionString);
108
+ CFSession cfSession = null;
109
+ try {
110
+ JSONObject jsonObject = new JSONObject(sessionString);
111
+ cfSession = new CFSession.CFSessionBuilder()
112
+ .setEnvironment(CFSession.Environment.valueOf(jsonObject.getString("environment")))
113
+ .setOrderId(jsonObject.getString("orderID"))
114
+ .setPaymentSessionID(jsonObject.getString("payment_session_id"))
115
+ .build();
116
+ } catch (Exception exception) {
117
+ throw new IllegalStateException("Session is invalid");
118
+ }
119
+ try {
120
+ Activity activity = getCurrentActivity();
121
+ CFWebCheckoutPayment cfWebCheckoutPayment = new CFWebCheckoutPayment.CFWebCheckoutPaymentBuilder()
122
+ .setSession(cfSession)
123
+ .build();
124
+ cfWebCheckoutPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
125
+ cfWebCheckoutPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.WEB_CHECKOUT);
126
+ if (activity != null) {
127
+ CFPaymentGatewayService.getInstance().doPayment(activity, cfWebCheckoutPayment);
128
+ } else {
129
+ throw new IllegalStateException("activity is null");
130
+ }
131
+ } catch (Exception e) {
132
+ e.printStackTrace();
127
133
  }
134
+ }
128
135
 
129
136
  @ReactMethod
130
137
  public void doSubscriptionPayment(String sessionString) {
@@ -157,82 +164,82 @@ public class CashfreePgApiModule extends ReactContextBaseJavaModule implements C
157
164
  }
158
165
  }
159
166
 
160
- @ReactMethod
161
- public void doCardPayment(String data) {
162
- CFSession cfSession = null;
163
- CFCard card = null;
164
- boolean saveCard;
165
- try {
166
- JSONObject jsonObject = new JSONObject(data);
167
- JSONObject session = jsonObject.getJSONObject("session");
168
- JSONObject cardObject = jsonObject.getJSONObject("card");
169
- saveCard = cardObject.optBoolean("saveCard", false);
170
- cfSession = new CFSession.CFSessionBuilder()
171
- .setEnvironment(CFSession.Environment.valueOf(session.getString("environment")))
172
- .setOrderId(session.getString("orderID"))
173
- .setPaymentSessionID(session.getString("payment_session_id"))
167
+ @ReactMethod
168
+ public void doCardPayment(String data) {
169
+ CFSession cfSession = null;
170
+ CFCard card = null;
171
+ boolean saveCard;
172
+ try {
173
+ JSONObject jsonObject = new JSONObject(data);
174
+ JSONObject session = jsonObject.getJSONObject("session");
175
+ JSONObject cardObject = jsonObject.getJSONObject("card");
176
+ saveCard = cardObject.optBoolean("saveCard", false);
177
+ cfSession = new CFSession.CFSessionBuilder()
178
+ .setEnvironment(CFSession.Environment.valueOf(session.getString("environment")))
179
+ .setOrderId(session.getString("orderID"))
180
+ .setPaymentSessionID(session.getString("payment_session_id"))
181
+ .build();
182
+ if (cardObject.has("instrumentId")) {
183
+ card = new CFCard.CFCardBuilder()
184
+ .setInstrumentId(cardObject.getString("instrumentId"))
185
+ .setCVV(cardObject.getString("cardCvv"))
174
186
  .build();
175
- if (cardObject.has("instrumentId")) {
176
- card = new CFCard.CFCardBuilder()
177
- .setInstrumentId(cardObject.getString("instrumentId"))
178
- .setCVV(cardObject.getString("cardCvv"))
179
- .build();
180
- } else {
181
- card = new CFCard.CFCardBuilder()
182
- .setCardNumber(cardObject.getString("cardNumber"))
183
- .setCardHolderName(cardObject.getString("cardHolderName"))
184
- .setCardExpiryMonth(cardObject.getString("cardExpiryMM"))
185
- .setCardExpiryYear(cardObject.getString("cardExpiryYY"))
186
- .setCVV(cardObject.getString("cardCvv"))
187
- .setChannel("post")
188
- .build();
189
- }
190
- } catch (Exception exception) {
191
- throw new IllegalStateException(exception.getMessage());
192
- }
193
- try {
194
- Activity activity = getCurrentActivity();
195
- CFCardPayment cardPayment = new CFCardPayment.CFCardPaymentBuilder()
196
- .setSession(cfSession)
197
- .setCard(card)
198
- .setSaveCardDetail(saveCard)
187
+ } else {
188
+ card = new CFCard.CFCardBuilder()
189
+ .setCardNumber(cardObject.getString("cardNumber"))
190
+ .setCardHolderName(cardObject.getString("cardHolderName"))
191
+ .setCardExpiryMonth(cardObject.getString("cardExpiryMM"))
192
+ .setCardExpiryYear(cardObject.getString("cardExpiryYY"))
193
+ .setCVV(cardObject.getString("cardCvv"))
194
+ .setChannel("post")
199
195
  .build();
200
- cardPayment.setCfSDKFlow(CFPayment.CFSDKFlow.WITH_CASHFREE_FULLSCREEN_LOADER);
201
- cardPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
202
- cardPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.ELEMENT);
203
- if (activity != null) {
204
- CFPaymentGatewayService.getInstance().doPayment(activity, cardPayment);
205
- } else {
206
- throw new IllegalStateException("activity is null");
207
- }
208
- } catch (Exception e) {
209
- e.printStackTrace();
210
196
  }
197
+ } catch (Exception exception) {
198
+ throw new IllegalStateException(exception.getMessage());
199
+ }
200
+ try {
201
+ Activity activity = getCurrentActivity();
202
+ CFCardPayment cardPayment = new CFCardPayment.CFCardPaymentBuilder()
203
+ .setSession(cfSession)
204
+ .setCard(card)
205
+ .setSaveCardDetail(saveCard)
206
+ .build();
207
+ cardPayment.setCfSDKFlow(CFPayment.CFSDKFlow.WITH_CASHFREE_FULLSCREEN_LOADER);
208
+ cardPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
209
+ cardPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.ELEMENT);
210
+ if (activity != null) {
211
+ CFPaymentGatewayService.getInstance().doPayment(activity, cardPayment);
212
+ } else {
213
+ throw new IllegalStateException("activity is null");
214
+ }
215
+ } catch (Exception e) {
216
+ e.printStackTrace();
211
217
  }
218
+ }
212
219
 
213
- @ReactMethod
214
- public void getInstalledUpiApps(Callback cb){
215
- Activity activity = getCurrentActivity();
216
- final Intent intent = new Intent();
217
- intent.setAction(Intent.ACTION_VIEW);
218
- intent.setData(Uri.parse("upi://pay"));
219
- PackageManager pm = activity.getPackageManager();
220
- final List<ResolveInfo> resInfo = pm.queryIntentActivities(intent, 0);
221
- JSONArray packageNames = new JSONArray();
222
- try {
223
- for (ResolveInfo info : resInfo) {
224
- JSONObject appInfo = new JSONObject();
225
- String appName = (String)activity.getPackageManager().getApplicationLabel(info.activityInfo.applicationInfo);
226
- appInfo.put("appName", appName);
227
- appInfo.put("appPackage", info.activityInfo.packageName);
228
- packageNames.put(appInfo);
229
- }
230
- } catch (Exception ex) {
231
- ex.printStackTrace();
220
+ @ReactMethod
221
+ public void getInstalledUpiApps(Callback cb) {
222
+ Activity activity = getCurrentActivity();
223
+ final Intent intent = new Intent();
224
+ intent.setAction(Intent.ACTION_VIEW);
225
+ intent.setData(Uri.parse("upi://pay"));
226
+ PackageManager pm = activity.getPackageManager();
227
+ final List<ResolveInfo> resInfo = pm.queryIntentActivities(intent, 0);
228
+ JSONArray packageNames = new JSONArray();
229
+ try {
230
+ for (ResolveInfo info : resInfo) {
231
+ JSONObject appInfo = new JSONObject();
232
+ String appName = (String) activity.getPackageManager().getApplicationLabel(info.activityInfo.applicationInfo);
233
+ appInfo.put("appName", appName);
234
+ appInfo.put("appPackage", info.activityInfo.packageName);
235
+ packageNames.put(appInfo);
232
236
  }
233
- Log.d("CashfreePgApiModule", "getInstalledUpiApps::--" + packageNames);
234
- cb.invoke(packageNames.toString());
237
+ } catch (Exception ex) {
238
+ ex.printStackTrace();
235
239
  }
240
+ Log.d("CashfreePgApiModule", "getInstalledUpiApps::--" + packageNames);
241
+ cb.invoke(packageNames.toString());
242
+ }
236
243
 
237
244
  @ReactMethod
238
245
  public void doElementUPIPayment(String upiPaymentData) {
@@ -276,80 +283,195 @@ public class CashfreePgApiModule extends ReactContextBaseJavaModule implements C
276
283
  }
277
284
  }
278
285
 
279
- @ReactMethod
280
- public void setCallback() {
281
- try {
282
- CFPaymentGatewayService.getInstance().setCheckoutCallback(this);
283
- } catch (CFException cfException) {
284
- }
286
+ @ReactMethod
287
+ public void doSubsCardPayment(String data) {
288
+ CFSubscriptionSession cfSubsSession = null;
289
+ CFSubsCard cfSubsCard = null;
290
+ try {
291
+ JSONObject jsonObject = new JSONObject(data);
292
+ JSONObject sessionObject = jsonObject.getJSONObject("session");
293
+ JSONObject cardObject = jsonObject.getJSONObject("card");
294
+
295
+ cfSubsSession = new CFSubscriptionSession.CFSubscriptionSessionBuilder()
296
+ .setEnvironment(CFSubscriptionSession.Environment.valueOf(sessionObject.getString("environment")))
297
+ .setSubscriptionId(sessionObject.getString("subscription_id"))
298
+ .setSubscriptionSessionID(sessionObject.getString("subscription_session_id"))
299
+ .build();
300
+
301
+ cfSubsCard = new CFSubsCard.CFSubsCardBuilder()
302
+ .setCardNumber(cardObject.getString("cardNumber"))
303
+ .setCardHolderName(cardObject.getString("cardHolderName"))
304
+ .setCardExpiryMonth(cardObject.getString("cardExpiryMM"))
305
+ .setCardExpiryYear(cardObject.getString("cardExpiryYY"))
306
+ .setCVV(cardObject.getString("cardCvv"))
307
+ .setChannel("link")
308
+ .build();
309
+
310
+ CFSubsCardPayment subsCardPayment = new CFSubsCardPayment.CFSubsCardPaymentBuilder()
311
+ .setSubscriptionSession(cfSubsSession)
312
+ .setSubsCard(cfSubsCard)
313
+ .build();
314
+
315
+ doSubscriptionElementPayment(subsCardPayment);
316
+ } catch (Exception exception) {
317
+ throw new IllegalStateException(exception.getMessage());
285
318
  }
319
+ }
286
320
 
287
- @ReactMethod
288
- public void setEventSubscriber() {
289
- try {
290
- CFAnalyticsService.getInstance().setSubscriber(this);
291
- } catch (Exception ignored) {
292
- }
321
+ @ReactMethod
322
+ public void doSubsUPIPayment(String data) {
323
+ CFSubscriptionSession cfSubsSession = null;
324
+ CFSubsUpi cfSubsUpi = null;
325
+ try {
326
+ JSONObject jsonObject = new JSONObject(data);
327
+ JSONObject sessionObject = jsonObject.getJSONObject("session");
328
+ JSONObject upiObject = jsonObject.getJSONObject("upi");
329
+
330
+ cfSubsSession = new CFSubscriptionSession.CFSubscriptionSessionBuilder()
331
+ .setEnvironment(CFSubscriptionSession.Environment.valueOf(sessionObject.getString("environment")))
332
+ .setSubscriptionId(sessionObject.getString("subscription_id"))
333
+ .setSubscriptionSessionID(sessionObject.getString("subscription_session_id"))
334
+ .build();
335
+
336
+ cfSubsUpi = new CFSubsUpi.CFSubsUpiBuilder()
337
+ .setUPIID(upiObject.getString("id"))
338
+ .setMode(CFSubsUpi.Mode.INTENT)
339
+ .build();
340
+
341
+ CFSubsUpiPayment subsUpiPayment = new CFSubsUpiPayment.CFSubsUpiPaymentBuilder()
342
+ .setSubscriptionSession(cfSubsSession)
343
+ .setSubsUpi(cfSubsUpi)
344
+ .build();
345
+
346
+ doSubscriptionElementPayment(subsUpiPayment);
347
+ } catch (Exception exception) {
348
+ throw new IllegalStateException(exception.getMessage());
293
349
  }
350
+ }
294
351
 
295
- @ReactMethod
296
- public void removeEventSubscriber() {
297
- try {
298
- CFAnalyticsService.getInstance().removeSubscriber();
299
- } catch (Exception ignored) {
300
- }
352
+ @ReactMethod
353
+ public void doSubsNBPayment(String data) {
354
+ CFSubscriptionSession cfSubsSession = null;
355
+ CFSubsNetBanking cfSubsNetBanking = null;
356
+ try {
357
+ JSONObject jsonObject = new JSONObject(data);
358
+ JSONObject sessionObject = jsonObject.getJSONObject("session");
359
+ JSONObject nbObject = jsonObject.getJSONObject("nb");
360
+
361
+ cfSubsSession = new CFSubscriptionSession.CFSubscriptionSessionBuilder()
362
+ .setEnvironment(CFSubscriptionSession.Environment.valueOf(sessionObject.getString("environment")))
363
+ .setSubscriptionId(sessionObject.getString("subscription_id"))
364
+ .setSubscriptionSessionID(sessionObject.getString("subscription_session_id"))
365
+ .build();
366
+
367
+ cfSubsNetBanking = new CFSubsNetBanking.CFSubsNetBankingBuilder()
368
+ .setAccountType(nbObject.getString("accountType"))
369
+ .setAccountNumber(nbObject.getString("accountNumber"))
370
+ .setAccountHolderName(nbObject.getString("accountHolderName"))
371
+ .setAccountBankCode(nbObject.getString("accountBankCode"))
372
+ .build();
373
+
374
+ CFSubsNetBankingPayment netBankingPayment = new CFSubsNetBankingPayment.CFNetBankingPaymentBuilder()
375
+ .setSubscriptionSession(cfSubsSession)
376
+ .setCfSubsNetBanking(cfSubsNetBanking)
377
+ .build();
378
+
379
+ doSubscriptionElementPayment(netBankingPayment);
380
+ } catch (Exception exception) {
381
+ throw new IllegalStateException(exception.getMessage());
301
382
  }
383
+ }
302
384
 
303
- @Override
304
- public void onPaymentVerify(String orderID) {
305
- this.getReactApplicationContext()
306
- .getJSModule(RCTNativeAppEventEmitter.class)
307
- .emit("cfSuccess", orderID);
385
+ private void doSubscriptionElementPayment(CFSubsPayment subsPayment){
386
+ try {
387
+ Activity activity = getCurrentActivity();
388
+ subsPayment.setCfsdkFramework(CFPayment.CFSDKFramework.REACT_NATIVE);
389
+ subsPayment.setCfSDKFlavour(CFPayment.CFSDKFlavour.SUBSCRIPTION);
390
+ if (activity != null) {
391
+ CFPaymentGatewayService.getInstance().setSubscriptionCheckoutCallback(this);
392
+ CFPaymentGatewayService.getInstance().doSubscriptionPayment(activity, subsPayment);
393
+ } else {
394
+ throw new IllegalStateException("activity is null");
395
+ }
396
+ } catch (Exception e) {
397
+ e.printStackTrace();
308
398
  }
399
+ }
309
400
 
310
- @Override
311
- public void onPaymentFailure(CFErrorResponse cfErrorResponse, String orderID) {
312
- JSONObject jsonObject = new JSONObject();
313
- try {
314
- jsonObject.put("error", cfErrorResponse.toJSON().toString());
315
- if(orderID !=null && !orderID.isEmpty()) {
316
- jsonObject.put("orderID", orderID);
317
- }
318
- } catch (JSONException e) {
319
- e.printStackTrace();
320
- }
321
- this.getReactApplicationContext()
322
- .getJSModule(RCTNativeAppEventEmitter.class)
323
- .emit("cfFailure", jsonObject.toString());
401
+ @ReactMethod
402
+ public void setCallback() {
403
+ try {
404
+ CFPaymentGatewayService.getInstance().setCheckoutCallback(this);
405
+ } catch (CFException cfException) {
406
+ }
407
+ }
408
+
409
+ @ReactMethod
410
+ public void setEventSubscriber() {
411
+ try {
412
+ CFAnalyticsService.getInstance().setSubscriber(this);
413
+ } catch (Exception ignored) {
324
414
  }
415
+ }
416
+
417
+ @ReactMethod
418
+ public void removeEventSubscriber() {
419
+ try {
420
+ CFAnalyticsService.getInstance().removeSubscriber();
421
+ } catch (Exception ignored) {
422
+ }
423
+ }
325
424
 
326
- @Override
327
- public void receivedEvent(String s, @Nullable Map<String, String> map) {
328
- JSONObject jsonObject = new JSONObject();
329
- JSONObject jsonMeta = new JSONObject();
330
- try {
331
- if (map != null) {
332
- for (String key : map.keySet()) {
333
- jsonMeta.put(key, map.get(key));
334
- }
335
- }
336
- jsonObject.put("eventName", s);
337
- jsonObject.put("meta", jsonMeta);
338
- } catch (JSONException e) {
339
- e.printStackTrace();
425
+ @Override
426
+ public void onPaymentVerify(String orderID) {
427
+ this.getReactApplicationContext()
428
+ .getJSModule(RCTNativeAppEventEmitter.class)
429
+ .emit("cfSuccess", orderID);
430
+ }
431
+
432
+ @Override
433
+ public void onPaymentFailure(CFErrorResponse cfErrorResponse, String orderID) {
434
+ JSONObject jsonObject = new JSONObject();
435
+ try {
436
+ jsonObject.put("error", cfErrorResponse.toJSON().toString());
437
+ if (orderID != null && !orderID.isEmpty()) {
438
+ jsonObject.put("orderID", orderID);
439
+ }
440
+ } catch (JSONException e) {
441
+ e.printStackTrace();
442
+ }
443
+ this.getReactApplicationContext()
444
+ .getJSModule(RCTNativeAppEventEmitter.class)
445
+ .emit("cfFailure", jsonObject.toString());
446
+ }
447
+
448
+ @Override
449
+ public void receivedEvent(String s, @Nullable Map<String, String> map) {
450
+ JSONObject jsonObject = new JSONObject();
451
+ JSONObject jsonMeta = new JSONObject();
452
+ try {
453
+ if (map != null) {
454
+ for (String key : map.keySet()) {
455
+ jsonMeta.put(key, map.get(key));
340
456
  }
341
- this.getReactApplicationContext()
342
- .getJSModule(RCTNativeAppEventEmitter.class)
343
- .emit("cfEvent", jsonObject.toString());
457
+ }
458
+ jsonObject.put("eventName", s);
459
+ jsonObject.put("meta", jsonMeta);
460
+ } catch (JSONException e) {
461
+ e.printStackTrace();
344
462
  }
463
+ this.getReactApplicationContext()
464
+ .getJSModule(RCTNativeAppEventEmitter.class)
465
+ .emit("cfEvent", jsonObject.toString());
466
+ }
345
467
 
346
468
  @Override
347
469
  public void onSubscriptionVerify(CFSubscriptionResponse cfSubscriptionResponse) {
348
- onPaymentVerify(cfSubscriptionResponse.getSubscriptionId());
470
+ onPaymentVerify(cfSubscriptionResponse.getSubscriptionId());
349
471
  }
350
472
 
351
473
  @Override
352
474
  public void onSubscriptionFailure(CFErrorResponse cfErrorResponse) {
353
- onPaymentFailure(cfErrorResponse, "");
475
+ onPaymentFailure(cfErrorResponse, "");
354
476
  }
355
477
  }
@@ -11,6 +11,9 @@ RCT_EXTERN_METHOD(doWebPayment:(NSString)paymentObject)
11
11
  RCT_EXTERN_METHOD(doSubscriptionPayment:(NSString)paymentObject)
12
12
  RCT_EXTERN_METHOD(doCardPayment:(NSString)paymentObject)
13
13
  RCT_EXTERN_METHOD(doElementUPIPayment:(NSString)paymentObject)
14
+ RCT_EXTERN_METHOD(doSubsCardPayment:(NSString)paymentObject)
15
+ RCT_EXTERN_METHOD(doSubsUPIPayment:(NSString)paymentObject)
16
+ RCT_EXTERN_METHOD(doSubsNBPayment:(NSString)paymentObject)
14
17
  RCT_EXTERN_METHOD(getInstalledUpiApps)
15
18
 
16
19
  RCT_EXTERN_METHOD(setCallback)