Start the integration
Save a payment method, take a payment, and subscribe to events.
A dhango integration comes down to three jobs. Save the payer's payment method as a token, use that token to take a payment or send a payout, and listen for webhooks that tell you what happened next. dhango hosts the dashboard and the merchant sign-up form, so you do not build those.
The browser scripts send card and bank details straight to dhango, so they never reach your server. If you send raw card numbers through your own server instead, your platform takes on that PCI scope.
Save a payment method
Collect the payment method in one of three ways:
- Drop-in form. The dhango script builds the fields for you. Add your own CSS to match your platform.
- Custom form. You build the inputs, and the dhango script submits them.
- Raw details on
POST /v1/tokens. Use this only when your platform has to handle the payment details itself.
Each way returns a token id. Store that id, not the card or account number. When the payer comes back, GET /v1/tokens/{id} returns the brand and the masked number so they can recognize the saved method. See Save a payment method.
Take a payment
POST /v1/transactions/pay charges the token in one step. To place a hold first and collect the funds later, call POST /v1/transactions/authorize, then POST /v1/transactions/{id}/capture.
The Transactions reference lists every field on the pay request.
curl -s -u "$DHANGO_KEY:$DHANGO_SECRET" \ -H "Content-Type: application/json" \ -H "accountKey: $ACCOUNT_KEY" \ -H "Idempotency-Key: 6f1c0c3e-8b0a-4f0e-9c1a-2d3e4f5a6b7c" \ -d '{"tokenId":"tok_example","payer":"Ada Lovelace","amount":25.00,"payerFee":0}' \ https://api.dhangodemo.com/v1/transactions/payconst auth = Buffer.from(process.env.DHANGO_KEY + ":" + process.env.DHANGO_SECRET).toString("base64");const response = await fetch("https://api.dhangodemo.com/v1/transactions/pay", { method: "POST", headers: { Authorization: "Basic " + auth, "Content-Type": "application/json", accountKey: process.env.ACCOUNT_KEY, "Idempotency-Key": crypto.randomUUID() }, body: JSON.stringify({ tokenId: "tok_example", payer: "Ada Lovelace", amount: 25, payerFee: 0 })});const payment = await response.json();import os, uuid, requestsauth = (os.environ["DHANGO_KEY"], os.environ["DHANGO_SECRET"])headers = {"accountKey": os.environ["ACCOUNT_KEY"]}response = requests.post( "https://api.dhangodemo.com/v1/transactions/pay", auth=auth, headers={**headers, "Idempotency-Key": str(uuid.uuid4())}, json={ "tokenId": "tok_example", "payer": "Ada Lovelace", "amount": 25.0, "payerFee": 0 },)response.raise_for_status()payment = response.json()Send a payout
POST /v1/transactions/payout sends funds to a bank account. Send a payout covers the destination fields and has a sandbox request you can run.
Listen for the result
Payments keep changing after the API responds. ACH can be returned days later, and funding happens in batches. Register one HTTPS URL on your platform account, and dhango posts every event to it. Verify the signature, then branch on Type. Webhooks has the steps.