payme-mini-app 0.1.0 → 0.1.2
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/android/build.gradle +1 -1
- package/android/src/main/java/com/paymeminiapp/JsonConvert.kt +98 -0
- package/android/src/main/java/com/paymeminiapp/RNPayMEMiniAppModule.kt +125 -20
- package/ios/RNPayMEMiniApp-Bridging-Header.h +1 -0
- package/ios/RNPayMEMiniApp.m +6 -2
- package/ios/RNPayMEMiniApp.swift +57 -11
- package/lib/commonjs/index.js +9 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.type.js +2 -0
- package/lib/commonjs/index.type.js.map +1 -0
- package/lib/module/index.js +7 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.type.js +2 -0
- package/lib/module/index.type.js.map +1 -0
- package/lib/typescript/index.d.ts +5 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/index.type.d.ts +19 -0
- package/lib/typescript/index.type.d.ts.map +1 -0
- package/package.json +1 -1
- package/payme-mini-app.podspec +1 -1
- package/src/index.tsx +11 -4
- package/src/index.type.ts +11 -0
package/android/build.gradle
CHANGED
|
@@ -74,7 +74,7 @@ dependencies {
|
|
|
74
74
|
//noinspection GradleDynamicVersion
|
|
75
75
|
implementation "com.facebook.react:react-native"
|
|
76
76
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
77
|
-
implementation 'com.github.PayME-Miniapp:native-android:0.0.
|
|
77
|
+
implementation 'com.github.PayME-Miniapp:native-android:0.0.20'
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
if (isNewArchitectureEnabled()) {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
package com.paymeminiapp
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.*
|
|
4
|
+
import org.json.JSONArray
|
|
5
|
+
import org.json.JSONException
|
|
6
|
+
import org.json.JSONObject
|
|
7
|
+
|
|
8
|
+
object JsonConvert {
|
|
9
|
+
@Throws(JSONException::class)
|
|
10
|
+
fun reactToJSON(readableMap: ReadableMap?): JSONObject {
|
|
11
|
+
val jsonObject = JSONObject()
|
|
12
|
+
val iterator = readableMap!!.keySetIterator()
|
|
13
|
+
while (iterator.hasNextKey()) {
|
|
14
|
+
val key = iterator.nextKey()
|
|
15
|
+
val valueType = readableMap.getType(key)
|
|
16
|
+
when (valueType) {
|
|
17
|
+
ReadableType.Null -> jsonObject.put(key, JSONObject.NULL)
|
|
18
|
+
ReadableType.Boolean -> jsonObject.put(key, readableMap.getBoolean(key))
|
|
19
|
+
ReadableType.Number -> try {
|
|
20
|
+
jsonObject.put(key, readableMap.getInt(key))
|
|
21
|
+
} catch (e: Exception) {
|
|
22
|
+
jsonObject.put(key, readableMap.getDouble(key))
|
|
23
|
+
}
|
|
24
|
+
ReadableType.String -> jsonObject.put(key, readableMap.getString(key))
|
|
25
|
+
ReadableType.Map -> jsonObject.put(key, reactToJSON(readableMap.getMap(key)))
|
|
26
|
+
ReadableType.Array -> jsonObject.put(key, reactToJSON(readableMap.getArray(key)))
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return jsonObject
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Throws(JSONException::class)
|
|
33
|
+
fun reactToJSON(readableArray: ReadableArray?): JSONArray {
|
|
34
|
+
val jsonArray = JSONArray()
|
|
35
|
+
for (i in 0 until readableArray!!.size()) {
|
|
36
|
+
val valueType = readableArray.getType(i)
|
|
37
|
+
when (valueType) {
|
|
38
|
+
ReadableType.Null -> jsonArray.put(JSONObject.NULL)
|
|
39
|
+
ReadableType.Boolean -> jsonArray.put(readableArray.getBoolean(i))
|
|
40
|
+
ReadableType.Number -> try {
|
|
41
|
+
jsonArray.put(readableArray.getInt(i))
|
|
42
|
+
} catch (e: Exception) {
|
|
43
|
+
jsonArray.put(readableArray.getDouble(i))
|
|
44
|
+
}
|
|
45
|
+
ReadableType.String -> jsonArray.put(readableArray.getString(i))
|
|
46
|
+
ReadableType.Map -> jsonArray.put(reactToJSON(readableArray.getMap(i)))
|
|
47
|
+
ReadableType.Array -> jsonArray.put(reactToJSON(readableArray.getArray(i)))
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return jsonArray
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Throws(JSONException::class)
|
|
54
|
+
fun jsonToReact(jsonObject: JSONObject): WritableMap {
|
|
55
|
+
val writableMap: WritableMap = Arguments.createMap()
|
|
56
|
+
val iterator: Iterator<*> = jsonObject.keys()
|
|
57
|
+
while (iterator.hasNext()) {
|
|
58
|
+
val key = iterator.next() as String
|
|
59
|
+
val value: Any = jsonObject.get(key)
|
|
60
|
+
if (value is Float || value is Double) {
|
|
61
|
+
writableMap.putDouble(key, jsonObject.getDouble(key))
|
|
62
|
+
} else if (value is Number) {
|
|
63
|
+
writableMap.putInt(key, jsonObject.getInt(key))
|
|
64
|
+
} else if (value is String) {
|
|
65
|
+
writableMap.putString(key, jsonObject.getString(key))
|
|
66
|
+
} else if (value is JSONObject) {
|
|
67
|
+
writableMap.putMap(key, jsonToReact(jsonObject.getJSONObject(key)))
|
|
68
|
+
} else if (value is JSONArray) {
|
|
69
|
+
writableMap.putArray(key, jsonToReact(jsonObject.getJSONArray(key)))
|
|
70
|
+
} else if (value === JSONObject.NULL) {
|
|
71
|
+
writableMap.putNull(key)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return writableMap
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Throws(JSONException::class)
|
|
78
|
+
fun jsonToReact(jsonArray: JSONArray): WritableArray {
|
|
79
|
+
val writableArray: WritableArray = Arguments.createArray()
|
|
80
|
+
for (i in 0 until jsonArray.length()) {
|
|
81
|
+
val value: Any = jsonArray.get(i)
|
|
82
|
+
if (value is Float || value is Double) {
|
|
83
|
+
writableArray.pushDouble(jsonArray.getDouble(i))
|
|
84
|
+
} else if (value is Number) {
|
|
85
|
+
writableArray.pushInt(jsonArray.getInt(i))
|
|
86
|
+
} else if (value is String) {
|
|
87
|
+
writableArray.pushString(jsonArray.getString(i))
|
|
88
|
+
} else if (value is JSONObject) {
|
|
89
|
+
writableArray.pushMap(jsonToReact(jsonArray.getJSONObject(i)))
|
|
90
|
+
} else if (value is JSONArray) {
|
|
91
|
+
writableArray.pushArray(jsonToReact(jsonArray.getJSONArray(i)))
|
|
92
|
+
} else if (value === JSONObject.NULL) {
|
|
93
|
+
writableArray.pushNull()
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return writableArray
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -1,26 +1,131 @@
|
|
|
1
1
|
package com.paymeminiapp
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
-
import
|
|
5
|
-
import com.facebook.react.bridge
|
|
6
|
-
import com.facebook.react.
|
|
7
|
-
import com.facebook.react.bridge.Promise
|
|
4
|
+
import android.util.Log
|
|
5
|
+
import com.facebook.react.bridge.*
|
|
6
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
8
7
|
import com.payme.sdk.PayMEMiniApp
|
|
8
|
+
import com.payme.sdk.models.*
|
|
9
|
+
import org.json.JSONObject
|
|
9
10
|
|
|
10
11
|
class RNPayMEMiniAppModule(reactContext: ReactApplicationContext) :
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
13
|
+
private var payMEMiniApp: PayMEMiniApp? = null
|
|
14
|
+
override fun getName(): String {
|
|
15
|
+
return NAME
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private val eventNames = arrayListOf("onResponse", "onError")
|
|
19
|
+
|
|
20
|
+
@ReactMethod
|
|
21
|
+
fun initPayME(appId: String, publicKey: String, privateKey: String) {
|
|
22
|
+
payMEMiniApp = PayMEMiniApp(
|
|
23
|
+
currentActivity as Context, appId, publicKey, privateKey
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@ReactMethod
|
|
28
|
+
fun open(type: String, openingParam: ReadableMap) {
|
|
29
|
+
val action = openingParam.getString("action") ?: "PAYME"
|
|
30
|
+
val phone = openingParam.getString("phone") ?: ""
|
|
31
|
+
val data = openingParam.getMap("data")
|
|
32
|
+
val amount = data?.getInt("amount")
|
|
33
|
+
val transactionId = data?.getString("transactionId")
|
|
34
|
+
val note = data?.getString("note")
|
|
35
|
+
val ipnUrl = data?.getString("ipnUrl")
|
|
36
|
+
val env = data?.getString("env")
|
|
37
|
+
var paymentData: PaymentData? = null
|
|
38
|
+
if (amount != null && transactionId != null) {
|
|
39
|
+
paymentData = PaymentData(transactionId, amount, note, ipnUrl)
|
|
40
|
+
}
|
|
41
|
+
val openMiniAppData =
|
|
42
|
+
OpenMiniAppData(
|
|
43
|
+
getActionOpenMiniApp(action),
|
|
44
|
+
phone,
|
|
45
|
+
env = ENV.LOCAL,
|
|
46
|
+
paymentData = paymentData
|
|
47
|
+
)
|
|
48
|
+
payMEMiniApp?.openMiniApp(
|
|
49
|
+
getTypeOpenMiniApp(type),
|
|
50
|
+
openMiniAppData,
|
|
51
|
+
onSuccess = { actionOpenMiniApp: ActionOpenMiniApp, jsonObject: JSONObject? ->
|
|
52
|
+
if (jsonObject != null) {
|
|
53
|
+
try {
|
|
54
|
+
val payload = JsonConvert.jsonToReact(jsonObject)
|
|
55
|
+
payload.putString("action", actionOpenMiniApp.toString())
|
|
56
|
+
sendEvent(
|
|
57
|
+
reactApplicationContext,
|
|
58
|
+
"onResponse", payload
|
|
59
|
+
)
|
|
60
|
+
} catch (e: Exception) {
|
|
61
|
+
Log.d("PAYME", "exception $e")
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
onError = { actionOpenMiniApp: ActionOpenMiniApp, payMEError: PayMEError ->
|
|
66
|
+
val payload = Arguments.createMap()
|
|
67
|
+
payload.putString("action", actionOpenMiniApp.toString())
|
|
68
|
+
payload.putString("code", payMEError.code)
|
|
69
|
+
payload.putString("description", payMEError.message)
|
|
70
|
+
sendEvent(
|
|
71
|
+
reactApplicationContext,
|
|
72
|
+
"onError", payload
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private var listenerCount = 0
|
|
79
|
+
|
|
80
|
+
@ReactMethod
|
|
81
|
+
fun addListener(eventName: String) {
|
|
82
|
+
if (listenerCount == 0) {
|
|
83
|
+
// Set up any upstream listeners or background tasks as necessary
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
listenerCount += 1
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@ReactMethod
|
|
90
|
+
fun removeListeners(count: Int) {
|
|
91
|
+
listenerCount -= count
|
|
92
|
+
if (listenerCount == 0) {
|
|
93
|
+
// Remove upstream listeners, stop unnecessary background tasks
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private fun getTypeOpenMiniApp(type: String): OpenMiniAppType {
|
|
98
|
+
if (type.lowercase() == OpenMiniAppType.modal.toString()) {
|
|
99
|
+
return OpenMiniAppType.modal
|
|
100
|
+
}
|
|
101
|
+
if (type.lowercase() == OpenMiniAppType.screen.toString()) {
|
|
102
|
+
return OpenMiniAppType.screen
|
|
103
|
+
}
|
|
104
|
+
return OpenMiniAppType.screen
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private fun getActionOpenMiniApp(action: String): ActionOpenMiniApp {
|
|
108
|
+
if (action == ActionOpenMiniApp.PAYME.toString()) {
|
|
109
|
+
return ActionOpenMiniApp.PAYME
|
|
110
|
+
}
|
|
111
|
+
if (action == ActionOpenMiniApp.OPEN.toString()) {
|
|
112
|
+
return ActionOpenMiniApp.OPEN
|
|
113
|
+
}
|
|
114
|
+
if (action == ActionOpenMiniApp.PAY.toString()) {
|
|
115
|
+
return ActionOpenMiniApp.PAY
|
|
116
|
+
}
|
|
117
|
+
return ActionOpenMiniApp.PAYME
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
private fun sendEvent(reactContext: ReactContext, eventName: String, params: WritableMap?) {
|
|
121
|
+
if (eventNames.contains(eventName)) {
|
|
122
|
+
reactContext
|
|
123
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
124
|
+
.emit(eventName, params)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
companion object {
|
|
129
|
+
const val NAME = "RNPayMEMiniApp"
|
|
130
|
+
}
|
|
131
|
+
}
|
package/ios/RNPayMEMiniApp.m
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTEventEmitter.h>
|
|
2
3
|
|
|
3
|
-
@interface RCT_EXTERN_MODULE(RNPayMEMiniApp,
|
|
4
|
+
@interface RCT_EXTERN_MODULE(RNPayMEMiniApp, RCTEventEmitter)
|
|
4
5
|
|
|
5
|
-
RCT_EXTERN_METHOD(
|
|
6
|
+
RCT_EXTERN_METHOD(initPayME:(NSString*)appId publicKey:(NSString)publicKey privateKey:(NSString)privateKey)
|
|
7
|
+
RCT_EXTERN_METHOD(open:(NSString*)type param:(NSDictionary)param)
|
|
6
8
|
|
|
7
9
|
+ (BOOL)requiresMainQueueSetup
|
|
8
10
|
{
|
|
@@ -10,3 +12,5 @@ RCT_EXTERN_METHOD(open:(NSString*)type)
|
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
@end
|
|
15
|
+
|
|
16
|
+
|
package/ios/RNPayMEMiniApp.swift
CHANGED
|
@@ -1,17 +1,63 @@
|
|
|
1
1
|
import PayMEMiniApp
|
|
2
2
|
|
|
3
3
|
@objc(RNPayMEMiniApp)
|
|
4
|
-
class RNPayMEMiniApp:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@objc func
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
payme.open()
|
|
13
|
-
} else {
|
|
14
|
-
payme.open(from: RNVC)
|
|
4
|
+
class RNPayMEMiniApp: RCTEventEmitter, PayMEDelegate {
|
|
5
|
+
var payme: PayME!
|
|
6
|
+
|
|
7
|
+
@objc func initPayME(_ appId: String, publicKey: String, privateKey: String) {
|
|
8
|
+
DispatchQueue.main.sync {
|
|
9
|
+
PayMEConfig.instance.env = .local
|
|
10
|
+
self.payme = PayME(key: PayMEKey(appId: appId, publicKey: publicKey, privateKey: privateKey))
|
|
11
|
+
self.payme.delegate = self
|
|
15
12
|
}
|
|
16
13
|
}
|
|
14
|
+
|
|
15
|
+
@objc func open(_ type: String = "modal", param: NSDictionary) {
|
|
16
|
+
let openAction: PayMEAction = {
|
|
17
|
+
switch param["action"] as? String {
|
|
18
|
+
case "PAYME": return PayMEAction.PayME
|
|
19
|
+
case "OPEN": return PayMEAction.Open
|
|
20
|
+
case "PAY": return PayMEAction.Pay
|
|
21
|
+
default: fatalError("Invalid action!")
|
|
22
|
+
}
|
|
23
|
+
}()
|
|
24
|
+
var openData: Any? {
|
|
25
|
+
guard let data = param["data"] as? NSDictionary else { return nil }
|
|
26
|
+
switch param["action"] as? String {
|
|
27
|
+
case "PAYME": fallthrough
|
|
28
|
+
case "OPEN": return nil
|
|
29
|
+
case "PAY":
|
|
30
|
+
return PayMEPaymentParam(amount: data["amount"] as! Int, transactionId: data["transactionId"] as! String, note: data["note"] as? String)
|
|
31
|
+
default: fatalError("Invalid action!")
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
DispatchQueue.main.sync {
|
|
36
|
+
let RNVC = UIApplication.shared.delegate?.window??.rootViewController
|
|
37
|
+
if (type == "screen") {
|
|
38
|
+
guard let navigationController = RNVC as? UINavigationController else { return }
|
|
39
|
+
navigationController.pushViewController(self.payme, animated: true)
|
|
40
|
+
// payme.open()
|
|
41
|
+
} else {
|
|
42
|
+
self.payme.open(with: PayMEOpeningParam(action: openAction, phone: param["phone"] as! String, data: openData), from: RNVC)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override func supportedEvents() -> [String]! {
|
|
48
|
+
return ["onError", "onResponse"]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
func onError(action: PayMEMiniApp.PayMEAction, error: PayMEMiniApp.PayMEError) {
|
|
52
|
+
sendEvent(withName: "onError", body: ["action": action.value, "code": error.code, "description": error.description])
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
func onResponse(action: PayMEMiniApp.PayMEAction, response: [String: String]) {
|
|
56
|
+
sendEvent(withName: "onResponse", body: ["action": action.value].merging(response) { (_, new) in new })
|
|
57
|
+
}
|
|
17
58
|
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.PayMEMiniAppEvents = void 0;
|
|
7
|
+
exports.init = init;
|
|
6
8
|
exports.open = open;
|
|
7
9
|
var _reactNative = require("react-native");
|
|
8
10
|
const RNPayMEMiniApp = _reactNative.NativeModules.RNPayMEMiniApp;
|
|
9
|
-
function
|
|
10
|
-
return RNPayMEMiniApp.
|
|
11
|
+
function init(appId, publicKey, privateKey) {
|
|
12
|
+
return RNPayMEMiniApp.initPayME(appId, publicKey, privateKey);
|
|
11
13
|
}
|
|
14
|
+
function open(type, openingParam) {
|
|
15
|
+
return RNPayMEMiniApp.open(type, openingParam);
|
|
16
|
+
}
|
|
17
|
+
const PayMEMiniAppEvents = new _reactNative.NativeEventEmitter(RNPayMEMiniApp);
|
|
18
|
+
exports.PayMEMiniAppEvents = PayMEMiniAppEvents;
|
|
12
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RNPayMEMiniApp","NativeModules","open","type"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"names":["RNPayMEMiniApp","NativeModules","init","appId","publicKey","privateKey","initPayME","open","type","openingParam","PayMEMiniAppEvents","NativeEventEmitter"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;AAAA;AAGA,MAAMA,cAAc,GAAGC,0BAAa,CAACD,cAAc;AAE5C,SAASE,IAAI,CAACC,KAAa,EAAEC,SAAiB,EAAEC,UAAkB,EAAE;EACzE,OAAOL,cAAc,CAACM,SAAS,CAACH,KAAK,EAAEC,SAAS,EAAEC,UAAU,CAAC;AAC/D;AAEO,SAASE,IAAI,CAACC,IAAY,EAAEC,YAA+B,EAAE;EAClE,OAAOT,cAAc,CAACO,IAAI,CAACC,IAAI,EAAEC,YAAY,CAAC;AAChD;AAEO,MAAMC,kBAAkB,GAAG,IAAIC,+BAAkB,CAACX,cAAc,CAAC;AAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.type.ts"],"mappings":""}
|
package/lib/module/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
1
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
2
|
const RNPayMEMiniApp = NativeModules.RNPayMEMiniApp;
|
|
3
|
-
export function
|
|
4
|
-
return RNPayMEMiniApp.
|
|
3
|
+
export function init(appId, publicKey, privateKey) {
|
|
4
|
+
return RNPayMEMiniApp.initPayME(appId, publicKey, privateKey);
|
|
5
5
|
}
|
|
6
|
+
export function open(type, openingParam) {
|
|
7
|
+
return RNPayMEMiniApp.open(type, openingParam);
|
|
8
|
+
}
|
|
9
|
+
export const PayMEMiniAppEvents = new NativeEventEmitter(RNPayMEMiniApp);
|
|
6
10
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","RNPayMEMiniApp","open","type"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","RNPayMEMiniApp","init","appId","publicKey","privateKey","initPayME","open","type","openingParam","PayMEMiniAppEvents"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAGhE,MAAMC,cAAc,GAAGD,aAAa,CAACC,cAAc;AAEnD,OAAO,SAASC,IAAI,CAACC,KAAa,EAAEC,SAAiB,EAAEC,UAAkB,EAAE;EACzE,OAAOJ,cAAc,CAACK,SAAS,CAACH,KAAK,EAAEC,SAAS,EAAEC,UAAU,CAAC;AAC/D;AAEA,OAAO,SAASE,IAAI,CAACC,IAAY,EAAEC,YAA+B,EAAE;EAClE,OAAOR,cAAc,CAACM,IAAI,CAACC,IAAI,EAAEC,YAAY,CAAC;AAChD;AAEA,OAAO,MAAMC,kBAAkB,GAAG,IAAIX,kBAAkB,CAACE,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.type.ts"],"mappings":""}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { NativeEventEmitter } from 'react-native';
|
|
2
|
+
import type { PayMEOpeningParam } from './index.type';
|
|
3
|
+
export declare function init(appId: string, publicKey: string, privateKey: string): any;
|
|
4
|
+
export declare function open(type: string, openingParam: PayMEOpeningParam): any;
|
|
5
|
+
export declare const PayMEMiniAppEvents: NativeEventEmitter;
|
|
2
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAiB,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAItD,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,OAExE;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,OAEjE;AAED,eAAO,MAAM,kBAAkB,oBAAyC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type PayMEPaymentParam = {
|
|
2
|
+
amount: number;
|
|
3
|
+
transactionId: string;
|
|
4
|
+
note?: string;
|
|
5
|
+
ipnUrl: string;
|
|
6
|
+
};
|
|
7
|
+
export type PayMEOpeningParam = {
|
|
8
|
+
action: 'PAYME';
|
|
9
|
+
phone: string;
|
|
10
|
+
} | {
|
|
11
|
+
action: 'OPEN';
|
|
12
|
+
phone: string;
|
|
13
|
+
} | {
|
|
14
|
+
action: 'PAY';
|
|
15
|
+
phone: string;
|
|
16
|
+
data: PayMEPaymentParam;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=index.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.type.d.ts","sourceRoot":"","sources":["../../src/index.type.ts"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,CAAC"}
|
package/package.json
CHANGED
package/payme-mini-app.podspec
CHANGED
|
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
s.swift_versions = "5.0"
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
18
|
|
|
19
|
-
s.dependency "PayMEMiniApp", "
|
|
19
|
+
s.dependency "PayMEMiniApp", "0.0.1"
|
|
20
20
|
s.dependency "React-Core"
|
|
21
21
|
s.pod_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' }
|
|
22
22
|
# Don't install the dependencies when we run `pod install` in the old architecture.
|
package/src/index.tsx
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
1
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
|
+
import type { PayMEOpeningParam } from './index.type';
|
|
2
3
|
|
|
3
|
-
const RNPayMEMiniApp = NativeModules.RNPayMEMiniApp
|
|
4
|
+
const RNPayMEMiniApp = NativeModules.RNPayMEMiniApp;
|
|
4
5
|
|
|
5
|
-
export function
|
|
6
|
-
return RNPayMEMiniApp.
|
|
6
|
+
export function init(appId: string, publicKey: string, privateKey: string) {
|
|
7
|
+
return RNPayMEMiniApp.initPayME(appId, publicKey, privateKey);
|
|
7
8
|
}
|
|
9
|
+
|
|
10
|
+
export function open(type: string, openingParam: PayMEOpeningParam) {
|
|
11
|
+
return RNPayMEMiniApp.open(type, openingParam);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const PayMEMiniAppEvents = new NativeEventEmitter(RNPayMEMiniApp);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type PayMEPaymentParam = {
|
|
2
|
+
amount: number;
|
|
3
|
+
transactionId: string;
|
|
4
|
+
note?: string;
|
|
5
|
+
ipnUrl: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type PayMEOpeningParam =
|
|
9
|
+
| { action: 'PAYME'; phone: string }
|
|
10
|
+
| { action: 'OPEN'; phone: string }
|
|
11
|
+
| { action: 'PAY'; phone: string; data: PayMEPaymentParam };
|