- Fetch products and plans from Firmhouse.
- Create a cart.
- Add products to the cart.
- Let customers update product quantities or remove products.
- Update address and customer details.
- Create a payment link and redirect the customer to payment.
Requirements
Before you start:- Create the products you want to sell in Firmhouse.
- For Product-as-a-Service projects, create at least one plan.
- Set up a payment provider.
- Generate a project access token in Settings > Integrations. For client-side storefront calls, use a token with Storefront access.
Fetch products
Use theproducts query to show products configured in the Firmhouse Portal.
after and first for pagination. Pass pageInfo.endCursor as after to fetch the next page.
Fetch plans
For Product-as-a-Service projects, use theplans query to show the plans configured in Firmhouse.
Create a cart
Create a cart withcreateCart. Firmhouse returns a subscription token for the draft subscription.
X-Subscription-Token header for later cart calls. In a web app, store it in a cookie or local storage so returning customers can continue the same checkout.
If the default plan includes products, those products are automatically added when you create the cart.
Add products to the cart
UsecreateOrderedProduct to add a product.
orderedProduct to show an added-to-cart confirmation. Use subscription to update the cart UI with totals and cart contents.
If you need to add metadata to ordered products, use a project access token with Write access and pass metadata. If multiple rows of the same product need different metadata, pass ensureNewRecord: true.
Use createOrderedProductV2 when you need the same cart behavior with extra options such as orderedProductType. Set orderedProductType to ONE_OFF_ADDON when the product should only be included in the next order.
Remove products from the cart
UsedestroyOrderedProduct to remove a product from the cart.
Update product quantities
UseupdateOrderedProductQuantity to update quantities in the cart.
Update the subscription plan
UseupdatePlan to change the active plan for the draft subscription.
Fetch current cart information
UsegetSubscription to fetch the current cart state. This is useful when customers return to the storefront or when they navigate to checkout.
subscription.checkoutUrl.
Update address details
UseupdateAddressDetails to collect billing, invoice, and shipping details.
name, email, address, city, and country before payment. You can change the required fields in Checkout > Preferences > Customer fields in your Firmhouse project.
Generate a payment link
UsecreateSubscriptionFromCart to create a paymentUrl. Redirect the customer to that URL to complete payment.
paymentUrl is null and errors explains what still needs to be collected.