Skip to content

Commit

Permalink
Run code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ob-stripe committed Jan 16, 2019
1 parent 8b53bf9 commit ba6bb75
Show file tree
Hide file tree
Showing 177 changed files with 3,103 additions and 3,477 deletions.
10 changes: 5 additions & 5 deletions examples/charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import stripe


stripe.api_key = os.environ.get('STRIPE_SECRET_KEY')
stripe.api_key = os.environ.get("STRIPE_SECRET_KEY")

print("Attempting charge...")

resp = stripe.Charge.create(
amount=200,
currency='usd',
card='tok_visa',
description='customer@gmail.com'
currency="usd",
card="tok_visa",
description="customer@gmail.com",
)

print('Success: %r' % (resp))
print("Success: %r" % (resp))
40 changes: 22 additions & 18 deletions examples/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,55 @@
from flask import Flask, request, redirect


stripe.api_key = os.environ.get('STRIPE_SECRET_KEY')
stripe.client_id = os.environ.get('STRIPE_CLIENT_ID')
stripe.api_key = os.environ.get("STRIPE_SECRET_KEY")
stripe.client_id = os.environ.get("STRIPE_CLIENT_ID")

app = Flask(__name__)


@app.route('/')
@app.route("/")
def index():
return '<a href="/authorize">Connect with Stripe</a>'


@app.route('/authorize')
@app.route("/authorize")
def authorize():
url = stripe.OAuth.authorize_url(scope='read_only')
url = stripe.OAuth.authorize_url(scope="read_only")
return redirect(url)


@app.route('/oauth/callback')
@app.route("/oauth/callback")
def callback():
code = request.args.get('code')
code = request.args.get("code")
try:
resp = stripe.OAuth.token(grant_type='authorization_code', code=code)
resp = stripe.OAuth.token(grant_type="authorization_code", code=code)
except stripe.oauth_error.OAuthError as e:
return 'Error: ' + str(e)
return "Error: " + str(e)

