Invoices vs orders: These guides walk through invoices (formal billing, line items, publish). The collect flow is the same for orders — use /v1/orders/* instead of /v1/invoices/* and set source_type: "ORDER" on the checkout session. See Orders and Parties & counterparties .Hosted checkout: To skip party, invoice, session, and execute steps entirely, see Hosted checkout .
End-to-end invoice collection with Java 11+ java.net.http.HttpClient and Jackson (or Gson) for JSON.
Prerequisites
Java 11+
Jackson ObjectMapper (or equivalent) on the classpath
Store credentials in environment variables or a secrets manager
Steps
HTTP client and token
import java.net.URI;
import java.net.http. * ;
import java.nio.charset.StandardCharsets;
String baseUrl = "https://api.heydollr.app" ;
HttpClient client = HttpClient . newHttpClient ();
String authBody = """
{"client_id":"%s","client_secret":"%s"}
""" . formatted ( System . getenv ( "DOLLR_CLIENT_ID" ), System . getenv ( "DOLLR_CLIENT_SECRET" ));
HttpRequest tokenReq = HttpRequest . newBuilder ()
. uri ( URI . create (baseUrl + "/v1/jwt/client/obtain/token" ))
. header ( "Content-Type" , "application/json" )
. POST ( HttpRequest . BodyPublishers . ofString (authBody))
. build ();
String tokenJson = client . send (tokenReq, HttpResponse . BodyHandlers . ofString ()). body ();
// Parse access_token from JSON with your mapper
Authenticated POST helper
HttpRequest . Builder authed ( String path, String bearer) {
return HttpRequest . newBuilder ()
. uri ( URI . create (baseUrl + path))
. header ( "Authorization" , "Bearer " + bearer)
. header ( "Content-Type" , "application/json" );
}
// POST /v1/parties/create, /v1/counterparties/create, /v1/invoices/create
// Store party id, counterparty id, invoice id from responses
Publish and execute
// PUT /v1/invoices/publish/{invoiceId}
// POST /v1/sessions/checkout body: {"source_id":101,"source_type":"INVOICE"}
// POST /v1/payment-accounts/create?operation_type=COLLECTION
String referenceId = java . util . UUID . randomUUID (). toString ();
String executeBody = """
{"session_id":"%s","payment_account_id":"%s","currency":"USD","reference_id":"%s"}
""" . formatted (sessionId, paymentAccountId, referenceId);
HttpRequest execute = authed ( "/v1/executions/collection" , bearer)
. POST ( HttpRequest . BodyPublishers . ofString (executeBody))
. build ();
Persist referenceId before client.send(execute, ...).
Poll status
HttpRequest status = HttpRequest . newBuilder ()
. uri ( URI . create (baseUrl + "/v1/status/collection/" + referenceId))
. header ( "Authorization" , "Bearer " + bearer)
. GET ()
. build ();
Try it yourself
Hosted checkout Mobile money and card on a Dollr-hosted page — fastest path.
Orders Same collect flow with source_type: ORDER and /v1/orders/*.
Direct checkout One API call to create source — API-embedded flow.
Last modified on May 22, 2026