Send a check through the API
Upload check images, validate them, and pay with the returned file ids.
Use this flow to deposit a paper check from your own software. Your platform uploads images of the front and back, and dhango builds the image cash letter (ICL) and sends it to the bank. dhango does not print or mail checks.
Upload images with the categories CheckFront and CheckBack only. The ICL categories, CheckFrontIcl and CheckBackIcl, are rejected with 400, because dhango creates the ICL itself.
Check payments are USD only, and they cannot carry a payer fee. Send payerFee as 0.
1. Upload the images
Upload each image to POST /v1/checks/files/{transactionFileCategory} as multipart form data, once with CheckFront and once with CheckBack. Each response returns a file id.
2. Validate
Send both file ids to POST /v1/checks/validate. When dhango can read them from the images, the response includes checkNumber, routingNumber, accountNumber, and amount, which you can show the user to confirm.
If the account has a check processor credential, the account key alone can call validate. The pay call in the next step always needs the API key and secret.
3. Pay
Call POST /v1/transactions/pay with a check object that includes the fileIds. checkNumber, routingNumber, and accountNumber are optional, and you can pass the values returned by validate. Also send amount, payer, and a payerFee of 0.
4. Follow the transaction
Check payments send TransactionEvent webhooks like any other payment. The transaction's payment method is Check, and checks captured on a hardware scanner have the channel Scan. Transaction lifecycles shows the sequence of events.
To scan or upload checks from the dashboard instead of the API, see Check processing.
curl -s -u "$DHANGO_KEY:$DHANGO_SECRET" \ -H "accountKey: $ACCOUNT_KEY" \ -F "file=@front.jpg" \ https://api.dhangodemo.com/v1/checks/files/CheckFrontcurl -s -u "$DHANGO_KEY:$DHANGO_SECRET" \ -H "Content-Type: application/json" \ -H "accountKey: $ACCOUNT_KEY" \ -d '{"fileIds":["file_front","file_back"]}' \ https://api.dhangodemo.com/v1/checks/validatecurl -s -u "$DHANGO_KEY:$DHANGO_SECRET" \ -H "Content-Type: application/json" \ -H "accountKey: $ACCOUNT_KEY" \ -d '{"payer":"Ada Lovelace","amount":86.14,"payerFee":0,"check":{"fileIds":["file_front","file_back"]}}' \ https://api.dhangodemo.com/v1/transactions/payconst auth = "Basic " + Buffer.from(process.env.DHANGO_KEY + ":" + process.env.DHANGO_SECRET).toString("base64");const form = new FormData();form.set("file", new Blob([frontBytes]), "front.jpg");const uploaded = await fetch("https://api.dhangodemo.com/v1/checks/files/CheckFront", { method: "POST", headers: { Authorization: auth, accountKey: process.env.ACCOUNT_KEY }, body: form});const file = await uploaded.json();import os, requestsauth = (os.environ["DHANGO_KEY"], os.environ["DHANGO_SECRET"])headers = {"accountKey": os.environ["ACCOUNT_KEY"]}file_ids = []for category, path in [("CheckFront", "front.jpg"), ("CheckBack", "back.jpg")]: with open(path, "rb") as image: upload = requests.post( f"https://api.dhangodemo.com/v1/checks/files/{category}", auth=auth, headers=headers, files={"file": image}, ) upload.raise_for_status() file_ids.append(upload.json()["id"])validation = requests.post( "https://api.dhangodemo.com/v1/checks/validate", auth=auth, headers=headers, json={"fileIds": file_ids},).json()response = requests.post( "https://api.dhangodemo.com/v1/transactions/pay", auth=auth, headers=headers, json={ "payer": "Ada Lovelace", "amount": 86.14, "payerFee": 0, "check": {"fileIds": file_ids}, },)response.raise_for_status()