Payment APIs
목차

Whether you're using widgets or window, Payment APIs are integral to Toss Payments. Use your test API secret key starting with test_sk or test_gsk to use the APIs in test mode. In test mode, live data and payment methods are not affected. Use your live API secret key starting with live_sk or live_gsk to start accepting payments in production.

For the full list of Toss Payment APIs, see the Core API reference page (Korean).


Overview

Authorization

All Payments APIs use Basic authorization. Add a colon to the end of your secret key. Encode the secret key and colon in base 64. Add the encoded secret key and colon to the Basic auth header as below.

English header

Get API responses in English by using the below request header.

Idempotency

Use the idempotency key header to ensure API POST requests are only made once. Requests sent with the same idempotency key will return the same response even on multiple requests, even in the case of an error. The idempotency key should be a unique and random value up to 300 characters long. An idempotency key is valid for 15 days.


Create a payment

POST/v1/payments

Create a payment window. Use as an alternative to the SDK.

Request body parameters

  • method 필수 · string

    Specify the customer's payment method with an enumerated value.

    • CARD: Card and digital wallet payments
    • VIRTUAL_ACCOUNT: Virtual account payments
    • MOBILE_PHONE: Mobile phone payments
    • TRANSFER: Bank transfer payments
    • FOREIGN_EASY_PAY: PayPal, Alipay and other foreign digital wallet payments
  • amount 필수 · number

    Amount to charge the customer.

  • currency string

    Currency of the payment amount. Default is KRW. Only USD is supported for FOREIGN_EASY_PAY payments.

  • orderId 필수 · string

    Unique identifier for the payment. Generate a random string between 6 and 64 characters, using upper and lowercase letters, numerals, -, and _. (No other special characters are allowed.)

  • orderName 필수 · string

    Name of the order. E.g., Bottled water etc.. The maximum length is 100 characters.

  • successUrl string

    The URL customers are redirected to upon payment request success. Check query parameters for paymentKey, orderId, and amount. The successUrl must include the origin; for example, https://www.example.com/success.

    * Required for all domestic payments and PayPal

  • failUrl string

    The URL customers are redirected upon payment request failure. Check query parameters for the error code and message. The failUrl must include the origin; for example, https://www.example.com/fail.

    * Required for all domestic payments and PayPal

  • pendingUrl string

    The URL customers are redirected to after completing a Chinese or Southeast Asian payment. Integrate the PAYMENT_STATUS_CHANGED webhook to get the result of the payment asynchronously.

    * Required for all FOREIGN_EASY_PAY payments except PayPal

  • flowMode string

    Payment window type. To open the hosted type window, use DEFAULT. To open the direct type window, input DIRECT and use the cardCompany or easyPay parameters.

  • easyPay string

    Code of the digital wallet you want to open. For example, if you input TOSSPAY, the Toss Pay payment window will open.

    * Some digital wallet providers do not work in test environments.

  • cardCompany string

    Code of the card payment you want to open. For example, if you input HYUNDAI, the Hyundai Card payment window will open.

    * Only Korean card companies are accepted.

  • provider string

    FOREIGN_EASY_PAY provider codes.

    With the exception of PayPal, the below foreign easypay providers must be integrated asynchronously, meaning you must get the result of the payment through the PAYMENT_STATUS_CHANGED webhook.

    Payment method (Provider)Code
    AlipayALIPAY
    AlipayHKALIPAYHK
    BillEaseBILLEASE
    BoostBOOST
    BPIBPI
    DANADANA
    GCashGCASH
    PayPalPAYPAL
    Rabbit LINE PayRABBIT_LINE_PAY
    Touch 'n Go eWalletTOUCHNGO
    TrueMoney WalletTRUEMONEY
  • appScheme string

    App scheme of your service. After the customer completes the payment on an mobile ISP app, this app scheme is used to redirect them back to your ap. Specify your store's app scheme like this: testapp://.

Returns


Returns a Payment object if successful. Provide the customer with the checkout.url to open the payment window.

Returns an error object if unsuccessful.

Authorize a payment

POST/v1/payments/confirm

Authorize payments to finalize the transaction.

Request body parameters

  • paymentKey 필수 · string

    Unique key given to each payment, issued by Toss Payments. The maximum length is 200 characters.

  • orderId 필수 · string

    Unique identifier for payment. Generate a random string between 6 and 64 characters, using upper and lowercase letters, numerals, -, and _. (No other special characters are allowed.)

  • amount 필수 · number

    Amount to charge the customer.

Returns


