Neither needs an API key. The examples use the sandbox at
https://apistagepc.grogov.us. The full schemas are in the API Reference: Start a hosted checkout and Open a hosted checkout from a launch link.
Post a form
Put a form on your page that posts to the intake. The payer’s browser follows the redirect to the checkout. Nest fields with brackets:items[0][id].
Send JSON from your server
You can send the same fields as JSON from your backend. Do not follow the redirect: read itsLocation header and send the payer there.
Node.js
303 redirect, never a JSON body, including on failure. A failure points at your cancel_url or the GroGov error page; see Errors.
Use a launch link
A launch link carries the checkout in its query string. Each time someone opens it, a new checkout is created, so you can reuse one link. Anyone who has the link can start a checkout with it. Number the items from 1 withitem<N>_ fields:
- Each item takes
item<N>_id,item<N>_description,item<N>_amount, and optionallyitem<N>_quantityanditem<N>_category.item<N>_amount_centsworks in place ofitem<N>_amount. Bracket names such asitems[0][id]also work. - For a single item, you can send
descriptionandamount, with optionalitem_id(defaultITEM-001) andquantity. - The top-level fields are the same as in a post. A launch link cannot carry
metadata, or the items’requiredandmetadata. - URL-encode every value.
Show the checkout in an iframe
Use the launch link as the iframe’ssrc and add embed=iframe:
Fields
Each item:
The total is the sum of
amount × quantity over all items. The service fee is added on top of it at checkout.
Errors
When a request fails, no checkout is created and the payer is redirected:- To your
cancel_urlwitherror=validation_error,detail=<code>, and asigwhen the portal has a signing secret. See Results and signatures. - To the GroGov error page with
?code=<code>when there is no usablecancel_url: noportal_idor an unknown one, acancel_urlthat is not allowed, or a server error.
Only the first problem is reported. Fix it and try again to see the next one.