@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
|
-
|
|
12
|
+
reactContext: ReactApplicationContext
|
|
12
13
|
) : ReactContextBaseJavaModule(reactContext) {
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
33
|
-
|
|
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
|
-
|
|
53
|
-
|
|
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
|
-
//
|
|
10
|
+
// Suppress Deprecated warning
|
|
11
|
+
@Suppress("DEPRECATION")
|
|
9
12
|
class RNAlipayPackage : ReactPackage {
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return listOf(RNAlipayModule(reactContext))
|
|
15
|
-
}
|
|
14
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
15
|
+
return listOf(RNAlipayModule(reactContext))
|
|
16
|
+
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return emptyList()
|
|
21
|
-
}
|
|
18
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
19
|
+
return emptyList()
|
|
20
|
+
}
|
|
22
21
|
}
|