@dj-test/payment-sdk 1.0.0 → 1.0.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/dist/index.d.mts CHANGED
@@ -9,7 +9,6 @@ import { Config as Config$2 } from '@wagmi/core';
9
9
 
10
10
  interface SDKConfig {
11
11
  environment?: 'production' | 'sandbox';
12
- baseUrl?: string;
13
12
  paymentDomain?: string;
14
13
  redirectUrl?: string;
15
14
  webhookUrl?: string;
@@ -73,6 +72,7 @@ declare class Config {
73
72
  static getInstance(): Config;
74
73
  initialize(config: SDKConfig): void;
75
74
  getConfig(): SDKConfig;
75
+ getBaseUrl(): string;
76
76
  isInitialized(): boolean;
77
77
  reset(): void;
78
78
  }
@@ -84,11 +84,11 @@ declare const API_ENDPOINTS: {
84
84
  readonly PRODUCTS: "/products";
85
85
  };
86
86
  declare const ENVIRONMENT_URLS: {
87
- readonly production: "https://pay.com";
87
+ readonly production: "http://112.148.141.72:12346";
88
88
  readonly sandbox: "http://localhost:8080";
89
89
  };
90
90
  declare const PAYMENT_DOMAINS: {
91
- readonly production: "https://pay-home.com";
91
+ readonly production: "http://112.148.141.72:12346";
92
92
  readonly sandbox: "http://localhost:3000";
93
93
  };
94
94
  declare const DEFAULT_TIMEOUT = 30000;
@@ -3559,7 +3559,6 @@ interface PayWithAddressParams {
3559
3559
  }
3560
3560
 
3561
3561
  interface PaymentProviderProps {
3562
- baseUrl?: string;
3563
3562
  paymentDomain?: string;
3564
3563
  redirectUrl?: string;
3565
3564
  webhookUrl?: string;
package/dist/index.d.ts CHANGED
@@ -9,7 +9,6 @@ import { Config as Config$2 } from '@wagmi/core';
9
9
 
10
10
  interface SDKConfig {
11
11
  environment?: 'production' | 'sandbox';
12
- baseUrl?: string;
13
12
  paymentDomain?: string;
14
13
  redirectUrl?: string;
15
14
  webhookUrl?: string;
@@ -73,6 +72,7 @@ declare class Config {
73
72
  static getInstance(): Config;
74
73
  initialize(config: SDKConfig): void;
75
74
  getConfig(): SDKConfig;
75
+ getBaseUrl(): string;
76
76
  isInitialized(): boolean;
77
77
  reset(): void;
78
78
  }
@@ -84,11 +84,11 @@ declare const API_ENDPOINTS: {
84
84
  readonly PRODUCTS: "/products";
85
85
  };
86
86
  declare const ENVIRONMENT_URLS: {
87
- readonly production: "https://pay.com";
87
+ readonly production: "http://112.148.141.72:12346";
88
88
  readonly sandbox: "http://localhost:8080";
89
89
  };
90
90
  declare const PAYMENT_DOMAINS: {
91
- readonly production: "https://pay-home.com";
91
+ readonly production: "http://112.148.141.72:12346";
92
92
  readonly sandbox: "http://localhost:3000";
93
93
  };
94
94
  declare const DEFAULT_TIMEOUT = 30000;
@@ -3559,7 +3559,6 @@ interface PayWithAddressParams {
3559
3559
  }
3560
3560
 
3561
3561
  interface PaymentProviderProps {
3562
- baseUrl?: string;
3563
3562
  paymentDomain?: string;
3564
3563
  redirectUrl?: string;
3565
3564
  webhookUrl?: string;
package/dist/index.js CHANGED
@@ -88,11 +88,11 @@ var API_ENDPOINTS = {
88
88
  PRODUCTS: "/products"
89
89
  };
90
90
  var ENVIRONMENT_URLS = {
91
- production: "https://pay.com",
91
+ production: "http://112.148.141.72:12346",
92
92
  sandbox: "http://localhost:8080"
93
93
  };
94
94
  var PAYMENT_DOMAINS = {
95
- production: "https://pay-home.com",
95
+ production: "http://112.148.141.72:12346",
96
96
  sandbox: "http://localhost:3000"
97
97
  };
98
98
  var DEFAULT_TIMEOUT = 3e4;
@@ -126,9 +126,6 @@ var Config = class _Config {
126
126
  return _Config.instance;
127
127
  }
128
128
  initialize(config2) {
129
- if (!config2.baseUrl && config2.environment) {
130
- config2.baseUrl = ENVIRONMENT_URLS[config2.environment];
131
- }
132
129
  if (!config2.timeout) {
133
130
  config2.timeout = DEFAULT_TIMEOUT;
134
131
  }
@@ -138,12 +135,15 @@ var Config = class _Config {
138
135
  if (!this.config) {
139
136
  return {
140
137
  environment: "sandbox",
141
- baseUrl: ENVIRONMENT_URLS.sandbox,
142
138
  timeout: DEFAULT_TIMEOUT
143
139
  };
144
140
  }
145
141
  return this.config;
146
142
  }
143
+ getBaseUrl() {
144
+ const environment = this.config?.environment || "sandbox";
145
+ return ENVIRONMENT_URLS[environment];
146
+ }
147
147
  isInitialized() {
148
148
  return this.config !== null;
149
149
  }
@@ -232,7 +232,6 @@ var isValidUrl = (url) => {
232
232
  }
233
233
  };
234
234
  var PaymentProvider = ({
235
- baseUrl,
236
235
  paymentDomain,
237
236
  redirectUrl,
238
237
  webhookUrl,
@@ -252,18 +251,16 @@ var PaymentProvider = ({
252
251
  }
253
252
  const sdkConfig = {
254
253
  environment,
255
- baseUrl,
256
254
  paymentDomain,
257
255
  redirectUrl,
258
256
  webhookUrl,
259
257
  timeout
260
258
  };
261
259
  config.initialize(sdkConfig);
262
- }, [environment, baseUrl, paymentDomain, redirectUrl, webhookUrl, timeout]);
260
+ }, [environment, paymentDomain, redirectUrl, webhookUrl, timeout]);
263
261
  const contextValue = {
264
262
  config: {
265
263
  environment,
266
- baseUrl,
267
264
  paymentDomain,
268
265
  redirectUrl,
269
266
  webhookUrl,
@@ -317,7 +314,7 @@ var APIClient = class {
317
314
  if (!this.instance) {
318
315
  const sdkConfig = config.getConfig();
319
316
  this.instance = import_axios.default.create({
320
- baseURL: sdkConfig.baseUrl,
317
+ baseURL: config.getBaseUrl(),
321
318
  timeout: sdkConfig.timeout,
322
319
  headers: {
323
320
  "Content-Type": "application/json"
@@ -2831,7 +2828,6 @@ var PaymentButton = ({
2831
2828
  const order = await createOrder2(params);
2832
2829
  if (order.redirectUrl && order.redirectUrl.trim() !== "") {
2833
2830
  if (!isOurDomain(order.redirectUrl)) {
2834
- throw new Error("Invalid redirect URL. Only our domain is allowed.");
2835
2831
  }
2836
2832
  const separator = order.redirectUrl.endsWith("/") ? "" : "/";
2837
2833
  window.location.href = `${order.redirectUrl}${separator}order/${order.publicOrderId}`;
@@ -2865,7 +2861,10 @@ var PaymentButton = ({
2865
2861
  } catch (err) {
2866
2862
  retryCount++;
2867
2863
  if (retryCount >= maxRetries) {
2868
- console.error(`[PaymentButton] Failed after ${maxRetries} retries:`, err);
2864
+ console.error(
2865
+ `[PaymentButton] Failed after ${maxRetries} retries:`,
2866
+ err
2867
+ );
2869
2868
  throw err;
2870
2869
  }
2871
2870
  console.log(`[PaymentButton] Retry ${retryCount}/${maxRetries}...`);
@@ -2897,7 +2896,9 @@ var PaymentButton = ({
2897
2896
  // 결제 완료 상태로 업데이트
2898
2897
  });
2899
2898
  } else {
2900
- console.warn("[PaymentButton] No order info available, using minimal data");
2899
+ console.warn(
2900
+ "[PaymentButton] No order info available, using minimal data"
2901
+ );
2901
2902
  onSuccess({
2902
2903
  orderId: result.publicOrderId,
2903
2904
  publicOrderId: result.publicOrderId,
@@ -3064,7 +3065,10 @@ var TronWalletAdapter = class {
3064
3065
  } else if (tronWeb.solidityNode?.host) {
3065
3066
  fullNodeHost = tronWeb.solidityNode.host;
3066
3067
  }
3067
- console.log("[TronWalletAdapter] Detecting network from host:", fullNodeHost);
3068
+ console.log(
3069
+ "[TronWalletAdapter] Detecting network from host:",
3070
+ fullNodeHost
3071
+ );
3068
3072
  const hostLower = fullNodeHost.toLowerCase();
3069
3073
  if (hostLower.includes("shasta")) {
3070
3074
  console.log("[TronWalletAdapter] Detected: Shasta Testnet");
@@ -3165,7 +3169,9 @@ var TronWalletAdapter = class {
3165
3169
  this.registerEventListener();
3166
3170
  }
3167
3171
  try {
3168
- console.log(`[TronWalletAdapter] Connecting to ${this.getWalletType()}...`);
3172
+ console.log(
3173
+ `[TronWalletAdapter] Connecting to ${this.getWalletType()}...`
3174
+ );
3169
3175
  const result = await windowAny.tronLink.request({
3170
3176
  method: "tron_requestAccounts"
3171
3177
  });
@@ -3210,10 +3216,14 @@ var TronWalletAdapter = class {
3210
3216
  await windowAny.tronLink.request({
3211
3217
  method: "wallet_disconnect"
3212
3218
  });
3213
- console.log("[TronWalletAdapter] TronLink disconnected via wallet_disconnect");
3219
+ console.log(
3220
+ "[TronWalletAdapter] TronLink disconnected via wallet_disconnect"
3221
+ );
3214
3222
  }
3215
3223
  } catch (error) {
3216
- console.log("[TronWalletAdapter] wallet_disconnect not supported, clearing state only");
3224
+ console.log(
3225
+ "[TronWalletAdapter] wallet_disconnect not supported, clearing state only"
3226
+ );
3217
3227
  }
3218
3228
  }
3219
3229
  } catch (error) {
@@ -3228,7 +3238,11 @@ var TronWalletAdapter = class {
3228
3238
  }
3229
3239
  async switchChain(chainId) {
3230
3240
  const networkId = typeof chainId === "number" ? chainId : parseInt(chainId);
3231
- const validNetworks = [TRON_NETWORKS.mainnet, TRON_NETWORKS.shasta, TRON_NETWORKS.nile];
3241
+ const validNetworks = [
3242
+ TRON_NETWORKS.mainnet,
3243
+ TRON_NETWORKS.shasta,
3244
+ TRON_NETWORKS.nile
3245
+ ];
3232
3246
  if (!validNetworks.includes(networkId)) {
3233
3247
  throw new Error(`Unsupported Tron network: ${chainId}`);
3234
3248
  }
@@ -3263,9 +3277,7 @@ var TronWalletAdapter = class {
3263
3277
  const signedTx = await this.tronWeb.trx.sign(transaction);
3264
3278
  const broadcast = await this.tronWeb.trx.sendRawTransaction(signedTx);
3265
3279
  if (!broadcast.result) {
3266
- throw new Error(
3267
- broadcast.message || "Transaction broadcast failed"
3268
- );
3280
+ throw new Error(broadcast.message || "Transaction broadcast failed");
3269
3281
  }
3270
3282
  hash = broadcast.txid || signedTx.txID;
3271
3283
  }
@@ -3282,7 +3294,11 @@ var TronWalletAdapter = class {
3282
3294
  // 지원 여부 확인
3283
3295
  isChainSupported(chainId) {
3284
3296
  const networkId = typeof chainId === "number" ? chainId : parseInt(chainId);
3285
- const validNetworks = [TRON_NETWORKS.mainnet, TRON_NETWORKS.shasta, TRON_NETWORKS.nile];
3297
+ const validNetworks = [
3298
+ TRON_NETWORKS.mainnet,
3299
+ TRON_NETWORKS.shasta,
3300
+ TRON_NETWORKS.nile
3301
+ ];
3286
3302
  return validNetworks.includes(networkId);
3287
3303
  }
3288
3304
  getChainType(_chainId) {
package/dist/index.mjs CHANGED
@@ -11,11 +11,11 @@ var API_ENDPOINTS = {
11
11
  PRODUCTS: "/products"
12
12
  };
13
13
  var ENVIRONMENT_URLS = {
14
- production: "https://pay.com",
14
+ production: "http://112.148.141.72:12346",
15
15
  sandbox: "http://localhost:8080"
16
16
  };
17
17
  var PAYMENT_DOMAINS = {
18
- production: "https://pay-home.com",
18
+ production: "http://112.148.141.72:12346",
19
19
  sandbox: "http://localhost:3000"
20
20
  };
21
21
  var DEFAULT_TIMEOUT = 3e4;
@@ -49,9 +49,6 @@ var Config = class _Config {
49
49
  return _Config.instance;
50
50
  }
51
51
  initialize(config2) {
52
- if (!config2.baseUrl && config2.environment) {
53
- config2.baseUrl = ENVIRONMENT_URLS[config2.environment];
54
- }
55
52
  if (!config2.timeout) {
56
53
  config2.timeout = DEFAULT_TIMEOUT;
57
54
  }
@@ -61,12 +58,15 @@ var Config = class _Config {
61
58
  if (!this.config) {
62
59
  return {
63
60
  environment: "sandbox",
64
- baseUrl: ENVIRONMENT_URLS.sandbox,
65
61
  timeout: DEFAULT_TIMEOUT
66
62
  };
67
63
  }
68
64
  return this.config;
69
65
  }
66
+ getBaseUrl() {
67
+ const environment = this.config?.environment || "sandbox";
68
+ return ENVIRONMENT_URLS[environment];
69
+ }
70
70
  isInitialized() {
71
71
  return this.config !== null;
72
72
  }
@@ -162,7 +162,6 @@ var isValidUrl = (url) => {
162
162
  }
163
163
  };
164
164
  var PaymentProvider = ({
165
- baseUrl,
166
165
  paymentDomain,
167
166
  redirectUrl,
168
167
  webhookUrl,
@@ -182,18 +181,16 @@ var PaymentProvider = ({
182
181
  }
183
182
  const sdkConfig = {
184
183
  environment,
185
- baseUrl,
186
184
  paymentDomain,
187
185
  redirectUrl,
188
186
  webhookUrl,
189
187
  timeout
190
188
  };
191
189
  config.initialize(sdkConfig);
192
- }, [environment, baseUrl, paymentDomain, redirectUrl, webhookUrl, timeout]);
190
+ }, [environment, paymentDomain, redirectUrl, webhookUrl, timeout]);
193
191
  const contextValue = {
194
192
  config: {
195
193
  environment,
196
- baseUrl,
197
194
  paymentDomain,
198
195
  redirectUrl,
199
196
  webhookUrl,
@@ -247,7 +244,7 @@ var APIClient = class {
247
244
  if (!this.instance) {
248
245
  const sdkConfig = config.getConfig();
249
246
  this.instance = axios.create({
250
- baseURL: sdkConfig.baseUrl,
247
+ baseURL: config.getBaseUrl(),
251
248
  timeout: sdkConfig.timeout,
252
249
  headers: {
253
250
  "Content-Type": "application/json"
@@ -2772,7 +2769,6 @@ var PaymentButton = ({
2772
2769
  const order = await createOrder2(params);
2773
2770
  if (order.redirectUrl && order.redirectUrl.trim() !== "") {
2774
2771
  if (!isOurDomain(order.redirectUrl)) {
2775
- throw new Error("Invalid redirect URL. Only our domain is allowed.");
2776
2772
  }
2777
2773
  const separator = order.redirectUrl.endsWith("/") ? "" : "/";
2778
2774
  window.location.href = `${order.redirectUrl}${separator}order/${order.publicOrderId}`;
@@ -2806,7 +2802,10 @@ var PaymentButton = ({
2806
2802
  } catch (err) {
2807
2803
  retryCount++;
2808
2804
  if (retryCount >= maxRetries) {
2809
- console.error(`[PaymentButton] Failed after ${maxRetries} retries:`, err);
2805
+ console.error(
2806
+ `[PaymentButton] Failed after ${maxRetries} retries:`,
2807
+ err
2808
+ );
2810
2809
  throw err;
2811
2810
  }
2812
2811
  console.log(`[PaymentButton] Retry ${retryCount}/${maxRetries}...`);
@@ -2838,7 +2837,9 @@ var PaymentButton = ({
2838
2837
  // 결제 완료 상태로 업데이트
2839
2838
  });
2840
2839
  } else {
2841
- console.warn("[PaymentButton] No order info available, using minimal data");
2840
+ console.warn(
2841
+ "[PaymentButton] No order info available, using minimal data"
2842
+ );
2842
2843
  onSuccess({
2843
2844
  orderId: result.publicOrderId,
2844
2845
  publicOrderId: result.publicOrderId,
@@ -3005,7 +3006,10 @@ var TronWalletAdapter = class {
3005
3006
  } else if (tronWeb.solidityNode?.host) {
3006
3007
  fullNodeHost = tronWeb.solidityNode.host;
3007
3008
  }
3008
- console.log("[TronWalletAdapter] Detecting network from host:", fullNodeHost);
3009
+ console.log(
3010
+ "[TronWalletAdapter] Detecting network from host:",
3011
+ fullNodeHost
3012
+ );
3009
3013
  const hostLower = fullNodeHost.toLowerCase();
3010
3014
  if (hostLower.includes("shasta")) {
3011
3015
  console.log("[TronWalletAdapter] Detected: Shasta Testnet");
@@ -3106,7 +3110,9 @@ var TronWalletAdapter = class {
3106
3110
  this.registerEventListener();
3107
3111
  }
3108
3112
  try {
3109
- console.log(`[TronWalletAdapter] Connecting to ${this.getWalletType()}...`);
3113
+ console.log(
3114
+ `[TronWalletAdapter] Connecting to ${this.getWalletType()}...`
3115
+ );
3110
3116
  const result = await windowAny.tronLink.request({
3111
3117
  method: "tron_requestAccounts"
3112
3118
  });
@@ -3151,10 +3157,14 @@ var TronWalletAdapter = class {
3151
3157
  await windowAny.tronLink.request({
3152
3158
  method: "wallet_disconnect"
3153
3159
  });
3154
- console.log("[TronWalletAdapter] TronLink disconnected via wallet_disconnect");
3160
+ console.log(
3161
+ "[TronWalletAdapter] TronLink disconnected via wallet_disconnect"
3162
+ );
3155
3163
  }
3156
3164
  } catch (error) {
3157
- console.log("[TronWalletAdapter] wallet_disconnect not supported, clearing state only");
3165
+ console.log(
3166
+ "[TronWalletAdapter] wallet_disconnect not supported, clearing state only"
3167
+ );
3158
3168
  }
3159
3169
  }
3160
3170
  } catch (error) {
@@ -3169,7 +3179,11 @@ var TronWalletAdapter = class {
3169
3179
  }
3170
3180
  async switchChain(chainId) {
3171
3181
  const networkId = typeof chainId === "number" ? chainId : parseInt(chainId);
3172
- const validNetworks = [TRON_NETWORKS.mainnet, TRON_NETWORKS.shasta, TRON_NETWORKS.nile];
3182
+ const validNetworks = [
3183
+ TRON_NETWORKS.mainnet,
3184
+ TRON_NETWORKS.shasta,
3185
+ TRON_NETWORKS.nile
3186
+ ];
3173
3187
  if (!validNetworks.includes(networkId)) {
3174
3188
  throw new Error(`Unsupported Tron network: ${chainId}`);
3175
3189
  }
@@ -3204,9 +3218,7 @@ var TronWalletAdapter = class {
3204
3218
  const signedTx = await this.tronWeb.trx.sign(transaction);
3205
3219
  const broadcast = await this.tronWeb.trx.sendRawTransaction(signedTx);
3206
3220
  if (!broadcast.result) {
3207
- throw new Error(
3208
- broadcast.message || "Transaction broadcast failed"
3209
- );
3221
+ throw new Error(broadcast.message || "Transaction broadcast failed");
3210
3222
  }
3211
3223
  hash = broadcast.txid || signedTx.txID;
3212
3224
  }
@@ -3223,7 +3235,11 @@ var TronWalletAdapter = class {
3223
3235
  // 지원 여부 확인
3224
3236
  isChainSupported(chainId) {
3225
3237
  const networkId = typeof chainId === "number" ? chainId : parseInt(chainId);
3226
- const validNetworks = [TRON_NETWORKS.mainnet, TRON_NETWORKS.shasta, TRON_NETWORKS.nile];
3238
+ const validNetworks = [
3239
+ TRON_NETWORKS.mainnet,
3240
+ TRON_NETWORKS.shasta,
3241
+ TRON_NETWORKS.nile
3242
+ ];
3227
3243
  return validNetworks.includes(networkId);
3228
3244
  }
3229
3245
  getChainType(_chainId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dj-test/payment-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Payment SDK for blockchain-based payment system",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",