react-native-cashfree-pg-sdk 2.1.1 → 2.1.3-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/android/.gradle/6.8/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.8/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/6.8/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -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/.idea/compiler.xml +1 -1
- package/android/.idea/jarRepositories.xml +20 -10
- package/android/.idea/libraries/Gradle__androidx_activity_activity_1_2_3_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_2_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_3_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_3_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_1_3_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_core_core_1_5_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_dynamicanimation_dynamicanimation_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_3_4_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_gridlayout_gridlayout_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_3_1.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_3_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_3_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_3_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_cashfree_pg_analytics_1_0_6_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_cashfree_pg_api_1_0_11_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_cashfree_pg_base_1_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_cashfree_pg_core_1_0_11_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_cashfree_pg_image_caching_1_0_2_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_cashfree_pg_network_1_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_cashfree_pg_ui_1_0_11_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_facebook_fbjni_fbjni_java_only_0_0_3.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_2_0_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_2_0_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_2_0_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_2_0_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_base_2_0_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp3_2_0_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagefilters_2_0_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagetranscoder_2_0_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_infer_annotation_infer_annotation_0_11_2.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_63_4_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_soloader_annotation_0_9_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_soloader_nativeloader_0_9_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_soloader_soloader_0_9_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_yoga_proguard_annotations_1_14_1.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_android_material_material_1_4_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_3_12_12.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_urlconnection_3_12_12.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okio_okio_1_15_0.xml +13 -0
- package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +13 -0
- package/android/.idea/misc.xml +2 -2
- package/android/.idea/modules/android.androidTest.iml +106 -0
- package/android/.idea/modules/android.iml +40 -0
- package/android/.idea/modules/android.main.iml +113 -0
- package/android/.idea/modules/android.unitTest.iml +101 -0
- package/android/.idea/modules.xml +11 -0
- package/android/build.gradle +1 -1
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/local.properties +2 -2
- package/android/src/main/java/com/reactnativecashfreepgsdk/CashfreePgApiModule.java +132 -113
- package/ios/CashfreePgApi.m +2 -0
- package/ios/CashfreePgApi.swift +40 -0
- package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/CashfreePgApi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/CashfreePgApi.xcodeproj/xcuserdata/aabhasjindal.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/commonjs/index.js +4 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/package.json +2 -2
- package/react-native-cashfree-pg-sdk.podspec +1 -1
- package/src/index.js +4 -0
- package/src/index.ts +5 -0
- package/android/.gradle/6.8/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/6.8/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/6.8/javaCompile/classAnalysis.bin +0 -0
- package/android/.gradle/6.8/javaCompile/jarAnalysis.bin +0 -0
- package/android/.gradle/6.8/javaCompile/javaCompile.lock +0 -0
- package/android/.gradle/6.8/javaCompile/taskHistory.bin +0 -0
- package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/7.2/gc.properties +0 -0
- package/android/.gradle/8.1/checksums/checksums.lock +0 -0
- package/android/.gradle/8.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.1/gc.properties +0 -0
- 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 -8
- package/android/.idea/sonarlint/issuestore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
- package/android/.idea/sonarlint/issuestore/index.pb +0 -9
- 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/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
- package/android/.idea/sonarlint/securityhotspotstore/index.pb +0 -9
- package/android/gradlew +0 -234
- package/android/gradlew.bat +0 -89
|
@@ -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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
@ReactMethod
|
|
114
|
+
public void setCallback() {
|
|
115
|
+
try {
|
|
116
|
+
CFPaymentGatewayService.getInstance().setCheckoutCallback(this);
|
|
117
|
+
} catch (CFException cfException) {
|
|
118
|
+
}
|
|
115
119
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
150
|
-
|
|
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/CashfreePgApi.m
CHANGED
package/ios/CashfreePgApi.swift
CHANGED
|
@@ -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)!
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>CashfreePgApi.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>0</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|
package/lib/commonjs/index.js
CHANGED
|
@@ -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":["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","
|
|
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.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 doUPIPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(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,GA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,YAAA;IAAAlC,eAAA,iBACF,QAAQ;IAAAA,eAAA,kBACP,oBAAoB;IAAAA,eAAA,eACvB,gBAAgB;IAAAA,eAAA,eAChB,gBAAgB;EAAA;EAEvCyE,QAAQA,CAACK,WAAmB,EAAE;IAC5B1B,OAAO,CAACC,GAAG,CAAC,eAAe,GAAGyB,WAAW,CAAC;IAC1C,MAAMC,MAAM,GAAGpC,IAAI,CAACY,KAAK,CAACuB,WAAW,CAAC;IACtC1B,OAAO,CAACC,GAAG,CAAC,qBAAqB,GAAG0B,MAAM,CAAC;IAC3C,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;IAC3B,IAAI,CAACR,OAAO,GAAGO,MAAM,CAACP,OAAO;IAC7B,IAAI,CAACS,IAAI,GAAGF,MAAM,CAACE,IAAI;IACvB,IAAI,CAACC,IAAI,GAAGH,MAAM,CAACG,IAAI;EACzB;EAEAC,SAASA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACH,MAAM;EACpB;EAEAI,UAAUA,CAAA,EAAW;IACnB,OAAO,IAAI,CAACZ,OAAO;EACrB;EAEAa,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;EAEAK,OAAOA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACJ,IAAI;EAClB;AACF;AAACK,OAAA,CAAAhB,eAAA,GAAAA,eAAA;AAEM,MAAMiB,uBAAuB,GAAG,IAAIvD,gBAAgB,EAAE;AAACsD,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
|
package/lib/module/index.js
CHANGED
|
@@ -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
|
}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeAppEventEmitter","NativeEventEmitter","NativeModules","Platform","version","LINKING_ERROR","select","ios","default","CashfreePgApi","Proxy","get","Error","CFPaymentGateway","constructor","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,
|
|
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.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 doUPIPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(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,GACv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,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.
|
|
3
|
+
"version": "2.1.3-dev.0",
|
|
4
4
|
"description": "Cashfree PG Plugin for React Native",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -145,6 +145,6 @@
|
|
|
145
145
|
]
|
|
146
146
|
},
|
|
147
147
|
"dependencies": {
|
|
148
|
-
"cashfree-pg-api-contract": "2.0.
|
|
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
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
�
|
|
3
|
-
java:S1598"�This file "CashfreePgApiPackage.java" should be located in "com/reactnativecashfreepgapi" directory, not in "/Users/kishankumarmaurya/Development/ReactNative/RN_PG_APP/react-native-cashfree-pg-sdk/android/src/main/java/com/reactnativecashfreepgsdk".(ٻ�������8�����0
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
�
|
|
3
|
-
java:S1598"�This file "CashfreePgApiModule.java" should be located in "com/reactnativecashfreepgapi" directory, not in "/Users/kishankumarmaurya/Development/ReactNative/RN_PG_APP/react-native-cashfree-pg-sdk/android/src/main/java/com/reactnativecashfreepgsdk".(ٻ�������
|
|
4
|
-
> java:S108b")Either remove or fill this block of code.(����
|
|
5
|
-
C java:S108j")Either remove or fill this block of code.(Ƹۂ�����
|
|
6
|
-
C java:S108r")Either remove or fill this block of code.(Ƹۂ�����
|
|
7
|
-
P
|
|
8
|
-
java:S2864�"4Iterate over the "entrySet" instead of the "keySet".(�ֲ������
|
|
File without changes
|