Stripeでconnectの子アカウントをコードから作る方法 – Python
やりたいこと
Stripe使ってショッピングモール作成したくて、我々のモールに、ショップから出店したとき、ショップの出店情報をモールに登録する。
環境
$ python --version
Python 3.6.8
$ pip --version
pip 19.3.1 from /Users/ryosuke/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pip (python 3.6)
実装
import stripe
import time
# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
stripe.api_key = 'sk_live_key'
account = stripe.Account.create(
type="custom",
country="JP",
email="test@test.com",
requested_capabilities=['card_payments', 'transfers'],
)
account = stripe.Account.retrieve(account.id)
account.legal_entity.type="individual"
account.legal_entity.business_name="my company inc"
account.legal_entity.first_name_kana="タナカ"
account.legal_entity.first_name_kanji="田中"
account.legal_entity.last_name_kana="タロウ"
account.legal_entity.last_name_kanji="太郎"
account.legal_entity.phone_number="09011113333"
account.legal_entity.dob.day="04"
account.legal_entity.dob.month="02"
account.legal_entity.dob.year="1997"
account.legal_entity.gender="female"
account.legal_entity.address_kana.city="ヒミツケン"
account.legal_entity.address_kana.line1="ヒミツシ"
account.legal_entity.address_kana.postal_code="00011112222"
account.legal_entity.address_kana.state="ヒミツシ"
account.legal_entity.address_kana.town="ヒミツ 4-9-1 221"
account.legal_entity.address_kanji.city="秘密県"
account.legal_entity.address_kanji.line1="秘密市"
account.legal_entity.address_kanji.postal_code="00011112222"
account.legal_entity.address_kanji.state="秘密区"
account.legal_entity.address_kanji.town="秘密 4-9-1 221"
account.external_accounts.create(external_account= {
'object':'bank_account',
'account_number': '銀行口座',
'routing_number': '数字', #銀行コード+支店コード
'account_holder_name':'カタカナ',
'currency':'jpy',
'country':'jp',
})
account.save()
stripe.Account.modify(
account.id,
metadata={'business_name':"マイカンパニー"
},
tos_acceptance={
'date': int(time.time()),
'ip': '8.8.8.8', # Stripeのポリシーに同意
}
)
残りの作業
ここまでで、連結されたカウントが保留になる。あとは、個人情報の写真をアップしなければ行けない。これはまた今度やろう
身分を確認するファイル必要

保留になる
