When a user sends a request to CREATE or UPDATE a resource, a REQUEST_-TOKEN header can be sent to identify the request as unique. A record in the RequestTokens table will be created containing the id
of the logged in user, the given token, the primary resource category number and the id of the created/updated resource. Whenever we detect that a request is duplicate (by checking the login/REQUEST_-TOKEN sent) we simply return the results of the original request and an indicator (duplicateRequest) set to true in the details part of the response.
...
The RequestTokens table is not available to all users (only ADMINs have access to the table) and records can be created, queried or deleted.
Example:
First request to create a new transaction will be processed:
Code Block |
---|
POST: /txns HEADERS: REQUEST_-TOKEN: abcdef123456 BODY: { "type":"1", "merchant":"000000000000007", "mid":"01242567", "origin":"2", "total":"4500", "terminal":"123654789", "payment":{ "number":"4111111111111111", "expiration":"0818", "cvv":"123" }, "zip":"99999" } |
...
Code Block |
---|
POST: /txns HEADERS: REQUEST_-TOKEN: abcdef123456 BODY: { "type":"1", "merchant":"000000000000007", "mid":"01242567", "origin":"2", "total":"4500", "terminal":"123654789", "payment":{ "number":"4111111111111111", "expiration":"0818", "cvv":"123" }, "zip":"99999" } RESPONSE: "details": { "duplicateRequest": true } |
...
Code Block |
---|
PUT: /txns/00000000000000001 HEADERS: REQUEST_-TOKEN: abcdef123456 BODY: { "batch":null } RESPONSE: "details": { "duplicateRequest": true } |
...
Code Block |
---|
PUT: /txns/00000000000000001 HEADERS: REQUEST_-TOKEN: 123456abcdef BODY: { "batch":null } |
...
Code Block |
---|
POST: /txns HEADERS: REQUEST_-TOKEN: 654321fedcba BODY: { "type":"1", "merchant":"000000000000007", "mid":"01242567", "origin":"2", "total":"4500", "terminal":"123654789", "payment":{ "number":"4111111111111111", "expiration":"0818", "cvv":"123" }, "zip":"99999" } |
...