Skip to main content

Asyncio Stripe API bindings

Project description

https://travis-ci.org/jsbronder/asyncio_stripe.svg?branch=master

Introduction

As the header says, this is a wrapper around the Stripe API using asyncio and aiohttp. Stripe data is modeled using frozen objects built using attrs. Required arguments to API calls are explicitly listed while optional arguments are simply keyword arguments.

Installation

asyncio_stripe be installed via pip or by simply running the included setup.py script:

pip install asyncio_stripe
# OR
python setup.py install --root <destination> --record installed_files.txt

Examples

Create a Client:

import aiohttp
import asyncio_stripe

session = aiohttp.ClientSession()
client = asyncio_stripe.Client(session, 'sk_test_aabbcc')

Authorize then capture $1.00 from a Customer’s default card:

auth = await client.create_charge(
    amount=100,
    currency='usd',
    description='Creating a test charge',
    customer=customer_id,
    capture=False)

charge = await client.capture_charge(charge.id)

Capture funds using a token:

charge = await client.create_charge(
    amount=100,
    currency='usd',
    description='Capturing with a token',
    source='tok_aabbcc')

Create, retrieve and pretty print a customer:

import pprint
import attr

customer = await client.create_customer(
    email='new_user@invalid',
    source='tok_aabbcc')

ret_customer = await client.retrieve_customer(
    customer.id)

customers = await client.list_customers(limit=1)

assert(customer == ret_customer == customers[0])
pprint.pprint(attr.asdict(customer))

Thanks

While this project represents the company in no way, thanks to Kuvée (https://kuvee.com) for generously sponsoring some of the time I’ve spent in development.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
asyncio_stripe-0.2.1.tar.gz (10.0 kB) Copy SHA256 hash SHA256 Source None Feb 11, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page