@gyjshow/react-native-alipay 1.0.3 → 1.0.4

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.
@@ -1,4 +1,4 @@
1
- // Kotlin 模块实现
1
+ // Kotlin 模块实现
2
2
 
3
3
  package com.gyj.alipay
4
4
 
@@ -9,48 +9,48 @@ import com.alipay.sdk.app.PayTask
9
9
  import com.facebook.react.bridge.*
10
10
 
11
11
  class RNAlipayModule(
12
- private val reactContext: ReactApplicationContext
12
+ reactContext: ReactApplicationContext
13
13
  ) : ReactContextBaseJavaModule(reactContext) {
14
14
 
15
- override fun getName(): String = "RNAlipay"
16
-
17
- /**
18
- * 发起支付
19
- */
20
- @ReactMethod
21
- fun pay(orderInfo: String, promise: Promise) {
22
- val activity: Activity? = currentActivity
23
- if (activity == null) {
24
- promise.reject("NO_ACTIVITY", "Current activity is null")
25
- return
26
- }
15
+ override fun getName(): String = "RNAlipay"
16
+
17
+ /**
18
+ * 发起支付
19
+ */
20
+ @ReactMethod
21
+ fun pay(orderInfo: String, promise: Promise) {
22
+ val activity: Activity? = reactApplicationContext.currentActivity
23
+ if (activity == null) {
24
+ promise.reject("NO_ACTIVITY", "Current activity is null")
25
+ return
26
+ }
27
27
 
28
- Thread {
29
- try {
30
- val alipay = PayTask(activity)
31
- val result: Map<String, String> = alipay.payV2(orderInfo, true)
28
+ Thread {
29
+ try {
30
+ val alipay = PayTask(activity)
31
+ val result: Map<String, String> = alipay.payV2(orderInfo, true)
32
+
33
+ Handler(Looper.getMainLooper()).post {
34
+ promise.resolve(Arguments.makeNativeMap(result))
35
+ }
36
+ } catch (e: Exception) {
37
+ promise.reject("ALIPAY_ERROR", e)
38
+ }
39
+ }.start()
40
+ }
32
41
 
33
- Handler(Looper.getMainLooper()).post {
34
- promise.resolve(Arguments.makeNativeMap(result))
42
+ /**
43
+ * 获取 SDK 版本
44
+ */
45
+ @ReactMethod
46
+ fun getVersion(promise: Promise) {
47
+ val activity: Activity? = reactApplicationContext.currentActivity
48
+ if (activity == null) {
49
+ promise.reject("NO_ACTIVITY", "Current activity is null")
50
+ return
35
51
  }
36
- } catch (e: Exception) {
37
- promise.reject("ALIPAY_ERROR", e)
38
- }
39
- }.start()
40
- }
41
-
42
- /**
43
- * 获取 SDK 版本
44
- */
45
- @ReactMethod
46
- fun getVersion(promise: Promise) {
47
- val activity: Activity? = currentActivity
48
- if (activity == null) {
49
- promise.reject("NO_ACTIVITY", "Current activity is null")
50
- return
51
- }
52
52
 
53
- val alipay = PayTask(activity)
54
- promise.resolve(alipay.version)
55
- }
53
+ val alipay = PayTask(activity)
54
+ promise.resolve(alipay.version)
55
+ }
56
56
  }
@@ -7,18 +7,15 @@ import com.facebook.react.bridge.NativeModule
7
7
  import com.facebook.react.bridge.ReactApplicationContext
8
8
  import com.facebook.react.uimanager.ViewManager
9
9
 
10
+ // Suppress Deprecated warning
10
11
  @Suppress("DEPRECATION")
11
12
  class RNAlipayPackage : ReactPackage {
12
13
 
13
- override fun createNativeModules(
14
- reactContext: ReactApplicationContext
15
- ): List<NativeModule> {
16
- return listOf(RNAlipayModule(reactContext))
17
- }
14
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
15
+ return listOf(RNAlipayModule(reactContext))
16
+ }
18
17
 
19
- override fun createViewManagers(
20
- reactContext: ReactApplicationContext
21
- ): List<ViewManager<*, *>> {
22
- return emptyList()
23
- }
18
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
19
+ return emptyList()
20
+ }
24
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gyjshow/react-native-alipay",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "private": false,
5
5
  "description": "基于 React Native 的支付宝插件,支持 Android / iOS。",
6
6
  "main": "lib/index.js",