@apps-in-toss/framework 0.0.13 → 0.0.15

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.ts CHANGED
@@ -2,6 +2,7 @@ import { ComponentType, PropsWithChildren } from 'react';
2
2
  import { InitialProps, BedrockProps } from 'react-native-bedrock';
3
3
  import { EmitterSubscription } from 'react-native';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { PartnerWebViewScreenProps, ExternalWebViewScreenProps } from '@toss-design-system/react-native';
5
6
  import { WebViewProps as WebViewProps$1 } from '@react-native-bedrock/native/react-native-webview';
6
7
 
7
8
  type AppsInTossProps = Pick<BedrockProps, 'context'>;
@@ -206,6 +207,395 @@ declare function startUpdateLocation(eventParams: {
206
207
  options: StartUpdateLocationOptions;
207
208
  }): () => void;
208
209
 
210
+ /**
211
+ * @public
212
+ * @category 토스페이
213
+ * @name CheckoutPaymentOptions
214
+ * @description 토스페이 결제를 생성할 때 필요한 옵션 객체예요.
215
+ * @property {string} orderNo 가맹점의 상품 주문번호예요.
216
+ * @property {string} productDesc 상품 설명이에요.
217
+ * @property {number} amount 결제 금액이에요.
218
+ * @property {number} amountTaxFree 결제 금액 중 비과세 금액이에요.
219
+ * @property {number} [amountTaxable] 결제 금액 중 과세 금액이에요.
220
+ * @property {number} [amountVat] 결제 금액 중 부가세예요.
221
+ * @property {number} [amountServiceFee] 결제 금액 중 봉사료예요.
222
+ * @property {'TOSS_MONEY' | 'CARD' | null} [enablePayMethods] 결제수단 구분 변수예요. (TOSS_MONEY: 토스머니만, CARD: 카드만, null: 기본 결제수단)
223
+ * @property {boolean} [cashReceipt] 현금영수증 발급 가능 여부예요.
224
+ * @property {'CULTURE' | 'GENERAL' | 'PUBLIC_TP'} [cashReceiptTradeOption] 현금영수증 발급 타입이에요. (CULTURE: 문화비, GENERAL: 일반, PUBLIC_TP: 교통비)
225
+ * @property {'USE' | 'NO_USE'} [installment] 할부를 사용할 지 말 지 여부에요. (USE: 사용, NO_USE: 할부 미사용)
226
+ */
227
+ interface CheckoutPaymentOptions {
228
+ /**
229
+ * 가맹점의 상품 주문번호에요.
230
+ */
231
+ orderNo: string;
232
+ /**
233
+ * 상품 설명이에요.
234
+ */
235
+ productDesc: string;
236
+ /**
237
+ * 결제 금액이예요.
238
+ */
239
+ amount: number;
240
+ /**
241
+ * 결제 금액 중 비과세 금액이에요.
242
+ */
243
+ amountTaxFree: number;
244
+ /**
245
+ * 결제 금액 중 과세 금액이에요.
246
+ */
247
+ amountTaxable?: number;
248
+ /**
249
+ * 결제 금액 중 부가세예요.
250
+ */
251
+ amountVat?: number;
252
+ /**
253
+ * 결제 금액 중 봉사료예요.
254
+ */
255
+ amountServiceFee?: number;
256
+ /**
257
+ * 결제수단 구분 변수예요.
258
+ *
259
+ * - 'TOSS_MONEY': 결제수단 중 토스머니만 노출
260
+ * - 'CARD': 결제수단 중 카드만 노출
261
+ * - null: 상점에 설정된 기본 결제 수단 노출
262
+ */
263
+ enablePayMethods?: 'TOSS_MONEY' | 'CARD' | null;
264
+ /**
265
+ * 현금영수증 발급 가능 여부예요.
266
+ */
267
+ cashReceipt?: boolean;
268
+ /**
269
+ * 현금영수증 발급 타입이에요.
270
+ *
271
+ * - 'CULTURE': 문화비
272
+ * - 'GENERAL': 일반(기본값)
273
+ * - 'PUBLIC_TP': 교통비
274
+ */
275
+ cashReceiptTradeOption?: 'CULTURE' | 'GENERAL' | 'PUBLIC_TP';
276
+ /**
277
+ * 할부를 사용할 지 말 지 여부에요.
278
+ *
279
+ * - 'USE': 사용(기본값)
280
+ * - 'NO_USE': 할부 미사용
281
+ */
282
+ installment?: 'USE' | 'NO_USE';
283
+ }
284
+ /**
285
+ * @public
286
+ * @category 토스페이
287
+ * @name checkoutPayment
288
+ * @description 토스페이 결제를 생성하는 함수예요.
289
+ *
290
+ * @param {CheckoutPaymentOptions} options 결제를 생성할 때 필요한 옵션 객체예요.
291
+ * @param {string} options.orderNo 가맹점의 상품 주문번호예요.
292
+ * @param {string} options.productDesc 상품 설명이에요.
293
+ * @param {number} options.amount 결제 금액이에요.
294
+ * @param {number} options.amountTaxFree 결제 금액 중 비과세 금액이에요.
295
+ * @param {number} [options.amountTaxable] 결제 금액 중 과세 금액이에요.
296
+ * @param {number} [options.amountVat] 결제 금액 중 부가세예요.
297
+ * @param {number} [options.amountServiceFee] 결제 금액 중 봉사료예요.
298
+ * @param {'TOSS_MONEY' | 'CARD' | null} [options.enablePayMethods] 결제수단 구분 변수예요. (TOSS_MONEY: 토스머니만, CARD: 카드만, null: 기본 결제수단)
299
+ * @param {boolean} [options.cashReceipt] 현금영수증 발급 가능 여부예요.
300
+ * @param {'CULTURE' | 'GENERAL' | 'PUBLIC_TP'} [options.cashReceiptTradeOption] 현금영수증 발급 타입이에요. (CULTURE: 문화비, GENERAL: 일반, PUBLIC_TP: 교통비)
301
+ * @param {'USE' | 'NO_USE'} [options.installment] 할부를 사용할 지 말 지 여부에요. (USE: 사용, NO_USE: 할부 미사용)
302
+ * @returns {Promise<{ payToken: string }>} 결제 인증 후 발급된 결제 토큰 값이 포함된 객체를 반환해요.
303
+ *
304
+ * @example
305
+ * ### 결제 생성하기
306
+ *
307
+ * ```tsx
308
+ * import { TossPay } from '@apps-in-toss/framework';
309
+ *
310
+ * async function handlePayment() {
311
+ * try {
312
+ * const result = await TossPay.checkoutPayment({
313
+ * orderNo: 'ORDER_12345',
314
+ * productDesc: '티셔츠',
315
+ * amount: 15000,
316
+ * amountTaxFree: 0,
317
+ * amountTaxable: 13636,
318
+ * amountVat: 1364,
319
+ * enablePayMethods: 'CARD',
320
+ * installment: 'USE'
321
+ * });
322
+ *
323
+ * console.log('결제 토큰:', result.payToken);
324
+ * } catch (error) {
325
+ * console.error('결제 생성에 실패했어요:', error);
326
+ * }
327
+ * }
328
+ * ```
329
+ */
330
+ declare function checkoutPayment(options: CheckoutPaymentOptions): Promise<{
331
+ payToken: string;
332
+ }>;
333
+
334
+ /**
335
+ * @public
336
+ * @category 토스페이
337
+ * @name ExecutePaymentOptions
338
+ * @description 생성한 토스페이 결제를 실행할 때 필요한 옵션이에요.
339
+ * @property {string} orderNo 결제를 생성할 때 사용한 주문번호예요.
340
+ * @property {string} payToken 결제 인증 과정에서 전달받은 결제 토큰이에요. 결제를 실행할 때 사용해요.
341
+ */
342
+ interface ExecutePaymentOptions {
343
+ /**
344
+ * 결제를 생성할 때 사용한 주문번호예요.
345
+ */
346
+ orderNo: string;
347
+ /**
348
+ * 결제 인증 과정에서 전달받은 Pay 토큰이에요.
349
+ */
350
+ payToken: string;
351
+ }
352
+ /**
353
+ * @public
354
+ * @category 토스페이
355
+ * @name CardExecutePaymentResult
356
+ * @description 카드로 결제 요청을 실행한 뒤 돌아오는 결제 결과 객체예요. 결제 승인 여부, 결제된 금액, 주문 정보 등을 담고 있어요.
357
+ * @property {'CARD'} payMethod 결제 수단이에요.
358
+ * @property {number} code 결제 요청의 결과 코드예요.
359
+ * @property {'LIVE' | 'TEST'} mode 현재 결제 환경이에요.
360
+ * @property {string} orderNo 주문번호예요.
361
+ * @property {number} amount 총 결제 금액이에요.
362
+ * @property {string} approvalTime 결제가 승인된 시간이에요. (ISO 8601 형식)
363
+ * @property {string} stateMsg 결제 상태 메시지예요.
364
+ * @property {number} discountedAmount 적용된 할인 금액이에요.
365
+ * @property {number} paidAmount 실제 결제된 금액이에요.
366
+ * @property {string} payToken 결제 요청 시 사용한 Pay 토큰이에요.
367
+ * @property {string} transactionId 거래 ID예요.
368
+ * @property {number} cardCompanyCode 카드사 코드예요.
369
+ * @property {string} cardCompanyName 카드사 이름이에요.
370
+ * @property {string} cardAuthorizationNo 카드사 승인 번호예요. (라이브 결제 환경에서만 확인 가능해요)
371
+ * @property {number} spreadOut 할부 개월 수예요. (5만원 미만 금액 및 일시불 결제의 경우에는 `0`)
372
+ * @property {boolean} noInterest 무이자 할부 여부예요.
373
+ * @property {string} salesCheckLinkUrl 결제 내역을 확인할 수 있는 매출전표 URL이에요.
374
+ * @property {'CREDIT' | 'CHECK' | 'PREPAYMENT'} cardMethodType 카드 유형이에요.
375
+ * @property {string} cardNumber 마스킹된 카드 번호예요. (`****-****-****-1234` 형식)
376
+ * @property {string} cardNum4Print 카드 번호의 마지막 4자리예요.
377
+ * @property {string} cardBinNumber 카드 BIN 번호예요.
378
+ */
379
+ interface CardExecutePaymentResult {
380
+ /**
381
+ * 결제 수단이에요.
382
+ */
383
+ payMethod: 'CARD';
384
+ /**
385
+ * 결제 요청의 결과 코드예요.
386
+ */
387
+ code: number;
388
+ /**
389
+ * 현재 결제 환경이에요.
390
+ *
391
+ * - `LIVE`: 실제 환경
392
+ * - `TEST`: 테스트 환경
393
+ */
394
+ mode: 'LIVE' | 'TEST';
395
+ /**
396
+ * 주문번호예요.
397
+ */
398
+ orderNo: string;
399
+ /**
400
+ * 총 결제 금액이에요.
401
+ */
402
+ amount: number;
403
+ /**
404
+ * 결제가 승인된 시간이에요. (ISO 8601 형식)
405
+ */
406
+ approvalTime: string;
407
+ /**
408
+ * 결제 상태 메시지예요.
409
+ */
410
+ stateMsg: string;
411
+ /**
412
+ * 적용된 할인 금액이에요.
413
+ */
414
+ discountedAmount: number;
415
+ /**
416
+ * 실제 결제된 금액이에요.
417
+ */
418
+ paidAmount: number;
419
+ /**
420
+ * 결제 요청 시 사용한 Pay 토큰이에요.
421
+ */
422
+ payToken: string;
423
+ /**
424
+ * 거래 ID예요.
425
+ */
426
+ transactionId: string;
427
+ /**
428
+ * 카드사 코드예요.
429
+ */
430
+ cardCompanyCode: number;
431
+ /**
432
+ * 카드사 이름이에요.
433
+ */
434
+ cardCompanyName: string;
435
+ /**
436
+ * 카드사 승인 번호예요. (라이브 결제 환경에서만 확인 가능해요)
437
+ */
438
+ cardAuthorizationNo: string;
439
+ /**
440
+ * 할부 개월 수예요. (5만원 미만 금액 및 일시불 결제의 경우에는 `0`)
441
+ */
442
+ spreadOut: number;
443
+ /**
444
+ * 무이자 할부 여부예요.
445
+ */
446
+ noInterest: boolean;
447
+ /**
448
+ * 결제 내역을 확인할 수 있는 매출전표 URL이에요.
449
+ */
450
+ salesCheckLinkUrl: string;
451
+ /**
452
+ * 카드 유형이에요.
453
+ *
454
+ * - 'CREDIT': 신용카드
455
+ * - 'CHECK': 체크카드
456
+ * - 'PREPAYMENT': 선불카드
457
+ */
458
+ cardMethodType: 'CREDIT' | 'CHECK' | 'PREPAYMENT';
459
+ /**
460
+ * 마스킹된 카드 번호예요. (`****-****-****-1234` 형식)
461
+ */
462
+ cardNumber: string;
463
+ /**
464
+ * 카드 사용자 구분을 나타내는 값이에요.
465
+ *
466
+ * - 'PERSONAL': 개인 카드
467
+ * - 'PERSONAL_FAMILY': 가족 카드
468
+ * - 'CORP_PERSONAL': 법인지정 결제계좌 (임직원)
469
+ * - 'CORP_PRIVATE': 법인 공용
470
+ * - 'CORP_COMPANY': 법인지정 결제계좌 회사 (하나카드 Only)
471
+ */
472
+ cardUserType: 'PERSONAL' | 'PERSONAL_FAMILY' | 'CORP_PERSONAL' | 'CORP_PRIVATE' | 'CORP_COMPANY';
473
+ /**
474
+ * 카드 번호의 마지막 4자리예요.
475
+ */
476
+ cardNum4Print: string;
477
+ /**
478
+ * 카드 BIN 번호예요.
479
+ */
480
+ cardBinNumber: string;
481
+ }
482
+ /**
483
+ * @public
484
+ * @category 토스페이
485
+ * @name TossMoneyExecutePaymentResult
486
+ * @description 토스머니로 결제 요청을 실행한 뒤 돌아오는 결제 결과 객체예요. 결제 승인 여부, 결제된 금액, 주문 정보 등을 담고 있어요.
487
+ * @property {'TOSS_MONEY'} payMethod 결제 수단이에요.
488
+ * @property {number} code 결제 요청의 결과 코드예요.
489
+ * @property {'LIVE' | 'TEST'} mode 현재 결제 환경이에요.
490
+ * @property {string} orderNo 주문번호예요.
491
+ * @property {number} amount 총 결제 금액이에요.
492
+ * @property {string} approvalTime 결제가 승인된 시간이에요. (ISO 8601 형식)
493
+ * @property {string} stateMsg 결제 상태 메시지예요.
494
+ * @property {number} discountedAmount 적용된 할인 금액이에요.
495
+ * @property {number} paidAmount 실제 결제된 금액이에요.
496
+ * @property {string} payToken 결제 요청 시 사용한 Pay 토큰이에요.
497
+ * @property {string} transactionId 거래 ID예요.
498
+ * @property {string} cashReceiptMgtKey 현금영수증 관리번호 식별값이에요.
499
+ * @property {string} accountBankName 결제된 은행의 코드예요.
500
+ * @property {string} accountNumber 결제된 계좌번호예요.
501
+ */
502
+ interface TossMoneyExecutePaymentResult {
503
+ /**
504
+ * 결제에 사용된 결제 수단이에요.
505
+ */
506
+ payMethod: 'TOSS_MONEY';
507
+ /**
508
+ * 결제 요청의 결과 코드예요.
509
+ */
510
+ code: number;
511
+ /**
512
+ * 현재 결제 환경이에요.
513
+ *
514
+ * - `LIVE`: 실제 환경
515
+ * - `TEST`: 테스트 환경
516
+ */
517
+ mode: 'LIVE' | 'TEST';
518
+ /**
519
+ * 결제 승인된 상품의 주문번호예요.
520
+ */
521
+ orderNo: string;
522
+ /**
523
+ * 결제 승인된 상품의 총 결제 금액이에요.
524
+ */
525
+ amount: number;
526
+ /**
527
+ * 결제가 승인된 시간이에요. (ISO 8601 형식)
528
+ */
529
+ approvalTime: string;
530
+ /**
531
+ * 결제 상태 메시지예요.
532
+ */
533
+ stateMsg: string;
534
+ /**
535
+ * 적용된 할인 금액이에요.
536
+ */
537
+ discountedAmount: number;
538
+ /**
539
+ * 실제 결제 승인된 금액이에요.
540
+ */
541
+ paidAmount: number;
542
+ /**
543
+ * 결제 요청 시 사용한 Pay 토큰이에요.
544
+ */
545
+ payToken: string;
546
+ /**
547
+ * 거래 ID예요.
548
+ */
549
+ transactionId: string;
550
+ /**
551
+ * 현금영수증 관리번호 식별값이에요.
552
+ */
553
+ cashReceiptMgtKey: string;
554
+ /**
555
+ * 결제된 은행의 코드예요.
556
+ */
557
+ accountBankName: string;
558
+ /**
559
+ * 결제된 계좌번호예요.
560
+ */
561
+ accountNumber: string;
562
+ }
563
+ /**
564
+ * @public
565
+ * @category 토스페이
566
+ * @name executePayment
567
+ * @description 구매자가 결제를 시도하면, 먼저 결제 정보를 생성하고 인증을 받아요. 이때 결제 상태는 '대기' 중이에요. 이후 결제를 실제로 승인하려면 주어진 주문번호와 결제 토큰을 사용해서 이 함수로 생성된 결제를 승인해요. 결제 승인이 완료되면, 구매자의 결제 수단(예: 카드, 계좌)에서 실제로 금액이 출금돼요. 이 함수를 호출하지 않으면 결제가 자동으로 만료되고, 출금도 발생하지 않아요.
568
+ *
569
+ * @param {ExecutePaymentOptions} options 결제를 실행할 때 필요한 옵션이에요.
570
+ * @param {string} options.orderNo 결제를 생성할 때 사용한 주문번호예요.
571
+ * @param {string} options.payToken 결제 인증 과정에서 전달받은 결제 토큰이에요. 결제를 실행할 때 사용해요.
572
+ * @returns {Promise<CardExecutePaymentResult | TossMoneyExecutePaymentResult>} 결제 결과 객체를 반환해요. 자세한 내용은 [카드 결제 결과](reference/framework/토스페이/CardExecutePaymentResult.html) 또는 [토스머니 결제 결과](reference/framework/토스페이/TossMoneyExecutePaymentResult.html)를 참고하세요.
573
+ *
574
+ * @example
575
+ *
576
+ * ### 카드 결제 실행하기
577
+ *
578
+ * ```tsx
579
+ * import { TossPay } from '@apps-in-toss/framework';
580
+ *
581
+ * async function handlePayment() {
582
+ * try {
583
+ * const payToken = 'PAY_TOKEN_12345'; // 결제 인증 후 받은 토큰
584
+ *
585
+ * const result = await TossPay.executePayment({
586
+ * orderNo: 'ORDER_12345',
587
+ * payToken,
588
+ * });
589
+ *
590
+ * console.log('결제가 완료되었어요:', result);
591
+ * } catch (error) {
592
+ * console.error('결제에 실패했어요:', error);
593
+ * }
594
+ * }
595
+ * ```
596
+ */
597
+ declare function executePayment(options: ExecutePaymentOptions): Promise<CardExecutePaymentResult | TossMoneyExecutePaymentResult>;
598
+
209
599
  /**
210
600
  * @public
211
601
  * @category 클립보드
@@ -637,13 +1027,40 @@ declare function appLogin(): Promise<{
637
1027
  */
