# async-stripe
[![Build Status](https://github.com/bhch/async-stripe/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/bhch/async-stripe/actions/workflows/ci.yml)
An asynchronous wrapper around Stripe's official python library.
## How it works
async-stripe monkey-patches the stripe library and replaces the synchronous
http request methods with asynchronous methods.
Monkey-patching allows us to avoid a complete rewrite and keep the usage api
similar to the official library.
This **doesn't use threads**, but **actual async coroutines** and
[non-blocking http client][1] to make requests. Hence, the performance is much
better than other wrapper libraries which use threading.
## Install
Install requires Python 3.6 or newer.
```sh
$ pip install async-stripe
```
## Usage
The usage api is similar to Stripe's official library:
```python
from async_stripe import stripe
stripe.api_key = '<stripe-secret-key>'
payment_intent = await stripe.PaymentIntent.create(amount=1000, currency='usd')
print(payment_intent.id)
```
---
**/!\ Note:** Since this library monkey-patches the actual `stripe` library,
you should avoid using the two in the same process.
Once you import `async_stripe`, the official `stripe` library gets patched with
async methods and the original synchronous api won't be available.
---
## Configuration
Please see [`stripe-python`'s README][5] file for configuring logging and other things.
#### Unsupported configurations:
`async-stripe` aims to be a drop-in async replacement for `stripe`. However,
there are a few things which are not yet supported:
- Custom http client: Currently, it's not possible to configure a
custom http client and Tornado's [`AsyncHTTPClient`][1] will be used by default.
- Proxy: Connecting to api via a proxy is not supported yet.
## Development and Testing
When adding new features and monkey-patches, please add relevant tests and
ensure that all the tests also pass.
In most cases, you shouldn't need to write the tests yourself: you can just
copy-paste the tests form the original stripe library and change the synchronous
methods to asynchronous methods.
For testing, first, [install and run the `stripe-mock` api server][2].
Next, install `pytest`, `pytest-mock` and `pytest-asyncio` python packages in
your virtualenv.
Finally, run the tests like this:
```sh
$ pytest tests
# or run a specific test
$ pytest tests/api_resources/test_customer.py
$ pytest tests/api_resources/test_customer.py::TestCustomer
```
## License
A lot of the code (especially tests) are copied with slight modifications from
Stripe's official library. That code is licensed under
[MIT License][3].
Rest of the original code is licensed under [BSD-3-Clause License][4].
[1]: https://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.AsyncHTTPClient
[2]: https://github.com/stripe/stripe-mock
[3]: LICENSE.stripe.txt
[4]: LICENSE.txt
[5]: https://github.com/stripe/stripe-python/blob/master/README.md
Raw data
{
"_id": null,
"home_page": "https://github.com/bhch/async-stripe",
"name": "async-stripe",
"maintainer": "Bharat Chauhan",
"docs_url": null,
"requires_python": ">=3.6,<4.0",
"maintainer_email": "tell.bhch@gmail.com",
"keywords": "stripe,async,asynchronous,wrapper",
"author": "Bharat Chauhan",
"author_email": "tell.bhch@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9d/27/a634ef4b7fb6e28027c69d61c1b8862c0071bab650bbcb96d36294264c27/async_stripe-6.1.0.tar.gz",
"platform": null,
"description": "# async-stripe\n\n[![Build Status](https://github.com/bhch/async-stripe/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/bhch/async-stripe/actions/workflows/ci.yml)\n\nAn asynchronous wrapper around Stripe's official python library. \n\n## How it works\n\nasync-stripe monkey-patches the stripe library and replaces the synchronous \nhttp request methods with asynchronous methods.\n\nMonkey-patching allows us to avoid a complete rewrite and keep the usage api \nsimilar to the official library.\n\nThis **doesn't use threads**, but **actual async coroutines** and \n[non-blocking http client][1] to make requests. Hence, the performance is much\nbetter than other wrapper libraries which use threading.\n\n## Install\n\nInstall requires Python 3.6 or newer.\n\n```sh\n$ pip install async-stripe\n```\n\n## Usage\n\nThe usage api is similar to Stripe's official library:\n\n```python\nfrom async_stripe import stripe\n\nstripe.api_key = '<stripe-secret-key>'\n\npayment_intent = await stripe.PaymentIntent.create(amount=1000, currency='usd')\n\nprint(payment_intent.id)\n```\n\n---\n\n**/!\\ Note:** Since this library monkey-patches the actual `stripe` library, \nyou should avoid using the two in the same process.\n\nOnce you import `async_stripe`, the official `stripe` library gets patched with \nasync methods and the original synchronous api won't be available.\n\n---\n\n## Configuration\n\nPlease see [`stripe-python`'s README][5] file for configuring logging and other things.\n\n#### Unsupported configurations:\n\n`async-stripe` aims to be a drop-in async replacement for `stripe`. However, \nthere are a few things which are not yet supported:\n\n - Custom http client: Currently, it's not possible to configure a \n custom http client and Tornado's [`AsyncHTTPClient`][1] will be used by default.\n - Proxy: Connecting to api via a proxy is not supported yet.\n\n## Development and Testing\n\nWhen adding new features and monkey-patches, please add relevant tests and \nensure that all the tests also pass. \n\nIn most cases, you shouldn't need to write the tests yourself: you can just \ncopy-paste the tests form the original stripe library and change the synchronous \nmethods to asynchronous methods. \n\nFor testing, first, [install and run the `stripe-mock` api server][2].\n\nNext, install `pytest`, `pytest-mock` and `pytest-asyncio` python packages in \nyour virtualenv.\n\nFinally, run the tests like this:\n\n```sh\n$ pytest tests\n\n# or run a specific test\n$ pytest tests/api_resources/test_customer.py\n$ pytest tests/api_resources/test_customer.py::TestCustomer\n```\n\n## License\n\nA lot of the code (especially tests) are copied with slight modifications from \nStripe's official library. That code is licensed under \n[MIT License][3].\n\nRest of the original code is licensed under [BSD-3-Clause License][4].\n\n\n[1]: https://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.AsyncHTTPClient\n[2]: https://github.com/stripe/stripe-mock\n[3]: LICENSE.stripe.txt\n[4]: LICENSE.txt\n[5]: https://github.com/stripe/stripe-python/blob/master/README.md",
"bugtrack_url": null,
"license": "BSD 3-Clause",
"summary": "An asynchronous wrapper around Stripe's official python library.",
"version": "6.1.0",
"project_urls": {
"Homepage": "https://github.com/bhch/async-stripe",
"Repository": "https://github.com/bhch/async-stripe"
},
"split_keywords": [
"stripe",
"async",
"asynchronous",
"wrapper"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1af9ad205b82ce1e7ada4035d979ba703530f90d47e498afdeb37685bbef693e",
"md5": "14f111a0403673dbb416ad6ab187be2c",
"sha256": "3662e05c471565ec36aad7fa3acd4fae34598a6ea00a03f34cfc038d3ad1af19"
},
"downloads": -1,
"filename": "async_stripe-6.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "14f111a0403673dbb416ad6ab187be2c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6,<4.0",
"size": 24038,
"upload_time": "2023-11-18T03:41:34",
"upload_time_iso_8601": "2023-11-18T03:41:34.107097Z",
"url": "https://files.pythonhosted.org/packages/1a/f9/ad205b82ce1e7ada4035d979ba703530f90d47e498afdeb37685bbef693e/async_stripe-6.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9d27a634ef4b7fb6e28027c69d61c1b8862c0071bab650bbcb96d36294264c27",
"md5": "c13d5d1ce1ceed94ca4fcde259e31717",
"sha256": "e141beda440809e1f05638dc0bb4aec31da5eb1ddfd791b215ac42202940a086"
},
"downloads": -1,
"filename": "async_stripe-6.1.0.tar.gz",
"has_sig": false,
"md5_digest": "c13d5d1ce1ceed94ca4fcde259e31717",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6,<4.0",
"size": 14055,
"upload_time": "2023-11-18T03:41:35",
"upload_time_iso_8601": "2023-11-18T03:41:35.896575Z",
"url": "https://files.pythonhosted.org/packages/9d/27/a634ef4b7fb6e28027c69d61c1b8862c0071bab650bbcb96d36294264c27/async_stripe-6.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-18 03:41:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bhch",
"github_project": "async-stripe",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "async-stripe"
}