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 the standard library net/http and encoding/json.
Prerequisites
Go 1.21+
os.Getenv for DOLLR_CLIENT_ID and DOLLR_CLIENT_SECRET
Steps
Client and token
package main
import (
" bytes "
" encoding/json "
" net/http "
" os "
)
const baseURL = "https://api.heydollr.app"
func obtainToken () ( string , error ) {
body , _ := json . Marshal ( map [ string ] string {
"client_id" : os . Getenv ( "DOLLR_CLIENT_ID" ),
"client_secret" : os . Getenv ( "DOLLR_CLIENT_SECRET" ),
})
req , _ := http . NewRequest ( http . MethodPost , baseURL + "/v1/jwt/client/obtain/token" , bytes . NewReader ( body ))
req . Header . Set ( "Content-Type" , "application/json" )
res , err := http . DefaultClient . Do ( req )
// decode access_token from res.Body
return "" , err
}
POST helper
func dollrPost ( path , token string , payload any ) ( map [ string ] any , error ) {
b , _ := json . Marshal ( payload )
req , _ := http . NewRequest ( http . MethodPost , baseURL + path , bytes . NewReader ( b ))
req . Header . Set ( "Authorization" , "Bearer " + token )
req . Header . Set ( "Content-Type" , "application/json" )
res , err := http . DefaultClient . Do ( req )
// json.NewDecoder(res.Body).Decode(&out)
return nil , err
}
Chain: parties → counterparties → invoices → items → publish.
Execute with idempotency key
import " github.com/google/uuid "
referenceID := uuid . New (). String ()
_ , err = dollrPost ( "/v1/executions/collection" , token , map [ string ] string {
"session_id" : sessionID ,
"payment_account_id" : paymentAccountID ,
"currency" : "USD" ,
"reference_id" : referenceID ,
})
Poll status
req , _ := http . NewRequest ( http . MethodGet , baseURL + "/v1/status/collection/" + referenceID , nil )
req . Header . Set ( "Authorization" , "Bearer " + token )
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