Finalize
Finialization involves making API calls, displaying the transaction status, and responding to HTTP callbacks.
Flow Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram autonumber actor u as User participant b as Browser participant cs as Customer Server participant dt1 as DT One u->>+b: Open customer's webpage note over u, dt1: UI SDK initialized and the user selects and checkouts a product. b->>cs: Payment Hook<br/>(Session ID extracted<br/>from Session Data, Payment Details) activate cs cs->>b: Render Payment Page note over b, cs: Collect payment, finalize session and redirect<br/>to Transaction status view (Session ID) note over b,dt1: The finalize session call should happen with 1 hour of payment hook cs->>dt1: Finalize Session<br/>(Auth, Session ID, Payment Details) activate dt1 dt1->>cs: Finalize Session Response deactivate dt1 cs->>b: Render Transaction Status Page deactivate cs deactivate b
Steps
Finalize the session identified by the sessionID
to confirm all transactions. Make this API call after you collect the payment.
- URL:
/v1/sessions/{sessionID}/finalize
- Method:
POST
Request Body
[
{
"transaction_id": 65430,
"price": {
"currency": "SGD",
"amount": 9.9
}
}
]
Response (200 OK)
[
{
"is_confirmed": true,
"transaction_id": 65430
}
]
Errors
400
: Bad Request401
: Unauthorized403
: Forbidden404
: Not Found500
: Server Error
Schemas
SessionFinalizeRequest
{
"transaction_id": "integer",
"price": {
"amount": "number",
"currency": "ISO 4217 code"
}
]
SessionFinalizeResponse
{
"is_confirmed": true,
"transaction_id": "integer"
}
Example
The callbacks.onSubmit
function passes a Transaction object (described here: https://dvs-api-doc.dtone.com/#operation/getTransactionById) and a sessionId in the function parameters. Extract the transaction.id
from the transaction object.
Examples
# Request
curl --location --request POST '<domain>/v1/sessions/{sessionID}/finalize' \
--header 'Content-Type: application/json' \
--user <APIKey:APISecret> \
--data '[ { "transaction_id": 125757, "price": { "currency": "SGD", "amount": 21.613 } }]'
# Response
[ { "transaction_id": 125758, "is_confirmed": true }]
Updated 2 months ago