638
1028
  declare function getOperationalEnvironment(): 'toss' | 'sandbox';
639
1029
 
640
- interface WebViewProps extends Omit<WebViewProps$1, 'cacheEnabled' | 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
641
- local: {
642
- port: number;
643
- host: number;
644
- };
1030
+ /**
1031
+ * @public
1032
+ * @category 토스페이
1033
+ * @name TossPay
1034
+ * @description 토스페이 결제 관련 함수를 모아둔 객체예요.
1035
+ * @property {typeof checkoutPayment} [checkoutPayment] 토스페이 결제를 생성하는 함수예요. 자세한 내용은 [checkoutPayment](reference/framework/토스페이/checkoutPayment)를 참고하세요.
1036
+ * @property {typeof executePayment} [executePayment] 토스페이 결제를 실행하는 함수예요. 자세한 내용은 [executePayment](reference/framework/토스페이/executePayment)를 참고하세요.
1037
+ */
1038
+ declare const TossPay: {
1039
+ checkoutPayment: typeof checkoutPayment;
1040
+ executePayment: typeof executePayment;
1041
+ };
1042
+
1043
+ type GameWebViewProps$1 = WebViewProps$1;
1044
+
1045
+ type WebViewProps = PartnerWebViewProps | ExternalWebViewProps | GameWebViewProps;
1046
+ interface PartnerWebViewProps extends Omit<PartnerWebViewScreenProps, InternalProps> {
1047
+ type: 'partner';
1048
+ local: LocalNetwork;
1049
+ }
1050
+ interface ExternalWebViewProps extends Omit<ExternalWebViewScreenProps, InternalProps> {
1051
+ type: 'external';
1052
+ local: LocalNetwork;
1053
+ }
1054
+ interface GameWebViewProps extends Omit<GameWebViewProps$1, InternalProps> {
1055
+ type: 'game';
1056
+ local: LocalNetwork;
1057
+ }
1058
+ interface LocalNetwork {
1059
+ port: number;
1060
+ host: string;
645
1061
  }
646
- declare function WebView({ local, onMessage, ...props }: WebViewProps): react_jsx_runtime.JSX.Element;
1062
+ type InternalProps = 'source' | 'cacheEnabled' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded';
1063
+ declare function WebView({ type, local, onMessage, ...props }: WebViewProps): react_jsx_runtime.JSX.Element;
647
1064
 
648
1065
  type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
649
1066
  /**
@@ -695,4 +1112,4 @@ declare const env: {
695
1112
  getDeploymentId: () => string | undefined;
696
1113
  };
697
1114
 
698
- export { Accuracy, AppsInToss, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type LocationCoords, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getOperationalEnvironment, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
1115
+ export { Accuracy, AppsInToss, type ContactEntity, type ExternalWebViewProps, type FetchAlbumPhotosOptions, type GameWebViewProps, type GetCurrentLocationOptions, type ImageResponse, type Location, type LocationCoords, type OpenCameraOptions, type PartnerWebViewProps, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, TossPay, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getOperationalEnvironment, openCamera, setClipboardText, startUpdateLocation, useGeolocation };