{"id":13510273,"url":"https://github.com/netlify/gocommerce-js","last_synced_at":"2025-03-30T15:31:04.199Z","repository":{"id":47422463,"uuid":"62555038","full_name":"netlify/gocommerce-js","owner":"netlify","description":"A gocommerce client library","archived":true,"fork":false,"pushed_at":"2021-09-01T02:32:16.000Z","size":1017,"stargazers_count":130,"open_issues_count":15,"forks_count":27,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-03-24T12:56:37.778Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/gocommerce-js","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netlify.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-04T10:49:38.000Z","updated_at":"2025-03-14T05:55:28.000Z","dependencies_parsed_at":"2022-09-05T01:11:18.444Z","dependency_job_id":null,"html_url":"https://github.com/netlify/gocommerce-js","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fgocommerce-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fgocommerce-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fgocommerce-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fgocommerce-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netlify","download_url":"https://codeload.github.com/netlify/gocommerce-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246338789,"owners_count":20761436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:01:31.599Z","updated_at":"2025-03-30T15:30:59.192Z","avatar_url":"https://github.com/netlify.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","others"],"sub_categories":[],"readme":"# GoCommerce JS\n\nThis is a JS client library for [GoCommerce](https://github.com/netlify/gocommerce) API.\n\n**IMPORTANT:** This requires at least version 1.8.0 of the GoCommerce backend (since v5.0.0).\n\nIt handles orders and payments. Integrates with Stripe for payments and will support international pricing and VAT verification.\n\n## Usage\n\n```js\nimport GoCommerce from \"gocommerce-js\";\n\nconst commerce = new GoCommerce({\n  APIUrl: \"https://commerce.netlify.com\"\n});\n\ncommerce.addToCart({\n\tpath: \"/products/book-1/\",\n\tquantity: 2,\n\tmeta: {\n    // You can add anything in metadata and use it in your checkout ui\n\t\tphoto: \"/images/mugs/netlig-01.png\"\n\t}\n}).then((lineItem) =\u003e console.log(lineItem));\n\nconsole.log(commerce.getCart());\n/*\n{\n  items: [{\n  \ttitle: \"Netlify Mug\",\n  \tsku: \"netlify-mug-01\",\n  \tdescription: \"A mug with a netlify sticker!\",\n  \tprice: {amount: \"49.00\", \"currency\": \"USD\", cents: 4900},\n    tax: {amount: \"0.00\", currency: \"USD\", cents: 0},\n  \tquantity: 2,\n  \tmetadata: {\n  \t\tphoto: \"/images/mugs/netlig-01.png\" // You can add anything in metadata\n  \t}\n  }],\n  subtotal: {amount: \"98.00\", \"currency\": \"USD\", cents: 9800},\n  taxes: {amount: \"0.00\", \"currency\": \"USD\", cents: 0},\n  total: {amount: \"98.00\", \"currency\": \"USD\", cents: 9800}\n}\n*/\n\ncommerce.updateCart(\"netlify-mug-01\", 3); // Set to 0 to remove\n\ncommerce.order({\n  email: \"matt@netlify.com\",\n  shipping_address: {\n    name: \"Matt Biilmann\",\n    company: \"netlify\", // Optional\n    address1: \"610 22nd Street\",\n    city: \"San Francisco\",\n    state: \"CA\",\n    country: \"USA\",\n    zip: \"94107\"\n  }\n  /* You can optionally specify billing_address as well */\n}).then(({cart, order}) =\u003e {\n  return commerce.payment({\n    // Get a token from Stripes button or a custom integration\n    \"provider\": \"stripe\",\n    \"stripe_token\": TOKEN_FROM_STRIPE_CC_FORM,\n    // The commerce API will verify that the amount and order ID match\n    \"amount\": cart.total.cents,\n    \"order_id\": order.id,\n  })\n}).then((transaction) =\u003e {\n  console.log(\"Order confirmed!\")\n});\n\ncommerce.clearCart(); // Will be called automatically after a successful order\n```\n\nYou can change country (for VAT calculations) or currency at any time:\n\n```js\ncommerce.setCountry(\"USA\");\ncommerce.setCurrency(\"USD\");\n```\n\nYou can use GoCommerce JS together with [GoTrue](https://github.com/netlify/gotrue) to let users log in and claim view order history.\n\n```js\ngoTrue.login(email, password).then((user) =\u003e {\n  commerce.setUser(user);\n\n  commerce.order({\n    email: user.email,\n    shipping_address_id: \"some-previously-generated-address\"\n    /* Normal order details */\n  });\n\n  commerce.orderHistory().then((orders) =\u003e {\n    console.log(orders);\n  });\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetlify%2Fgocommerce-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetlify%2Fgocommerce-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetlify%2Fgocommerce-js/lists"}