{"id":20926101,"url":"https://github.com/starhoshi/orderable","last_synced_at":"2025-05-13T17:33:24.772Z","repository":{"id":62449797,"uuid":"118733074","full_name":"starhoshi/Orderable","owner":"starhoshi","description":"An order processing framework works with Cloud Functions for Firebase","archived":false,"fork":false,"pushed_at":"2018-02-27T06:25:48.000Z","size":24927,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-17T00:24:53.736Z","etag":null,"topics":["cloud-function-for-firebase","cloud-functions","cocoapods","firebase","firestore","ios","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/starhoshi.png","metadata":{"files":{"readme":"README.ja.md","changelog":null,"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":"2018-01-24T08:03:25.000Z","updated_at":"2019-09-25T01:14:57.000Z","dependencies_parsed_at":"2022-11-01T23:31:53.659Z","dependency_job_id":null,"html_url":"https://github.com/starhoshi/Orderable","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starhoshi%2FOrderable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starhoshi%2FOrderable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starhoshi%2FOrderable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starhoshi%2FOrderable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/starhoshi","download_url":"https://codeload.github.com/starhoshi/Orderable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225248914,"owners_count":17444350,"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":["cloud-function-for-firebase","cloud-functions","cocoapods","firebase","firestore","ios","swift"],"created_at":"2024-11-18T20:36:48.221Z","updated_at":"2024-11-18T20:36:48.830Z","avatar_url":"https://github.com/starhoshi.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/starhoshi/orderable.ts/master/docs/logo.png\" width='180px' /\u003e\n\u003c/p\u003e\n\n# Orderable\n\n\u003cb\u003e⚠️ Orderable は現在開発中です ⚠️\u003c/b\u003e\n\nOrderable は Cloud Functions for Firebase と連携し、決済が簡単に実行できるライブラリです。  \nEC に必要な在庫チェック、購入処理、購入後の履歴作成などを実行できます。\n\nOrderable の Protocol を実装し、[orderable.ts](https://github.com/starhoshi/Orderable.ts) を Cloud Functions for Firebase に deploy する必要があります。\n\n\n## Installation\n\nPodfile:\n\n```\npod 'Orderable'\n```\n\n## Usage\n\n### 1. Protocol\n\n[Orderable/Model\\.swift](https://github.com/starhoshi/Orderable/blob/master/SampleModel/Model.swift) を参考に、あなたのプロジェクトで必要な Model の定義をしてください。\n\n* User\n  * 購入者\n* Shop\n  * 販売者\n* Product\n  * 商品の概念。\n* SKU\n  * 商品の実態。在庫や値段などを持つ。\n* Order\n  * 注文。ユーザが支払う金額や支払い方法などを持つ。\n* OrderShop\n  * Shop ごとの注文情報。\n* OrderSKU\n  * 注文された商品。購入数などを持つ。\n\n### 2. Deploy\n\n[orderable.ts](https://github.com/starhoshi/Orderable.ts) を Cloud Functions に Deploy してください。\n\n### 3. Pay an order\n\nSample code is [here](https://github.com/starhoshi/Orderable/blob/master/Demo/ViewController.swift). `order.paymentStatus = OrderPaymentStatus.paymentRequested` にして update すると Cloud Functions が動き出します。\n\n```swift\nlet order = Order()\norder.amount = 1000\nlet stripe = Stripe()\nstripe.customerID = \"new_cus\"\nstripe.cardID = \"new_card\"\norder.stripe = stripe\norder.paymentStatus = OrderPaymentStatus.created\norder.save()\n\n...\n\n// functions trigger\norder.paymentStatus = OrderPaymentStatus.paymentRequested\norder.update() // start cloud functions\n```\n\n### 4. Result\n\nCloud Functions が成功すると、 `order.neoTask.status === 1` がセットされます。 order を observe して処理が完了するのを待ってください。\n\n```swift\nimport Pring\n\nvar disposer: Disposer\u003cOrder\u003e?\nself?.disposer = Order.listen(order.id) { order, error in\n  if order.neoTask.status === 1, order.stripeChargeID != nil {\n    // stripe charge completed.\n  }\n}\n```\n\n## Error\n\n詳細なエラーは [starhoshi/orderable\\.ts#Error](https://github.com/starhoshi/orderable.ts#neotask) に記載してありますので、それぞれのエラーに対しクライアント側で適切にハンドリングしてください。\n\nクライアント側が意識するべきエラーは以下の2つです。\n\n* invalid\n  * クライアント側で修正が必要なエラー\n* fatal\n  * 開発者が手動で対応しなければならないもの\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarhoshi%2Forderable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarhoshi%2Forderable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarhoshi%2Forderable/lists"}