swellstores / swell-js

JS library for building storefronts and checkouts with Swell ecommerce.
https://swell.is
MIT License
139 stars 29 forks source link

`account_id` validation error when submitting order from cart #104

Closed cpvdeveloper closed 1 year ago

cpvdeveloper commented 1 year ago

I'm trying to use swell-js to build a custom checkout flow i.e. not using the hosted checkout. I'm following the swell-js docs for a basic checkout flow as follows (create cart, add items, update card, convert to order):

swell.init(SWELL_STORE_ID, SWELL_PUBLIC_KEY, { useCamelCase: true });
...
await swell.cart.addItem({
  productId: product.id,
  quantity: 1,
});
...
await swell.cart.update({
  billing: {
    method: "cash",  // <-- note that I am using a manual payment method
    .....
  },
  shipping: { ... }
});
...
await swell.cart.submitOrder();  // <--- the error happens from this

but I'm getting this error about account_id parameter missing. From what I understand, this is the account_id of my own Swell account, and isn't something that I should have to pass as a parameter anywhere during the steps above (the cart should already contain this read-only value).

{"error":{"code":"validation_error","message":"Required","param":"account_id"}}
cpvdeveloper commented 1 year ago

Close. I was moving this to a discussion instead, when I found a discussion like this with a solution already: https://github.com/orgs/swellstores/discussions/93