Skip to main content

bri-direct-debit-validate-create-payment-sample

Maximum Retry OTP is 5 times

The customer only have 5 times maximum for retrying the OTP if the OTP they input is invalid. After that, the card will temporary blocked by the BRI for 24 hours.

Now the payment is created but the status is PENDING. BRI will send the OTP to the customers and you will need to provide the form to let the customer input the OTP.

To validate the OTP, you will need to hit this API through your Backend:

API Request

TypeValue
HTTP MethodPOST
API endpoint (Sandbox)https://api-sandbox.doku.com/direct-debit/v1/payment/validate
API endpoint (Production)https://api.doku.com/direct-debit/v1/payment/validate

Here is the sample of request header to validate the OTP:

Client-Id: MCH-0001-10791114622547
Request-Id: bce963fc-bb93-4ef2-948a-7838044b537e
Request-Timestamp: 2020-08-11T08:45:42Z
Signature: HMACSHA256=vl9DBTX5KhEiXmnpOD0TSm8PYQknuHPdyHSTSc3W6Ps=
Request Header Explanation
ParameterDescription
Client-IdClient ID retrieved from DOKU Back Office
Request-IdUnique random string (max 128 characters) generated from merchant side to protect duplicate request
Request-TimestampTimestamp request on UTC time in ISO8601 UTC+0 format. It means to proceed transaction on UTC+7 (WIB), merchant need to subtract time with 7. Ex: to proceed transaction on September 22th 2020 at 08:51:00 WIB, the timestamp should be 2020-09-22T01:51:00Z
SignatureSecurity parameter that needs to be generated on merchant Backend and placed to the header request to ensure that the request is coming from valid merchant. Please refer to this section to generate the signature

Here is the sample of request body to validate the OTP:

{
"payment":{
"token": "kSooS93xUk6kJu9VuH33ec5QjlYxoNDEc+AfnoZYaB0=",
"otp": "999999"
}
}
Request Body Explanation
ParameterTypeMandatoryDescription
debit_card.tokenstringMandatoryThe token that generated by DOKU for the transaction
Max length: 128
debit_card.otpstringMandatoryThe Payment OTP that sent by the BRI to the customer
Max length: 6

API Response

After hitting the above API request, DOKU will give the response.

TypeValue
HTTP Status200
ResultSUCCESS

Here is the sample response header:

Client-Id: MCH-0001-10791114622547
Request-Id: bce963fc-bb93-4ef2-948a-7838044b537e
Response-Timestamp: 2020-08-11T08:45:42Z
Signature: HMACSHA256=1jap2tpgvWt83tG4J7IhEwUrwmMt71OaIk0oL0e6sPM=
Response Header Explanation
ParameterDescription
Client-IdSame as the request
Request-IdSame as the request
Response-TimestampTimestamp Response on UTC with format ISO8601 UTC+0 from DOKU
SignatureSignature generated by DOKU based on the response body

Here is the sample of response body:

{
"order": {
"invoice_number": "INV-20210118-0001",
"amount": 90000,
"line_items": [
{
"name": "T-Shirt Red",
"price": 30000,
"quantity": 2
},
{
"name": "Polo Navy",
"price": 30000,
"quantity": 1
}
]
},
"payment": {
"token": "kSooS93xUk6kJu9VuH33ec5QjlYxoNDEc+AfnoZYaB0=",
"status": "SUCCESS"
},
"customer": {
"id": "CUST-0001",
"name": "Anton Budiman",
"email": "anton@example.com",
"phone": "6285694566147",
"address": "Menara Mulia Lantai 8",
"country": "ID",
"id_card": "182918299187776",
"date_of_birth": "15-12-1996"
}
}
Response Body Explanation
ParameterTypeMandatoryDescription
customer.idstringMandatorySame as the request
customer.namestringOptionalSame as the request
customer.emailstringOptionalSame as the request
customer.phonestringOptionalSame as the request
customer.addressstringOptionalSame as the request
customer.countrystringOptionalSame as the request
customer.id_cardstringOptionalSame as the request
customer.date_of_birthstringOptionalSame as the request
order.amountnumberMandatorySame as the request
order.invoice_numberstringMandatorySame as the request
order.line_items.namestringOptionalSame as the request
order.line_items.pricenumberOptionalSame as the request
order.line_items.quantitynumberOptionalSame as the request
payment.tokenstringMandatorySame as the request
payment.statusstringMandatoryPayment status. In this state, it should be SUCCESS or FAILED