vialink-react-native-sdk 2.1.8 → 2.1.10
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.
|
@@ -61,16 +61,48 @@ class ViaLinkModule(reactContext: ReactApplicationContext) :
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
@ReactMethod
|
|
64
|
-
fun createLink(
|
|
64
|
+
fun createLink(
|
|
65
|
+
path: String,
|
|
66
|
+
data: ReadableMap?,
|
|
67
|
+
campaign: String?,
|
|
68
|
+
linkType: String,
|
|
69
|
+
options: ReadableMap?,
|
|
70
|
+
promise: Promise
|
|
71
|
+
) {
|
|
65
72
|
scope.launch {
|
|
66
|
-
|
|
67
|
-
//
|
|
68
|
-
val
|
|
73
|
+
val dataMap = data?.toHashMap()?.mapValues { it.value as Any }
|
|
74
|
+
// 5번째 인자는 폴백 URL/OG/채널/태그 등 부가 옵션 (선택).
|
|
75
|
+
val tagsList = options?.takeIf { it.hasKey("tags") && !it.isNull("tags") }
|
|
76
|
+
?.getArray("tags")
|
|
77
|
+
?.toArrayList()
|
|
78
|
+
?.mapNotNull { it as? String }
|
|
79
|
+
val result = ViaLinkSDK.createLink(
|
|
80
|
+
path = path,
|
|
81
|
+
data = dataMap,
|
|
82
|
+
campaign = campaign,
|
|
83
|
+
linkType = linkType,
|
|
84
|
+
iosUrl = options?.optString("iosUrl"),
|
|
85
|
+
androidUrl = options?.optString("androidUrl"),
|
|
86
|
+
webUrl = options?.optString("webUrl"),
|
|
87
|
+
ogTitle = options?.optString("ogTitle"),
|
|
88
|
+
ogDescription = options?.optString("ogDescription"),
|
|
89
|
+
ogImageUrl = options?.optString("ogImageUrl"),
|
|
90
|
+
channel = options?.optString("channel"),
|
|
91
|
+
feature = options?.optString("feature"),
|
|
92
|
+
tags = tagsList,
|
|
93
|
+
expiresAt = options?.optString("expiresAt"),
|
|
94
|
+
)
|
|
69
95
|
result.onSuccess { promise.resolve(it) }
|
|
70
96
|
result.onFailure { promise.reject("CREATE_LINK_ERROR", it.message) }
|
|
71
97
|
}
|
|
72
98
|
}
|
|
73
99
|
|
|
100
|
+
/// ReadableMap에서 String을 안전하게 꺼냄 (없거나 null이면 null 반환).
|
|
101
|
+
private fun ReadableMap.optString(key: String): String? {
|
|
102
|
+
if (!hasKey(key) || isNull(key)) return null
|
|
103
|
+
return getString(key)
|
|
104
|
+
}
|
|
105
|
+
|
|
74
106
|
/// 결제 시도 이벤트를 native SDK(payment.initiated)로 전달.
|
|
75
107
|
/// args: { orderId, amount, currency, linkId?, paymentMethod?, metadata? }
|
|
76
108
|
/// resolve: { success: Boolean, paymentEventId: String }
|
package/dist/ViaLinkSDK.d.ts
CHANGED
|
@@ -28,6 +28,18 @@ export interface PaymentInitiatedArgs {
|
|
|
28
28
|
* - success: 서버에서 성공 처리되었는지 여부
|
|
29
29
|
* - paymentEventId: 서버에서 발급한 결제 이벤트 ID (문자열로 정규화)
|
|
30
30
|
*/
|
|
31
|
+
export interface CreateLinkExtraOptions {
|
|
32
|
+
iosUrl?: string;
|
|
33
|
+
androidUrl?: string;
|
|
34
|
+
webUrl?: string;
|
|
35
|
+
ogTitle?: string;
|
|
36
|
+
ogDescription?: string;
|
|
37
|
+
ogImageUrl?: string;
|
|
38
|
+
channel?: string;
|
|
39
|
+
feature?: string;
|
|
40
|
+
tags?: string[];
|
|
41
|
+
expiresAt?: string;
|
|
42
|
+
}
|
|
31
43
|
export interface PaymentInitiatedResult {
|
|
32
44
|
success: boolean;
|
|
33
45
|
paymentEventId: string;
|
|
@@ -91,7 +103,7 @@ export declare class ViaLinkSDK {
|
|
|
91
103
|
* const url = await ViaLinkSDK.shared.createLink('/product/123', { promo: 'FRIEND' }, 'referral', 'static');
|
|
92
104
|
* ```
|
|
93
105
|
*/
|
|
94
|
-
createLink(path: string, data?: Record<string, unknown>, campaign?: string, linkType?: 'dynamic' | 'static'): Promise<string>;
|
|
106
|
+
createLink(path: string, data?: Record<string, unknown>, campaign?: string, linkType?: 'dynamic' | 'static', options?: CreateLinkExtraOptions): Promise<string>;
|
|
95
107
|
/**
|
|
96
108
|
* 결제 추적 namespace.
|
|
97
109
|
*
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var reactNative=require('react-native');var {ViaLinkSDK:n}=reactNative.NativeModules,i=new reactNative.NativeEventEmitter(n),
|
|
1
|
+
'use strict';var reactNative=require('react-native');var {ViaLinkSDK:n}=reactNative.NativeModules,i=new reactNative.NativeEventEmitter(n),m=/^[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"||!m.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,s="static",d){return n.createLink(e,t??null,o??null,s,d??null)}destroy(){this.deepLinkSub?.remove(),this.deferredSub?.remove();}};exports.ViaLinkSDK=r;
|
package/ios/ViaLinkModule.m
CHANGED
|
@@ -14,6 +14,7 @@ RCT_EXTERN_METHOD(createLink:(NSString *)path
|
|
|
14
14
|
data:(NSDictionary *)data
|
|
15
15
|
campaign:(NSString *)campaign
|
|
16
16
|
linkType:(NSString *)linkType
|
|
17
|
+
options:(NSDictionary *)options
|
|
17
18
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
18
19
|
reject:(RCTPromiseRejectBlock)reject)
|
|
19
20
|
|
package/ios/ViaLinkModule.swift
CHANGED
|
@@ -66,13 +66,28 @@ class ViaLinkModule: RCTEventEmitter {
|
|
|
66
66
|
|
|
67
67
|
@objc func createLink(_ path: String, data: NSDictionary?, campaign: String?,
|
|
68
68
|
linkType: String,
|
|
69
|
+
options: NSDictionary?,
|
|
69
70
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
70
71
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
71
72
|
Task {
|
|
72
73
|
do {
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
// 5번째 인자(options)는 폴백 URL/OG/채널/태그 등 부가 옵션 (선택).
|
|
75
|
+
let url = try await ViaLinkSDK.shared.createLink(
|
|
76
|
+
path: path,
|
|
77
|
+
data: data as? [String: String],
|
|
78
|
+
campaign: campaign,
|
|
79
|
+
linkType: linkType,
|
|
80
|
+
iosUrl: options?["iosUrl"] as? String,
|
|
81
|
+
androidUrl: options?["androidUrl"] as? String,
|
|
82
|
+
webUrl: options?["webUrl"] as? String,
|
|
83
|
+
ogTitle: options?["ogTitle"] as? String,
|
|
84
|
+
ogDescription: options?["ogDescription"] as? String,
|
|
85
|
+
ogImageUrl: options?["ogImageUrl"] as? String,
|
|
86
|
+
channel: options?["channel"] as? String,
|
|
87
|
+
feature: options?["feature"] as? String,
|
|
88
|
+
tags: options?["tags"] as? [String],
|
|
89
|
+
expiresAt: options?["expiresAt"] as? String
|
|
90
|
+
)
|
|
76
91
|
DispatchQueue.main.async { resolve(url) }
|
|
77
92
|
} catch {
|
|
78
93
|
DispatchQueue.main.async { reject("CREATE_LINK_ERROR", error.localizedDescription, error) }
|
package/package.json
CHANGED