Capture API

Overview

Transactions that have set options.payment.capture as false when requesting the Request API payment will be put on hold when the payment is completed with the Confirm API. In order to finalize the payment, an additional purchase with Capture API is required.

send

send(captureRequestConfig)

Returns Promise<ApiResponse<CaptureResponseBody>>

Request Config

export type Options = {
  extra: {
    /**
     * 點數限制資訊 (Taiwan only)
     *
     * - useLimit: 不可使用點數折抵的金額
     * - rewardLimit: 不可回饋點數的金額
     * ```json
     * "promotionRestriction": {
     *     "useLimit": 100,
     *     "rewardLimit": 100
     * }
     * ```
     */
    promotionRestriction: Record<string, unknown>
  }
}

export type CaptureRequestBody = {
  /**
   * Payment amount
   */
  amount: number
  /**
   * Payment currency (ISO 4217)
   * - Supported currencies: USD, JPY, TWD, THB
   */
  currency: string
  /**
   * Options
   */
  options?: Options
}

export type CaptureRequestConfig = GeneralRequestConfig & {
  /**
   * ID of the transaction
   */
  transactionId: string
  /**
   * Request body of capture API
   */
  body: CaptureRequestBody
}

Response Body

export type PayInfo = {
  /**
   * A payment method used to process the payment
   * - Credit card: CREDIT_CARD
   * - Balance: BALANCE
   * - Discount: DISCOUNT
   */
  method: 'CREDIT_CARD' | 'BALANCE' | 'DISCOUNT'
  /**
   * Payment amount
   */
  amount: number
}

export type Info = {
  /**
   * An order ID sent from the merchant when reserving a payment.
   */
  orderId: string
  /**
   * A transaction ID returned as the payment reservation result (19 digits).
   */
  transactionId: string
  /**
   * Payment information
   */
  payInfo: PayInfo[]
}

export type CaptureResponseBody = GeneralResponseBody & {
  /**
   * Capture information
   */
  info: Info
}

Return Code

Success

CodeDescription
0000Success

Error

CodeDescription
1104Non-existing merchant
1105The merchant cannot use the LINE Pay.
1106A header info error
1150Cannot find the transaction history
1155Wrong transaction number
1170Balance of the member's account has been changed.
1172A record of transaction with the same order number already exists.
1179Unable to proceed the transaction.
1183The payment amount should be greater than 0.
1184The payment amount exceeds requested amount.
1198Either API call has been duplicated or purchase API has been called while re-authorization was automatically processed (Repeat after several minutes).
1199Internal request error
1280A temporary error occurred while processing the credit card payment.
1281A credit card payment error
1282A credit card authorization error
1283The payment was refused due to suspected fraud.
1284The credit card payment has temporarily stopped.
1285Missing credit card payment information
1286Wrong credit card payment information
1287The credit card has been expired
1288The credit card has low balance
1289Exceeded the credit card limit
1290Exceeded the limit of the credit card per payment
1291The card has been reported as a stolen card.
1292The card has been suspended.
1293A CVN input error
1294The card is listed on the blacklist.
1295A wrong credit card number
1296Unable to proceed the amount
1298The card has been declined.
9000An internal error

Example

Request

const res = await linePayClient.capture
  .send({
    transactionId: '2021121300698360310',
    body: {
      currency: 'TWD',
      amount: 1000
    }
  })

Response

{
  "body": {
    "returnCode": "0000",
    "returnMessage": "Success.",
    "info": {
      "transactionId": "2021121300698360310",
      "orderId": "20211216002",
      "payInfo": [{
        "method": "BALANCE",
        "amount": 900
      }, {
        "method": "DISCOUNT",
        "amount": 100
      }]
    }
  },
  "comments": {}
}

addHandler

addHandler(handler)

Returns CaptureClient

Example:

client.addHandler(({ type, req, next, httpClient }) => {
  console.log(type) // capture
  return next(req)
})

addHandlers

addHandlers(...handlers)

Returns CaptureClient

Example:

client.addHandlers(
  ({ req, next }) => next(req),
  ({ req, next }) => next(req),
  ({ req, next }) => next(req)
)
Last Updated:
Contributors: Sean Lin