{"id":13509630,"url":"https://github.com/beam-community/stripity-stripe","last_synced_at":"2026-05-01T04:01:05.572Z","repository":{"id":37035108,"uuid":"43581088","full_name":"beam-community/stripity-stripe","owner":"beam-community","description":"An Elixir Library for Stripe","archived":false,"fork":false,"pushed_at":"2026-05-01T02:06:07.000Z","size":5097,"stargazers_count":1066,"open_issues_count":3,"forks_count":376,"subscribers_count":30,"default_branch":"main","last_synced_at":"2026-05-01T02:15:53.580Z","etag":null,"topics":["elixir","hex","hex-package","stripe","stripe-api"],"latest_commit_sha":null,"homepage":"","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/beam-community.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-10-02T23:32:01.000Z","updated_at":"2026-05-01T02:05:55.000Z","dependencies_parsed_at":"2024-01-26T05:07:20.059Z","dependency_job_id":"18f3c69d-2934-4f72-970c-b180d7c0b006","html_url":"https://github.com/beam-community/stripity-stripe","commit_stats":null,"previous_names":["code-corps/stripity_stripe","robconery/stripity-stripe"],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/beam-community/stripity-stripe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beam-community%2Fstripity-stripe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beam-community%2Fstripity-stripe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beam-community%2Fstripity-stripe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beam-community%2Fstripity-stripe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beam-community","download_url":"https://codeload.github.com/beam-community/stripity-stripe/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beam-community%2Fstripity-stripe/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32484353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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","hex","hex-package","stripe","stripe-api"],"created_at":"2024-08-01T02:01:10.645Z","updated_at":"2026-05-01T04:01:05.562Z","avatar_url":"https://github.com/beam-community.png","language":"Elixir","funding_links":[],"categories":["Third Party APIs","Elixir"],"sub_categories":[],"readme":"# Stripe for Elixir\n\nAn Elixir library for working with [Stripe](https://stripe.com/).\n\n[![Hex.pm](https://img.shields.io/hexpm/v/stripity_stripe.svg?maxAge=2592000)](https://hex.pm/packages/stripity_stripe) [![Hex.pm](https://img.shields.io/hexpm/dt/stripity_stripe.svg?maxAge=2592000)](https://hex.pm/packages/stripity_stripe)\n\n## 2.x.x status\n\n[![Hex Docs](https://img.shields.io/badge/hex-docs-9768d1.svg)](https://hexdocs.pm/stripity_stripe) [![Inline docs](https://inch-ci.org/github/beam-community/stripity_stripe.svg?branch=main)](https://inch-ci.org/github/beam-community/stripity_stripe?branch=main) [![Coverage Status](https://coveralls.io/repos/github/beam-community/stripity_stripe/badge.svg?branch=main)](https://coveralls.io/github/beam-community/stripity_stripe?branch=main)\n\n# Which version should I use?\n\nBelow is a list of which Stripe API version recent releases of Stripe Elixir. It only indicates the API version being called, not necessarily its compatibility. See the [Stripe API Upgrades page](https://stripe.com/docs/upgrades) for more details.\n\nStarting with stripity_stripe version 2.5.0, you can specify the Stripe API Version to use for a specific request by including the `:api_version` option. Note that while this will use a specific Stripe API Version to make the request, the library will still expect a response matching its corresponding default Stripe API Version. See the [Shared Options documentation](https://hexdocs.pm/stripity_stripe/2.17.2/Stripe.html#module-shared-options) for more details.\n\n| `:stripity_stripe` | Stripe API Version |\n| ------------------ | ------------------ |\n| `2.0.x`            | `2018-02-28`       |\n| `2.1.0 - 2.2.0`    | `2018-05-21`       |\n| `2.2.2`            | `2018-08-23`       |\n| `2.2.3 - 2.3.0`    | `2018-11-08`       |\n| `2.4.0 - 2.7.0`    | `2019-05-16`       |\n| `master`           | `2019-10-17`       |\n\n# Documentation\n\n- [Latest HexDocs](https://hexdocs.pm/stripity_stripe/)\n\n## Installation\n\nInstall the dependency by version:\n\n```elixir\n{:stripity_stripe, \"~\u003e 2.0\"}\n```\n\nOr by commit reference:\n\n```elixir\n{:stripity_stripe, git: \"https://github.com/beam-community/stripity_stripe\", ref: \"017d7ecdb5aeadccc03986c02396791079178ba2\"}\n```\n\nNext, add to your applications:\n\n_Not necessary if using elixir \u003e= 1.4_\n\n```elixir\ndefp application do\n  [applications: [:stripity_stripe]]\nend\n```\n\n## Configuration\n\nTo make API calls, it is necessary to configure your Stripe secret key.\n\n```elixir\nimport Config\n\nconfig :stripity_stripe, api_key: System.get_env(\"STRIPE_SECRET\")\n# OR\nconfig :stripity_stripe, api_key: \"YOUR SECRET KEY\"\n```\n\nIt's possible to use a function or a tuple to resolve the secret:\n\n```elixir\nconfig :stripity_stripe, api_key: {MyApp.Secrets, :stripe_secret, []}\n# OR\nconfig :stripity_stripe, api_key: fn -\u003e System.get_env(\"STRIPE_SECRET\") end\n```\n\nMoreover, if you are using Poison instead of Jason, you can configure the library to use Poison like so:\n\n```elixir\nconfig :stripity_stripe, json_library: Poison\n```\n\n### Timeout\n\nTo set timeouts, pass opts for the http client. The default one is Hackney.\n\n```elixir\nconfig :stripity_stripe, hackney_opts: [{:connect_timeout, 1000}, {:recv_timeout, 5000}]\n```\n\n### Request Retries\n\nTo set retries, you can pass the number of attempts and range of backoff (time between attempting the request again) in milliseconds.\n\n```elixir\nconfig :stripity_stripe, :retries, [max_attempts: 3, base_backoff: 500, max_backoff: 2_000]\n```\n\n## Examples\n\nStripe supports a token based, and intent based approach for processing payments. The token based approach is simpler, but it is not supported in Europe. The intents API is the way forward, and should be used for new development.\n\n### Intents\n\nCreate a new `SetupIntent` object in [Stripe](https://stripe.com/docs/api/setup_intents). The created intent ID will be passed to the frontend to use with Stripe elements so the end user can enter their payment details. SetupIntents are ephemeral. It is best to create a new one each time the user reaches your payment page.\n\n```elixir\n{:ok, setup_intent} = Stripe.SetupIntent.create(%{})\n\n# Return the ID to your frontend, and pass it to the confirmCardSetup method from Stripe elements\n{:ok, setup_intent.id}\n```\n\nOn the frontend, use the setup intent ID you created in conjunction with Stripe elements `confirmCardSetup` method.\n\n```javascript\nstripe.confirmCardSetup(setupIntentId, {\n  payment_method: {\n    ...\n  }\n})\n.then(result =\u003e {\n  const setupIntentId = result.setupIntent.id\n  const paymentMethodId = result.setupIntent.payment_method\n\n  // send the paymentMethodId and optionally (if needed) the setupIntentId\n})\n```\n\nWith the new payment method ID, you can associate the payment method with a Stripe customer.\n\n\nGet an existing customer.\n\n```elixir\n{:ok, stripe_customer} = Stripe.Customer.retrieve(stripe_customer_id)\n```\n\nOr create a new one.\n\n```elixir\nnew_customer = %{\n  email: email,\n}\n\n{:ok, stripe_customer} = Stripe.Customer.create(new_customer)\n```\n\nAttach the payment method to the customer.\n\n```elixir\n{:ok, _result} = Stripe.PaymentMethod.attach(%{customer: stripe_customer.id, payment_method: payment_method_id})\n```\n\nNow you can charge the customer using a `PaymentIntent` from [Stripe](https://stripe.com/docs/api/payment_intents). Since we used a setup intent initially, the payment intent will be authorized to make payments off session, for example to charge for a recurring subscription.\n\n```elixir\n{:ok, charge} = Stripe.PaymentIntent.create(%{\n  amount: cents_int,\n  currency: \"USD\",\n  customer: stripe_customer.id,\n  payment_method: payment_method_id,\n  off_session: true,\n  confirm: true\n})\n```\n\n## Note: Object Expansion\n\nSome Stripe API endpoints support returning related objects via the object expansion query parameter. To take advantage of this feature, stripity_stripe accepts\na list of strings to be passed into `opts` under the `:expand` key indicating which objects should be expanded.\n\nFor example, calling `Charge.retrieve(\"ch_123\")` would return a charge without expanding any objects.\n\n```elixir\n%Charge{\n  id: \"ch_123\",\n  balance_transaction: \"txn_123\",\n  ...\n}\n```\n\nHowever if we now include an expansion on the `balance_transaction` field using\n\n```elixir\nCharge.retrieve(\"ch_123\", expand: [\"balance_transaction\"])\n```\n\nWe will get the full object back as well.\n\n```elixir\n%Charge{\n  id: \"ch_123\",\n  balance_transaction: %BalanceTransaction{\n    id: \"txn_123\",\n    fee: 125,\n    ...\n  },\n  ...\n}\n```\n\nFor details on which objects can be expanded check out the [stripe object expansion](https://stripe.com/docs/api#expanding_objects) docs.\n\n# Testing\n\n## Starting stripe-mock\n\nTo run the tests you'll need to install [`stripe-mock`](https://github.com/stripe/stripe-mock).\nIt is a mock HTTP server that responds like the real Stripe API. It's powered by\nthe [Stripe OpenAPI specification](https://github.com/stripe/openapi), which is\ngenerated from within Stripe's API.\n\nThe [stripe-mock instructions](https://github.com/stripe/stripe-mock#usage)\nhave more details, but if you have docker installed already you can quickly\nand easily start an instance to test against:\n\n```sh\ndocker run --rm -it -p 12111-12112:12111-12112 stripe/stripe-mock:latest\n```\n\n## Running the tests\n\nBy default, `mix test` will start `stripe-mock` by finding and invoking the\n`stripe-mock` executable.  If you would prefer to start it yourself, do so\nand add an env var `SKIP_STRIPE_MOCK_RUN` to skip starting stripe-mock.  Any\nvalue will do.  Example:\n\n```sh\nSKIP_STRIPE_MOCK_RUN=1 mix test\n```\n\nTo configure your test environment to use the local stripe-mock server, you may\nneed to set the `api_base_url` field in your config:\n\n```\nconfig :stripity_stripe,\n  api_key: \"sk_test_thisisaboguskey\",\n  api_base_url: \"http://localhost:12111\"\n```\n\n# Documentation for 1.x.x\n\n\u003cdetails\u003e\u003csummary\u003eClick to expand\u003c/summary\u003e\n\u003cp\u003e\n\n## Stripe API\n\nWorks with API version 2015-10-16\n\n## Installation\n\nInstall the dependency:\n\n```elixir\n{:stripity_stripe, \"~\u003e 1.6\"}\n```\n\nNext, add to your applications:\n\n```elixir\ndefp application do\n  [applications: [:stripity_stripe]]\nend\n```\n\n## Configuration\n\nTo make API calls, it is necessary to configure your Stripe secret key (and optional platform client id if you are using Stripe Connect):\n\n```elixir\nimport Config\n\nconfig :stripity_stripe, secret_key: \"YOUR SECRET KEY\"\nconfig :stripity_stripe, platform_client_id: \"YOUR CONNECT PLATFORM CLIENT ID\"\n```\n\n## Testing\n\nIf you start contributing and you want to run mix test, first you need to export STRIPE_SECRET_KEY environment variable in the same shell as the one you will be running mix test in. All tests have the @tag disabled: false and the test runner is configured to ignore disabled: true. This helps to turn tests on/off when working in them. Most of the tests depends on the order of execution (test random seed = 0) to minimize runtime. I've tried having each tests isolated but this made it take ~10 times longer.\n\n```\nexport STRIPE_SECRET_KEY=\"yourkey\"\nmix test\n```\n\n## The API\n\nI've tried to make the API somewhat comprehensive and intuitive. If you'd like to see things in detail be sure to have a look at the tests - they show (generally) the way the API goes together.\n\nIn general, if Stripe requires some information for a given API call, you'll find that as part of the arity of the given function. For instance if you want to delete a Customer, you'll find that you _must_ pass the id along:\n\n```elixir\n{:ok, result} = Stripe.Customers.delete \"some_id\"\n```\n\nFor optional arguments, you can send in a Keyword list that will get translated to parameters. So if you want to update a Subscription, for instance, you must send in the `customer_id` and `subscription_id` with the list of changes:\n\n```elixir\n# Change customer to the Premium subscription\n{:ok, result} = Stripe.Customers.change_subscription \"customer_id\", \"sub_id\", [plan: \"premium\"]\n```\n\nMetadata (metadata:) key is supported on most object type and allow the storage of extra information on the stripe platform. See [test](https://github.com/code-corps/stripity-stripe/blob/master/test/stripe/customer_test.exs) for an example.\n\nThat's the rule of thumb with this library. If there are any errors with your call, they will bubble up to you in the `{:error, message}` match.\n\n```elixir\n# Example of paging through events\n{:ok, events} = Stripe.Events.list(key, \"\", 100) # second arg is a marker for paging\n\ncase events[:has_more] do\n  true -\u003e\n    # retrieve marker\n    last = List.last( events[:data] )\n    case Stripe.Events.list key, last[\"id\"], 100 do\n      {:ok, events} -\u003e events[:data]\n      # ...\n    end\n  false -\u003e events[:data]\nend\n```\n\n# Connect\n\nStripe Connect allows you to provide your customers with an easy onboarding to their own Stripe account. This is useful when you run an e-commerce as a service platform. Each merchant can transact using their own account using your platform. Then your platform uses Stripe's API with their own API key obtained in the onboarding process.\n\nFirst, you need to register your platform on Stripe Connect to obtain a `client_id`. In your account settings, there's a \"Connect\" tab, select it. Then fill the information to activate your connect platform settings. The select he `client_id` (notice there's one for dev and one for prod), stash this `client_id` in the config file under\n\n```elixir\nconfig :stripity_stripe, platform_client_id: \"ac_???\"\n```\n\nor in an env var named `STRIPE_PLATFORM_CLIENT_ID`.\n\nThen you send your users to sign up for the stripe account using a link.\n\nHere's an example of a button to start the workflow:\n\u003ca href=\"https://connect.stripe.com/oauth/authorize?response_type=code\u0026client_id=ca_32D88BD1qLklliziD7gYQvctJIhWBSQ7\u0026scope=read_write\"\u003eConnect with Stripe\u003c/a\u003e\n\nYou can generate this URL using:\n\n```elixir\nurl = Stripe.Connect.generate_button_url csrf_token\n```\n\nWhen the user gets back to your platform, the following url (`redirect_uri` form item on your \"Connect\" settings) will be used:\n\n```\n//yoursvr/your_endpoint?scope=read_write\u0026code=AUTHORIZATION_CODE\n```\n\nor\n\n```\n//yoursvr/your_endpoint?error=access_denied\u0026error_description=The%20user%20denied%20your%20request\n```\n\nUsing the code request parameter, you make the following call:\n\n```elixir\n{:ok, resp} -\u003e Stripe.Connect.oauth_token_callback code\nresp[:access_token]\n```\n\n`resp` will look like this:\n\n```elixir\n%{\n  token_type: \"bearer\",\n  stripe_publishable_key: PUBLISHABLE_KEY,\n  scope: \"read_write\",\n  livemode: false,\n  stripe_user_id: USER_ID,\n  refresh_token: REFRESH_TOKEN,\n  access_token: ACCESS_TOKEN\n}\n```\n\nYou can then pass the `access_token` to the other API modules to act on their behalf.\n\nSee a [demo](https://github.com/nicrioux/stripity-connect-phoenix) using the Phoenix framework with the bare minimum to get this working.\n\n## Testing Connect\n\nThe tests are currently manual as they require a unique OAuth authorization code per test. You need to obtain this code manually using the stripe connect workflow (that your user would go through using the above url).\n\nFirst, log in your account. Then go to the following url: https://dashboard.stripe.com/account/applications/settings\n\nCreate a connect standalone account. Grab your development `client_id`. Put it in your config file. Enter a redirect url to your endpoint. Capture the \"code\" request parameter. Pass it to `Stripe.Connect.oauth_token_callback` or `Stripe.Connect.get_token`.\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n# Contributing\n\nFeedback, feature requests, and fixes are welcomed and encouraged. Please make appropriate use of [Issues](https://github.com/code-corps/stripity-stripe/issues) and [Pull Requests](https://github.com/code-corps/stripity-stripe/pulls). All code should have accompanying tests.\n\n# License\n\nPlease see [LICENSE.md](./LICENSE.md) for licensing details.\n\n# History\n\n## Statement from original author\n\nWhy another Stripe Library? Currently there are a number of them in the Elixir world that are, well just not \"done\" yet. I started to fork/help but soon it became clear to me that what I wanted was\n\n- an existing/better test story\n- an API that didn't just mimic a REST interaction\n- a library that was up to date with Elixir \u003e 1.0 and would, you know, actually _compile_.\n- function calls that returned a standard `{:ok, result}` or `{:error, message}` response\n\nAs I began digging things up with these other libraries it became rather apparent that I was not only tweaking the API, but also ripping out a lot of the existing code... and that usually means I should probably do my own thing. So I did.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeam-community%2Fstripity-stripe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeam-community%2Fstripity-stripe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeam-community%2Fstripity-stripe/lists"}