return '''
return """
<p>Success! Account <code>{stripe_user_id}</code> is connected.</p>
<p>Click <a href="/deauthorize?stripe_user_id={stripe_user_id}">here</a> to
disconnect the account.</p>
'''.format(stripe_user_id=resp['stripe_user_id'])
""".format(
stripe_user_id=resp["stripe_user_id"]
)


@app.route('/deauthorize')
@app.route("/deauthorize")
def deauthorize():
stripe_user_id = request.args.get('stripe_user_id')
stripe_user_id = request.args.get("stripe_user_id")
try:
stripe.OAuth.deauthorize(stripe_user_id=stripe_user_id)
except stripe.oauth_error.OAuthError as e:
return 'Error: ' + str(e)
return "Error: " + str(e)

return '''
return """
<p>Success! Account <code>{stripe_user_id}</code> is disconnected.</p>
<p>Click <a href="/">here</a> to restart the OAuth flow.</p>
'''.format(stripe_user_id=stripe_user_id)
""".format(
stripe_user_id=stripe_user_id
)


if __name__ == '__main__':
app.run(port=int(os.environ.get('PORT', 5000)))
if __name__ == "__main__":
app.run(port=int(os.environ.get("PORT", 5000)))
22 changes: 11 additions & 11 deletions examples/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import stripe


stripe.api_key = os.environ.get('STRIPE_SECRET_KEY')
stripe.api_key = os.environ.get("STRIPE_SECRET_KEY")

print("Attempting charge...")

Expand All @@ -16,22 +16,22 @@

clients = (
stripe.http_client.RequestsClient(
verify_ssl_certs=stripe.verify_ssl_certs,
proxy=stripe.proxy),
verify_ssl_certs=stripe.verify_ssl_certs, proxy=stripe.proxy
),
stripe.http_client.PycurlClient(
verify_ssl_certs=stripe.verify_ssl_certs,
proxy=stripe.proxy),
verify_ssl_certs=stripe.verify_ssl_certs, proxy=stripe.proxy
),
stripe.http_client.Urllib2Client(
verify_ssl_certs=stripe.verify_ssl_certs,
proxy=stripe.proxy),
verify_ssl_certs=stripe.verify_ssl_certs, proxy=stripe.proxy
),
)

for c in clients:
stripe.default_http_client = c
resp = stripe.Charge.create(
amount=200,
currency='usd',
card='tok_visa',
description='customer@gmail.com'
currency="usd",
card="tok_visa",
description="customer@gmail.com",
)
print('Success: %s, %r' % (c.name, resp))
print("Success: %s, %r" % (c.name, resp))
30 changes: 17 additions & 13 deletions examples/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,36 @@
from flask import Flask, request


stripe.api_key = os.environ.get('STRIPE_SECRET_KEY')
webhook_secret = os.environ.get('WEBHOOK_SECRET')
stripe.api_key = os.environ.get("STRIPE_SECRET_KEY")
webhook_secret = os.environ.get("WEBHOOK_SECRET")

app = Flask(__name__)


@app.route('/webhooks', methods=['POST'])
@app.route("/webhooks", methods=["POST"])
def webhooks():
payload = request.data.decode('utf-8')
received_sig = request.headers.get('Stripe-Signature', None)
payload = request.data.decode("utf-8")
received_sig = request.headers.get("Stripe-Signature", None)

try:
event = stripe.Webhook.construct_event(
payload, received_sig, webhook_secret)
payload, received_sig, webhook_secret
)
except ValueError:
print("Error while decoding event!")
return 'Bad payload', 400
return "Bad payload", 400
except stripe.error.SignatureVerificationError:
print("Invalid signature!")
return 'Bad signature', 400
return "Bad signature", 400

print("Received event: id={id}, type={type}".format(
id=event.id, type=event.type))
print(
"Received event: id={id}, type={type}".format(
id=event.id, type=event.type
)
)

return '', 200
return "", 200


if __name__ == '__main__':
app.run(port=int(os.environ.get('PORT', 5000)))
if __name__ == "__main__":
app.run(port=int(os.environ.get("PORT", 5000)))
45 changes: 23 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@


class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to pass into pytest")]
user_options = [("pytest-args=", "a", "Arguments to pass into pytest")]

def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = '-n auto'
self.pytest_args = "-n auto"

def run_tests(self):
import shlex
import pytest

errno = pytest.main(shlex.split(self.pytest_args))
sys.exit(errno)

Expand All @@ -23,42 +24,42 @@ def run_tests(self):

os.chdir(here)

with open(os.path.join(here, 'LONG_DESCRIPTION.rst'), encoding='utf-8') as f:
with open(os.path.join(here, "LONG_DESCRIPTION.rst"), encoding="utf-8") as f:
long_description = f.read()

version_contents = {}
with open(os.path.join(here, 'stripe', 'version.py'), encoding='utf-8') as f:
with open(os.path.join(here, "stripe", "version.py"), encoding="utf-8") as f:
exec(f.read(), version_contents)

setup(
name='stripe',
version=version_contents['VERSION'],
description='Python bindings for the Stripe API',
name="stripe",
version=version_contents["VERSION"],
description="Python bindings for the Stripe API",
long_description=long_description,
author='Stripe',
author_email='support@stripe.com',
url='https://github.com/stripe/stripe-python',
license='MIT',
keywords='stripe api payments',
packages=find_packages(exclude=['tests', 'tests.*']),
package_data={'stripe': ['data/ca-certificates.crt']},
author="Stripe",
author_email="support@stripe.com",
url="https://github.com/stripe/stripe-python",
license="MIT",
keywords="stripe api payments",
packages=find_packages(exclude=["tests", "tests.*"]),
package_data={"stripe": ["data/ca-certificates.crt"]},
zip_safe=False,
install_requires=[
'requests >= 2.20; python_version >= "3.0"',
'requests[security] >= 2.20; python_version < "3.0"',
],
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
tests_require=[
'pytest >= 3.4',
'pytest-mock >= 1.7',
'pytest-xdist >= 1.22',
'pytest-cov >= 2.5',
"pytest >= 3.4",
"pytest-mock >= 1.7",
"pytest-xdist >= 1.22",
"pytest-cov >= 2.5",
],
cmdclass={'test': PyTest},
cmdclass={"test": PyTest},
project_urls={
'Bug Tracker': 'https://github.com/stripe/stripe-python/issues',
'Documentation': 'https://stripe.com/docs/api/python',
'Source Code': 'https://github.com/stripe/stripe-python',
"Bug Tracker": "https://github.com/stripe/stripe-python/issues",
"Documentation": "https://stripe.com/docs/api/python",
"Source Code": "https://github.com/stripe/stripe-python",
},
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
19 changes: 10 additions & 9 deletions stripe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

api_key = None
client_id = None
api_base = 'https://api.stripe.com'
connect_api_base = 'https://connect.stripe.com'
upload_api_base = 'https://files.stripe.com'
api_base = "https://api.stripe.com"
connect_api_base = "https://connect.stripe.com"
upload_api_base = "https://files.stripe.com"
api_version = None
verify_ssl_certs = True
proxy = None
Expand All @@ -24,7 +24,8 @@
enable_telemetry = False
max_network_retries = 0
ca_bundle_path = os.path.join(
os.path.dirname(__file__), 'data/ca-certificates.crt')
os.path.dirname(__file__), "data/ca-certificates.crt"
)

# Set to either 'debug' or 'info', controls console logging
log = None
Expand All @@ -35,7 +36,7 @@
from stripe.api_resources import radar # noqa
from stripe.api_resources import reporting # noqa
from stripe.api_resources import sigma # noqa
from stripe.api_resources import terminal # noqa
from stripe.api_resources import terminal # noqa

# OAuth
from stripe.oauth import OAuth # noqa
Expand All @@ -52,8 +53,8 @@
def set_app_info(name, partner_id=None, url=None, version=None):
global app_info
app_info = {
'name': name,
'partner_id': partner_id,
'url': url,
'version': version,
"name": name,
"partner_id": partner_id,
"url": url,
"version": version,
}
Loading

0 comments on commit ba6bb75

Please sign in to comment.