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.
- package/README.md +2 -1
- package/android/.project +34 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativecashfreepgsdk/CashfreePgApiModule.java +317 -195
- package/ios/CashfreePgApi.m +3 -0
- package/ios/CashfreePgApi.swift +117 -1
- package/lib/commonjs/Card/CFCardComponent.js +1 -2
- package/lib/commonjs/Card/CFCardComponent.js.map +1 -1
- package/lib/commonjs/Card/index.js.map +1 -1
- package/lib/commonjs/index.js +13 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/Card/CFCardComponent.js +4 -8
- package/lib/module/Card/CFCardComponent.js.map +1 -1
- package/lib/module/Card/index.js.map +1 -1
- package/lib/module/index.js +14 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/package.json +9 -2
- package/react-native-cashfree-pg-sdk.podspec +1 -1
- package/src/index.js +17 -1
- package/src/index.ts +17 -0
- package/android/.gradle/8.10.2/checksums/checksums.lock +0 -0
- package/android/.gradle/8.10.2/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.10.2/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.10.2/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.10.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.10.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.10.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.10.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.10.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/8.10.2/gc.properties +0 -0
- package/android/.gradle/8.12/checksums/checksums.lock +0 -0
- package/android/.gradle/8.12/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.12/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.12/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.12/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.12/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.12/gc.properties +0 -0
- package/android/.gradle/8.7/checksums/checksums.lock +0 -0
- package/android/.gradle/8.7/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.7/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.7/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.7/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.7/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.7/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.7/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.7/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.7/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/8.7/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/config.properties +0 -2
- package/android/.gradle/configuration-cache/gc.properties +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/caches/deviceStreaming.xml +0 -1414
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/copilot.data.migration.ask2agent.xml +0 -6
- package/android/.idea/gradle.xml +0 -19
- package/android/.idea/jarRepositories.xml +0 -50
- package/android/.idea/kotlinc.xml +0 -6
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -9
- package/android/.idea/modules/android.androidTest.iml +0 -6
- package/android/.idea/modules/android.main.iml +0 -6
- package/android/.idea/modules/android.unitTest.iml +0 -6
- package/android/.idea/other.xml +0 -736
- package/android/.idea/runConfigurations.xml +0 -17
- package/android/.idea/sonarlint/issuestore/0/6/066a3db98a4a279fde40d6ddf92c417b5c93198b +0 -0
- package/android/.idea/sonarlint/issuestore/3/e/3e1984987c20cd21984de8c97894175bd94b0037 +0 -3
- package/android/.idea/sonarlint/issuestore/4/4/44aaf172f11159c609e569cf1b49bcd49376a770 +0 -4
- package/android/.idea/sonarlint/issuestore/f/0/f07866736216be0ee2aba49e392191aeae700a35 +0 -0
- package/android/.idea/sonarlint/issuestore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
- package/android/.idea/sonarlint/issuestore/index.pb +0 -11
- package/android/.idea/sonarlint/securityhotspotstore/0/6/066a3db98a4a279fde40d6ddf92c417b5c93198b +0 -0
- package/android/.idea/sonarlint/securityhotspotstore/3/e/3e1984987c20cd21984de8c97894175bd94b0037 +0 -0
- package/android/.idea/sonarlint/securityhotspotstore/4/4/44aaf172f11159c609e569cf1b49bcd49376a770 +0 -0
- package/android/.idea/sonarlint/securityhotspotstore/f/0/f07866736216be0ee2aba49e392191aeae700a35 +0 -0
- package/android/.idea/sonarlint/securityhotspotstore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
- package/android/.idea/sonarlint/securityhotspotstore/index.pb +0 -11
- package/android/.idea/sonarlint.xml +0 -6
- package/android/.idea/vcs.xml +0 -6
- package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/xcuserdata/kishankumarmaurya.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/CashfreePgApi.xcodeproj/xcuserdata/kishankumarmaurya.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
- 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
|
-
      [](https://packagephobia.com/result?p=react-native-cashfree-pg-sdk@2.2.7)
|
|
4
4
|
|
|
5
|
+
[](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
|
|
package/android/.project
ADDED
|
@@ -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>
|
package/android/build.gradle
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
57
|
+
public static final String NAME = "CashfreePgApi";
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
public CashfreePgApiModule(ReactApplicationContext reactContext) {
|
|
60
|
+
super(reactContext);
|
|
61
|
+
}
|
|
55
62
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
@Override
|
|
64
|
+
@NonNull
|
|
65
|
+
public String getName() {
|
|
66
|
+
return NAME;
|
|
67
|
+
}
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
234
|
-
|
|
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
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
|
|
470
|
+
onPaymentVerify(cfSubscriptionResponse.getSubscriptionId());
|
|
349
471
|
}
|
|
350
472
|
|
|
351
473
|
@Override
|
|
352
474
|
public void onSubscriptionFailure(CFErrorResponse cfErrorResponse) {
|
|
353
|
-
|
|
475
|
+
onPaymentFailure(cfErrorResponse, "");
|
|
354
476
|
}
|
|
355
477
|
}
|
package/ios/CashfreePgApi.m
CHANGED
|
@@ -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)
|