Skip to content

Integrate Commerce Into My App

Start checkouts and gate premium features directly from your app code.

Once you’ve connected Stripe and created a product, your app can take payments. In a Proyecta-built app this runs from the browser against the public commerce API — there’s no backend for you to stand up, and no secret key involved.

Storefront catalogs are content. If your products are a content-backed sellable collection (see Products & Features), you read the catalog and render prices through the Content API — the product data lives there. You still start checkout the same way, passing the variant_id of the woven Commerce product.

import * as platform from '@/lib/platformClient.ts';
import { useEntitlement } from '@/hooks/useEntitlement.ts';

commerceCheckout creates a Stripe-hosted checkout session and returns a URL to send the shopper to. You don’t create a customer first — the platform records one from the checkout itself:

const { url } = await platform.commerceCheckout({
lineItems: [{ variantId: 'var_pro_monthly', quantity: 1 }],
successUrl: 'https://myapp.com/welcome',
cancelUrl: 'https://myapp.com/pricing',
customerEmail: shopperEmail, // optional — prefills Stripe checkout
});
window.location.href = url;

Multiple line items are supported. For subscriptions, quantity is the seat count. If a shopper typed a coupon code, pass it along — the server validates it and computes the discount from your commerce data, never from an amount the browser supplies.

const { hasAccess, isLoading } = useEntitlement('pro_features');
if (isLoading) return <Spinner />;
if (!hasAccess) return <UpgradePrompt />;
return <ProOnlyThing />;

The key is the feature slug (e.g. pro_features), not the feature object’s id. The check is server-side and tied to the signed-in session, so it can’t be spoofed from the browser. See Products & Features for the entitlement model.

  • "Build a /pricing page that shows my products and starts a checkout when a button is clicked."
  • "Gate the /pro route so only customers with pro_features access can see it."
  • "Add a cart with a coupon code field and a Checkout button."