Last active
May 22, 2017 23:58
-
-
Save devraj/70f873b11896d73395efd1a7499161f0 to your computer and use it in GitHub Desktop.
Create Stripe managed account with a bank account and verification document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#: Stripe on OSX might need | |
#: pip install pyOpenSSL backports.ssl requests | |
#: Your Stripe secret key | |
STRIPE_API_KEY = "STRIPE_KEY" | |
#: JPEG that has evidence for the entity | |
EVIDENCE_JPEG_PATH = "abn.jpg" | |
import stripe | |
from datetime import datetime | |
stripe.api_key = STRIPE_API_KEY | |
#: Create a managed account stub | |
managed_account = stripe.Account.create(country="AU", managed=True) | |
print("Created account with id %s" % managed_account.id) | |
#: Getting the account object back | |
account = stripe.Account.retrieve(managed_account.id) | |
#: What you need for an account to be marked complete | |
account.legal_entity.type = "company" | |
account.tos_acceptance.date = datetime.now() | |
account.tos_acceptance.ip = "8.8.8.8" | |
account.legal_entity.last_name = "Mukherjee" | |
account.legal_entity.first_name = "Dev" | |
account.legal_entity.dob.year = 1970 | |
account.legal_entity.dob.day = 20 | |
account.legal_entity.dob.month = 1 | |
account.legal_entity.address.city = "Wagga Wagga" | |
account.legal_entity.address.line1 = "Suite 101, 63-65 Johnston Street" | |
account.legal_entity.address.postal_code = "2650" | |
account.legal_entity.address.state = "NSW" | |
account.legal_entity.business_name = "Anomaly Software Pty Ltd" | |
account.legal_entity.business_tax_id = "89107600975" | |
#: Payout bank account details | |
acc_details = { | |
"currency": "AUD", | |
"country":"AU", | |
"object":"bank_account", | |
"account_number":"000123456", | |
"routing_number":"110000" | |
} | |
#: Create a new external account | |
account.external_accounts.create(external_account=acc_details) | |
account.save() | |
#: Upload a file as identity only JPEG/GIF allowed | |
with open(EVIDENCE_JPEG_PATH, "r") as fp: | |
identity_file = stripe.FileUpload.create( | |
purpose="identity_document", | |
file=fp, | |
stripe_account=account.id) | |
account.legal_entity.verification.document = identity_file.id | |
account.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment