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