๐Ÿ’ณ ํ† ์ŠคํŽ˜์ด๋จผ์ธ  ์—ฐ๋™ํ•˜๊ธฐ (1) _๊ฒฐ์ œ ํ๋ฆ„

ํ˜„์ฃผยท2023๋…„ 5์›” 30์ผ
0

ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ ๊ฒฐ์ œ ์‹œ์Šคํ…œ์„ ๋„์ž…ํ•ด์•ผ ํ–ˆ๋Š”๋ฐ,

์šฐ๋ฆฌ๋Š” ์ข€ ๋” ์‰ฝ๊ณ  ํŽธํ•˜๊ฒŒ ๋„์ž…ํ•  ์ˆ˜ ์žˆ๋Š” ํ† ์ŠคํŽ˜์ด๋จผ์ธ ๋ฅผ ์„ ํƒํ•˜์˜€๋‹ค.

ํ† ์ŠคํŽ˜์ด๋จผ์ธ ๋Š” ๊ฒฐ์ œ ์‹œ์Šคํ…œ ์—ฐ๋™์„ ์œ„ํ•ด ํ•„์š”ํ•œ ์ž๋ฃŒ๋“ค์„ <์š”๊ธฐ>์— ์ž์„ธํ•˜๊ฒŒ ์•ˆ๋‚ดํ•ด์ฃผ๊ณ  ์žˆ๋‹ค.

์ด ๋ฌธ์„œ๋“ค์„ ์ฐธ๊ณ ํ•˜์—ฌ ์—ฐ๋™ํ•ด์ฃผ๋ฉด ๋˜๊ณ ,
์ด๋ฒˆ ๊ฒŒ์‹œ๋ฌผ์—์„œ๋Š” ์ ์šฉ ์ „ ๊ฒฐ์ œ ํ๋ฆ„๋ถ€ํ„ฐ ์‚ดํŽด๋ณด๋ ค๊ณ  ํ•œ๋‹ค.


โœ๏ธ ํ† ์ŠคํŽ˜์ด๋จผ์ธ  ๊ฒฐ์ œ ํ๋ฆ„ ( ๊ณ ๊ฐ ์ž…์žฅ )

1. ๊ฒฐ์ œ ๋ฒ„ํŠผ ํด๋ฆญ

2. ๊ฒฐ์ œ ๊ด€๋ จ ๋™์˜ ๋ฐ ๊ฒฐ์ œ ์ˆ˜๋‹จ ์„ ํƒ

3. ์„ ํƒํ•œ ๊ฒฐ์ œ ์ˆ˜๋‹จ์œผ๋กœ ๊ฒฐ์ œ
( ๋‚˜์˜ ๊ฒฝ์šฐ ํ† ์ŠคํŽ˜์ด๋กœ ํ•˜์˜€๋‹ค. )

4. ์„ ํƒ๋œ ๊ฒฐ์ œ ์ˆ˜๋‹จ์—์„œ ์ด์–ด์„œ ๊ฒฐ์ œ ์ง„ํ–‰

โžœ ํœด๋Œ€ํฐ ๋ฒˆํ˜ธ์™€ ์ƒ๋…„์›”์ผ 6์ž๋ฆฌ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ํ•ด๋‹น ํœด๋Œ€ํฐ์œผ๋กœ ์•„๋ž˜์™€ ๊ฐ™์€ ์•Œ๋ฆผ์ด ๊ฐ€๊ฒŒ ๋œ๋‹ค.

5. ํœด๋Œ€ํฐ์˜ ํ† ์Šค ์•ฑ์œผ๋กœ ๊ฒฐ์ œ ์ง„ํ–‰

โžœ ์œ„์™€ ๊ฐ™์ด ๊ฒฐ์ œ์ฐฝ์ด ๋œจ๊ณ  ๋™์˜ํ•˜๊ณ  ๊ฒฐ์ œํ•˜๊ธฐ๋ฅผ ๋ˆ„๋ฅด๋ฉด ์ตœ์ข…์ ์œผ๋กœ ๊ฒฐ์ œ๊ฐ€ ์ด๋ฃจ์–ด์ง€๊ฒŒ ๋œ๋‹ค.
์ด ๋•Œ, ์—ฌ๋Ÿฌ ์ด์œ ๋กœ ๊ฒฐ์ œ๊ฐ€ ๊ฑฐ๋ถ€๋˜๋ฉด ์‹คํŒจ ์‹œ ์ฝœ๋ฐฑ URL๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ๋˜๊ณ ,
๊ฒฐ์ œ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ง„ํ–‰๋˜๋ฉด ์„ฑ๊ณต ์‹œ ์ฝœ๋ฐฑ URL๋กœ ํ•„์š”ํ•œ ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ€ ๋‹ด๊ฒจ์„œ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ๋œ๋‹ค.

