{"id":21443605,"url":"https://github.com/svileng/stripy","last_synced_at":"2025-08-22T08:13:43.261Z","repository":{"id":57554096,"uuid":"100724391","full_name":"svileng/stripy","owner":"svileng","description":"Micro wrapper for Stripe's REST API.","archived":false,"fork":false,"pushed_at":"2020-08-03T14:06:33.000Z","size":23,"stargazers_count":50,"open_issues_count":0,"forks_count":10,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-14T21:37:16.074Z","etag":null,"topics":["elixir","payments","stripe","stripe-api"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/stripy","language":"Elixir","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/svileng.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":"2017-08-18T15:13:12.000Z","updated_at":"2025-05-26T14:59:05.000Z","dependencies_parsed_at":"2022-09-10T13:40:28.529Z","dependency_job_id":null,"html_url":"https://github.com/svileng/stripy","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/svileng/stripy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svileng%2Fstripy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svileng%2Fstripy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svileng%2Fstripy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svileng%2Fstripy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/svileng","download_url":"https://codeload.github.com/svileng/stripy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svileng%2Fstripy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271606595,"owners_count":24788979,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["elixir","payments","stripe","stripe-api"],"created_at":"2024-11-23T02:12:04.336Z","updated_at":"2025-08-22T08:13:43.230Z","avatar_url":"https://github.com/svileng.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stripy [![hex.pm](https://img.shields.io/hexpm/v/stripy.svg?style=flat-square)](https://hex.pm/packages/stripy) [![hexdocs.pm](https://img.shields.io/badge/docs-latest-green.svg?style=flat-square)](https://hexdocs.pm/stripy)\n\nStripy is a micro wrapper intended to be\nused for sending requests to Stripe's REST API. It is\nmade for developers who prefer to work directly with the\nofficial API and provide their own abstractions on top\nif such are needed.\n\nStripy takes care of setting headers, encoding the data,\nconfiguration settings, etc (the usual boring boilerplate);\nit also makes testing easy by letting you plug your own\nmock server (see Testing section below).\n\nSome basic examples:\n\n```elixir\niex\u003e Stripy.req(:get, \"subscriptions\")\n{:ok, %HTTPoison.Response{...}}\n\niex\u003e Stripy.req(:post, \"customers\", %{\"email\" =\u003e \"a@b.c\", \"metadata[user_id]\" =\u003e 1})\n{:ok, %HTTPoison.Response{...}}\n```\n\nWhere `subscriptions` and `customers` are [REST API resources](https://stripe.com/docs/api).\n\nIf you prefer to work with a higher-level library, check out\n\"stripity_stripe\" or \"stripe_elixir\" on Hex.\n\n## Installation\n\nAdd to your `mix.exs` as usual:\n```elixir\ndef deps do\n  [{:stripy, \"~\u003e 2.0\"}]\nend\n```\nIf you're not using [application inference](https://elixir-lang.org/blog/2017/01/05/elixir-v1-4-0-released/#application-inference), then add `:stripy` to your `applications` list.\n\nThen configure the `stripy` app per environment like so:\n\n```elixir\nconfig :stripy,\n  secret_key: \"sk_test_xxxxxxxxxxxxx\", # required\n  endpoint: \"https://api.stripe.com/v1/\", # optional\n  version: \"2017-06-05\", # optional\n  httpoison: [recv_timeout: 5000, timeout: 8000] # optional\n```\n\nYou may also use environment variables:\n\n``` elixir\nconfig :stripy,\n  secret_key: {:system, \"STRIPE_SECRET_KEY\"},\n  endpoint: {:system, \"STRIPE_ENDPOINT\"},\n  version: {:system, \"STRIPE_VERSION\"}\n```\n\n## Testing\n\nYou can disable actual calls to the Stripe API like so:\n\n```elixir\n# Usually in your test.exs.\nconfig :stripy,\n  testing: true\n```\n\nAll functions that use Stripy would receive response `{:ok, %{status_code: 200, body: \"{}\"}}`.\n\nTo provide your own responses, you need to configure a mock server:\n\n```elixir\nconfig :stripy,\n  testing: true,\n  mock_server: MyApp.StripeMockServer\n```\n\nHere's an example mock server that mocks the `/customer` endpoint and returns a basic\nobject for a customer with id `cus_test`\n\n```elixir\ndefmodule MyApp.StripeMockServer do\n  @behaviour Stripy.MockServer\n\n  @ok_res %{status_code: 200}\n\n  @impl Stripy.MockServer\n  def request(:get, \"customers/cus_test\", %{}) do\n    body = Poison.encode!(%{\"email\" =\u003e \"email@email.com\"})\n    {:ok, Map.put(@ok_res, :body, body)}\n  end\nend\n```\n\nNow let's quickly write a naive function that gets user's billing email:\n\n```elixir\ndef stripe_email(user) do\n  {:ok, res} = Stripy.req(:get, \"customers/#{user.stripe_id}\")\n  res[\"email\"]\nend\n```\n\nWe can test it like so:\n\n```elixir\nfake_user = %{stripe_id: \"cus_test\"}\nassert stripe_email(fake_user) == \"email@email.com\"\n```\n\n## Custom headers\n\nYou can add custom headers to the request by supplying a fourth parameter:\n\n```elixir\nStripy.req(:post, \"charges\", %{amount: 1000}, %{\"Idempotency-Key\" =\u003e \"123456\"})\n```\n\n## License\n\n- Stripy: See LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvileng%2Fstripy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsvileng%2Fstripy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvileng%2Fstripy/lists"}