Skip to main content

Implement capture-separated payment

When you implement online payment, you can separate payment confirmation and capture. You can separate payment confirmation and capture to account for the possibility that you may need to delay the settlement of the payment or that the amount of the payment may change.

In Taiwan, automatic capture is the basic payment method, and you cannot process payment with capture separated without a prior request. To use capture-separated payments in Taiwan, contact the representative of LINE Pay.

The flow for separating payment confirmation and capture is as follows.

To separate capture, implement the following in merchant server.

Capture

To separate payment confirmation and capture, set the value of the field (options.payment.capture) that determines whether to automatically capture when you request payment to false. Below is the code to call the payment request API that separates payment confirmation and capture.

For information on obtaining the credentials needed to call the Online API, see Prepare API credentials. The code example described on this page uses the requestOnlineAPI() function defined in the Prepare API credentials code example.

try {
// Request payments to be separated into payment confirmation and capture
let response = await requestOnlineAPI({
method: "POST",
baseUrl: targetAPIServer,
apiPath: "/v3/payments/request",
data: {
amount: 1000,
currency: "TWD",
// ...
options: {
payment: {
capture: false,
},
},
},
});

console.log("Response: ", response);
} catch (error) {
console.log(error);
}

If you request as above and then confirm payment, you can either capture the payment or void the payment. If the transaction with the customer is completed and the settlement amount is determined, request the capture. When requesting a capture, specify the target payment confirmation with the payment transaction ID (info.transactionId) you received after calling the payment confirmation request API. The following is an example of requesting a capture.

try {
// Payment confirmation request
let confirmationResponse = await requestOnlineAPI({
method: "POST",
baseUrl: targetAPIServer,
apiPath: `/v3/payments/${requestTransactionId}/confirm`,
data: {
amount: 1000,
currency: "TWD",
},
});

console.log("Confirmation response: ", confirmationResponse);

let captureResponse = await requestOnlineAPI({
method: "POST",
baseUrl: targetAPIServer,
apiPath: `/v3/payments/authorizations/${confirmationResponse.info.transactionId}/capture`,
data: {
amount: 800,
currency: "TWD",
},
});

console.log("Capture response: ", captureResponse);
} catch (error) {
console.log(error);
}

If you request payment confirmation with capture separated, the LINE Pay server includes the payment confirmation expiration date and time information (info.authorizationExpireDate) in the response. If the payment isn't captured before the payment confirmation expiration date and time, the confirmed payment is automatically voided. You can also manually void the payment.

Depending on the service implementation language, you may need to process the transaction ID as a string when handling transaction ID information. For more information, see the Transaction ID.

Once the capture is completed, you will receive the following response.

{
"returnCode": "0000",
"returnMessage": "OK",
"info": {
"transactionId": 2023042201206549440,
"orderId": "EXAMPLE_ORDER_20230422_1000002",
"payInfo": [
{
"method": "BALANCE",
"amount": 20
}
]
}
}

You cannot capture an amount greater than the payment amount that was originally requested. However, you can capture an amount equal to or less than the payment amount. Partial capture is processed if you capture an amount less than the payment amount, and the remaining amount that wasn't captured is partially canceled. Once the capture is complete, you cannot void the payment. You can only process the refund.

Void

If you are processing payment with capture separated, you may also void the payment without capturing after payment confirmation. The process for voiding a payment is as follows.

Just as with a capture, call the void API with the value of the payment transaction ID (info.transactionId) received after calling the payment confirmation request API. The following is an example of voiding a payment.

try {
// ...
// Void request
let voidResponse = await requestOnlineAPI({
method: "POST",
baseUrl: targetAPIServer,
apiPath: `/v3/payments/authorizations/${confirmationResponse.info.transactionId}/void`,
});

console.log("Response: ", voidResponse);
} catch (error) {
console.log(error);
}

Once the payment is voided, you will receive the following response.

{
"returnCode": "0000",
"returnMessage": "Success"
}

You can retrieve payment details of a captured or confirmed payment.