6. ์ตœ์ข… ๊ฒฐ์ œ ์Šน์ธ ์š”์ฒญ

https://{ORIGIN}/success?paymentKey={PAYMENT_KEY}&orderId={ORDER_ID}&amount={AMOUNT}
  • paymentKey = ํ† ์ŠคํŽ˜์ด๋จผ์ธ ์—์„œ ์ •ํ•œ ๊ฒฐ์ œ ๊ตฌ๋ถ„์šฉ ํ‚ค
  • orderId = ์„œ๋น„์Šค์—์„œ ์ •ํ•œ ์ฃผ๋ฌธ ๊ณ ์œ ๋ฒˆํ˜ธ
  • amount = ๊ฐ€๊ฒฉ ์ •๋ณด

โžœ ์œ„์™€ ๊ฐ™์€ ์‹์œผ๋กœ, ์ตœ์ดˆ ๊ฒฐ์ œ ์š”์ฒญ ์‹œ ์ฝœ๋ฐฑ ์ฃผ์†Œ + ์œ„ ์„ธ๊ฐ€์ง€ ์ •๋ณด๊ฐ€ ๋‹ด๊ฒจ์„œ ์˜ค๊ณ 
์ด ๊ฐ’๋“ค์„ ๊ฐ€์ง€๊ณ  ๋‹ค์‹œ ํ† ์ŠคํŽ˜์ด๋จผ์ธ ์—๊ฒŒ ์ตœ์ข… ๊ฒฐ์ œ ์Šน์ธ ์š”์ฒญ์„ ๋ณด๋‚ด๋ฉด ๋œ๋‹ค.
โ €
โžœ ์ด ํ›„, ํ† ์ŠคํŽ˜์ด๋จผ์ธ ์—์„œ ์ด์ƒ์ด ์—†๋‹ค๋ฉด ์Šน์ธํ•˜๊ณ  ์ƒํ’ˆ ์ •๋ณด / ๊ฒฐ์ œ ์ •๋ณด ๋“ฑ ๊ฒฐ์ œ ๊ด€๋ จ ์ •๋ณด๋“ค์„ ๋‹ด์•„์„œ JSON์œผ๋กœ ์‘๋‹ตํ•ด์ค€๋‹ค.
( ์•„๋ž˜๋Š” ํ† ์Šค์—์„œ ์ œ๊ณตํ•˜๋Š” ์‘๋‹ต ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค. )

{
  "mId": "tosspayments",
  "version": "2022-11-16",
  "paymentKey": "8uc3GNBacphSFe-EpgbvV", // ํ† ์ŠคํŽ˜์ด๋จผ์ธ ์—์„œ ๊ฒฐ์ œ๋ฅผ ๊ตฌ๋ถ„ํ•˜๋Š” ํ‚ค
  "status": "DONE",
  "lastTransactionKey": "yEYX-9U5AAP7l0qbIFOF_",
  "orderId": "qJYf2biY9yBqKcr-21Y2G", // ์„œ๋น„์Šค์—์„œ ์ •ํ•œ ์ฃผ๋ฌธ ๊ณ ์œ  ๋ฒˆํ˜ธ
  "orderName": "ํ† ์Šค ํ‹ฐ์…”์ธ  ์™ธ 2๊ฑด",
  "requestedAt": "2022-06-08T15:40:09+09:00",
  "approvedAt": "2022-06-08T15:40:49+09:00",
  "useEscrow": false,
  "cultureExpense": false,
  "card": {
    "issuerCode": "61",
    "acquirerCode": "31",
    "number": "12345678****789*",
    "installmentPlanMonths": 0,
    "isInterestFree": false,
    "interestPayer": null,
    "approveNo": "00000000",
    "useCardPoint": false,
    "cardType": "์‹ ์šฉ",
    "ownerType": "๊ฐœ์ธ",
    "acquireStatus": "READY",
    "amount": 15000
  },
  "virtualAccount": null,
  "transfer": null,
  "mobilePhone": null,
  "giftCertificate": null,
  "cashReceipt": null,
  "cashReceipts": null,
  "discount": null,
  "cancels": null,
  "secret": null,
  "type": "NORMAL",
  "easyPay": null,
  "country": "KR",
  "failure": null,
  "isPartialCancelable": true,
  "receipt": {
    "url": "https://dashboard.tosspayments.com/sales-slip?transactionId=KAgfjGxIqVVXDxOiSW1wUnRWBS1dszn3DKcuhpm7mQlKP0iOdgPCKmwEdYglIHX&ref=PX"
  },
  "checkout": {
    "url": "https://api.tosspayments.com/v1/payments/8uc3GNBacphSFe-EpgbvV/checkout"
  },
  "currency": "KRW",
  "totalAmount": 15000,
  "balanceAmount": 15000,
  "suppliedAmount": 13636,
  "vat": 1364,
  "taxFreeAmount": 0,
  "taxExemptionAmount": 0,
  "method": "์นด๋“œ"
}