Returns a Payment object if successful. Provide the customer with the checkout.url to open the payment window.

Returns an error object if unsuccessful.

Retrieve a payment

GET/v1/payments/{paymentKey}

Retrieve a payment using the paymentKey.

Path parameters

  • paymentKey 필수 · string

    Unique key given to each payment, issued by Toss Payments. The maximum length is 200 characters.

Returns


Returns a Payment object if successful.

Returns an error object if unsuccessful.

Cancel a payment

POST/v1/payments/{paymentKey}/cancel

Cancel payments. Full and partial cancellations are available.

Path parameters

  • paymentKey 필수 · string

    Unique key given to each payment, issued by Toss Payments. The maximum length is 200 characters.

Request body parameters

  • cancelReason 필수 · string

    Reason for canceling payments. The maximum length is 200 characters.

  • cancelAmount number

    Amount to cancel. On default, the whole payment amount is canceled.

  • refundReceiveAccount object

    The customer's refund account information. This parameter is required only for virtual account payments.

  • bank 필수 · string

    Code of the bank. Refer to bank and securities codes.

  • accountNumber 필수 · string

    Bank account number of the customer. Limited to a string of only numbers up to 20 characters long.

  • holderName 필수 · string

    Name registered as the bank account holder. Maximum length is 60 characters.

  • taxFreeAmount number

    The tax-exempted amount out total cancel amount. The default value is 0.

    * This parameter will work only for duty-free stores or stores selling both tax-free and taxable products. Stores selling taxable products cannot use this function. For more information, please refer to the tax guide.

  • currency string

    The currency of the payment. Required as USD for foreign digital wallet payments.

  • refundableAmount number ・ deprecated

    The available amount for refunds. Use this parameter to ensure you don't cancel more than the actual refundable amount.

    If the available amount for refunds is different from refundableAmount, an error is sent without processing the cancellation.

    * Deprecated parameter. Use IDEMPOTENCY_KEY in request header to cancel payments safely.

Returns


Returns a Payment object if successful. Check the cancels array for details.

Returns an error object if unsuccessful.

Keyed transactions

POST/v1/payments/key-in

In keyed transactions, the customer must manually enter their card information to make a payment. It is not permitted to save or tokenize the customer's card information.

Keyed transactions require a separate contract. Contact your sales associate for more information.

Request body parameters

  • amount 필수 · integer

    Amount to charge the customer.

  • orderId 필수 · string

    Unique identifier for the payment. Generate a random string between 6 and 64 characters, using upper and lowercase letters, numerals, -, and _. (No other special characters are allowed.)

  • cardNumber 필수 · string

    Card number. The maximum length is 20 characters.

  • cardExpirationYear 필수 · string

    Card expiration year.

  • cardExpirationMonth 필수 · string

    Card expiration month.

  • cardPassword string

    The first two digits of the card password (PIN).

  • orderName 필수 · string

    Name of the order. E.g., Bottled water etc.. The maximum length is 100 characters.

  • customerIdentityNumber 필수 · string

    Card holder information. This string has 6 digits of the card holder’s date of birth (YYMMDD) or 10 digits of a business registration number.

  • cardInstallmentPlan integer

    Monthly installment period. Enter values between 2 and 12. Entering 0 will trigger a one-time payment, not an installment.

  • useFreeInstallmentPlan boolean

    Whether or not to apply an interest-free installment plan supported by the card company. The default value is false. If the value is true, an interest-free installment plan will be applied for the months set at cardInstallmentPlan.

    * The interest-free installment plan fees incurred by this parameter is paid by the store.

  • taxFreeAmount integer

    The tax-exempted amount out total cancel amount. The default value is 0.

    * This parameter will work only for duty-free stores or stores selling both tax-free and taxable products. Stores selling taxable products cannot use this function. For more information, please refer to the tax guide.

  • customerEmail string

    Customer’s email address. Customers will be alerted about their payment result through this email. The maximum length is 100 characters.

  • customerName string

    Customer’s name. The maximum length is 100 characters.

  • vbv string

    Information for 3D Secure(3DS) authentication. Required if you must have 3DS authentication results.

  • cavv string

    Authentication value for the 3DS authentication session

  • xid string

    Transaction ID.

  • eci string

    Code value for the 3DS authentication result.

Returns


Returns a Payment object if successful.

Returns an error object if unsuccessful. See the related errors.

  • 더 궁금한 내용이 있나요?
  • 코드 샘플을 참고하세요
  • 기술지원이 필요한가요?
    실시간 문의|이메일 보내기