The line of credits API endpoint supports the use of an additional idempotency-key
header. This header helps prevent duplicate payment creation.
When a payment request is received, the idempotency-key
is hashed and stored alongside the request body in a cache within LMS. This cache is compared against future payments that use the same idempotency-key
to catch duplicate payments. If a duplicate payment is received, the existing payment's oData object is returned instead of creating a duplicate payment.
Creating and using the idempotency-key
The idempotency-key
must be a valid UUID, recommended as v4 or v7, and is included in the request headers when sending a request. Below is an example cURL request header.
curl --request POST \
--url https://loanpro.simnang.com/api/public/api/1/odata.svc/LineOfCreditPayments \
--header 'Authorization: Bearer {token}' \
--header 'Autopal-Instance-Id: {tenant}' \
--header 'idempotency-key: {UUID}' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
This header is optional and is used in our POST
log payment and POST
process payment requests.
Testing this request yourself in a Postman workspace?
Create an
idempotency-key
header and use Postman's built in{{$guid}}
variable in the header value.
Responses
Using the idempotency-key
header will return a different set of responses. If LMS detects a duplicate UUID and original request payload, a 200
response containing the oData object of the original payment will be returned. If the request contains a duplicate UUID and a different request payload, a 409
response will be returned.
{
"error": {
"message": "Keys for idempotent requests can only be used with the same parameters they were first used with. Try using a key other than 'd002416e-6c07-4875-9be0-515fa26cc132' if you meant to execute a different request"
},
"error_v2": {
"event": "odata-idempotency-hashes-does-not-match-event",
"data": {
"error": {
"code": "odata-idempotency-hashes-does-not-match-409-001",
"message": "Keys for idempotent requests can only be used with the same parameters they were first used with. Try using a key other than 'd002416e-6c07-4875-9be0-515fa26cc132' if you meant to execute a different request",
"metadata": {
"idempotencyKey": "d002416e-6c07-4875-9be0-515fa26cc132"
}
},
"reference_id": "Root=1-689e470e-3ff7c0a309a429731ab915c8"
}
}
}