7. ๊ฒฐ์ œ ์™„๋ฃŒ


โœ๏ธ ํ† ์ŠคํŽ˜์ด๋จผ์ธ  ๊ฒฐ์ œ ํ๋ฆ„ ( ์—ญํ• ๋ณ„ ์ •๋ฆฌ )

๊ฒฐ์ œ ์‹œ์— ์œ„์™€ ๊ฐ™์€ ํ๋ฆ„์œผ๋กœ ์š”์ฒญ/์‘๋‹ต์ด ์ด๋ฃจ์–ด์ง€๋Š”๋ฐ,
ํ† ์ŠคํŽ˜์ด๋จผ์ธ ์—์„œ ๋ฐœ๊ธ‰ํ•ด์ค€ {ํด๋ผ์ด์–ธํŠธ_ํ‚ค}๋ฅผ ๊ฐ€์ง€๊ณ  TossPayments ๊ฐ์ฒด๋ฅผ ์ดˆ๊ธฐํ™”ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.
์ด๋ ‡๊ฒŒ ์ดˆ๊ธฐํ™”๋œ ๊ฐ์ฒด๋กœ requestPayment()๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๊ฒฐ์ œ์ฐฝ ํ˜ธ์ถœ์„ ํ•˜๊ฒŒ ๋œ๋‹ค.
โ €
( ๐ŸŒผ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ ํฌ์ŠคํŒ…์—์„œ ๋‹ค๋ฃจ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค! )

( ์•„๋ž˜๋Š” ํ”„๋ก ํŠธ / ๋ฐฑ์—”๋“œ / ํ† ์ŠคํŽ˜์ด๋จผ์ธ  ๊ฐ„์˜ ์—ญํ• ๋ณ„ ๊ฒฐ์ œ ๊ณผ์ •์ž…๋‹ˆ๋‹ค. )

  1. ํ”„๋ก ํŠธ๊ฐ€ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์ •๋ณด๋ฅผ ๊ฐ€์ง€๊ณ  [๊ฒฐ์ œํ•˜๊ธฐ] ๋ฒ„ํŠผ์„ ํ†ตํ•ด ๋ฐฑ์—”๋“œ์˜ ๊ฒฐ์ œ ์š”์ฒญ API๋ฅผ ํ˜ธ์ถœ

  2. ๋ฐฑ์—”๋“œ๊ฐ€ ํ•ด๋‹น [์š”์ฒญ ๊ฐ์ฒด]๋ฅผ ๊ฐ€์ง€๊ณ  ๊ฒ€์ฆ ํ›„ ํ•„์š”ํ•œ ๊ฐ’๋“ค์„ ์ฑ„์›Œ์ฃผ๊ณ  DB์— ๊ฒฐ์ œ ์ •๋ณด ์ €์žฅ ํ›„ ๋ฐ˜ํ™˜

  3. ํ”„๋ก ํŠธ๊ฐ€ ๋ฐ˜ํ™˜๋ฐ›์€ ๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์ด์–ด์„œ tossPayments.requestPayment('์นด๋“œ',{๊ฒฐ์ œ ์ •๋ณด ํŒŒ๋ผ๋ฏธํ„ฐ})๋ฅผ ํ†ตํ•ด ํ† ์ŠคํŽ˜์ด๋จผ์ธ ์— [๊ฒฐ์ œ์ฐฝ ํ˜ธ์ถœ]์„ ํ•˜๊ฒŒ ํ•จ

  4. ๊ฒฐ์ œ์ฐฝ์—์„œ ๊ตฌ๋งค์ž๋Š” ์ผ๋ จ์˜ ์ ˆ์ฐจ ํ›„ ์ตœ์ข…์ ์œผ๋กœ ๊ฒฐ์ œ ์™„๋ฃŒ.
    ์ด ํ›„, ํ† ์ŠคํŽ˜์ด๋จผ์ธ ๋Š” ๊ฒฐ์ œ์˜ ์„ฑ๊ณต ์—ฌ๋ถ€ ๋ฐ ๊ด€๋ จ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ฝœ๋ฐฑ ์ฃผ์†Œ๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ

  5. ๋ฐฑ์—”๋“œ๋Š” ์„ฑ๊ณต/์‹คํŒจ์— ๋”ฐ๋ผ ์ ์ ˆํ•œ Controller๋กœ ์‘๋‹ต์„ ๋ฐ›์Œ.
    ์„ฑ๊ณต์ ์œผ๋กœ ๊ฒฐ์ œ๊ฐ€ ์ด๋ฃจ์–ด์กŒ๋‹ค๋ฉด ๋ฐฑ์—”๋“œ์—์„œ ํ† ์ŠคํŽ˜์ด๋จผ์ธ ์—๊ฒŒ [์ตœ์ข… ๊ฒฐ์ œ ์Šน์ธ ์š”์ฒญ]์„ ๋ณด๋ƒ„.
    ( ์ด ๋•Œ, ์‹คํŒจ๋ฉด ํ”„๋ก ํŠธ์—๊ฒŒ ์‹คํŒจ ์ •๋ณด๋ฅผ ํ•จ๊ป˜ ๋‹ด์•„ ๋ฐ˜ํ™˜ํ•˜๊ณ  ๋ )

  6. ํ† ์ŠคํŽ˜์ด๋จผ์ธ ๋Š” ํ•ด๋‹น ์š”์ฒญ์„ ๊ฒ€์ฆํ•˜๊ณ  ์ •์ƒ์ ์ด๋ผ๋ฉด ๋ฐฑ์—”๋“œ์— ๋ฐ˜ํ™˜.
    ๋ฐฑ์—”๋“œ๋„ ํ•ด๋‹น ๋ฐ์ดํ„ฐ ํ™•์ธ ํ›„ ์ž˜ ํฌ์žฅํ•ด์„œ ํ”„๋ก ํŠธ์— ๋ฐ˜ํ™˜

  7. ํ”„๋ก ํŠธ๊ฐ€ ์‘๋‹ต ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ง€๊ณ  ๊ตฌ๋งค์ž์—๊ฒŒ ๊ฒฐ์ œ ๊ฒฐ๊ณผ / ์ •๋ณด๋ฅผ ๋ณด์—ฌ์คŒ


