{"id":24842955,"url":"https://github.com/didomarchet/craft-commerce-headless-sdk","last_synced_at":"2025-04-12T12:34:21.774Z","repository":{"id":274646594,"uuid":"923095325","full_name":"DidoMarchet/craft-commerce-headless-sdk","owner":"DidoMarchet","description":"Craft Commerce Headless SDK provides tools to integrate Craft Commerce in headless environments, focusing on building API-driven checkout experiences.","archived":false,"fork":false,"pushed_at":"2025-04-01T15:51:44.000Z","size":145,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T07:11:29.809Z","etag":null,"topics":["commerce","craftcms","headless","sdk"],"latest_commit_sha":null,"homepage":"https://craft-commerce-headless-sdk.netlify.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DidoMarchet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-27T16:29:43.000Z","updated_at":"2025-04-01T15:51:48.000Z","dependencies_parsed_at":"2025-02-13T17:37:00.343Z","dependency_job_id":null,"html_url":"https://github.com/DidoMarchet/craft-commerce-headless-sdk","commit_stats":null,"previous_names":["didomarchet/craft-commerce-headless-sdk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DidoMarchet%2Fcraft-commerce-headless-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DidoMarchet%2Fcraft-commerce-headless-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DidoMarchet%2Fcraft-commerce-headless-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DidoMarchet%2Fcraft-commerce-headless-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DidoMarchet","download_url":"https://codeload.github.com/DidoMarchet/craft-commerce-headless-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248566910,"owners_count":21125748,"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":["commerce","craftcms","headless","sdk"],"created_at":"2025-01-31T08:35:02.369Z","updated_at":"2025-04-12T12:34:21.755Z","avatar_url":"https://github.com/DidoMarchet.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Craft Commerce Headless SDK Documentation Index\n\nThis SDK is designed to simplify integration with **Craft Commerce**, offering specialized modules for users, carts, payments, subscriptions, and more. Whether you're building a headless e-commerce application or enhancing an existing Craft Commerce setup, this guide will help you navigate and implement the SDK effectively.\n\n\u003e **Note:** Craft Commerce version 4 or higher is required for compatibility with this SDK.\n\n---\n\n## Table of Contents\n\n1. [Demo and Local Testing](#demo-and-local-testing)\n2. [Craft CMS Configuration Guide](#craft-cms-configuration-guide)\n3. [Package Installation](#package-installation)\n4. [Client Module](#client-module)\n5. [Users Module](#users-module)\n6. [Cart Module](#cart-module)\n7. [Payment Sources Module](#payment-sources-module)\n8. [Payment Module](#payment-module)\n9. [Subscriptions Module](#subscriptions-module)\n10. [Suggestions for Craft CMS Improvements](#suggestions-for-craft-cms-improvements)\n\n---\n\n## Demo and Local Testing\n\nYou can see a working demo of the SDK at this link:  \n[https://craft-commerce-headless-sdk.netlify.app/](https://craft-commerce-headless-sdk.netlify.app/)\n\nIf you want to test the SDK locally, follow these steps:\n1. Clone the repository.\n2. Navigate to the `demo` folder.\n3. Run the following commands:\n   ```bash\n   npm install\n   npm run dev\n   ```\n   This will start the demo locally. Before using the SDK, ensure that Craft CMS and Craft Commerce are correctly configured for headless usage. Follow the [Craft CMS Configuration Guide](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CONFIGURATION.md) for essential setup steps, including CORS configuration and cookie settings.\n\n---\n\n## Craft CMS Configuration Guide\n\nThis section provides details on configuring Craft CMS for headless usage, including CORS setup and other necessary settings.\n\n- [Configuration](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CONFIGURATION.md)\n\n---\n\n## Package Installation\n\nTo use the Craft Commerce Headless SDK in your project, you can install it using your preferred package manager. Here are the commands for different managers:\n\n### npm\n```bash\nnpm install craft-commerce-headless-sdk\n```\n\n### pnpm\n```bash\npnpm add craft-commerce-headless-sdk\n```\n\n### yarn\n```bash\nyarn add craft-commerce-headless-sdk\n```\n\nAfter installation, you can import the SDK in your code:\n\n```javascript\nimport { craftCommerceHeadlessSdk } from 'craft-commerce-headless-sdk';\n```\n\n---\n\n## Client Module\n\nThe base module for API communication, handling HTTP requests with `post` and `get` methods.\n\n- [Installation](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CLIENT.md#installation)\n- [Methods](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CLIENT.md#methods)\n  - [post](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CLIENT.md#post)\n  - [get](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CLIENT.md#get)\n- [Examples](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CLIENT.md#examples)\n\n---\n\n## Users Module\n\nThis module handles user account creation, profile management, and address handling. It simplifies operations like login, password resets, and managing user-related data, all essential for e-commerce platforms.\n\n- [Installation](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/USERS.md#installation)\n- [Methods](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/USERS.md#methods)\n  - [loginUser](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/USERS.md#loginuser)\n  - [saveUser](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/USERS.md#saveuser)\n  - [uploadUserPhoto](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/USERS.md#uploaduserphoto)\n  - [sendPasswordResetEmail](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/USERS.md#sendpasswordresetemail)\n  - [setPassword](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/USERS.md#setpassword)\n  - [saveAddress](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/USERS.md#saveaddress)\n  - [deleteAddress](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/USERS.md#deleteaddress)\n  - [getSessionInfo](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/USERS.md#getsessioninfo)\n- [Examples](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/USERS.md#examples)\n\n---\n\n## Cart Module\n\nManage shopping cart actions, including retrieval, updates, and checkout operations. This module supports typical e-commerce workflows in Craft Commerce.\n\n- [Installation](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CART.md#installation)\n- [Methods](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CART.md#methods)\n  - [completeCart](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CART.md#completecart)\n  - [getCart](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CART.md#getcart)\n  - [loadCart](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CART.md#loadcart)\n  - [forgetCart](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CART.md#forgetcart)\n  - [updateCart](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CART.md#updatecart)\n- [Examples](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/CART.md#examples)\n\n---\n\n## Payment Sources Module\n\nCreate, manage, and assign payment methods to user accounts. This module supports common payment operations like adding or removing payment sources, tailored for Craft Commerce.\n\n- [Installation](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/PAYMENT_SOURCES.md#installation)\n- [Methods](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/PAYMENT_SOURCES.md#methods)\n  - [addPaymentSource](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/PAYMENT_SOURCES.md#addpaymentsource)\n  - [setPrimaryPaymentSource](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/PAYMENT_SOURCES.md#setprimarypaymentsource)\n  - [deletePaymentSource](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/PAYMENT_SOURCES.md#deletepaymentsource)\n- [Examples](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/PAYMENT_SOURCES.md#examples)\n\n---\n\n## Payment Module\n\nHandle payments, including support for 3D Secure and other gateway integrations. This module streamlines the process of initiating and completing payments in Craft Commerce.\n\n- [Installation](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/PAYMENT.md#installation)\n- [Methods](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/PAYMENT.md#methods)\n  - [pay](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/PAYMENT.md#pay)\n  - [completePayment](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/PAYMENT.md#completepayment)\n- [Examples](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/PAYMENT.md#examples)\n\n---\n\n## Subscriptions Module\n\nManage subscriptions, including plan creation, cancellations, switching, and reactivation. This module simplifies recurring payment setups in Craft Commerce.\n\n- [Installation](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/SUBSCRIPTIONS.md#installation)\n- [Methods](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/SUBSCRIPTIONS.md#methods)\n  - [subscribe](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/SUBSCRIPTIONS.md#subscribe)\n  - [cancel](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/SUBSCRIPTIONS.md#cancel)\n  - [switchPlan](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/SUBSCRIPTIONS.md#switchplan)\n  - [reactivate](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/SUBSCRIPTIONS.md#reactivate)\n- [Examples](https://github.com/DidoMarchet/craft-commerce-headless-sdk/blob/main/doc/SUBSCRIPTIONS.md#examples)\n\n---\n\n## Suggestions for Craft CMS Improvements\n\nWhile this SDK provides extensive functionality, there are a few additional features that would greatly enhance the integration experience if included directly in Craft CMS or Craft Commerce:\n\n- **Include Available Payment Gateways in the Cart**: Similar to how shipping methods are returned, having payment gateways listed directly in the cart data would streamline the checkout process and improve integration ease.\n\n- **Return User-Associated Addresses**: Adding a feature to retrieve addresses associated with a user, similar to the `actions/users/session-info` method for session data, would simplify managing user information in headless implementations.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidomarchet%2Fcraft-commerce-headless-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdidomarchet%2Fcraft-commerce-headless-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidomarchet%2Fcraft-commerce-headless-sdk/lists"}