vialink-react-native-sdk 2.0.15 → 2.1.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/android/src/main/java/com/vialink/reactnative/ViaLinkModule.kt +57 -1
- package/dist/ViaLinkSDK.d.ts +50 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/ios/Frameworks/ViaLinkCore.xcframework/Info.plist +5 -5
- package/ios/Frameworks/ViaLinkCore.xcframework/ios-arm64/ViaLinkCore.framework/Modules/ViaLinkCore.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/ios/Frameworks/ViaLinkCore.xcframework/ios-arm64/ViaLinkCore.framework/ViaLinkCore +0 -0
- package/ios/Frameworks/ViaLinkCore.xcframework/ios-arm64_x86_64-simulator/ViaLinkCore.framework/Modules/ViaLinkCore.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/ios/Frameworks/ViaLinkCore.xcframework/ios-arm64_x86_64-simulator/ViaLinkCore.framework/Modules/ViaLinkCore.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/ios/Frameworks/ViaLinkCore.xcframework/ios-arm64_x86_64-simulator/ViaLinkCore.framework/ViaLinkCore +0 -0
- package/ios/ViaLinkModule.m +4 -0
- package/ios/ViaLinkModule.swift +51 -2
- package/package.json +1 -1
- package/vialink-react-native-sdk.podspec +1 -1
|
@@ -4,6 +4,7 @@ import com.facebook.react.bridge.*
|
|
|
4
4
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
5
5
|
import com.vialink.sdk.ViaLinkSDK
|
|
6
6
|
import com.vialink.sdk.model.DeepLinkData
|
|
7
|
+
import com.vialink.sdk.model.PaymentInitiatedArgs
|
|
7
8
|
import kotlinx.coroutines.*
|
|
8
9
|
|
|
9
10
|
class ViaLinkModule(reactContext: ReactApplicationContext) :
|
|
@@ -11,7 +12,7 @@ class ViaLinkModule(reactContext: ReactApplicationContext) :
|
|
|
11
12
|
ActivityEventListener {
|
|
12
13
|
|
|
13
14
|
companion object {
|
|
14
|
-
const val WRAPPER_VERSION = "2.0
|
|
15
|
+
const val WRAPPER_VERSION = "2.1.0"
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
private val scope = CoroutineScope(Dispatchers.Main + SupervisorJob())
|
|
@@ -68,6 +69,61 @@ class ViaLinkModule(reactContext: ReactApplicationContext) :
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
/// 결제 시도 이벤트를 native SDK(payment.initiated)로 전달.
|
|
73
|
+
/// args: { orderId, amount, currency, linkId?, paymentMethod?, metadata? }
|
|
74
|
+
/// resolve: { success: Boolean, paymentEventId: String }
|
|
75
|
+
@ReactMethod
|
|
76
|
+
fun paymentInitiated(args: ReadableMap, promise: Promise) {
|
|
77
|
+
try {
|
|
78
|
+
val orderId = if (args.hasKey("orderId") && !args.isNull("orderId"))
|
|
79
|
+
args.getString("orderId") else null
|
|
80
|
+
if (orderId.isNullOrEmpty()) {
|
|
81
|
+
return promise.reject("E_INVALID_ARG", "orderId가 필요합니다.")
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!args.hasKey("amount") || args.isNull("amount")) {
|
|
85
|
+
return promise.reject("E_INVALID_ARG", "amount가 필요합니다.")
|
|
86
|
+
}
|
|
87
|
+
val amount = args.getDouble("amount")
|
|
88
|
+
|
|
89
|
+
val currency = if (args.hasKey("currency") && !args.isNull("currency"))
|
|
90
|
+
args.getString("currency") else null
|
|
91
|
+
if (currency.isNullOrEmpty()) {
|
|
92
|
+
return promise.reject("E_INVALID_ARG", "currency가 필요합니다.")
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
val linkId = if (args.hasKey("linkId") && !args.isNull("linkId"))
|
|
96
|
+
args.getInt("linkId") else null
|
|
97
|
+
val paymentMethod = if (args.hasKey("paymentMethod") && !args.isNull("paymentMethod"))
|
|
98
|
+
args.getString("paymentMethod") else null
|
|
99
|
+
val metadata = if (args.hasKey("metadata") && !args.isNull("metadata"))
|
|
100
|
+
args.getMap("metadata")?.toHashMap()?.mapValues { it.value as Any? } else null
|
|
101
|
+
|
|
102
|
+
val payArgs = PaymentInitiatedArgs(
|
|
103
|
+
orderId = orderId,
|
|
104
|
+
amount = amount,
|
|
105
|
+
currency = currency,
|
|
106
|
+
linkId = linkId,
|
|
107
|
+
paymentMethod = paymentMethod,
|
|
108
|
+
metadata = metadata,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
scope.launch {
|
|
112
|
+
try {
|
|
113
|
+
val result = ViaLinkSDK.payment.initiated(payArgs)
|
|
114
|
+
val map = Arguments.createMap()
|
|
115
|
+
map.putBoolean("success", result.success)
|
|
116
|
+
map.putString("paymentEventId", result.paymentEventId)
|
|
117
|
+
promise.resolve(map)
|
|
118
|
+
} catch (e: Exception) {
|
|
119
|
+
promise.reject("E_PAYMENT_FAILED", e.message ?: e.toString(), e)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} catch (e: Exception) {
|
|
123
|
+
promise.reject("E_PAYMENT_FAILED", e.message ?: e.toString(), e)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
71
127
|
@ReactMethod
|
|
72
128
|
fun addListener(eventName: String) {
|
|
73
129
|
listenerCount++
|
package/dist/ViaLinkSDK.d.ts
CHANGED
|
@@ -3,6 +3,34 @@ export interface DeepLinkData {
|
|
|
3
3
|
params: Record<string, string>;
|
|
4
4
|
shortCode?: string;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* 결제 시도 이벤트 입력 인자.
|
|
8
|
+
*
|
|
9
|
+
* - orderId: 운영자가 발급하는 주문번호 (1~100자, 영문/숫자/하이픈/언더스코어)
|
|
10
|
+
* - amount: 결제 금액 (통화 단위 그대로, > 0)
|
|
11
|
+
* - currency: ISO 4217 통화 코드 (예: "KRW", "USD", "JPY")
|
|
12
|
+
* - linkId: (옵션) 사용자가 진입한 링크 id
|
|
13
|
+
* - paymentMethod: (옵션) 결제 수단 식별자 (예: "card", "kakao_pay")
|
|
14
|
+
* - metadata: (옵션) 운영자 자유 메타데이터 (iOS 호환을 위해 string-only)
|
|
15
|
+
*/
|
|
16
|
+
export interface PaymentInitiatedArgs {
|
|
17
|
+
orderId: string;
|
|
18
|
+
amount: number;
|
|
19
|
+
currency: string;
|
|
20
|
+
linkId?: number;
|
|
21
|
+
paymentMethod?: string;
|
|
22
|
+
metadata?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 결제 시도 응답.
|
|
26
|
+
*
|
|
27
|
+
* - success: 서버에서 성공 처리되었는지 여부
|
|
28
|
+
* - paymentEventId: 서버에서 발급한 결제 이벤트 ID (문자열로 정규화)
|
|
29
|
+
*/
|
|
30
|
+
export interface PaymentInitiatedResult {
|
|
31
|
+
success: boolean;
|
|
32
|
+
paymentEventId: string;
|
|
33
|
+
}
|
|
6
34
|
/**
|
|
7
35
|
* ViaLink React Native SDK
|
|
8
36
|
*
|
|
@@ -56,5 +84,27 @@ export declare class ViaLinkSDK {
|
|
|
56
84
|
* ```
|
|
57
85
|
*/
|
|
58
86
|
createLink(path: string, data?: Record<string, unknown>, campaign?: string): Promise<string>;
|
|
87
|
+
/**
|
|
88
|
+
* 결제 추적 namespace.
|
|
89
|
+
*
|
|
90
|
+
* `succeeded`/`failed`는 서버-투-서버(S2S) 엔드포인트라 클라이언트 SDK에서는 노출하지 않습니다.
|
|
91
|
+
*
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const result = await ViaLinkSDK.shared.payment.initiated({
|
|
94
|
+
* orderId: 'ORD-2026-0001',
|
|
95
|
+
* amount: 19900,
|
|
96
|
+
* currency: 'KRW',
|
|
97
|
+
* paymentMethod: 'card',
|
|
98
|
+
* });
|
|
99
|
+
* // result.success === true, result.paymentEventId === '123'
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
readonly payment: {
|
|
103
|
+
/**
|
|
104
|
+
* 결제 시도 기록 (POST /v1/payments/initiated).
|
|
105
|
+
* 결제창을 띄우기 직전에 호출합니다. 즉시 전송 (배치 X).
|
|
106
|
+
*/
|
|
107
|
+
initiated: (args: PaymentInitiatedArgs) => Promise<PaymentInitiatedResult>;
|
|
108
|
+
};
|
|
59
109
|
destroy(): void;
|
|
60
110
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { ViaLinkSDK } from './ViaLinkSDK';
|
|
2
|
-
export type { DeepLinkData } from './ViaLinkSDK';
|
|
2
|
+
export type { DeepLinkData, PaymentInitiatedArgs, PaymentInitiatedResult, } from './ViaLinkSDK';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var reactNative=require('react-native');var {ViaLinkSDK:
|
|
1
|
+
'use strict';var reactNative=require('react-native');var {ViaLinkSDK:n}=reactNative.NativeModules,i=new reactNative.NativeEventEmitter(n),c=/^[A-Za-z0-9_-]{1,100}$/,r=class a{constructor(){this.payment={initiated:async e=>{if(!e||typeof e!="object")throw new Error("args\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4.");if(typeof e.orderId!="string"||!c.test(e.orderId))throw new Error("order_id \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4 (1~100\uC790, \uC601\uBB38/\uC22B\uC790/\uD558\uC774\uD508/\uC5B8\uB354\uC2A4\uCF54\uC5B4).");if(typeof e.amount!="number"||!Number.isFinite(e.amount)||e.amount<=0)throw new Error("amount\uB294 0\uBCF4\uB2E4 \uD070 \uC22B\uC790\uC5EC\uC57C \uD569\uB2C8\uB2E4.");if(typeof e.currency!="string"||e.currency.trim().length===0)throw new Error("currency\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4.");let t=await n.paymentInitiated({orderId:e.orderId,amount:e.amount,currency:e.currency.trim().toUpperCase(),linkId:e.linkId??null,paymentMethod:e.paymentMethod??null,metadata:e.metadata??null});return {success:!!t?.success,paymentEventId:String(t?.paymentEventId??"")}}};}static get shared(){return this._instance||(this._instance=new a),this._instance}async configure(e){await n.configure(e);}onDeepLink(e){this.deepLinkSub?.remove(),this.deepLinkSub=i.addListener("onDeepLink",e);}onDeferredDeepLink(e){this.deferredSub?.remove(),this.deferredSub=i.addListener("onDeferredDeepLink",e);}track(e,t){n.track(e,t??null);}async createLink(e,t,o){return n.createLink(e,t??null,o??null)}destroy(){this.deepLinkSub?.remove(),this.deferredSub?.remove();}};exports.ViaLinkSDK=r;
|
|
@@ -8,32 +8,32 @@
|
|
|
8
8
|
<key>BinaryPath</key>
|
|
9
9
|
<string>ViaLinkCore.framework/ViaLinkCore</string>
|
|
10
10
|
<key>LibraryIdentifier</key>
|
|
11
|
-
<string>ios-
|
|
11
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
12
12
|
<key>LibraryPath</key>
|
|
13
13
|
<string>ViaLinkCore.framework</string>
|
|
14
14
|
<key>SupportedArchitectures</key>
|
|
15
15
|
<array>
|
|
16
16
|
<string>arm64</string>
|
|
17
|
+
<string>x86_64</string>
|
|
17
18
|
</array>
|
|
18
19
|
<key>SupportedPlatform</key>
|
|
19
20
|
<string>ios</string>
|
|
21
|
+
<key>SupportedPlatformVariant</key>
|
|
22
|
+
<string>simulator</string>
|
|
20
23
|
</dict>
|
|
21
24
|
<dict>
|
|
22
25
|
<key>BinaryPath</key>
|
|
23
26
|
<string>ViaLinkCore.framework/ViaLinkCore</string>
|
|
24
27
|
<key>LibraryIdentifier</key>
|
|
25
|
-
<string>ios-
|
|
28
|
+
<string>ios-arm64</string>
|
|
26
29
|
<key>LibraryPath</key>
|
|
27
30
|
<string>ViaLinkCore.framework</string>
|
|
28
31
|
<key>SupportedArchitectures</key>
|
|
29
32
|
<array>
|
|
30
33
|
<string>arm64</string>
|
|
31
|
-
<string>x86_64</string>
|
|
32
34
|
</array>
|
|
33
35
|
<key>SupportedPlatform</key>
|
|
34
36
|
<string>ios</string>
|
|
35
|
-
<key>SupportedPlatformVariant</key>
|
|
36
|
-
<string>simulator</string>
|
|
37
37
|
</dict>
|
|
38
38
|
</array>
|
|
39
39
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/ios/ViaLinkModule.m
CHANGED
|
@@ -16,4 +16,8 @@ RCT_EXTERN_METHOD(createLink:(NSString *)path
|
|
|
16
16
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
17
17
|
reject:(RCTPromiseRejectBlock)reject)
|
|
18
18
|
|
|
19
|
+
RCT_EXTERN_METHOD(paymentInitiated:(NSDictionary *)args
|
|
20
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
21
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
22
|
+
|
|
19
23
|
@end
|
package/ios/ViaLinkModule.swift
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import React
|
|
3
|
-
import
|
|
3
|
+
import ViaLinkCore // xcframework module: ViaLinkCore (class: ViaLinkSDK)
|
|
4
4
|
|
|
5
5
|
@objc(ViaLinkSDK)
|
|
6
6
|
class ViaLinkModule: RCTEventEmitter {
|
|
7
7
|
|
|
8
|
-
static let wrapperVersion = "2.0
|
|
8
|
+
static let wrapperVersion = "2.1.0"
|
|
9
9
|
|
|
10
10
|
private var pendingDeepLink: [String: Any?]?
|
|
11
11
|
private var pendingDeferred: [String: Any?]?
|
|
@@ -76,6 +76,55 @@ class ViaLinkModule: RCTEventEmitter {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
|
|
80
|
+
/// 결제 시도 이벤트를 native iOS SDK(ViaLinkSDK.shared.payment.initiated)로 전달.
|
|
81
|
+
/// args: { orderId, amount, currency, linkId?, paymentMethod?, metadata? }
|
|
82
|
+
/// resolve: { success: Bool, paymentEventId: String }
|
|
83
|
+
@objc func paymentInitiated(_ args: NSDictionary,
|
|
84
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
85
|
+
reject: @escaping RCTPromiseRejectBlock) {
|
|
86
|
+
guard let orderId = args["orderId"] as? String, !orderId.isEmpty else {
|
|
87
|
+
reject("E_INVALID_ARG", "orderId가 필요합니다.", nil)
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
guard let amountValue = args["amount"] as? NSNumber else {
|
|
91
|
+
reject("E_INVALID_ARG", "amount가 필요합니다.", nil)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
guard let currency = args["currency"] as? String, !currency.isEmpty else {
|
|
95
|
+
reject("E_INVALID_ARG", "currency가 필요합니다.", nil)
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let linkId = args["linkId"] as? Int
|
|
100
|
+
let paymentMethod = args["paymentMethod"] as? String
|
|
101
|
+
let metadata = args["metadata"] as? [String: String]
|
|
102
|
+
|
|
103
|
+
let payArgs = PaymentInitiatedArgs(
|
|
104
|
+
orderId: orderId,
|
|
105
|
+
amount: amountValue.doubleValue,
|
|
106
|
+
currency: currency,
|
|
107
|
+
linkId: linkId,
|
|
108
|
+
paymentMethod: paymentMethod,
|
|
109
|
+
metadata: metadata
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
Task {
|
|
113
|
+
do {
|
|
114
|
+
let result = try await ViaLinkSDK.shared.payment.initiated(payArgs)
|
|
115
|
+
DispatchQueue.main.async {
|
|
116
|
+
resolve([
|
|
117
|
+
"success": result.success,
|
|
118
|
+
"paymentEventId": result.paymentEventId,
|
|
119
|
+
])
|
|
120
|
+
}
|
|
121
|
+
} catch {
|
|
122
|
+
DispatchQueue.main.async {
|
|
123
|
+
reject("E_PAYMENT_FAILED", error.localizedDescription, error)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
79
128
|
}
|
|
80
129
|
|
|
81
130
|
extension DeepLinkData {
|
package/package.json
CHANGED