์—ฌ๊ธฐ๊นŒ์ง€ ๊ฒฐ์ œ ํ๋ฆ„์„ ์‚ดํŽด๋ณด์•˜์œผ๋‹ˆ, ์ด ํ›„ ํฌ์ŠคํŒ…์—์„œ๋Š” ์ด๋ฅผ ํ† ๋Œ€๋กœ ์„œ๋น„์Šค์— ์ ์šฉํ•ด๋ณผ ์˜ˆ์ •์ด๋‹ค !

๐Ÿ“Œ ๋‹ค์Œ ํฌ์ŠคํŒ…์€ ๊ฒฐ์ œ ์š”์ฒญ์— ๋Œ€ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.
โ €
๐Ÿ‘‰ ๐Ÿ’ณ ํ† ์ŠคํŽ˜์ด๋จผ์ธ  ์—ฐ๋™ํ•˜๊ธฐ (2) _๊ฒฐ์ œ ์š”์ฒญ

7๊ฐœ์˜ ๋Œ“๊ธ€

comment-user-thumbnail
2023๋…„ 9์›” 24์ผ

์‹ค์ œ ๊ฒฐ์ œ๋˜์ง€ ์•Š๋Š” ํ…Œ์ŠคํŠธ๋ผ๊ณ  ํ•˜๋Š”๋ฐ ํœด๋Œ€ํฐ ํ† ์Šค ์•ฑ์— 5๋งŒ์›์ด ๊ฒฐ์ œ๋˜์–ด์ง„๊ฑด ๋ฌด์Šจ ์ด์œ ์ธ๊ฐ€์š”? ์‹ค์ œ๋กœ ๊ฒฐ์ œ๊ฐ€ ์ด๋ฃจ์–ด์ง„๊ฑด๊ฐ€์š”?

1๊ฐœ์˜ ๋‹ต๊ธ€
comment-user-thumbnail
2024๋…„ 10์›” 29์ผ

ํ•ด๋‹น ๋‚ด์šฉ ๋„ˆ๋ฌด ์ž˜๋ดค์Šต๋‹ˆ๋‹ค!!
๊ทผ๋ฐ ํ˜น์‹œ ์ปจํŠธ๋กค๋Ÿฌ๋งˆ๋‹ค ํด๋ž˜์Šค ๋ ˆ๋ฒจ์— @Validated๋ฅผ ๋ถ™์ธ ์ด์œ ๋ฅผ ์•Œ ์ˆ˜ ์žˆ์„๊นŒ์š”?

1๊ฐœ์˜ ๋‹ต๊ธ€