BigCommerce Developers — Samuel P. (Customer) asked a question.
We’re building a headless storefront where users can add items to their cart, authenticate using our own system, and then complete their purchase via the Optimized One-Page Checkout.However, we’re encountering intermittent issues preventing a smooth checkout experience:
- 25% of checkouts fail with a “Cannot start a checkout with an empty cart” error.
- Some users are unexpectedly redirected to an empty /cart.php
We’re using the Customer Login API to pre-authenticate users before redirecting them to the
checkout_url
These issues are blocking our production launch, and we’d appreciate guidance on resolving them.
Here are the detailed steps we are taking:
- Create cart, add items using graphql api
- *Once the user click "checkout" on our website*:
- Create bigcommerce user programatically using the rest API
- Update cart customer id using rest api
- Create cart redirects to get "checkout_url"
- Create a "Customer Login API" url using a Customer login JWT payload to pre-authenticate user before redirecting to "checkout_url".
Chains of network requests on the Big Commerce domain:
302 to
302 to
https://[store].mybigcommerce.com/checkout
302 to
https://[store].mybigcommerce.com/cart.php
With error: "Cannot start a checkout with an empty cart"
Sometimes the user is also redirected to /cart.php with items, but after clicking "Checkout" or refreshing the page,
he is redirected back to /cart.php with the same "Cannot start a checkout with an empty cart"
Example of JWT payload to create customer login url:
- {
- iss: '[BIGCOMMERCE_CLIENT_ID]',
- iat: 1739198337, // Math.round(new Date().getTime() / 1000)
- jti: 'c12163e8-db5c-4323-bf49-6ea8e96107d9', // uuidv4()
- operation: 'customer_login',
- store_hash: '[STORE_HASH]',
- customer_id: 353,
- redirect_to: '/cart.php?action=loadInCheckout&id=278ad36e-65fa-4aaf-ae0b-2df385d11ad0&token=4a6870b841a14e8aa19660f93d2a9fd340f30db06cfe3428c6f7a54f77c1218c',
- channel_id: 1
- }