Realtime Keys are short-lived tokens for subscribing to live payment status updates on a checkout session. Use these to update your UI immediately upon payment confirmation, without polling.
importuuidimportrequestsBASE_URL="https://api.heydollr.app"headers={"Authorization":"Bearer YOUR_ACCESS_TOKEN","Content-Type":"application/json"}response=requests.post(f"{BASE_URL}/v1/realtime-keys/collection",headers=headers,json={"session_id":55,"source_type":"INVOICE","reference_id":str(uuid.uuid4()),},)rt=response.json()print("Realtime token:",rt["access_token"])print("Expires in (seconds):",rt["expires_in"])
import{randomUUID}from"crypto";constBASE_URL="https://api.heydollr.app";constTOKEN="YOUR_ACCESS_TOKEN";constresponse=awaitfetch(`${BASE_URL}/v1/realtime-keys/collection`,{method:"POST",headers:{Authorization:`Bearer ${TOKEN}`,"Content-Type":"application/json",},body:JSON.stringify({session_id:55,source_type:"INVOICE",reference_id:randomUUID(),}),});constrt=awaitresponse.json();console.log("Realtime token:",rt.access_token);console.log("Expires in (seconds):",rt.expires_in);
// go get github.com/google/uuidpackagemainimport("bytes""encoding/json""fmt""io""net/http""github.com/google/uuid")funcmain(){payload:=map[string]interface{}{"session_id":55,"source_type":"INVOICE","reference_id":uuid.New().String(),}body,_:=json.Marshal(payload)req,_:=http.NewRequest("POST","https://api.heydollr.app/v1/realtime-keys/collection",bytes.NewBuffer(body),)req.Header.Set("Authorization","Bearer YOUR_ACCESS_TOKEN")req.Header.Set("Content-Type","application/json")client:=&http.Client{}resp,_:=client.Do(req)deferresp.Body.Close()data,_:=io.ReadAll(resp.Body)fmt.Println(string(data))}