{"id":21231383,"url":"https://github.com/1amageek/firestore-commerce","last_synced_at":"2025-07-10T16:33:38.984Z","repository":{"id":57093449,"uuid":"221162906","full_name":"1amageek/firestore-commerce","owner":"1amageek","description":"firestore-commerce is a framework that links Firestore and Stripe. By manipulating the Ballcap data model, you can sell immediately.","archived":false,"fork":false,"pushed_at":"2020-02-15T04:34:58.000Z","size":1399,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-20T06:14:28.639Z","etag":null,"topics":["cloudfirestore","cloudfunctions","firebase","payment","stripe"],"latest_commit_sha":null,"homepage":"","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/1amageek.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}},"created_at":"2019-11-12T08:04:20.000Z","updated_at":"2022-03-17T16:18:46.000Z","dependencies_parsed_at":"2022-08-22T21:40:09.760Z","dependency_job_id":null,"html_url":"https://github.com/1amageek/firestore-commerce","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1amageek%2Ffirestore-commerce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1amageek%2Ffirestore-commerce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1amageek%2Ffirestore-commerce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1amageek%2Ffirestore-commerce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1amageek","download_url":"https://codeload.github.com/1amageek/firestore-commerce/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225648988,"owners_count":17502183,"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":["cloudfirestore","cloudfunctions","firebase","payment","stripe"],"created_at":"2024-11-20T23:46:39.937Z","updated_at":"2024-11-20T23:46:40.493Z","avatar_url":"https://github.com/1amageek.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# firestore-commerce\n\n`firestore-commerce` is a framework that links Firestore and Stripe.\nBy manipulating the [Ballcap](https://github.com/1amageek/ballcap.ts) data model, you can sell immediately.\n\n## Usage\n\n### Set Stripe API Key\n\n```\nfirebase functions:config:set stripe.api_key=\"YOUR_STRIPE_API_KEY\"\n```\n\n### Quick start\n\n#### setup\n\n```\nnpm add @1amageek/firestore-commerce\n```\n\nAdd the following to CloudFunctions index.ts:\n\n```typescript:index.ts\nimport * as Commerce from '@1amageek/firestore-commerce'\nexport const commerce = { ...Commerce }\n```\n\nTo start selling, first create a `Product` and create a`SKU` or `Plan` in its SubCollection.\n`SKU` is an object for selling __Good__, and `Plan` is an object for __Subscription__.\n\nWhen you save `Product`, `SKU`, `Plan`, an object with the same ID is automatically created.\nIf an error occurs in Stripe, the data in Firestore is updated with `isAvailable = false`.\n\n#### Create Product\n\nWhen you save `Product`, a Stripe Product with a common ID is automatically created.\n\n```typescript\nconst user: User = new User(\"USER_ID\")\nconst product: Product = new Product(user.products.collectionReference.doc())\nproduct.type = \"service\"\nproduct.name = \"test-product\"\n```\n\n#### Create SKU\n\n```typescript\nconst sku: SKU = new SKU(product.SKUs.collectionReference.doc())\nsku.inventory = { type: StockType.finite, quantity: 1 }\nsku.currency = Currency.JPY\nsku.amount = 1000\n```\n\n#### Create Plan\n\n```typescript\nconst plan: Plan = new Plan(product.plans.collectionReference.doc())\nplan.interval = Interval.month\nplan.intervalCount = 1\nplan.currency = Currency.JPY\nplan.amount = 1000\nplan.isAvailable = true\n```\n\n## DB scheme\n\n![DB scheme](https://github.com/1amageek/firestore-commerce/blob/master/DB-scheme.png)\n\n## Test\n\nCreate `/test/config.ts` and `secret.json` \n\n__/test/config.ts__\n```\nexport default {\n\tstripe: {\n\t\tapi_key: \"\",\n\t\tcustomer_id: \"\",\n\t\tcord_id: \"\"\n\t}\n};\n```\n\n__/secret.json__\n```\n{\n\t\"type\": \"service_account\",\n\t\"project_id\": \"\",\n\t\"private_key_id\": \"\",\n\t\"private_key\": \"\",\n\t\"client_email\": \"\",\n\t\"client_id\": \"\",\n\t\"auth_uri\": \"\",\n\t\"token_uri\": \"\",\n\t\"auth_provider_x509_cert_url\": \"\",\n\t\"client_x509_cert_url\": \"\"\n}\n```\n\nRun tests\n```\nnpm run test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1amageek%2Ffirestore-commerce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1amageek%2Ffirestore-commerce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1amageek%2Ffirestore-commerce/lists"}